Skip to content

Crash-consistent lane worktree recovery: canonical inventory and RUNNING → SWAPPING → SWAPPED lifecycle #91

Closed

Description

@brettheap

Lane: openrepotools-3 (openRepoTools-3)

Backlog and governance record requested while the existing openRepoTools-3 Claude session is already implementing the lane-tooling refactor. This issue does not create a second implementation claim.

Problem

A lane can coordinate several Git worktrees with dirty or unpushed work. Token exhaustion can happen before /swap, after /swap starts but before it completes, or while the replacement process is starting. The current coordinator directory and PAUSED record do not fully distinguish those cases or provide a complete, machine-readable worktree inventory.

Required lifecycle

RUNNING --/swap begins--> SWAPPING --all mandatory steps complete--> SWAPPED
   ^                                                                  |
   +---------------- confirmed replacement SessionStart --------------+
  • RUNNING is written only after SessionStart confirms lane, transcript/session, agent, directory, and exclusive binding.
  • /swap atomically changes RUNNING to SWAPPING before inventory or preservation work.
  • /swap changes SWAPPING to SWAPPED only after writer polling, worktree inventory, handoff refresh, and pause records succeed.
  • A generation and operation ID fence every transition so an old finalizer or competing resume cannot overwrite a newer owner.
  • RUNNING without a verified holder means an ungraceful pre-swap stop.
  • SWAPPING without a verified holder means an interrupted swap.

Worktree recovery

  • Resolve a canonical lane control root from stable home owner/repo, estate, canonical lane name, and shape-aware worktree configuration.
  • Keep sidecar metadata outside Git worktrees.
  • Inventory every lane-owned tree with repository, relative path, branch or detached state, HEAD, upstream, writer identity, and last-observed dirty/unpushed state.
  • On resume, reconcile sidecars and handoff data against live holders, git worktree list --porcelain, actual paths, current Git state, and unpublished commits.
  • Preserve and report unknown or inconsistent trees; never delete, reset, overwrite, or force-add them.
  • Rebuild only through the existing estate parked-record resume mechanism. Missing uncommitted files cannot be reconstructed from metadata.
  • Keep profile rotation independent of lane and worktree identity.

Governed artifacts

  • OpenSpec change: openspec/changes/add-crash-consistent-lane-worktree-recovery/
  • Brainstorm overview: ideation/brainstorm/lane-worktree-recovery-state-overview.md
  • Normative capability: openspec/changes/add-crash-consistent-lane-worktree-recovery/specs/lane-worktree-recovery/spec.md
  • Implementation checklist: openspec/changes/add-crash-consistent-lane-worktree-recovery/tasks.md

The OpenSpec change validates strictly and is apply-ready. The brainstorm packet validates with three atomic documents, one synthesis, and one overview.

