@@ -468,6 +468,7 @@ describe("subagent worktree ownership", () => {
468468 "idle" ,
469469 "grandchild" ,
470470 "null-branch" ,
471+ "stale-branch" ,
471472 "isolated-owner" ,
472473 "fork-owner" ,
473474 "missing-parent" ,
@@ -512,7 +513,12 @@ describe("subagent worktree ownership", () => {
512513 } ) ;
513514 const child = shell ( {
514515 id : ThreadId . make ( "child" ) ,
515- branch : scenario === "null-branch" ? null : "feature" ,
516+ branch :
517+ scenario === "null-branch"
518+ ? null
519+ : scenario === "stale-branch"
520+ ? "t3/15a6e5ae"
521+ : "feature" ,
516522 worktreePath : fixture . worktree ,
517523 lineage : {
518524 parentThreadId :
@@ -580,8 +586,8 @@ describe("subagent worktree ownership", () => {
580586 ? "Thread is running or has pending work"
581587 : shared
582588 ? "Shared by 2 threads"
583- : scenario === "null-branch"
584- ? "A subagent thread has no branch to restore it from "
589+ : scenario === "null-branch" || scenario === "stale-branch"
590+ ? "A subagent thread's branch differs from this worktree's branch "
585591 : scenario === "recent-activity"
586592 ? "Settled for 2 of 8 days"
587593 : scenario === "recent-inactive"
@@ -601,6 +607,7 @@ describe("subagent worktree ownership", () => {
601607 "settled" ,
602608 "resettled" ,
603609 "null-branch" ,
610+ "stale-branch" ,
604611 ] as const ) ( "cancels removal when a child changes during measurement (%s)" , ( change ) =>
605612 runCleanupTest (
606613 Effect . gen ( function * ( ) {
@@ -623,7 +630,12 @@ describe("subagent worktree ownership", () => {
623630 root ,
624631 {
625632 ...child ,
626- branch : change === "null-branch" ? null : child . branch ,
633+ branch :
634+ change === "null-branch"
635+ ? null
636+ : change === "stale-branch"
637+ ? "t3/15a6e5ae"
638+ : child . branch ,
627639 settledAt : change === "settled" ? at ( - 20 * DAY_MS ) : child . settledAt ,
628640 updatedAt : change === "settled" || change === "resettled" ? at ( 0 ) : child . updatedAt ,
629641 status : change === "running" ? "running" : "idle" ,
0 commit comments