Repository navigation
[PR] test: close persist-guard foreign-write race by settling on the landed-write stamp - #3657
Conversation
…3652) The sibling test 'foreign write between DEBOUNCED saves' still races under loaded CI runners even after #3626's poll-for-landed fix (6748b23): it waits only for the envelope to be present on disk, but the ownership stamp is applied asynchronously in .then() AFTER the write resolves (after the file already landed). A foreign write slipping into that gap is adopted as ours by the stamp (#3406 residual gap) and the guard below never trips. Reproduced ~1-in-4 under CPU load. Waiting for __ownWriteStampedForTests closes it deterministically.
(ai: vllm-qwen/qwen3.8-27b) 收到,这是 agent 已完成的 PR( 查重: 不重复 — open+closed 检索 persist-guard-ownership / #3406 / foreign-write stamp / debounce flake,无同症状+同机制条目;本 PR 针对 #3652 的残留竞态(sibling test),与 master 上 正在审 diff 与 CI,结论按八问体例回复。 |
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4313-pr.3657.6917ae9This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3657.tgz
npm install -g packageInstall instructions are refreshed on each push. |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.565-master.21a860f # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #3652
What this is
#3652 reported
tests/persist-guard-ownership.test.tsintermittently failing on win22 shard 2 ("DEBOUNCED saves stay stamped", expected 5, got 4). The primary symptom of that report was already fixed on master by6748b235a("test: wait for debounced saves to land instead of fixed sleeps", landed via #3626 after the same flake showed up there) — it replaced the three blindsleep(150)calls with poll-for-landed.This PR closes the residual race that
6748b235aleft open in the sibling test "a foreign write between DEBOUNCED saves no longer clobbers the envelope."Root cause of the residual flake
The sibling test waits only for the envelope to be present on disk before performing its foreign write. But the ownership stamp (
ownCommit[id].written) is applied asynchronously — in a.then()after the awaitedwriteNowresolves, i.e. after the file has already landed. A foreign write that slips into that gap is adopted as ours by the stamp (the documented#3406residual gap atsrc/persist.ts→ownershipFastPath), so the second save's fast path passes and the guard below never trips → the test times out waiting for the full-read counter to move.Unlike the DEBOUNCED-stamp loop (which has a 25ms debounce buffer that absorbs the gap more as load grows — structurally safer under starvation), the sibling test issues the foreign write immediately after detecting the landing, with no buffer, so it is exposed.
Evidence (CPU-load stress, simulating a starved CI runner)
Real test file run under load: 10/10 green. Fast runs: 8/8 across multiple invocations.
tsc --noEmitclean.Fix
src/persist.ts: add a read-only test seam__ownWriteStampedForTests(id)(mirrors the existing__staleGuardFullReadsForTests). No production behavior change.tests/persist-guard-ownership.test.ts: gate the sibling test's first-save settle onlandedRequests >= 3 && __ownWriteStampedForTests(...)instead of file-presence alone. Builds directly on master's existingwaitForLanded/landedRequestshelpers (no duplication).Behavior / scope notes
src/change is a test-only getter (__…ForTests); no code path reads it outside tests. No config surface, wire/message shape, persistence format/version,kernel/,update.ts, or security change.