You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
lane's pick: the pty driver gets its own 240 s bound and reports a timeout as one; the lanes read's quadratic lookup is made linear (57 s → 3 s) - #146
1. The harness.tests/test_lane_helpers.sh drives lane's numbered pick under a real terminal with an embedded pty-run.py. That driver gave up after 60 s without output and SIGKILLed the child, so the case read 128 + 9 and printed expected [N], got [137]. That looks like a wrong exit code, but it was the driver's own clock. 60 s is also lanes-edit.sh's acquire_lock bound and its LANES_GIT_TIMEOUT, so a timeout could not be told from a helper waiting out its own 60 s.
The driver has its own bound: 240 s of silence. The clock restarts with every byte. The comment beside it gives the reasons for that number. It is more than twice the worst silence the measurements imply for CI: claim --force takes over a dead lane's hold; lane-end --retire ends a duplicate holder #61's 45 s call, on a runner ~2.2x slower than a workstation, is ~100 s. It also matches none of the bounds the driver drives: 60 (acquire_lock, LANES_GIT_TIMEOUT) and 300 (lane --wait). LANE_PTY_SILENCE overrides it for the one case that proves the timeout itself.
A timeout reports as a timeout. The driver kills the child's whole process group: SIGTERM, five seconds for traps, then SIGKILL. That includes the lanes-edit.sh reads under lane, which killing the single pid used to leave running. It then prints pty-run: TIMEOUT: the child wrote nothing for Ns and was killed … and the partial transcript on its own stderr, and exits 124, never a 128 + n. lane_pick turns that report into a FAIL of its own, prints the report and the transcript under it, and sets $rc to TIMEOUT. A pick case therefore cannot read a kill as the command's exit code.
The property has its own test. The test runs a child that prints, starts a grandchild, and goes silent past a 1 s bound. The driver must exit 124 (not 137), print the report and the partial transcript, and leave the grandchild gone. A zombie counts as gone, because pid 1 in this workstation's container is sleep infinity and never reaps. A second case checks that a child which answers keeps its own exit code. The test takes about 1.5 s.
2. The cost. I measured first, inside the suite's own environment: the suite was run up to the pick section and its sandbox frozen there, with 2,563 assertions passed, 194 register rows and 162 object logs. Almost all of one lane call is the lanes read, and almost all of that read is one loop:
table_lookup was quadratic.${table#*"$GS<lane>$US"} makes bash try a leading-* pattern against every prefix of the string, and lanes_rows makes three or more lookups per lane over tables with a line for every lane. ${table%%"$GS<lane>$US"*} finds the same first occurrence, and bash only tries the pattern where its first character ($GS, once per line) matches, so it is linear. The rest is cut by a character offset.
The --repo/--prefix filters forked lc for every lane in the estate. That was up to eight processes per lane, spent mostly on lanes the filter then drops. The two constant sides are now lower-cased once, with lc itself. The lane's side uses a new lower_into: tr 'A-Z' 'a-z''s mapping (the 26 ASCII capitals, nothing else) written as 26 literal substitutions, with no process.
Nothing else changed: no wire form, no column (A18's 13, A19's 14–17), no exit code. lane itself is untouched.
Measurements
All on Eagle (WSL2, 32 cores, bash 5.2.21), against the frozen fixture described above. Load was 9–14 throughout, because another lane's pytest runs were live. Old and new were run side by side wherever the numbers are compared directly.
One lane call (the listing, stdin not a terminal, LANG unset):
run 1
run 2
run 3
main (14641fd)
59.2 s
56.9 s
50.2 s
table_lookup linear only
6.0 s
6.6 s
5.6 s
this PR
3.4 s
3.2 s
3.2 s
One pick under the suite's own pty driver. Python's PEP 538 coercion hands the child LC_CTYPE=C.UTF-8, as on CI. Old and new ran concurrently:
main
this PR
lane_pick 1 … --dry-run
77.2 s (the old 60 s driver would have SIGKILLed it: got [137])
7.5 s
lane_pick f … --dry-run
81.1 s (likewise)
7.3 s
Per helper: each fork lane makes before printing anything, with its exact arguments:
Inside that lanes read: phase markers in scratch copies of both helpers, the two copies run concurrently:
phase
main, LANG unset
PR, LANG unset
main, C.UTF-8
PR, C.UTF-8
preamble (workspace, workstation, probes)
0.06 s
0.06 s
0.07 s
0.07 s
names (register + log list)
0.06 s
0.06 s
0.06 s
0.07 s
state_events + lane_row_facts (a git show per log)
0.89 s
0.92 s
0.97 s
0.97 s
register indexes, live records, log list
0.07 s
0.06 s
0.07 s
0.07 s
fork_map
0.30 s
0.31 s
0.34 s
0.35 s
per-lane loop
47.01 s
1.48 s
67.10 s
5.40 s
total
48.4 s
2.9 s
68.6 s
6.9 s
Same answers. I ran main's helper and this PR's side by side over nine scopes: --all, --all --closed, --here, --repo, --repo --closed, --prefix, --lane, the pick's own scoped read, and lane's listing. All nine are byte-identical in stdout, stderr and exit code. The timings from that run (18 reads at once, so slow on both sides): --all 71.1 → 6.1 s, --here 71.5 → 6.0 s, scoped 66.1 → 4.1 s, lane listing 66.8 → 4.5 s, --lane 1.6 → 1.3 s. lower_into matches lc on ASCII, mixed case, multibyte, glob characters and a tab, in the POSIX and C.UTF-8 locales. The lookup's micro-benchmark gives the same answers for a first match, a duplicate key, a missing key and multibyte content.
Two things the issue said that the code does not
lane does not read lanes twice.lane:364/:381 (now :366/:383) are the two branches of one read: with a temporary file for the helper's notes, or without one. The pick path forks workstation, lanes, lane-groups and next-free, once each. The only double read is next-free again in go_new when the answer is f (below).
The 60 s match with acquire_lock was a coincidence, as the issue's second reading had already found. The child was in the lanes read the whole time.
Follow-up: left alone because each needs a decision, not a measurement
The loop is still ~5.4 s in a UTF-8 locale (1.5 s without one). Each lookup converts the whole table to wide characters. A lookup in the C locale returns the same bytes, because every delimiter is ASCII, and is about 3x faster again in UTF-8. But it relies on bash undoing a function-local LC_ALL on return, and that wants a check on macOS bash 3.2 before it is trusted. A one-pass awk join of the tables would avoid both issues but restructures the loop.
state_events runs one git show per object log: ~0.9 s for 162 logs. One git cat-file --batch would read them all, but it changes the event stream's plumbing, which every state read is built on.
go_new forks next-free a second time over the same rows (~0.1 s, only on f). Reusing the listing's answer would make the act open exactly the position the question offered. But if the register moves while the question waits, today's act opens the next position and the reused answer would refuse instead. That is a behavior choice, so it is not made here.
Caching the listing across processes (lane → lanes-edit.sh ×4) is a design question for the read's freshness contract.
Tests
New cases. The driver's timeout: a silent child is 124 with the report and the partial transcript, its process group is gone, and a child that answers keeps its own code. The SIGTERM grace belongs to the whole group (added after Copilot/Codex round 1; it fails under the old loop). The case-blind filters: --prefix REPOPICK and --repo OpenSoft/REPOPICK must list exactly the rows' own spellings' lanes, and each must name one (added after Copilot round 1; it fails with lower_into broken).
Lane: openRepoTools-3
🤖 Generated with Claude Code
Summary by Sourcery
Speed up lane reads and make PTY-driver timeouts explicit and reliably isolated from command exit codes.
New Features:
Make the PTY test driver enforce an independent, configurable silence timeout and report timeouts distinctly from child exit codes.
Add coverage for timeout handling, process-group cleanup, termination grace periods, and case-insensitive lane filters.
Bug Fixes:
Prevent PTY-driven lane picks from misreporting driver-killed children as exit code 137.
Ensure timed-out child process groups, including descendants, are terminated cleanly.
Enhancements:
Replace quadratic lane table lookups with linear lookups and avoid repeated per-lane lowercasing processes, substantially accelerating lane reads and picks while preserving their output and exit behavior.
Tests:
Verify silent children return timeout status 124 with diagnostics and partial output, responsive children retain their exit codes, descendants are gone, and termination traps receive grace.
`table_lookup` found a lane's line with `${table#*"$GS<lane>$US"}`. Bash
removes a shortest prefix by trying the pattern against every prefix of
the string in turn, and a pattern that opens with `*` costs a scan of
that prefix each time, so each lookup was quadratic in the table's size.
`lanes_rows` makes three or more lookups per lane over tables holding a
line for every lane, so the cost grew with the square of the register.
`${table%%"$GS<lane>$US"*}` names the same first occurrence (everything
before it, where the old form gave everything through it), and bash only
tries that pattern where its first character matches -- `$GS`, once per
line -- so it is linear. The rest is cut by offset, counted in characters
on both sides, so a multibyte table cuts where it did.
Measured on the suite's own fixture register at the pick section (194
rows, 162 object logs), this change alone, load ~14 on 32 cores: one
`lanes --dir --prefix --repo` read 57.3 s -> 5.6 s (the per-lane loop
56.6 s -> 3.6 s), one `lane` listing 50.2-59.2 s -> 5.6-6.6 s. A
micro-benchmark of the two expansions over the same 200-line table gives
the same answers (first match, missing key, multibyte content) at
1,060 ms -> 15 ms for seven lookups.
Refs #107
Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The `--repo` and `--prefix` filters in `lanes_rows` compared
`$(lc "$lr_home")` with `$(lc "$lr_repo")` and `$(lc "$lr_l")` with
`$(lc "$lr_prefix")` for every lane in the estate -- a subshell and a
`tr` each, so up to eight processes per lane, spent mostly on lanes the
filter then drops. Once the lookup was linear this was the largest cost
left: 3.2 s of one scoped read on the suite's fixture register.
The repository and prefix sides do not change from lane to lane, so they
are lower-cased once, with `lc` itself, before the loop. The lane's side
goes through a new `lower_into`, which is `lc` without a process: the
twenty-six ASCII capitals and nothing else, as `tr 'A-Z' 'a-z'` maps
them, written as twenty-six literal substitutions so no locale's range or
case rules can widen it. Checked against `lc` on ASCII, mixed case,
multibyte, glob characters and a tab, in the POSIX and C.UTF-8 locales:
identical.
Measured on the same fixture with both changes, the old and new helpers
run side by side: one scoped `lanes` read 48.4 s -> 2.9 s (LANG unset)
and 68.6 s -> 6.9 s (LC_ALL=C.UTF-8); one `lane` listing ~55 s ->
3.2-3.4 s. Nine scopes (--all, --all --closed, --here, --repo,
--repo --closed, --prefix, --lane, the pick's own scoped read, and
`lane`'s listing) are byte-identical to main's: stdout, stderr and exit
code.
Refs #107
Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>
`pty-run.py`, which drives `lane`'s numbered pick under a real terminal,
waited 60 s for output and then SIGKILLed the child, so the case read
`128 + 9` and printed `expected [2], got [137]` -- a wrong exit code that
was really the driver's clock. 60 s is also `lanes-edit.sh`'s
`acquire_lock` bound and its `LANES_GIT_TIMEOUT`, so a helper that waited
its own 60 s out could not be told from it. `lane` prints nothing until
its listing is rendered, and that silence was 33-45 s on a workstation
and past 60 s on slow runners: six CI runs named in #107, darwin and
then Linux, the killed case moving between runs, none of them a defect
in `lane`.
* The driver's bound is its own: a 240 s SILENCE bound (the clock
restarts with every byte), more than twice the worst silence observed
on CI and none of the numbers it drives (60, 300). The comment says
why that number.
* A timeout kills the child's whole process group (SIGTERM, five
seconds, SIGKILL) -- `lane` and the `lanes-edit.sh` reads under it,
which a kill of the one pid left running -- and the driver says so on
its own stderr: the child wrote nothing for Ns and was killed, partial
transcript follows. It exits 124, never a `128 + n`.
* `lane_pick` turns that report into a FAIL of its own, prints the
report and the transcript under it, and sets `$rc` to `TIMEOUT`, so
no pick case can read a kill as the command's exit code.
* A case proves it: a child silent past a 1 s bound comes back as 124
with the report and the partial transcript, its grandchild is gone
(a zombie counts as gone -- pid 1 here is `sleep infinity` and never
reaps), and a child that answers keeps its own exit code.
Refs #107
Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The PR hardens the PTY-based lane-pick harness so silence timeouts are reported deterministically and kill complete process groups, adds focused regression tests for those semantics, and optimizes lane reads by replacing quadratic table lookups and repeated per-lane lowercasing forks with linear lookup and in-process ASCII normalization.
Sequence diagram for PTY silence timeout handling
sequenceDiagram
participant Test as lane_helper_test
participant Driver as pty-run.py
participant Child as lane_pick_child
participant Group as child_process_group
Test->>Driver: run child with LANE_PTY_SILENCE
Driver->>Child: start under PTY
Child-->>Driver: partial transcript
Note over Driver: Silence bound expires
Driver->>Group: SIGTERM
Driver-->>Group: wait five seconds
Driver->>Group: SIGKILL
Driver-->>Test: stderr timeout report and transcript
Driver-->>Test: exit 124
Test->>Test: verify process group is gone
Loading
Flow diagram for linear lane filtering
flowchart LR
Tables[Fenced lane tables] --> Lookup[table_lookup]
Lookup --> Linear[Find first GS lane US match with %%key*]
Linear --> Facts[Lane row facts]
Repo[--repo value] --> RepoLC[lc once]
Prefix[--prefix value] --> PrefixLC[lc once]
Facts --> Lane[Current lane]
Lane --> Lower[lower_into]
Lower --> Match[Compare repo or prefix]
RepoLC --> Match
PrefixLC --> Match
Match --> Rows[Filtered lane rows]
Loading
File-Level Changes
Change
Details
Files
Make the PTY harness distinguish driver timeouts from child exit statuses and terminate the entire child process group.
Increase the default silence bound to 240 seconds, reset on output, with an environment override for timeout testing.
On timeout, send SIGTERM, allow five seconds for traps, then SIGKILL the process group and drain the remaining transcript.
Report timeout details and partial output on stderr, preserve terminal output on stdout, and exit 124.
Teach pick assertions to recognize the timeout report as a harness failure rather than interpreting 137 as the command's status.
tests/test_lane_helpers.sh
Add regression coverage for timeout semantics, process-group cleanup, and normal exit-code pass-through.
Run a silent child with a grandchild under a one-second bound and verify exit 124, timeout diagnostics, partial output, and no running grandchild.
Verify a responsive child retains its own nonzero exit code and is not classified as a timeout.
Skip the PTY-specific cases when Python PTY support is unavailable.
tests/test_lane_helpers.sh
Replace the quadratic table lookup with a linear-time first-match lookup while preserving character-offset and multibyte behavior.
Use a longest-suffix expansion to locate the table key and slice the remainder by the key and prefix character lengths.
Keep the existing lookup output, missing-key status, and first-occurrence semantics.
lanes-edit.sh
Remove repeated per-lane lowercasing processes from filtered lane reads.
Precompute lowercased repository and prefix filter values once.
Add an in-process ASCII-only lowercasing helper for each lane value.
Use the helper for repository and prefix comparisons without changing filter behavior or output.
Give the pty driver an independent silence timeout and report driver-enforced timeouts distinctly, including the partial transcript, without exposing SIGKILL-derived exit codes as the child's result.
Prevent the macOS lane_pick cases from crossing the pty bound during normal execution by making the lanes read substantially faster while preserving its output and behavior.
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!
Copilot and Codex, round 1 on #146: the driver's five-second grace after
SIGTERM ended the moment it reaped the LEADER. `lane` can die on the
signal at once while a writer under it is still in its trap releasing a
lock, and the SIGKILL then came a tenth of a second later.
The leader is now reaped as the loop goes, and the grace runs until
nothing in the group is RUNNING or the five seconds are up. "Running"
excludes zombies, read from `ps -A -o pgid=,stat=`, because in a
container whose pid 1 never reaps (this workstation's is `sleep
infinity`) a dead group's zombies would otherwise hold the grace open
to the deadline every time.
A case proves it: a leader that dies on the SIGTERM at once, and a
grandchild that takes a second in its trap to write a marker. It passes
with this loop and fails with the old one (measured, both, on this
workstation). The grandchild traps HUP as well as TERM, and the comments
say why: the leader is the terminal's controlling process, so its exit
hangs the terminal up on the group -- the kernel's act, which no driver
can stop, and measured to kill an untrapped grandchild under either
loop. A dead holder's lock is `acquire_lock`'s to take over.
Refs #107
Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot round 1 on #146: the fork-free lowering `lower_into` added for
the `--repo` and `--prefix` filters was never exercised with a case
difference -- every existing `lanes --repo`/`--prefix` case asks in the
rows' own spelling, and the mixed-case cases go through `--lane`, which
skips both filters.
Three reads beside the pick section's own: `--prefix REPOPICK` and
`--repo OpenSoft/REPOPICK` must list exactly the lanes the rows' own
spellings list, and each must name a seeded lane, because two empty
lists are equal. Measured on the suite's frozen fixture: all four
assertions pass with this branch's helper and with main's; with
`lower_into` broken to return its input, both by-name assertions fail
(and the `--prefix` comparison alone passed, which is why they are
there).
Refs #107
Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>
edf6b45 went red on `tests` and `tests-no-submodule` (and locally) on one
case: "a descendant still in its SIGTERM trap when the leader has gone
is given its grace". The suite puts a FAKE `ps` first on PATH -- it
answers `-p <pid>` out of `$FAKE_PS_RECORDS` and exits 1 on anything
else -- so the driver's `ps -A -o pgid=,stat=` came back empty, read
the group as gone, and ended the grace the moment the leader was
reaped: the very defect 5c9515e fixed, re-created by the fake.
Both reads now name the real binary (`/bin/ps`, else `/usr/bin/ps`).
The bash `pty_running` beside the earlier process-group case had the
same exposure the other way round: the fake's empty answer read as
"gone", so that case passed in the suite without asking anything.
Reproduced standalone with the suite's own fake `ps` first on PATH:
edf6b45's driver fails that case exactly as CI did; this one passes
10/10, with and without the fake.
Refs #107
Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local and CI results on the current head da0e5bb. Each local run is tests/run.sh -k 'lane_helper or hygiene' behind the workstation lock, on Eagle.
run
head
result
local 1
7d60230
160 passed, 566 deselected in 1109.87s
local 2
edf6b45
1 failed, 159 passed, the new grace case (below)
local 3
da0e5bb
160 passed, 566 deselected in 1356.25s
local 4
da0e5bb
160 passed, 566 deselected in 1195.46s
CI tests
da0e5bb
success, 16 min 01 s
CI tests-no-submodule
da0e5bb
success, 13 min 28 s
CI tests-windows, parse-macos, guard-launch-mode
da0e5bb
success
The lane-helper suite's wrapper asserts its footer passed, 0 failed, so each green row above includes the whole lane pick section. #143's eight argv=--with-lane failures did not appear in any of the four local runs, although /usr/local/bin/lclaude is present.
The red at edf6b45 and its fix (da0e5bb). The round-1 grace fix asked ps -A -o pgid=,stat= whether the group was still running. The suite puts a fake ps first on PATH that answers only -p <pid>, so the read came back empty and the grace ended at once: the defect being fixed, re-created by the fake. CI's tests and tests-no-submodule and local run 2 all failed on exactly that one case. Both ps reads now name the real binary. The bash check beside the earlier process-group case had been passing vacuously for the same reason, and is now real. The fix was reproduced standalone with the suite's own fake ps on PATH: edf6b45 fails that case, and da0e5bb passes 10/10 with and without the fake.
Reviews. Copilot round 1 found 2 issues and Codex found 1, all taken, replied to and resolved. Copilot round 2 on edf6b45 recommended approval with no findings. Round 3 on da0e5bb, past the two-round cap, recommended approval with no findings and one "previously missed" wording note on a comment's run count. Per the cap that note is filed as #147.
Bring #97 onto a current base before the seam rework Brett Heap ruled on
2026-10-04 ("managed ledger owns enrolled lanes; #97 owns legacy — rework
both"). Main moved 14 commits past 957a26f, to daed209: #81 lane-rename,
#83 Amendment 18, #93 Amendment 19, #61 claim --force takeover, #146,
#119, #101-#103, #129, #131, #133, #135, #136, #139 and #134.
Four files conflicted, and in every one both intents survive:
- lanes-edit.sh, the function sections: both sides appended after
migrate_state_cells. Main's Amendment 19(c)/(d) sweep and archive stay
directly under it, because its header says "the shape
`migrate-state-cells` has one screen up"; #97's lifecycle and
inventory section follows them.
- lanes-edit.sh, the unknown-subcommand refusal: the union of both lists,
56 names, the same set as the dispatcher's 56 arms.
- lanes-edit.sh, the exit-code table, and the manual's copy of it: #97's
7 row ("another act got there first", in three verbs) is kept, and exit
9 now has two meanings, one per verb. #61 spent 9 on `claim --force`'s
abandoned takeover and #97 spent it on `lane-state`'s unreadable
snapshot, and each PR took it as unused. Neither verb can return the
other's 9, so the table names both and nothing is renumbered in a
merge. The manual's 9 row said "(`claim` only)", which the merge would
have made false; its 7 row now names #97's two fenced writers too, as
the code table already did. The next commit moves #97's 9 to 10.
- lane-handoff, the late-record restart line: #129's
`$lane_profile_word` (lclaude) with #97's lifecycle line under it.
- docs/README-lanes.md: Amendment 19's section, then #97's #91 section,
so the amendment sections stay in number order.
- tests/test_lane_helpers.sh: main's Amendment 19 and Amendment 18
sections run first, in main's order (A18's restores its fixtures), and
#97's self-contained #91 section follows them, before the
workstation-seam section, as it did on #97's branch.
lane-start auto-merged around #134's rewrite. #97's section 4a still
prints the reconciliation after Amendment 18's binding gate and before
section 5 and the STARTED/RESUMED write in 5b. AGENTS.md, README.md,
tests/test_repo_hygiene.py and skills/ are byte-identical to main, so
the 316- and 486-line caps already match the merged counts.
Locally, tests/run.sh -k 'lane_helpers_suite or repo_hygiene or
lane_start_claude_current or guard_launch_mode or install_skill_and_hook':
274 passed, 600 deselected, in 1560 s.
Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
readylanding gate: runs tests-macos once before the squash
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
#107 has two halves, and this PR does both.
1. The harness.
tests/test_lane_helpers.shdriveslane's numbered pick under a real terminal with an embeddedpty-run.py. That driver gave up after 60 s without output and SIGKILLed the child, so the case read128 + 9and printedexpected [N], got [137]. That looks like a wrong exit code, but it was the driver's own clock. 60 s is alsolanes-edit.sh'sacquire_lockbound and itsLANES_GIT_TIMEOUT, so a timeout could not be told from a helper waiting out its own 60 s.acquire_lock,LANES_GIT_TIMEOUT) and 300 (lane --wait).LANE_PTY_SILENCEoverrides it for the one case that proves the timeout itself.lanes-edit.shreads underlane, which killing the single pid used to leave running. It then printspty-run: TIMEOUT: the child wrote nothing for Ns and was killed …and the partial transcript on its own stderr, and exits124, never a128 + n.lane_pickturns that report into a FAIL of its own, prints the report and the transcript under it, and sets$rctoTIMEOUT. A pick case therefore cannot read a kill as the command's exit code.124(not137), print the report and the partial transcript, and leave the grandchild gone. A zombie counts as gone, because pid 1 in this workstation's container issleep infinityand never reaps. A second case checks that a child which answers keeps its own exit code. The test takes about 1.5 s.2. The cost. I measured first, inside the suite's own environment: the suite was run up to the pick section and its sandbox frozen there, with 2,563 assertions passed, 194 register rows and 162 object logs. Almost all of one
lanecall is thelanesread, and almost all of that read is one loop:table_lookupwas quadratic.${table#*"$GS<lane>$US"}makes bash try a leading-*pattern against every prefix of the string, andlanes_rowsmakes three or more lookups per lane over tables with a line for every lane.${table%%"$GS<lane>$US"*}finds the same first occurrence, and bash only tries the pattern where its first character ($GS, once per line) matches, so it is linear. The rest is cut by a character offset.--repo/--prefixfilters forkedlcfor every lane in the estate. That was up to eight processes per lane, spent mostly on lanes the filter then drops. The two constant sides are now lower-cased once, withlcitself. The lane's side uses a newlower_into:tr 'A-Z' 'a-z''s mapping (the 26 ASCII capitals, nothing else) written as 26 literal substitutions, with no process.Nothing else changed: no wire form, no column (A18's 13, A19's 14–17), no exit code.
laneitself is untouched.Measurements
All on Eagle (WSL2, 32 cores, bash 5.2.21), against the frozen fixture described above. Load was 9–14 throughout, because another lane's pytest runs were live. Old and new were run side by side wherever the numbers are compared directly.
One
lanecall (the listing, stdin not a terminal,LANGunset):14641fd)table_lookuplinear onlyOne pick under the suite's own pty driver. Python's PEP 538 coercion hands the child
LC_CTYPE=C.UTF-8, as on CI. Old and new ran concurrently:lane_pick 1 … --dry-rungot [137])lane_pick f … --dry-runPer helper: each fork
lanemakes before printing anything, with its exact arguments:workstationlanes --dir <root> --prefix repoPick --repo opensoft/repoPicklane-groups Eagle(rows on stdin)next-free repoPick(rows on stdin)Inside that
lanesread: phase markers in scratch copies of both helpers, the two copies run concurrently:LANGunsetLANGunsetC.UTF-8C.UTF-8state_events+lane_row_facts(agit showper log)fork_mapSame answers. I ran main's helper and this PR's side by side over nine scopes:
--all,--all --closed,--here,--repo,--repo --closed,--prefix,--lane, the pick's own scoped read, andlane's listing. All nine are byte-identical in stdout, stderr and exit code. The timings from that run (18 reads at once, so slow on both sides):--all71.1 → 6.1 s,--here71.5 → 6.0 s, scoped 66.1 → 4.1 s,lanelisting 66.8 → 4.5 s,--lane1.6 → 1.3 s.lower_intomatcheslcon ASCII, mixed case, multibyte, glob characters and a tab, in the POSIX and C.UTF-8 locales. The lookup's micro-benchmark gives the same answers for a first match, a duplicate key, a missing key and multibyte content.Two things the issue said that the code does not
lanedoes not readlanestwice.lane:364/:381(now:366/:383) are the two branches of one read: with a temporary file for the helper's notes, or without one. The pick path forksworkstation,lanes,lane-groupsandnext-free, once each. The only double read isnext-freeagain ingo_newwhen the answer isf(below).acquire_lockwas a coincidence, as the issue's second reading had already found. The child was in thelanesread the whole time.Follow-up: left alone because each needs a decision, not a measurement
LC_ALLon return, and that wants a check on macOS bash 3.2 before it is trusted. A one-passawkjoin of the tables would avoid both issues but restructures the loop.state_eventsruns onegit showper object log: ~0.9 s for 162 logs. Onegit cat-file --batchwould read them all, but it changes the event stream's plumbing, which every state read is built on.go_newforksnext-freea second time over the same rows (~0.1 s, only onf). Reusing the listing's answer would make the act open exactly the position the question offered. But if the register moves while the question waits, today's act opens the next position and the reused answer would refuse instead. That is a behavior choice, so it is not made here.lane→lanes-edit.sh×4) is a design question for the read's freshness contract.Tests
124with the report and the partial transcript, its process group is gone, and a child that answers keeps its own code. The SIGTERM grace belongs to the whole group (added after Copilot/Codex round 1; it fails under the old loop). The case-blind filters:--prefix REPOPICKand--repo OpenSoft/REPOPICKmust list exactly the rows' own spellings' lanes, and each must name one (added after Copilot round 1; it fails withlower_intobroken).tests/run.sh -k 'lane_helper or hygiene'at7d60230:160 passed, 566 deselected in 1109.87s. The lane-helper suite's own footer,passed, 0 failed, is asserted by its wrapper, so thelanepick section was green. The shell suite'slanecases fail on any workstation with workBenches'lclaudeinstalled: #129's lclaude-first launcher finds the host's, not the sandbox's #143's eightargv=--with-lanefailures did not appear, although/usr/local/bin/lclaudeis present on this workstation. A second run at the current head follows as a comment.lanesread in it does. Same workflow, Linux, as wall clock for the job:14641fd(this PR's base)7d60230teststests-no-submoduleCloses #107
Lane: openRepoTools-3
🤖 Generated with Claude Code
Summary by Sourcery
Speed up lane reads and make PTY-driver timeouts explicit and reliably isolated from command exit codes.
New Features:
Bug Fixes:
Enhancements:
Tests: