@@ -1550,6 +1550,49 @@ def test_publish_existing_dirty_control_plane_fails_closed_without_mutation(tmp_
15501550 assert evidence ["recovery_required" ] is True
15511551
15521552
1553+ def test_publish_rejects_nested_gitlink_before_staging (tmp_path : Path ) -> None :
1554+ config = config_root (tmp_path / "config-root" )
1555+ source_remote , _ , _ = make_remote (tmp_path / "source-fixture" , "source" )
1556+ workspace = tmp_path / "workspace"
1557+ assert run_wb (
1558+ config ,
1559+ "init-workspace" ,
1560+ str (workspace ),
1561+ "--slug" ,
1562+ "demo" ,
1563+ "--repository" ,
1564+ f"source-main={ source_remote } " ,
1565+ "--apply" ,
1566+ ).returncode == 0
1567+ control = workspace / ".work-bundle"
1568+ nested = control / "knowledge/notes/nested-repository"
1569+ nested .mkdir (parents = True )
1570+ git (nested , "init" , "-q" , "-b" , "main" )
1571+ git (nested , "config" , "user.email" , "test@example.com" )
1572+ git (nested , "config" , "user.name" , "Test" )
1573+ (nested / "README.md" ).write_text ("nested\n " , encoding = "utf-8" )
1574+ git (nested , "add" , "README.md" )
1575+ git (nested , "commit" , "-q" , "-m" , "nested" )
1576+ remote = tmp_path / "control.git"
1577+ subprocess .run (["git" , "init" , "--bare" , "-q" , str (remote )], check = True )
1578+
1579+ failed = run_wb (
1580+ config ,
1581+ "publish-control-plane" ,
1582+ str (workspace ),
1583+ "--remote" ,
1584+ str (remote ),
1585+ "--apply" ,
1586+ )
1587+
1588+ assert failed .returncode == 1
1589+ data = json .loads (failed .stdout )
1590+ assert data ["failure_code" ] == "WB_CONTROL_PLANE_GITLINK_FORBIDDEN"
1591+ assert data ["gitlink_paths" ] == ["knowledge/notes/nested-repository" ]
1592+ assert not (control / ".git" ).exists ()
1593+ assert (nested / ".git" ).is_dir ()
1594+
1595+
15531596def test_publish_failed_git_snapshot_fails_closed_without_mutation (tmp_path : Path ) -> None :
15541597 config = config_root (tmp_path / "config-root" )
15551598 source_remote , _ , _ = make_remote (tmp_path / "source-fixture" , "source" )
0 commit comments