Repository navigation
fix(net): a JS fill answers what the cache holds whole instead of asking its handler - #9771
Conversation
…se.md Quest-Claim: 555a1869e5c29fae
…ing its handler A time start asked once its group already landed (the cache cannot place the time below the eviction watermark) had no arrival to answer it, so `FillGroups.wanted` handed the handler a key the track already held and `accept` returned undefined. Answer such keys from the cache, as the Rust `FillGroups::wanted` does. This was the copy_fill harness's "expected a value" flake; its after-close guard, which masked the same symptom, goes too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. WalkthroughFill selection now checks whether the cache holds each owed group whole and resolves cached keys before requesting another key. A new test verifies that a cached group in a time-start fill does not invoke the source. The archive fill test helper no longer uses a closed flag or breaks when acceptance returns no group. The note describing an intermittent test error and its unconfirmed cause is deleted. Merge Risk:
|
Finishes quest/m0/test-flakes-5/copy-fill-accept-after-close.md (deleted here).
Problem
js/net/src/lite/copy_fill.test.tsthrewexpected a valuefromdefined(fill.accept(key))as an unhandled error between tests, knocking PRs out of the merge queue. Only the lite-07 case of "reads back what a finished copy evicted" triggers it: 20 errors in 200 isolated runs, 5 in 560 whole-file runs.The race is in the library, not the teardown. The copy asks the publisher for the evicted run twice: once by group (a run fill that lands groups 2 and 3) and once by time (a time start for time 2). Below the eviction watermark the publisher's cache cannot place the time by the groups it holds, so it asks a time-start fill. When that ask comes after group 2 already landed, no arrival answers it, and JS
FillGroups.wanted()handed the handler key 2 anyway.accept(2)then answered the lookup but returnedundefinedbecause the track already held the group. Rust'sFillGroups::wantedanswers such a key from the cache instead of asking the handler.Approach
FillGroups.wanted()answers a key the track holds whole from the cache (as an arrival would: a time start gets{ kind: "group" }, a run resolves the key) and moves on, mirroring Rust. A handler servingwanted()is never asked for a group it already has.copy_fill.test.tsdrops itsclosedguard (if (!group && closed) break), added in feat(net)!: remove FETCH from lite-07 and serve fetches via bounded SUBSCRIBE #9687 against this same symptom;defined(fill.accept(key))holds again.fill.test.tscase drives aFillStateover a fake track holding group 2: a time start and a run both get no held key fromwanted(). It fails onmain(wanted()returns2n).Rust already does this (
rs/moq-net/src/model/track/fill.rs,wanted_except), so no Rust change.Impact
FillGroups.wanted()no longer returns a key the track caches whole (behavior change, matching its doc and Rust).Alternatives
undefinedfromacceptas "already held" in the harness: matchesaccept's doc, but leaves every JS handler doing work Rust's never does, and hides the divergence. Rejected.Decisions
wanted()) rather than the harness, per the quest's plan ("Ifacceptcan returnundefinedwhile a case is still running, the fix belongs in the fill path"). Taken as my recommendation while the maintainer was away.acceptkeeps returningundefinedfor a held key without resolving a run fill: withwanted()answering held keys, a handler followingwanted()never reaches it, and the relay handlers that iterate runs already checkisWanted/undefined.Caused by
wanted()answering a group the cache already holds as Rust does (found by check)closedguard masked the symptom only after teardown (found by check)Validation
541c0839bf):bun test src/lite/copy_fill.test.ts --rerun-each 200 -t "moq-lite-07-wip reads back what a finished copy evicted": 200 pass, 20 errors.--rerun-each 20on the whole file: 560 pass, 5 errors.--rerun-each 400: 400 pass, 0 errors. The whole file--rerun-each 100: 2800 pass, 0 errors.src/fill.test.ts82 pass.just ci(scoped) passed, includingtest js(@moq/net3982 pass, 0 fail).Follow-ups
None.
Models
(Written by Claude Opus 5.5)
Review
Rewritten by
quest reviewafter each round.Head: d47ae6f
Base: origin/main at ed3a269
Risk: medium,
The change alters shipped JS fill behavior in js/net/src/fill.ts so that a time-start fill, or a run's group, the cache already holds whole is answered from the cache rather than asked of the source handler; the API and wire format are unchanged, so a bad fix would reach JS consumers of the next patch release, e.g. by a handler not being asked or a fill being answered from the cache wrongly, and it is easy to undo by reverting the commit, since the only other edits are tests and a deleted quest plan doc.Classified: medium by Claude Code, claude-haiku-5-5, low effort, session
eacd538f-3a82-43b8-8eca-47c3455bed94Risk file: bb7b1c0de60b
Reviewer: Codex, gpt-6.2-sol, medium effort
Session:
01a21db7-c43f-7df0-bcf0-996d60dd850e, round 1Score: 9/10,
Source review found no blocking regression in this medium-risk fix, which lets `wanted()` and `wantedChanged()` settle cached groups before reporting work to the handler while still requesting headless copies, but no tests were run.Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0
Findings: none