Skip to content

lane-start fails closed on three #138 fences: a new lane's rename is read back and undone when another window took the name, a row or log that says RETIRED is not started again, and a new lane never takes a window named for another registered lane - #216

Merged
brettheap merged 4 commits into
mainfrom
fix/lane-start-hardening-138
Oct 17, 2026

Conversation

@brettheap

@brettheap brettheap commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Refs #138 (items 3, 14, 16)

This PR covers the three lane-start items of #138. They are re-proved on main (f87fd5a), fixed fail-closed, and each has a proving test in the new tests/test_lane_start_hardening_138.py. The test drives a real lane-start in the claude-current sandbox (tests/test_lane_start_claude_current.py's Sandbox), with a stateful fake tmux: the server's windows live in a file, list-windows prints it and rename-window edits it. It uses no real tmux server, no real Claude Code and no network.

The other #138 items are not touched: the lanes-edit.sh items and items 6, 13 and 15 belong to other lane-4 writers. Nothing here is in lane-start ~:1435 (seam_refuse), ~:2584–2651 (live_holders_of_id/follow_transcript), ~:3502 (cut_to_line) or ~:3896.

Item 3: window-name uniqueness check vs rename (fixed)

On main: lane_check_local_fences scans list-windows (lane-start:2223-2236 at f87fd5a), and step 4 renames (:2477). Nothing reserves the name between the two calls. So two NEW-lane starts in two windows can both find the name free and both take it, and the register lock that comes after cannot undo a rename.

Fix: no reservation is added. #84 records that a lane reservation is a ruling's to make, and a file lock would not cover benches in other containers that share one tmux server. Instead, the rename is read back:

  • The scan is now one function, window_named_lane (:2288-2303). The fence calls it before the rename, as before.
  • After the rename, a NEW lane calls it again (:2549-2585).
  • If another window carries the name, or the list fails, this window gets its old name back and its automatic-rename restored: unset, or on, as show-options -w -v read it before the rename (:2543-2544). Then the run refuses with exit 2, before any write.
  • tmux runs one command at a time. So of two starts that each rename and then list, the later list always sees the earlier rename: at most one keeps the name, and both refusing is the fail-closed outcome.

Tests:

  • test_item3_a_name_another_window_took_during_the_rename_is_given_back: a rival's rename lands just before this run's.
  • test_item3_a_read_back_that_fails_is_not_a_name_that_is_free
  • test_item3_the_undo_restores_automatic_rename_when_the_window_had_it
  • test_item3_a_window_with_no_name_to_go_back_to_says_the_undo_was_not_made: where #W was empty, no rename back is made, and the refusal says the undo was not made instead of claiming it.
  • Control: test_item3_an_uncontested_rename_is_kept

Item 14: retired-identity fence asks only the archive (fixed, RETIRED only)

On main: lane_check_local_fences asks only retired-identity (:2201-2209), which reads the archive. A row that lane-end --retire or the dormant sweep marked RETIRED, but that archive-rows has not yet moved, still sits in lanes/LANES.md. retired-identity answers 8 about it, and the existing-row path resumes the lane. That appends a STARTED or RESUMED after its RETIRED line, in a log nothing ever rewrites.

Fix (:2212-2240, inside the same function, so it is asked again before the rename):

  • A row whose state word is RETIRED is refused (exit 2). Both copies are asked: this checkout's $row and the published $pub_row.
  • A lane whose log's last lane-kind line is RETIRED (read with lanes-edit.sh lane-last) is refused (exit 2).
  • A lane-last that cannot be read (anything but 0 or 8) refuses with exit 1.

ENDED is not refused, because ENDED is not terminal in this estate:

  • docs/README-lanes.md: lane-end is "the window is closing", while lane-end --retire is "the lane is not coming back".
  • Amendment 18(b), quoted in lane-start's own binding section: a binding is released by a PAUSED or an ENDED, and the lane can then be bound again.
  • lane's closed-lane refusal points at lane-start <repo> <n> as the way to reopen a lane.
  • The real register has an ENDED lane resumed by lane-start.

The earlier revision of this PR refused ENDED as well. That would need a ruling from Brett, so it was taken out.

Tests:

  • test_item14_a_retired_lane_still_in_the_register_is_not_started, parametrized over three cases: RETIRED in the cell with or without a log, and a PAUSED cell over a log that ends RETIRED.
  • test_item14_a_retirement_this_checkout_has_not_pushed_is_still_one
  • test_item14_a_log_that_cannot_be_read_is_not_a_lane_that_is_open
  • Controls: test_item14_an_ended_or_paused_lane_is_still_resumed, over three cases: an ENDED cell, a log ending ENDED, and a log ending PAUSED. Each resumes the recorded session: exit 0, --resume <id>, the row set to LIVE, and a RESUMED line.

Item 16: new-lane window-name fence skips this window (fixed)

On main: the scan skips this window (:2229). So a NEW lane started from a window still named for ANOTHER registered lane renames that window and takes that lane's tmux address.

Fix (:2260-2285): for a NEW lane whose window name differs from the lane's, the fence asks register-row and register-row-local about the window's own name. The local read is there because a row this checkout has not pushed already owns its window.

  • 8 from both passes.
  • 0 from either refuses (exit 2).
  • Any other answer refuses (exit 1).

A name that check_lane_name refuses (a space, a slash, a leading . or -) can be carried by no row. Such a name is reusable without a read, as are claude, a shell's name and any other name no row carries.

Tests:

  • test_item16_a_new_lane_does_not_take_another_lanes_window
  • test_item16_a_row_only_this_checkout_has_still_names_the_window
  • test_item16_a_window_name_read_that_fails_refuses, for each of the two reads
  • Control: test_item16_a_generic_or_unregistered_window_name_is_reused (zsh, my notes, REPOZ-1)

Verification

Local scoped run at ed933f5, under the shared lock (flock … python3 -m pytest tests/test_lane_start_hardening_138.py -q, lock taken 19:59Z):

  • Against a git archive of main (OPENREPOTOOLS_CODE_ROOT; lane-start is unchanged from f87fd5a to a74c7fc): 13 failed, 7 passed. Every proving test failed. The seven that passed are the controls, and among them are the three ENDED and PAUSED cases, which show that main resumes them too.
  • Against this branch: 20 passed.

CI's Linux tests job is the suite of record.

The shell suite's existing lane-start cases were reviewed for the new refusals. None starts a RETIRED lane, none starts a NEW lane from a window named for another registered lane (the repoVT-2, repoGD-* and guard choice-2 cases all start lanes that have rows), and the read-back predicate is the fence's own, so a fake whose windows do not change gives the same answer before and after the rename.

🤖 Generated with Claude Code

Brett Heap and others added 3 commits October 13, 2026 18:25
…pt, a closed row resumed, another lane's window taken

tests/test_lane_start_hardening_138.py drives a real lane-start in the
claude-current sandbox with a stateful fake tmux. Items 3, 14 and 16 of
#138.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sk the register about this window's own name

Item 3: a NEW lane's rename is read back with the same scan the fence makes;
another window carrying the name, or a list that fails, undoes this window's
rename and its automatic-rename and refuses. No reservation is added (#84).
Item 14: a register row (local or published) whose state word is ENDED or
RETIRED, or a log whose last lane-kind line is either, refuses before any
rename; a lane-last that fails refuses too.
Item 16: a new lane started from a window named for another registered lane
(published or this checkout's row) refuses; a read that fails refuses.

Refs #138 (items 3, 14, 16).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…es as well as a RESUMED

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 13, 2026

Copy link
Copy Markdown

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 22 hours and 55 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 13, 2026

Copy link
Copy Markdown

Reviewer's Guide

Hardens lane-start against three #138 fail-open paths: it rolls back colliding or unverifiable renames, refuses closed lanes based on register and log state, and prevents new lanes from taking windows belonging to other registered lanes. A stateful fake-tmux sandbox provides focused proving and control tests without real tmux, Claude Code, or network access.

File-Level Changes

Change Details Files
Make the post-rename window-name uniqueness check fail closed and roll back an uncontested rename when read-back detects a collision or fails.
  • Consolidate window-name scanning into a reusable predicate.
  • Re-read window names after a NEW-lane rename.
  • Restore the previous window name and automatic-rename setting before refusing.
  • Add stateful fake-tmux coverage for races, read failures, rollback, and the uncontested control case.
lane-start
tests/test_lane_start_hardening_138.py
Prevent restarting lanes whose local register row or log indicates the lane is closed, while preserving paused-lane resume behavior.
  • Check both checkout and published row state for ENDED and RETIRED.
  • Check the final lane-kind log entry and refuse unreadable logs.
  • Use distinct exit statuses for closed-lane refusals versus fence-read failures.
  • Cover row-only, log-only, unpushed, unreadable, and paused controls.
lane-start
tests/test_lane_start_hardening_138.py
Ensure a NEW lane cannot claim a tmux window currently named for another registered lane.
  • Query both published and local registration data for a differing window name.
  • Refuse on an existing row, including rows not yet pushed.
  • Fail closed when either registration lookup errors.
  • Continue reusing generic, invalid, or unregistered window names.
lane-start
tests/test_lane_start_hardening_138.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

… name says it was not made

ENDED is "the window is closing", not "the lane is not coming back": it
releases the binding as PAUSED does (Amendment 18(b)), `lane` sends a closed
lane back to `lane-start` to be reopened, and the real register has an ENDED
lane resumed by lane-start. The row loop and the `lane-last` case now match
RETIRED alone; a `lane-last` that cannot be read still refuses with 1. The
ENDED cases become controls that resume (exit 0, row LIVE, a RESUMED line).

Item 3's undo printed "This window's rename is undone" where `#W` was empty and
no rename back was made; it now says the undo was not made.

Refs #138 (items 3, 14).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@brettheap brettheap changed the title lane-start fails closed on three #138 fences: a new lane's rename is read back and undone when another window took the name, a row or log that says ENDED or RETIRED is not started again, and a new lane never takes a window named for another registered lane lane-start fails closed on three #138 fences: a new lane's rename is read back and undone when another window took the name, a row or log that says RETIRED is not started again, and a new lane never takes a window named for another registered lane Oct 13, 2026
@brettheap brettheap added ready landing gate: runs tests-macos once before the squash and removed ready landing gate: runs tests-macos once before the squash labels Oct 13, 2026
@brettheap brettheap added ready landing gate: runs tests-macos once before the squash and removed ready landing gate: runs tests-macos once before the squash labels Oct 17, 2026
@brettheap
brettheap merged commit 27b5c89 into main Oct 17, 2026
23 checks passed
@brettheap
brettheap deleted the fix/lane-start-hardening-138 branch October 17, 2026 23:43
brettheap pushed a commit that referenced this pull request Oct 18, 2026
…R on today's main

Main moved through files this PR also changes (#199 or #216, and #201) after the last green run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap pushed a commit that referenced this pull request Oct 18, 2026
…so CI tests this PR on today's main

Main moved through files this PR also changes (#199 or #216, and #201) after the last green run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap pushed a commit that referenced this pull request Oct 18, 2026
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready landing gate: runs tests-macos once before the squash

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant