Skip to content

P2: Worker cap can purge branch provenance after worktree cleanup #1404

Closed

Description

@currentbits

Problem

The per-orchestrator 20-worker cap uses worktreePath as its only protection for a worker's unlanded branch. Worktree GC intentionally preserves the Git branch but clears both worktreePath and branch on the thread. A later crew sweep can then purge that worker's thread and transcript, removing the app's remaining link between the lead, the worker, and its saved commits.

Evidence (origin/main e2924af, 2026-10-01)

  • worktrees.gcClean calls removeGcWorktree, which explicitly never deletes a branch, then store.updateThread(..., { worktreePath:null, branch:null }).
  • runner.sweepCrew sorts workers newest-first and purges entries beyond MAX_WORKERS_PER_ORCHESTRATOR=20 when they are done/failed/stopped and !active.has(id) && !t.worktreePath && !t.pinnedAt. It does not check the branch ref, unmerged commit count, or a landing receipt. Boot runs this sweep for all worker crews.
  • Live read-only inventory has 246 crews, two over 20 workers (24 and 22). Five excess workers currently retain branch and worktreePath fields, but their directories no longer exist. They are protected by the non-null path today; clearing their fields would make them eligible at the next sweep. This is a reachability observation, not proof that their work is unmerged or was deleted.
  • Git's worktree documentation distinguishes removing a worktree from preserving repository refs; preserving a branch ref alone does not preserve Solenta's thread-to-branch provenance.

Smallest safe outcome

Keep a durable branch/landing receipt on workers whose checkout is reclaimed, and have the 20-worker purge skip a worker with unlanded commits or an unresolved landing state. A cheap recorded flag/ref is preferable to retaining gigabytes of worktree files. Coordinate with #1400, which covers restoring a missing worktree onto the original branch; this ticket covers deletion of the worker record after cleanup.

Acceptance

  • In a disposable Git repo, create 21 workers for one lead; give the oldest worker a unique commit. GC its clean worktree after any grace period. Run the boot/terminal crew sweep. The worker's ID, branch ref or durable receipt, and lead relationship remain recoverable.
  • An excess worker whose changes are verified landed and whose thread has no active run/worktree/pin can still be purged.
  • No branch or committed work is deleted by GC or retention.
  • The sweep does not infer that a null worktreePath means a worker never had unlanded work.

Related #213 introduced the cap; #1400 covers branch rematerialization after a missing directory.

Activity

  1. added
    plan:todo
    on Oct 1, 2026
  2. currentbits commented on Oct 1, 2026

    @currentbits
    OwnerAuthor

    Additional read-only live check: of the five excess workers whose stored worktree paths are missing, four still have resolvable branch refs in their owning Git repositories. All four tips contain commits not reachable from the repository's default branch by ancestry. This raises the practical impact, but it does not prove their changes were never squash-merged, so the ticket's acceptance still requires explicit landing state rather than treating ancestry alone as finality. No branch or store data was modified.

  3. added
    plan:doing
    plan:done
    and removed
    plan:todo
    plan:doing
    on Oct 12, 2026
  4. currentbits commented on Oct 13, 2026

    @currentbits
    OwnerAuthor

    Landed from Solenta thread "P2: Worker cap can purge branch provenance after worktree cl" (PR #1610). Closed on merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions