Skip to content

lane-handoff refuses a closed lane with exit 2 before anything is written, as --late does, instead of taking it from CLOSED to SWAPPING (opensoft/openRepoTools#118) - #32

Merged
brettheap merged 6 commits into
mainfrom
fix/118-handoff-refuses-closed-lane
Nov 11, 2026
Merged

brettheap merged 6 commits into
mainfrom
fix/118-handoff-refuses-closed-lane

Conversation

@brettheap

@brettheap brettheap commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openRepoTools-5
Claim: opensoft/openRepoTools#118 (comment)

Five commits, on code main 92f9e10: 9fdcab2; ccfc85a, a merge of main that keeps both test blocks at the end of tests/test_a23_lane_handoff.py, #27's first; 1915f48, the fix round for lane 3's review (6780380332); 959e21a, a merge of main 4b1485d (#34) that adds only .github/workflows/verify.yml; and 4d211d2, a merge of main 92f9e10 (#35 and #36), whose one conflict, the end of tests/test_a23_lane_handoff.py, keeps both blocks, code#35's first. It makes lane-handoff refuse a closed lane with exit 2 before anything is written, as --late already does, instead of taking it from CLOSED to SWAPPING. It is part of opensoft/openRepoTools#118, which stays open for the transition table its "What's open" also asks for (the review's NIT-1). Lane 3 released opensoft/openRepoTools#118 to lane 5 at 12:47:16Z under Brett's "Yes, extend it (Recommended)", as lane 3 relays it on opensoft/openRepoTools#165 (6767535266): "Any lane may write a lane-tooling fix. Lane 3 reviews it and lands it under the standing word once it is READY and every check is green." The refusal is the option Brett chose for opensoft/openRepoTools#118, "Refuse, as --late does (Recommended)", relayed by the same lane 3 post.

READY for lane 3's landing. Every check is green on 4d211d2: 18 passed, SonarCloud Code Analysis among them; Mergify's queue check is neutral, and Sourcery's review was skipped (checked 2026-11-11T22:29:05Z). Codex's review of 4d211d2 found no major issues (6807990166). Lane 3 checked the merge 4d211d2 (opensoft/openRepoTools#165, 6807910478).

The defect

A lane whose log's last lane-kind line is an ENDED or a RETIRED is closed. lane-handoff on it read the lifecycle's CLOSED as the compare-and-swap's expected value and took the lane to SWAPPING, polled it, recorded an inventory, appended a PAUSED after the ENDED and finished at SWAPPED: a terminal lane reopened by a /handoff typed in a pane that was still there.

The fix

  • lane-handoff: --late's own read of lane-last and its ENDED or RETIRED refusal move into two functions, read_last_lane_line and refuse_a_closed_lane. Every mode but --late now calls them right after the managed-ledger seam's refusal, before the restart intent is reserved, the window is renamed, or the handoff file, the register, the object log or the lifecycle is touched. A closed lane exits 2 with --late's words. --late calls the same two functions where it always made the check, after its own --at checks, so its order of refusals and its words are what they were.
  • The log is the lane's state. A lane that a later STARTED or RESUMED reopened is never refused, whatever its lifecycle snapshot says, and a closed lane with no snapshot is. A lane-last read that fails exits 1 before any write, as --late does on the same failed read (the review's MUST-1): it shows the lane neither open nor closed (Amendment 7(d)), and R-A11-11 keeps only a swap that is owed.
  • tests/test_a23_lane_handoff.py: test_118_a_closed_lane_is_refused_before_any_write, for a plain handoff and for --restart. A started lane closed with an ENDED, its lifecycle CLOSED, exits 2 with --late's words, and the published register, the lane's log, W's reflog, the lane's checkout (head, changed files and handoff file), the lifecycle snapshot and the restart intent are all as they were. A second test, test_118_a_lane_started_again_after_its_close_is_handed_off_as_before, pins that a lane started again after its ENDED is handed off as before; its docstring now says what it sets up (NIT-2).
  • The fix round's tests: test_118_a_failed_read_of_the_last_line_is_not_an_open_lane (MUST-1) runs a stand-in LANES_EDIT that fails only lane-last, on a lane closed with ENDED, and asserts exit 1, the refusal's words, no PAUSED line, an unchanged lifecycle snapshot and an unchanged _held. test_118_a_closed_lane_is_refused_before_any_write now also takes --exit and --in-process (SHOULD-1).
  • What the old code does, read from lane-handoff at ecd1bce and not run for this body: the plain handoff exits 0 and takes the lifecycle CLOSED -> SWAPPING -> SWAPPED (lifecycle_begin at line 1963, lifecycle_finish at line 3023), and --restart exits 2 only after the record is written, because the test's shell has no tmux and the refusal at line 3071 follows the record. Only --late refuses a closed lane there (line 1942).

Checked

  • The fix round (1915f48), by node id, one short direct run each, as Brett's "CI verifies (Recommended)" asks (relayed in 6782534165):
  • The merge: the resolved test file's blob is 3927b532, the one lane 3's review gives.
  • The merge of main 92f9e10 (4d211d2): the test file's union drops no line either side added, and binds no top-level name twice; import re, which both sides added, appears once. The PR's three tests and code#35's two pass by node id.
  • The run.sh verify of 9fdcab2: tests/run.sh -k 'test_118_a_closed_lane_is_refused_before_any_write or test_a23_lane_handoff or repo_hygiene' (its log's command line: python3 -m pytest tests -q -p no:cacheprovider -k test_118_a_closed_lane_is_refused_before_any_write or test_a23_lane_handoff or repo_hygiene) exited 0 with 263 passed, 18 skipped, 4005 deselected in 678.05s (0:11:18).
  • The tree it tested is this commit's tree: git diff --binary HEAD on the worktree, taken when the run started and again just before the commit, has the sha256 8e192b6f97762a5735f7797ad555658d87eefb6ca0308126ace13ef0fce2757c, on HEAD ecd1bce.
  • CI: all 14 checks were green on 9fdcab2 and on 1915f48, including SonarCloud. On 4d211d2, 18 passed: the 14, and the CI pilot's four.

Part of opensoft/openRepoTools#118

🤖 Generated with Claude Code

Summary by Sourcery

Refuse handoffs for closed lanes before writing anything, while preserving safe behavior for reopened lanes and unreadable lane state.

Bug Fixes:

  • Prevent lane-handoff from reopening closed lanes by refusing before any state, log, checkout, or restart-intent changes.
  • Handle failures reading the lane's last state conservatively by exiting without treating the lane as open or closed.

Enhancements:

  • Preserve handoff behavior for lanes that are started again after being closed.

Tests:

  • Add coverage for closed-lane refusal across handoff modes, failed state reads, and lanes reopened after closure.

…tten, as `--late` does, instead of taking it from CLOSED to SWAPPING (opensoft/openRepoTools#118)

A lane whose log's last lane-kind line is an ENDED or a RETIRED is closed. `lane-handoff` on it read the lifecycle's CLOSED as the compare-and-swap's expected value and took the lane to SWAPPING, polled it, recorded an inventory, appended a PAUSED after the ENDED and finished at SWAPPED: a terminal lane reopened by a `/handoff` typed in a pane that was still there (opensoft/openRepoTools#118).

Now every mode but `--late` reads the lane's last lane-kind line right after the managed-ledger seam's refusal and exits 2 on an ENDED or a RETIRED, before the restart intent is reserved, the window is renamed, the handoff file, the register, the object log or the lifecycle is touched. The read and the refusal are `--late`'s own, moved into `read_last_lane_line` and `refuse_a_closed_lane`, so `--late` still refuses in the same order with the same words and the two modes cannot come to read a closed lane differently. Where they differ: `--late` and this check read the published object log through `lane-last`, whose last lane-kind line in file order is the lane's state, and the lifecycle's own read is `lane-state`, the snapshot `lane_state_follow` derived from those lines. A lane that a later STARTED or RESUMED reopened is therefore never refused, and a closed lane with no snapshot is. A `lane-last` that fails is said in a note and the swap goes on (R-A11-11), as the lifecycle's own failed reads let it; `--late` still dies 1 on it.

tests/test_a23_lane_handoff.py gains test_118_a_closed_lane_is_refused_before_any_write for a plain handoff and for `--restart`: a started lane closed with an ENDED, its lifecycle CLOSED, exits 2 with `--late`'s words, and the published register, the lane's log, W's reflog, the lane's checkout (head, changed files and handoff file), the lifecycle snapshot and the restart intent are all as they were. It fails against the old lane-handoff: the plain handoff exits 0 and takes the lifecycle CLOSED -> SWAPPING -> SWAPPED, and `--restart` exits 2 only after the record is written. A second case pins that a lane started again after its ENDED is handed off as before.

Brett Heap's answer, as lane 3 relays it on opensoft/openRepoTools#165 (6767535266): "`lane-handoff` refuses a CLOSED lane with exit 2 before any write, as `--late` does. That is Brett's "Refuse, as --late does (Recommended)"." Lane 3 released opensoft/openRepoTools#118 to lane 5 at 12:47:16Z.

Fixes opensoft/openRepoTools#118

Lane: openRepoTools-5
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Read the lane’s last lane-kind line and refuse closed lanes—or abort if the read fails—before handoff writes, while preserving --late’s existing refusal behavior.

  • lane-handoff L101-109, L1501-1511, L1763-1813 (+2 small edits)

Tests

Add coverage for closed-lane refusal without writes across handoff modes, failed lane-last reads, and lanes reopened after closure.

  • tests/test_a23_lane_handoff.py L44, L604-727

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

@sourcery-ai

sourcery-ai Bot commented Nov 10, 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 3 days and 21 hours by commenting @sourcery-ai review. Upgrade to get a review now.

brettheap and others added 2 commits November 10, 2026 23:59
…eeping both test blocks, #27's first

The merge brings #28, #29, #31 and #33 onto this
branch, on top of the #27 that lane 3 checked at 10799a5.

One conflict, at the end of tests/test_a23_lane_handoff.py: #27
appended its test_the_no_tmux_refusal_names_its_mode_not_both_words block
there, and this branch appended the #118 block (the _closed and _held helpers
and the three test_118 cases) at the same place. Resolved by keeping both,
unchanged and with two blank lines between them: code#27's block first, then
this branch's. No other file conflicted; lane-handoff merged by itself.

The resolved tests/test_a23_lane_handoff.py is blob
3927b53, the blob lane 3 computed on 10799a5.
No commit after 10799a5 on code main touches that file or lane-handoff
(git diff 10799a5 749e969 -- tests/test_a23_lane_handoff.py is empty), so the
blob is the same.

Checked before this commit: bash -n lane-handoff passes; each of the five test
ids of the two blocks passes, run one at a time (2 for code#27's block, 3 for
this branch's).

Lane: openRepoTools-5
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ot going on (MUST-1); the closed-lane test covers --exit and --in-process (SHOULD-1); a docstring says what it sets up (NIT-2)

Fix round for lane 3's review of #32 (post
6780380332), on top of the merge of code main (749e969).

MUST-1, lane-handoff: a lane-last read that failed let the handoff go on. The
block below seam_refuse (the one that runs for every mode but --late) said it
in a note and went on, so a lane closed with an ENDED, handed off with a
lane-last that exited 1, took CLOSED -> SWAPPING -> SWAPPED and got a PAUSED
after its ENDED: the defect of opensoft/openRepoTools#118 again. It now calls
read_last_lane_line and, where that fails, dies 1 before any write, naming the
failed read, as --late does on the same failed read (Amendment 7(d)): neither
exit 2, which claims the lane is closed, nor going on, which claims it is open.
The exit 2 refusal of a closed lane (refuse_a_closed_lane) is unchanged. The
two comments that described the old behaviour, the one above lifecycle_begin
and the one above this block, now say what the code does.

The test for it, test_118_a_failed_read_of_the_last_line_is_not_an_open_lane,
puts a stand-in for lanes-edit.sh in front of the real one that fails only
lane-last, with exit 1, on a lane closed with an ENDED. It asserts exit 1, the
refusal's words and not exit 2's, no PAUSED line in the log or in the register,
the lifecycle snapshot still CLOSED, and every place a handoff writes unchanged
(_held). On the merge commit's lane-handoff it fails: exit 0, with lifecycle
SWAPPING -> SWAPPED.

SHOULD-1: test_118_a_closed_lane_is_refused_before_any_write takes
("--exit",) and ("--in-process",) beside the plain form and --restart, since
the comment at the head of lane-handoff says every mode refuses.

NIT-2: the docstring of the started-again test implied an open log under a
CLOSED snapshot. lane-start's STARTED line resets the snapshot to RUNNING, so
it now says what the test sets up: log and snapshot both read open, and the
case guards against refusing an open lane. No assertion changed.

Part of opensoft/openRepoTools#118

Lane: openRepoTools-5
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ff-refuses-closed-lane

Lane 3 asked for this merge and a fresh CI run before landing (opensoft/openRepoTools#165, 6783977065).

Lane: openRepoTools-5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…osed-lane

code#35 landed first, so this PR takes main again, as lane 3 asked (opensoft/openRepoTools#165, 6784609742). The one conflict was the tail of tests/test_a23_lane_handoff.py, where both PRs append after code#27's block. The union keeps main's block first, then this PR's, and drops no line of either.

Lane: openRepoTools-5
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T22:38:49.969185Z 0356714 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 4d211d22dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…osed-lane

Lane 3 asked for this merge before landing (opensoft/openRepoTools#165, 6808628795).

Lane: openRepoTools-5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

@sonarqubecloud

Copy link
Copy Markdown

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 035671483b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@brettheap
brettheap merged commit ba2e6b9 into main Nov 11, 2026
20 checks passed
@brettheap
brettheap deleted the fix/118-handoff-refuses-closed-lane branch November 11, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant