@@ -469,6 +469,7 @@ describe("subagent worktree ownership", () => {
469469 "grandchild" ,
470470 "null-branch" ,
471471 "isolated-owner" ,
472+ "fork-owner" ,
472473 "missing-parent" ,
473474 "cycle" ,
474475 "two-tops" ,
@@ -498,12 +499,13 @@ describe("subagent worktree ownership", () => {
498499 branch : "feature" ,
499500 worktreePath : fixture . worktree ,
500501 settledAt : scenario === "child-settled-only" ? null : at ( - 20 * DAY_MS ) ,
501- ...( scenario === "isolated-owner"
502+ ...( scenario === "isolated-owner" || scenario === "fork-owner"
502503 ? {
503504 lineage : {
504505 parentThreadId : ThreadId . make ( "ancestor" ) ,
505506 rootThreadId : ThreadId . make ( "ancestor" ) ,
506- relationshipToParent : "subagent" as const ,
507+ relationshipToParent :
508+ scenario === "fork-owner" ? ( "fork" as const ) : ( "subagent" as const ) ,
507509 } ,
508510 }
509511 : { } ) ,
@@ -545,7 +547,7 @@ describe("subagent worktree ownership", () => {
545547 fixture . setThreads (
546548 scenario === "grandchild"
547549 ? [ grandchild , child , root ]
548- : scenario === "isolated-owner"
550+ : scenario === "isolated-owner" || scenario === "fork-owner"
549551 ? [ child , root , shell ( { id : ThreadId . make ( "ancestor" ) } ) ]
550552 : [ child , root ] ,
551553 ) ;
@@ -559,7 +561,13 @@ describe("subagent worktree ownership", () => {
559561 root ,
560562 ] ) ;
561563 const report = yield * fixture . service . runNow ;
562- const removed = [ "idle" , "grandchild" , "null-branch" , "isolated-owner" ] . includes ( scenario ) ;
564+ const removed = [
565+ "idle" ,
566+ "grandchild" ,
567+ "null-branch" ,
568+ "isolated-owner" ,
569+ "fork-owner" ,
570+ ] . includes ( scenario ) ;
563571 const shared = [
564572 "unrelated" ,
565573 "fork" ,
@@ -675,6 +683,14 @@ describe("storage cleanup reports and local file policies", () => {
675683 ) ,
676684 ) ;
677685 it . live . each ( [
686+ [
687+ "its owner's branch is cleared" ,
688+ ( worktree : string ) => [ shell ( { branch : null , worktreePath : worktree , updatedAt : at ( 0 ) } ) ] ,
689+ ] ,
690+ [
691+ "its owner's branch changes" ,
692+ ( worktree : string ) => [ shell ( { branch : "other" , worktreePath : worktree , updatedAt : at ( 0 ) } ) ] ,
693+ ] ,
678694 [
679695 "its thread starts" ,
680696 ( worktree : string ) => [
0 commit comments