Activity

  1. brettheap commented on Sep 15, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoTools-3, session 4135b2c9-34a6-47e3-a156-5adebb632fae@Eagle, 2026-09-15T20:12:03Z, for #91

    Logged in lanes/log/openRepoTools-3.md at 325f9f480229a1173e758a62177ab620ffeb3286.

    The three reads (lane-collision-protocol Rule 1):

    1. existing `CLAIMED —` comments on opensoft/openRepoTools#91:
       none
    2. `gh pr list --repo opensoft/openRepoTools --state all --search "#91"`, kept where the row or its body names `#91`:
    8	Bare `park` parks the estate around the cwd and ASKS before sweeping; `park --all` / `-a` is the sweep unasked	feat/park-all-flag	MERGED
    7	The no-estate sweep skips a root without the Speckit git overlay instead of counting it as a refusal	feat/park-skips-roots-without-overlay	MERGED
    1	`park` and `resume` move here from openRepoShape, with their own `openRepoTools --install`, their own suite, and the openRepoShape commit they were verified against pinned as a submodule (opensoft/openRepoShape#92)	feat/park-resume-and-installer	MERGED
    3. `git ls-remote --heads [email protected]:opensoft/openRepoTools` branches naming `91` as a whole token:
       none
    
  2. brettheap commented on Sep 16, 2026

    @brettheap
    ContributorAuthor

    Cross-link: opensoft/openRepoTools#94 and its PR #121 share this change's control root, and deliberately do not wait for it.

    #94 is the measured /ctx failure — a context clear whose replacement came up --resumeing the transcript it had just paused, because the fresh-session requirement was an environment variable the profile launcher's tmux new-session drops. Its fix needs the same thing this change needs: a small, fenced, atomically-replaced record beside the lane. #121 therefore writes restart-intent.yaml as a sibling sidecar of this change's lane-state.yaml, under a lane_control_root resolved the same three ways, with the same flat key: value grammar, the same atomic replace, the same lane_op_id shape and the same exit-code contract (0/1/2/7 fence lost/8/64).

    Four helpers are shared and were checked byte-for-byte on the two branches — lane_control_root, lane_sidecar_put, lane_sidecar_field, lane_op_id — so the merge of #97 and #121 is a textual conflict whose resolution is keep either copy. No second scheme was created, and neither branch blocks the other.

    Two things this change owns that #121 consumes where the workstation has them, and states honestly where it does not:

    • the lifecycle. #121's supervisor moves SWAPPED → RUNNING through set-lane-state --expect SWAPPED after readiness is confirmed, and is silent on the 2 a lanes-edit.sh without lane-state answers — the pre-cutover case, not a failure. On a main with no snapshot the "non-running until readiness" requirement is met in the restart intent, which #121 owns, and only met in the lane's lifecycle once this lands. That residual is written into its design decision 12 rather than hidden.
    • the generation. The intent carries this change's generation where there is one and 0 where there is not, which is what a workstation before this change can honestly say.

    One reconciliation is owed to this change when the two merge: lane_state_follow moves the snapshot to RUNNING on any STARTED/RESUMED line, and lane-start writes its Amendment 8(d) RESUMED before the launch — so on a #97 workstation the snapshot would reach RUNNING ahead of #121's readiness gate. #121's finalizer is fenced on --expect SWAPPED and would refuse, which is a safe failure but not the intended one. #121's design decision 12 names this as work for whichever branch merges second.

    And one collision already resolved in writing: this change's landed "THE LIFECYCLE NEVER REFUSES THE SWAP" against #121's brainstorm asking for fail-closed ownership. #121's decision 13 draws the line Amendment 17(f) already draws — the record is never refused, the kill always is when the record is incomplete — so both stand and neither is overruled.

    Lane: openRepoTools-3.

  3. brettheap commented on Nov 10, 2026

    @brettheap
    ContributorAuthor

    Lane: openRepoTools-3

    Verdict: fixed, with a named residue. Closing as completed. What this issue asked for is built on code main. Its first implementation (#97) left eight tasks of the OpenSpec change unticked on purpose, and they are listed first so that closing this issue does not hide them.

    The residue: eight unticked tasks in openspec/changes/add-crash-consistent-lane-worktree-recovery/tasks.md on opensoft/openRepoTools-spec (spec main e6eaa3c: 34 ticked, 8 unticked; its section 7 says what stands in each one's place):

    Open children that carry the live findings: #116 (the recorded checkout is never compared; its tree_id_for half is fixed), #117 (the READY line counts polled trees as recorded, and a stale registration is suppressed), #118 (lane-handoff takes a CLOSED lane to SWAPPING) and #253 (the lifecycle case in the shell suite fails now and then).

    The change is NOT archived. openspec/changes/add-crash-consistent-lane-worktree-recovery/ is still on the spec leg. Archiving it with eight tasks unticked is a separate decision and needs Brett's word.

    Evidence that the rest is built

    Method: read, not run. Lane 3's triage read code main at 86d635b on 2026-11-10 and ran no tests; one cite per issue was re-read at 9a219ed, and the task counts at spec main e6eaa3c.

    Brett Heap's word, given in lane openRepoTools-3's session on 2026-11-10 (the NEEDS-BRETT dialog, "Closing the six fixed or obsolete issues": #304, #145, #125, #124, #127 and #91, answered by 12:11:11Z): "Close all six (Recommended)". Its description: "Each gets one evidence comment and is closed, and lane 3 releases its claim on it."

    🤖 Generated with Claude Code

  4. brettheap commented on Nov 10, 2026

    @brettheap
    ContributorAuthor

    RELEASED — lane openRepoTools-3, session 83619980-06bb-4469-ae73-2a8c5e61981a@Eagle, 2026-11-10T12:45:10Z, for #91 — closed: its lifecycle is built; the residue is listed in 6767602266

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions