Repository navigation
test(ui-server): keep the real storage budget out of queue-adoption holds (#3561) - #4062
Merged
Merged
Conversation
…olds (#3561) Every write the dialogue journal tracks arms the real 10 s storage budget at submission. The queue-adoption cases submit up to 256 writes behind a native writer hold, and the worker drains them serially after release, so on a loaded host a write can stay pending past 10 s. The budget then withholds the owner and reports storage_indeterminate, and the case fails on whichever assertion reads the withheld callbacks or pages. The budget is not what these cases claim. storageDeadlineClock gains a manual mode, in which a registered budget fires only through expire() or captureLatest(), and counts registrations. The fixture installs it, and each case now asserts that budgets were armed and that every one was cleared by its write settling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 15, 2026
Merged
…ion-storage-budget
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.
Closes #3561
What changed
The queue-adoption cases in
packages/ui-server/tests/dialogue-queue-adoption.test.tsno longer let the real 10 s storage budget expire writes they hold on purpose.storageDeadlineClockgains amanualmode: a registered budget fires only throughexpire()orcaptureLatest(), never by elapsed time. It also counts registrations. The fixture installs the manual clock and restores it inclose(). Each of the five case families now ends by asserting that budgets were armed (STORAGE_BUDGET_ARMED_DURING_HOLD) and that every one was cleared by its write settling (STORAGE_BUDGET_CLEARED_BY_SETTLEMENT). No product code changes, and no assertion was weakened or removed.Why this shape
The race.
DialogueJournal.trackarmswithinStorageBudgetfor every tracked write at submission (track,packages/ui-server/src/ws/dialogue.ts:342-355;STORAGE_SETTLEMENT_MS,packages/ui-server/src/db/settlement.ts:2-16). Each case submits up to 256 writes behind a native writer hold. The writer then drains them one at a time afterf.release(). On a loaded host, the time from a write's submission to its settlement can pass 10 s. The budget then withholds the owner and reportsstorage_indeterminate. Whichever assertion next reads callbacks, pages or failures goes red. That matches the issue cell (savedreceived[]) and both assertions in the 2026-11-10 reproduction.The product behaves as documented, because a write held past its budget is indeterminate. The fault is in the test, which let a real deadline run over a load-dependent window it does not test. This follows
docs/process/test-waits.md: a production timer that a case does not claim is controlled, not spent in real time. The budget's own behaviour keeps its tests indialogue-owner-drain,dialogue-drain-deadline,sqlite-cleanup-owner-deadlineandapp-writer-cleanup, which use the helper's unchanged default mode.Not the cause: the
holdcontrol's own 5 s cap (Atomics.wait(..., 5000)intests/helpers/dialogue-test-writes.ts). Every fill loop in this file is synchronous, so nothing can run between the hold and the overflow check, whether a worker reply or a timer. I confirmed this, then left the cap alone.Rejected: raising the budget or the test timeout. That only moves the threshold, and the brief rules it out.
Proof
All runs are local at head
7134c7d51on baseorigin/maineb3c53ac2. Bun 1.4.4, 16 cores, with other workers' suites running concurrently.Deterministic reproduction (forced ordering). Install the default
storageDeadlineClock()in the original fixture and callclock.expire()inrelease(). That forces the budget to fire before the held writes settle. Result: 18/18 cells fail. Assertions includeexpect(saved).toEqual(Array(100).fill(true))(received[]) in the issue'sfresh-owner … outstanding=truecells,expect(f.failures).toEqual([])(received["storage_indeterminate"]) in the canonical-archive cells, and the pages-evidence assertion in theoutstanding=falsecells.Failing-first, real time. In
fresh-owner inactive-bind shares count admission with its canonical target outstanding=true, three extra capped holds are queued on the same worker ahead of the fill, so the worker drains it about 15 s after submission. That is the slow drain a loaded host causes, with noawaitadded in the held window.expect(saved).toEqual(Array(outstanding ? 100 : 0).fill(true)), received[](15.7 s).Mutations (each restored afterwards):
storageDeadlineClock({ manual: false })with the same slow drain: fails at the samesavedassertion, received[].STORAGE_SETTLEMENT_MS + 1instead of the production value, as if the budget constant drifted: 18/18 fail atSTORAGE_BUDGET_ARMED_DURING_HOLD.Repeated runs under load.
bun scripts/test-health.ts measure packages/ui-server/tests/dialogue-queue-adoption.test.ts --runs 10 --shuffle --stress: verdictstable, 30 runs, 0 failures, median 11.3 s, host load average 25 to 47 during the run. The same command produced 2 failures in 30 runs before this change (issue comment, 2026-11-10).Other checks:
dialogue-owner-drain,sqlite-cleanup-owner-deadline,dialogue-drain-deadline,app-writer-cleanup, 34/34.tsc --noEmitis clean.Bug-class audit. The other users of the capped
holdcontrol (dialogue-storage.test.tsand others) fill synchronously or hold only a few writes. None of them has a hold window that depends on load and is covered by an armed budget the test does not claim. No other instance found.{"version":1,"kind":"brain-check-pr-receipt","head":"7134c7d5174535fbcbb8ff7f0e6c92ab1d6fe1b4","base":"origin/main","mode":"focused","startedAt":"2026-11-15T21:41:59.411Z","finishedAt":"2026-11-15T21:43:23.005Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":49720.850059000004},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":307.25147400000424},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":396.20750899999985},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":33.054051999992225},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":33080.99366800001}]}Checklist
docs/reflect the change, or nothing documented moved.Collisions
bun scripts/collisions.ts --json --pr 4062at head7134c7d5174535fbcbb8ff7f0e6c92ab1d6fe1b4: 22closurereports and nopathorunknownreport. The closure reports are test-selection overlap through the ui-server workspace: #3622, #3806, #4002, #4018, #4028, #4041, #4050 and #4060 select some of the same ui-server tests, including this file. No other open PR editsdialogue-queue-adoption.test.tsorhelpers/storage-deadline-clock.ts.Anything left open
Nothing.
🤖 Generated with Claude Code