Skip to content

fix: 30s budgets for the partial-lock held-file scenarios (#245) - #276

Merged
abogartz merged 1 commit into
mainfrom
fix-issue-245-20261103T2230Z
Nov 3, 2026
Merged

abogartz merged 1 commit into
mainfrom
fix-issue-245-20261103T2230Z

Conversation

@ocsi-fixer

@ocsi-fixer ocsi-fixer Bot commented Nov 3, 2026

Copy link
Copy Markdown

Closes #245

What changed

test/lock-partial-outcomes.test.ts: every test and hook now carries an explicit 30s budget (2 hooks + 8 test registrations). No assertion moved; only time is granted. Mirrors the shipped pattern of d38e6a7 (#245 budgets for the sibling files).

Root cause

The flake is the Bun default-5s-timeout family the maintainer root-caused on this ticket (comment 2026-11-01T20:40:25Z, quoted below). A starved --parallel=4 ubuntu worker spends real time past Bun's default 5s inside a held-file scenario; the test dies mid-flight, afterEach deletes the fixture underneath the still-pending work, and the leftovers surface as Unhandled error between tests plus false assertion failures in the tests beside it.

The CI log of run 41356328156 (head b2f2929, the last occurrence) shows the cascade in this exact file:

  • ENOENT ... /tmp/osi-partial-lock-wC5try/memory/snapshots/... from claimSnapshot ← snapshotFiles ← the restore test's setup — i.e. the awaited snapshot ran after the fixture was already deleted, which only happens when the test was aborted mid-flight;
  • an escaped memory store is busy: 2026-01-02.logfmt has been locked for 40ms — retry in the merge_review test;
  • expect(...superseded_by).toBeDefined() received undefined in canonical update retains the gate's completed retirement on a later busy file.

b2f2929 predates both a175eda (the evidence-drain harness) and d38e6a7 (the sibling budgets). Current main still leaves THIS file with no explicit budget, so the exposure remains: Bun applies the default 5s to every test and hook in it.

Requirements taken from comments (owner, abogartz)

  • "Bun applies the default 5s timeout to beforeEach/afterEach hooks even when the test itself carries a longer override... pass an explicit timeout to the hooks... so a starved worker degrades to slow CI instead of red CI." — comment 2026-11-01T20:00:09Z. Implemented for both hooks and all tests here.
  • "The commit gives every test and hook in scenarios-consistency / concurrency / lifecycle-evidence an explicit 30s budget, no assertion changes." — comment 2026-11-01T20:40:25Z. This PR extends the same pattern to lock-partial-outcomes.test.ts, the file the ticket body names.

The body's other two fix-direction clauses are already on main: the evidence record lifetime is owned by the a175eda harness in this file (spy + drain in afterEach + expect(evidenceErrors).toEqual([])), and the retirement the failing assertion reads is written by awaited code (src/gate/gate.ts:597-609 → src/tools/update.ts:191-231), so no un-awaited write feeds it once the abort cascade cannot start.

Reproduction

  • Reproduced-by-mechanism on main 4cc8bf61005ff2585efe073cc0bf579f475ae213: the file carries zero explicit timeouts (verified by inspection of every test(/beforeEach(/afterEach( call), so Bun's 5s default applies — the owner-proven kill mechanism of run 41356328156 is live on that sha.
  • Empirical stress on that sha: 10 isolated runs + 12 full-suite --parallel=4 runs + 6 runs starved by hw.ncpu concurrent full-suite loads — all green locally. The starvation that fires the timeout is ubuntu-shared-runner-specific; it did not fire on this macOS host.

Proof (measured on branch head 87be831)

  • bun run typecheck — exit 0
  • bun run lint — exit 0
  • bun run test — 937 pass, 19 skip, 0 fail (956 tests across 90 files)
  • bun test ./test/lock-partial-outcomes.test.ts — 9 pass, 0 fail, 70 expect() calls
  • bun run test:e2e not run: no src/ file changed.

No regression test added: the change grants time budgets in a test file and moves no behaviour; there is no assertion that can fail without a timeout literal (d38e6a7 shipped the same pattern with no test).

Deliberately not changed

  • No assertion, tolerance, or timeout was weakened; nothing was skipped or deleted.
  • src/ untouched — the fire-and-forget void record("store_lock", ...) telemetry sites stay as shipped; their rejection route inside this test file is already captured by the a175eda harness.
  • The --parallel=4 → 2 question from the owner's comment is a decision for the maintainer, not implemented here.

The ubuntu flake in this file is the Bun 5s default-timeout family the
maintainer root-caused on #245: a starved --parallel=4 worker spends
real time past 5s inside a held-file scenario, the test dies
mid-flight, afterEach deletes the fixture underneath the still-pending
work, and the leftovers surface as 'Unhandled error between tests'
plus false assertion failures in the tests beside it. Run 41356328156
(head b2f2929) shows the cascade exactly: a snapshotFiles ENOENT after
teardown, an escaped busy error, and a superseded_by read that came
back undefined in 'canonical update retains the gate's completed
retirement on a later busy file'.

d38e6a7 gave the three sibling files this budget; this file — the one
the ticket names — was left without it. Give every test and hook here
an explicit 30s budget. No assertion moves; only time is granted.
@ocsi-triager ocsi-triager Bot added the review:requested Human-admitted for autonomous review by ocsi-reviewer label Nov 3, 2026

@WhollyMindless WhollyMindless left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head 87be831375f439140be3c10a61f132627698bb49 independently on Windows, Bun 1.4.4.

No blocking code finding in this diff. Verified that removing the added explanatory comment and the 30_000 timeout arguments reconstructs the parent test file exactly. Both hooks and all eight test registrations (nine expanded cases) receive the budget; the assertions, short lock-refusal budgets, evidence drain and error assertions remain intact.

Ran bun test ./test/lock-partial-outcomes.test.ts in a detached checkout: 9 pass / 0 fail, 70 assertions. All four hosted checks are green at this head. I did not independently rerun the full suite or reproduce the original hosted flake.

One evidence qualification for the description: the exact-file root cause remains inferred. The reported local stress runs stayed green, and the presence of default timeouts establishes exposure to timeout aborts but does not by itself reproduce the original failure. Please distinguish that inference from the verified timeout-budget hardening when describing resolution of #245. The larger budgets preserve the existing integrity assertions; they do not establish that a separate ordering race cannot remain.

This is a review of the bot-owned implementation; no competing fix or ownership claim. Maintainer judgment on merging/closing #245 remains appropriate.

@ocsi-reviewer ocsi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Head reviewed: 87be831375f439140be3c10a61f132627698bb49

Contract: #245 (author abogartz, trusted human) — "CI flake: 'canonical update retains the gate's completed retirement on a later busy file' fails intermittently on ubuntu". Spec anchor c502133b6bd90eb2 recomputed equal → spec frozen. The ticket body's "Fix direction" predates the maintainer's root-cause comment 6563591503 (2026-11-01T20:40:25Z), which identifies the family as "Bun's 5s default test timeout vs genuinely slow work under --parallel=4" and prescribes the shipped remedy: "every test and hook ... an explicit 30s budget, no assertion changes". Judged against that.

Per-criterion evidence:

  1. Fixes the root-caused family for this file — test/lock-partial-outcomes.test.ts was the one held-file file d38e6a7 (#245, same issue) did not cover: git show d38e6a7 --name-only | grep -c lock-partial → 0. This PR applies the identical pattern (}, 30_000);) to 2 hooks + 8 test registrations (10 total, matches PR body).
  2. No assertion moves; only time is granted — full diff read: +20/−9, one file. All 9 deletions are }); → }, 30_000); (plus one 30_000, param line for test.each); remaining 10 additions are the explanatory comment. Zero assertion, skip, tolerance or timeout-hiding changes. This is the maintainer-prescribed budget pattern, not a timeout raised to mask an unknown failure.
  3. Green at this head — local: bun run typecheck exit 0; bun run lint format clean (no fixes applied, infos only); bun run test 937 pass / 19 skip / 0 fail; target file stressed 5× → 9 tests green every run (~0.9 s/file, margin well under the old 5 s default). The starvation flake itself is runner-specific and not reproducible on macOS, as with d38e6a7; the maintainer's measured margins on the same family are the diagnostic authority.

Final gate re-check (verbatim): headRefOid = 87be831375f439140be3c10a61f132627698bb49; checks: lint pass, test pass, test-windows pass, smoke pass.

Findings: none. No P0, no P1, no nit.

Human merges.

@abogartz
abogartz merged commit 0fe0f61 into main Nov 3, 2026
4 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.15.20 🎉

The release is available on:

Your semantic-release bot 📦🚀

@abogartz
abogartz deleted the fix-issue-245-20261103T2230Z branch November 19, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released review:requested Human-admitted for autonomous review by ocsi-reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI flake: 'canonical update retains the gate's completed retirement on a later busy file' fails intermittently on ubuntu

2 participants