Repository navigation
Four tests and two tools stop failing at random: gate-ahead worktrees and the gbrain MCP probe (GST-3543) - #4710
Merged
Merged
Conversation
- gstack's own git worktree add and removal take one lock per repository, so two gate-ahead preparations no longer fail each other reading a half-written commondir. - gstack-gbrain-mcp-verify reads the SSE first line and data line without early-exit pipes, which failed with SIGPIPE under pipefail. - The git fixture template test's repos turn off auto-maintenance, whose detached run removed objects/maintenance.lock mid-copy. - The late-SDK-completion overlay test gives both arms 250 ms to start. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/specialist-batched#1 reader=testing Review-Finding: p1/specialist-batched#2 reader=testing Review-Finding: p1/red-team#2 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…time remove a stale one Review-Finding: p1/outside-voice#1 reader=outside-voice Review-Finding: p1/outside-voice#2 reader=outside-voice Review-Finding: p1/adversarial-native#1 reader=adversarial-native Review-Finding: p1/adversarial-native#2 reader=adversarial-native Review-Finding: p1/adversarial-native#3 reader=adversarial-native Review-Finding: p1/adversarial-native#5 reader=adversarial-native Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
Also: the fixture trace test's control looks for the push by name, which the Windows runner spells differently (windows-scoped-shard, run 45036384878). Review-Finding: p1/specialist-batched#1 reader=testing Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p1/red-team#2 reader=red-team Review-Finding: p1/red-team#3 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ree lock cannot be taken A filesystem without hard links, an unwritable git dir or a six-minute wait no longer fails gate-ahead or restamp; they fall back to the unlocked behaviour main had. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Merged
3 tasks done
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Two gate-ahead preparations for one PR no longer fail each other, and
gstack-gbrain-mcp-verifyno longer misreads a valid SSE reply as broken.Both turned up in the daily flaky-test pass from CI runs that failed once and passed on retry. Two test fixtures that raced on timing are fixed too.
Nothing to do for users; the version is written at merge.
What changed
lib/git-worktree-lock.ts). While git adds a worktree it reads every sibling'scommondir, and a concurrent add leaves its own empty for an instant, so the other add died withfailed to read .git/worktrees/worktree/commondir: Success(Trunk e3ed3abf, Free Tests 44999855570; the 4th time since 2026-10-29). Plain git failed 1 of 480 concurrent adds with that exact message, and 0 of 480 failed through the lock. The lock is best effort. When it can't be taken (a filesystem without hard links, an unwritable git directory, or six minutes of waiting), the command runs unlocked, as it does on main today, instead of failing.gstack-gbrain-mcp-verifyreads the SSE reply without early-exit pipes. Underpipefail,echo | head -1 | grep -qfails with SIGPIPE when the reader exits first. A valid SSE body was then parsed as plain JSON, and jq's exit 5 ended the probe (Trunk 1afdd260). Locally 7 of 400 runs failed before the fix and 0 of 400 after. A new test with a reply larger than a pipe buffer fails 5 of 5 on main and passes with the fix.git commitand the receiving end ofgit pushstart a detachedgit maintenance run --auto, which created and deletedobjects/maintenance.lockwhile the template was being copied (ENOENT in cpSync, Trunk 3a4e1509). A new test traces the build and fails on main.Why
Each of these failed a CI run at random and cost a rerun. Two of them are real bugs that users of
/ship's merge queue and/setup-gbraincould hit, not just test noise.Blast radius
The lock wraps only the worktree add and remove calls in
lib/restamp.tsandcrew/lib/ship-queue-gate.ts. When it can't be taken, those calls behave exactly as on main (8 lock tests, including the unlocked fallback, which is red on the version that threw). The verify script's output classes and JSON are unchanged (its existing test file plus the new large-body test). The other two changes touch tests only.Pre-Landing Review
The full review panel and a second-model review ran on this PR. Every finding was fixed except two edge cases in the new lock, which ship as notes: a takeover that stalls for more than 10 seconds, or a killed parent whose git child is still running, can let two worktree commands overlap. Both are no worse than main, which has no lock at all. A third second-model finding, that a lock error could fail a command main ran fine, is fixed by making the lock best effort, and a scoped re-check of that fix found nothing.
Documentation
Status: current. The docs already match this branch, so nothing was edited and nothing is blocked.
Scope audited:
a88cc7c1..dfb1a663onflaky-fixes-2026-11-22: 9 committed files (bin/gstack-gbrain-mcp-verify,crew/lib/ship-queue-gate.ts,lib/git-worktree-lock.ts,lib/restamp.ts, a changelog fragment and 4 test files), with nothing staged, unstaged or untracked. All 157 candidate docs were checked for the changed surfaces, and every doc that mentions them was read at the affected sections.Documentation health:
README.md Current (no feature or install claims touched)
CLAUDE.md Current (changelog-fragment pointer still accurate)
docs/ship-policy.md Current (staging and gate-ahead worktree descriptions still hold; the new lock is internal and falls back to running unlocked)
docs/troubleshooting.md Current (RESTAMP_* and gate-ahead entries unchanged by this diff)
setup-gbrain/memory.md Current (gstack-gbrain-mcp-verify still sorts failures into NETWORK, AUTH and MALFORMED)
setup-gbrain/sections/brain-init.md.tmpl Current (step 4c verify contract and JSON fields unchanged)
docs/evals/detector-inventory.md Current (
bin/gstack-gbrain-mcp-verify:64still points at error_class)CHANGELOG.md Skipped (ship-owned audit; top entry 1.102.2.0 matches VERSION)
TODOS.md Skipped (ship-owned audit)
Documentation coverage:
[entity] [reference] [how-to] [tutorial] [explanation]
lib/git-worktree-lock.ts (internal) ❌ ❌ ❌ ✅ source header comment
gstack-worktree.lock file ❌ ❌ ❌ ✅ source header comment
Documentation debt (low priority, no user-facing surface): the per-repository worktree lock (
gstack-worktree.lockin the git common dir, stale after 120 s, removed automatically) and thefailed to read .git/worktrees/<name>/commondir: Successrace it narrows are explained only inlib/git-worktree-lock.ts. A troubleshooting entry would fill the how-to gap if the error is still reported after this fix./document-generatecan draft it.Diagram drift: none. No architecture diagram names the changed modules.
Note for the author:
changelog.d/flaky-fixes-2026-11-22.mdsays the worktree calls now take one lock per repository. It doesn't mention that they run unlocked when the lock can't be taken. It was left unedited because this audit doesn't change changelog files.Tests
bun test test/git-worktree-lock.test.ts: 8 pass, 0 fail.Agent notes
Flaky pass GSTA-809 for 2026-11-22 (GST-3543). Ledger: the crew drive's handoffs/flaky-ledger.md. Not in this PR: the cso-snapshot-state REPEAT (lib/cso lock code, its own PR with the security panel).
REVIEW_LOOP: passes=2 blocking_found=3 deferred=0 noted=10 fixed=12 scope=frozen open=2 fix_checks=3 dispatches=6
Ruled note: lib/git-worktree-lock.ts:60:outside-voice at f857c25 ruled by GSTA-36 (relayed from GSTA-36:2026-11-22T15:24:33.060Z) at 2026-11-22T15:24:44.564Z: a takeover stalled past 10 s can let two worktree commands run at once, no worse than main, which has no lock (approval a-8d75c3223ccb)
Ruled note: lib/git-worktree-lock.ts:47:outside-voice at f857c25 ruled by GSTA-36 (relayed from GSTA-36:2026-11-22T15:24:33.060Z) at 2026-11-22T15:24:44.667Z: a takeover while a killed parent's git child still runs lets two worktree commands overlap, no worse than main, which has no lock (approval a-3e273d76901e)
Review round exception: one scoped fix-check of dfb1a66 after round 2, granted by GSTA-36 (approval a-3f3ac0fc408c): "A flaky-fix lock must fall back to main's unlocked behaviour on any failure; edges no worse than main are notes."
Approvals
Approved: yes (record r-c5165d4bb000). The full approval record stays private.
Plan: exempt: bug fixes for flaky tests (repro or failing-first test per fix)
Plan check: exempt bug fix