Skip to content

a14_three waits out every sync its unreachable leg forks and ends the poisoned leg's nudge at once, so no sync holds the index lock into the next leg (opensoft/openRepoTools#165, lane 4's batch 6 Q18) - #36

Merged
mergify[bot] merged 4 commits into
mainfrom
fix/a14-three-nudge-race
Nov 11, 2026

Conversation

@brettheap

@brettheap brettheap commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openRepoTools-3
Claim: none (lane 3's ruling on lane 4's batch 6 Q18, opensoft/openRepoTools#165)

Summary

Test-only fix to tests/test_lane_helpers.sh at 749e969: no sync that an a14_three leg forks may still be running when the next leg starts. lanes-index and lanes-edit.sh are untouched.

Lane 4's batch 6 Q18 found the race: set-lane-state's a14_three fails with "its nudge DID reach for that store", expected [0], got [1] (T430's run-1110d-1), because a detached sync from the leg before it still held lanes-index.lock. Lane 3 ruled: "Lane 3 opens the fix on the code leg: wait for the poisoned leg's detached sync before the next a14_three."

The race, as read at 749e969

  • lanes-index runs one sync at a time per workstation, on an fcntl.flock of state_dir()/lanes-index.lock (SyncLock, lanes-index:1539-1580). A sync that finds the lock held leaves a mark and returns 0 before it opens any store (lanes-index:2257-2262).
  • A write's nudge is that sync, forked detached by index_nudge (lanes-edit.sh:3844-3857) from the write's exit trap, and nobody waits for it.
  • The poisoned leg (:16558 on main) ran with the suite's own PATH. The suite puts no lanes-index on it (the copy at :712-722 omits it, and SCRIPT_DIR is the sandbox bin directory), so a host that has one installed, as every lane workstation does, forked a real sync into the poisoned store from every write, unwaited. A clean CI runner has none, so the race needs a workstation.
  • That sync is also not harmless to the leg's purpose: a sync compares digests, so it rewrites the rows a write changed (lanes-index:1626-1651), and the inventory sync deletes stored rows the inventory no longer names (lanes-index:2162-2166), which includes the forged repoRC-5:/a14/forged row. Later poisoned legs then read a partly true index.
  • The unreachable leg forks one too. a14_wait_psql returns at the sync's first psql line, with the sync still running and the lock held, so it can also outlive its leg.

Design

  • Unreachable leg. A wrapper lanes-index is first on its PATH. It appends start and done lines to a log around the real script, which it runs by its own absolute path ($A14_BIN/lanes-index, unchanged). New a14_wait_nudges polls the log (300 polls of 0.1 s) until every sync that began has ended, and a write leg also requires one to have begun, so a wrapper that was never on PATH is a failure and not a quiet pass. It runs before a14_restore. One is per call asserts it. No lock is probed and no flock is used: a probe that took the lock would make the nudge it waits for drop its sync.
  • Poisoned leg. A wrapper is first on its PATH that ends sync at once (no lock, no store) and hands every other subcommand to the real script. A stub that ended every call would also have ended an export, so an act that read the poisoned index would have found nothing to read. Reads of the poisoned store stay real, and the forged rows stay forged.
  • Why a wrapper in the poisoned leg and not a wait. The leg proves reads, not nudges, and a real nudge there erodes its poison. Ending the nudge is the smaller change and cannot make a leg wait on an unrelated store.
  • Known limit. The wait counts syncs that have logged start. An act that forked two nudges, the second of which had not yet started when the first ended, would be missed. None of the five write acts in the section does: the three register writers set only the register nudge (cp_pushed, lanes-edit.sh:3460) and set-lane-state and set-lane-tree set only the inventory one (lanes-edit.sh:22269 and 22470), and the lifecycle follow that can set both runs only after a started, resumed, ended or retired line (lanes-edit.sh:15529-15531).

Proof

The suite has no section selector at 749e969 (no OPENREPOTOOLS_SHELL_SECTIONS reader in the file), so the a14 section cannot run alone. tests/run.sh and pytest were not run; the code leg's CI runs the whole shell suite on this PR.

  • bash -n tests/test_lane_helpers.sh is clean, and the repository's text hygiene rules (unescaped backticks in descriptions, unbraced variables before a non-ASCII character, GNU-only utilities, case inside a substitution) were replayed over the file: nothing new.
  • The real a14_three, a14_wait_psql and a14_wait_nudges text of the old and the new file was driven over a model indexer with the same lock semantics, four calls each (three writes and one read):
    • old file, host indexer on PATH, slow poisoned sync: 2 failures, "its nudge DID reach for that store", expected [0], got [1], which is lane 4's failure;
    • old file, no host indexer, slow unreachable sync: 1 failure of the same kind, and 5 of 12 restores ran with a sync still in flight;
    • new file, three variants (host indexer, none, both syncs slow): 32 passed, 0 failed, and 12 of 12 restores saw no sync in flight.
  • The wait itself: a sync holding the lock for 3 s made it wait 3.11 s and return 0. A sync that never ends made it return 1 after about 32 s, which a14_three reported as FAIL ... none left holding the index's lock, expected [0], got [1]. A write leg with no wrapper run failed the same way, and a read leg returned at once.
  • The wrappers: the logging one passed arguments and the exit status through (sync --source inventory, exit 7, log start then done 7). The poisoned leg's ended sync and sync --source inventory with exit 0, took no lock and wrote nothing, and its export reached the real script.

🤖 Generated with Claude Code

Summary by Sourcery

Make Amendment 14 lane-helper tests wait for detached syncs and isolate poisoned-index behavior so successive legs cannot interfere with one another.

Bug Fixes:

  • Prevent Amendment 14 test legs from leaving detached index synchronization processes running into subsequent legs, eliminating workstation-dependent lock races and false nudge assertions.

Enhancements:

  • Strengthen the test harness by tracking sync-specific database calls and waiting for all forked syncs to finish before restoring snapshots.
  • Provide dedicated indexer wrappers so the unreachable leg observes real sync completion while the poisoned leg preserves its intentionally corrupted index during reads.

Tests:

  • Improve Amendment 14 coverage to verify that write nudges start and complete correctly without relying on index-lock probing.

… poisoned leg's nudge at once, so no sync holds the index lock into the next leg (opensoft/openRepoTools#165, lane 4's batch 6 Q18)

THE RACE. lanes-index runs one sync at a time per workstation on an fcntl lock
in its state directory, and a sync that finds the lock held leaves a mark and
returns 0 before it opens any store (lanes-index:2257-2262). A write's nudge is
that sync, forked detached by the write's exit trap (lanes-edit.sh:3844) and
waited for by nobody. a14_three forked two such syncs it never waited out:
  * the unreachable leg's: a14_wait_psql returns at the sync's FIRST psql line,
    with the sync still running and holding the lock;
  * the poisoned leg's: its PATH carried no indexer of its own, so a host with
    lanes-index installed (every lane workstation; a clean CI runner has none)
    forked a real sync into the poisoned store from every write.
The next a14_three then found the lock held and its unreachable-leg nudge
returned without reaching psql: T430's run-1110d-1, "set-lane-state ... its
nudge DID reach for that store", expected [0], got [1]. A real sync into the
poisoned store also mends the rows the leg exists to read wrong (the inventory
sync deletes the forged row and rewrites the rows a write changed).

THE DESIGN. Test file only; lanes-index and lanes-edit.sh are untouched.
  * Unreachable leg: a wrapper lanes-index, first on its PATH, logs a start
    line and a done line around the real script, run by its own absolute path
    ($A14_BIN, unchanged). a14_wait_nudges polls that log (300 x 0.1 s) until
    every sync that began has ended, and a write leg also needs one to have
    begun, before a14_restore. No lock is probed and no flock is used.
  * Poisoned leg: a wrapper that ends sync at once (no lock, no store) and
    hands every other subcommand to the real script, so a read of the poisoned
    store is still a read of it. The suite's bin directory holds no
    lanes-index, so without a wrapper an act that read the index would find
    none on a clean runner.
  * a14_three asserts the drain with one more is per call.

THE PROOF. The suite has no section selector at this commit, so the whole
section was not run (tests/run.sh and pytest were not run either). bash -n of
the file is clean, and the real a14_three, a14_wait_psql and a14_wait_nudges
text of the old and new file were driven over a model indexer with the same
lock semantics:
  * old file, host indexer on PATH, slow poisoned sync: 2 of 4 write legs fail
    with "nudge DID reach ... expected [0], got [1]";
  * old file, no host indexer, slow unreachable sync: 1 fails the same way, and
    5 of 12 restores ran with a sync still in flight;
  * new file, three variants (host indexer, none, both syncs slow): 32 passed,
    0 failed, and 12 of 12 restores saw no sync in flight;
  * a 3 s sync makes a14_wait_nudges wait 3.11 s and return 0; a sync that
    never ends makes it return 1 after about 32 s, which a14_three reports as
    an is failure; a write leg with no wrapper run fails the same way, and a
    read leg returns at once.

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

sourcery-ai Bot commented Nov 11, 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 17 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Tests

Update the Amendment 14 test harness to track unreachable-leg syncs, wait for them to finish before restoring snapshots, and suppress poisoned-leg nudges while preserving real reads.

  • tests/test_lane_helpers.sh L16417-16480, L16595-16611, L16616-16643 (+4 small edits)

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

brettheap and others added 3 commits November 11, 2026 01:19
…meout names its counts, and two comments say what was measured (#36 review)

Part of opensoft/openRepoTools#165 (lane 4's batch 6 Q18). Fix round on
#36 after its independent review, which read it
READY at 0be5f1b with three optional NITs; the first change is owed by lane 3
on opensoft/openRepoTools#165. Test file only.

  * The unreachable leg's wrapper logs start and done only when the
    subcommand is sync, with or without --source inventory, and execs the
    tree's own script ($A14_BIN) for every other subcommand with no log line.
    A mode question or a register prefetch is not a nudge, and counted as one
    it would let a write leg's "one began" prove only that lanes-index ran.
    a14_nudge_counts therefore counts exactly the syncs. The poisoned leg's
    wrapper and the control leg are untouched.
  * The timeout's failure description carries the counts from the wrapper's
    log and the count begun before the leg, so a failure shows whether a sync
    was stuck or never began. The status is taken before the description is
    built: its command substitution would otherwise be the status the
    assertion reads.
  * The wait's bound is stated as it is: 300 polls, each a 0.1 s sleep and an
    awk run, about 32 s idle and about 49 s under heavy load.
  * The poisoned leg's comment no longer says an act that read the index would
    prove nothing: it would still differ from the control leg on stderr, and
    what main lacked was the poisoned content.

Proof, with the whole shell suite not run (CI verifies): bash -n is clean;
the real a14 helpers over the model indexer pass 32 of 32 in three variants
with no sync in flight at any restore; export, mode and register read through
the wrapper leave the counts at 0 0, sync and sync --source inventory make
them 1 1 and 2 2; a sync that never ends fails the assertion after about 32 s
with "1 0; begun before this leg: 0", and a leg that forks nothing fails it
with "0 0; begun before this leg: 0".

Lane: openRepoTools-3
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…udge-race

Part of opensoft/openRepoTools#165 (lane 4's batch 6 Q18); the branch is
#36. main moved from 749e969 by
#34, which adds only .github/workflows/verify.yml,
so the merge changes nothing in tests/test_lane_helpers.sh.

Lane: openRepoTools-3
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…is not a nudge cannot satisfy the wait (#36)

Part of opensoft/openRepoTools#165

The unreachable leg's wrapper runs the real script for a sync with
A14_CALLER=sync in its environment and keeps its plain exec for every other
subcommand. The fake psql logs "psql sync" for that caller and "psql other"
for any other, with its stderr text and exit status as they were.
a14_wait_psql counts only the sync lines (new a14_psql_syncs), and the count
a14_three takes before the leg is taken the same way, so both sides of the
comparison count alike. Once T504's register prefetch or T409's mode question
reaches psql, an uncounted call would satisfy the wait before the nudge had
reached its store.

The read leg's "reached for no store at all" keeps counting every line, with
its own baseline: a read that reaches psql by any caller is what it exists to
catch. The poisoned leg, the control leg and the nudge counts are unchanged.
Test file only.

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

Copy link
Copy Markdown

@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-11T18:14:14.409928Z 63a47bd 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. You're on a roll.

Reviewed commit: 63a47bdcc9

ℹ️ 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

Copy link
Copy Markdown
Contributor Author

Brett approved landing #35 and #36 through one narrow real-code Mergify batch after full CI and exact-head Codex review. Queue configuration is in #42. Please leave this PR unmerged and its branch unchanged for this bounded batch; no hold on other work or repository-wide freeze is requested. This coordination does not restart, rebind, retarget or edit any lane session.

@brettheap

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue openrepotools-real-code-35-36

@brettheap

Copy link
Copy Markdown
Contributor Author

@Mergifyio refresh

@mergify

mergify Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

queue openrepotools-real-code-35-36

⚠️ Naming a queue is deprecated. Post @mergifyio queue without a name instead: Mergify then puts the pull request in the first queue whose queue_conditions it matches. A future release will stop accepting the name.

@mergify

mergify Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as ffe3a94 at 19:37 UTC

Merged together with #35. 38 min in the queue, 36 min of it CI.

So far

10 merge conditions met
  • check-success=@github-actions/guard-launch-mode
  • check-success=@github-actions/package
  • check-success=@github-actions/tests
  • check-success=@github-actions/tests-no-submodule
  • github-code-owner-review-satisfied · required by GitHub repository ruleset rule Require Code Owner Review
  • github-review-approved · required by GitHub repository ruleset rule Require Code Owner Review
  • any of · required by GitHub repository ruleset rule main: the four tests.yml jobs required (owner act 2):
    • check-success = guard-launch-mode
    • check-neutral = guard-launch-mode
    • check-skipped = guard-launch-mode
  • any of · required by GitHub repository ruleset rule main: the four tests.yml jobs required (owner act 2):
    • check-success = tests
    • check-neutral = tests
    • check-skipped = tests
  • any of · required by GitHub repository ruleset rule main: the four tests.yml jobs required (owner act 2):
    • check-success = tests-no-submodule
    • check-neutral = tests-no-submodule
    • check-skipped = tests-no-submodule
  • any of · required by GitHub repository ruleset rule main: the four tests.yml jobs required (owner act 2):
    • check-success = package
    • check-neutral = package
    • check-skipped = package

Times in UTC · dashboard · how the merge queue works

@mergify

mergify Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

refresh

✅ Pull request refreshed

@mergify mergify Bot added the queued label Nov 11, 2026
@mergify
mergify Bot merged commit ffe3a94 into main Nov 11, 2026
31 checks passed
@mergify mergify Bot removed the queued label Nov 11, 2026
brettheap added a commit that referenced this pull request Nov 11, 2026
…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 added a commit that referenced this pull request Nov 11, 2026
…tten, as `--late` does, instead of taking it from CLOSED to SWAPPING (opensoft/openRepoTools#118) (#32)

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`, then
`SWAPPED`, appending a `PAUSED` after the `ENDED`: a terminal lane reopened
by a `/handoff` typed in a pane that was still there.

- `lane-handoff`: `--late`'s read of `lane-last` and its `ENDED` or
  `RETIRED` refusal move into `read_last_lane_line` and
  `refuse_a_closed_lane`. Every mode but `--late` calls them right after
  the managed-ledger seam's refusal, before the restart intent, the window,
  the handoff, the register, the object log or the lifecycle is touched. A
  closed lane exits 2 with `--late`'s words, and `--late` keeps its own
  order and words.
- The log is the lane's state: a lane that a later `STARTED` or `RESUMED`
  reopened is never refused, and a `lane-last` read that fails exits 1
  before any write (Amendment 7(d)).
- tests/test_a23_lane_handoff.py: a closed lane is refused before any
  write, for the plain handoff, `--restart`, `--exit` and `--in-process`; a
  failed read of the last line is not an open lane; and a lane started
  again after its close is handed off as before.

It is the option Brett Heap chose for opensoft/openRepoTools#118, "Refuse,
as --late does (Recommended)". The issue stays open for the transition
table its "What's open" also asks for.

Lane openRepoTools-3's independent review read READY at 1915f48, after the
fix round for its MUST and SHOULD, and its delta check read READY at the
merge 959e21a. The merge 4d211d2 took code main 92f9e10
(#36 and #35): lane 3 checked that its tree
equals git merge-tree's in every file but tests/test_a23_lane_handoff.py,
which holds both sides' blocks, main's first, and Codex found no major
issue there. The head 0356714 then merges code main d3c55e5
(#44 and #45, two CI changes), and its tree,
3284253, is git merge-tree's of d3c55e5 and 4d211d2, so it adds nothing
of its own. Codex found no major issue at 0356714. All 18 checks that
ran passed at 0356714 on main d3c55e5 (Sourcery's review was skipped and
the Mergify queue check was neutral), so the tested tree is this commit's
tree, 3284253. Lane openRepoTools-3 lands it under Brett Heap's standing
landing word, which he extended on 2026-11-10 to lane-tooling fixes any
lane writes, once lane 3 has reviewed them.

Part of opensoft/openRepoTools#118

Lane: openRepoTools-5
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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