Repository navigation
test(ts): seed each differential case's inputs by its name - #522
Merged
Merged
Conversation
Quest-Claim: 0a3239b2b14e6b29
A harness that names its cases (`lang`'s fixtures, `stock`, `codec`, `task`'s steps) now draws each case's random inputs from a stream seeded by its name, so adding, removing, or reordering a case changes no other case's inputs. `stable.ts` checks it. Also deletes quest/m0/checks/fixture-layout.md, which #474 delivered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h drops `dequeToVec` left the capacity implicit when pushes alone would reach it, so a `clear` after `Vec::from(VecDeque::from(v))` dropped the capacity a `reserve` had held. `capacity::vecs`' own seeded inputs found it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 5 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
This was referenced Nov 3, 2026
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.
Problem
differential.tsdrew every random input from one seeded stream, and a harness picked the case by leading bytes modulo its case count:stock's andcodec's first byte,lang's first two, and the first byte of each oftask's steps. So adding a case shifted which case every random input reached, and the full-width boundary inputs reached only whatever sat in the first eight ops. A PR adding a case could then fail on another case's inputs, as #436 did onbuf::write_all.Approach
ts/tests/inputs.tsnow does the input generation that used to be inline indifferential.ts. A harness that exportsops, aMapfrom each case's name to the bytes that pick it, gets its inputs per case: the op alone, the op with every short tail, the u64 boundaries if it exportswide, andcountrandom tails from a xorshift stream seeded by the FNV-1a hash of the case's name. A harness with no cases (share,bind,crates) keeps the single stream it had.lang.tsandshapes' caller exportopsas aMap.shapesnames its0xffFault entryfmt::Fault.stock's caller exportsopsandwide.codec's harness names its cases, and a newcaller.tsexportsopsandwide.task.tsexportsopsand aninput(name, tail)hook. A step's random scripts run that step plus only a fixed list ofdrivers(open, send, close, clone, run, step, poll, drop). A step added later never appears in another step's scripts.capacity::vecshit it with its own seeded input0000670350e11df08b00993f: reserve, thenVec::from(VecDeque::from(v)), thenclear. TS dropped below the capacity the reserve had held.rt.dequeToVecleft a capacity that pushes alone would reach implicit, andcapOfrecomputes an implicit capacity from the length, so it shrank when the length did. It now holds the deque's buffer withcapHold, asiterToArrayalready does for the allocation it reuses. This is the only conversion that builds a freshVecfrom another allocation's capacity (a heap reuses its own array).quest/m0/checks/fixture-layout.md: #474 delivered its whole goal (lang split per module, a shared wasm target dir, reject keyed by item, targeted runs).Proof
fixtures::case_inputsrunstests/stable.ts:taskstep runs only that step and the drivers.stockfixture: I inserted("added", made)as the third case, translated, and hashed each case's inputs past its op. All 17 original cases' digests stayed identical, andaddedgot its own:Coverage, per case, against
origin/mainlang: 151 random inputs per case, exactly. Before, it was 151 on average, depending on where random first bytes landed. Total input counts are unchanged.stockandcodec: every case now gets the boundary inputs. Before, only the first eight did (stock'sbuf::reservesonward andcodec'serrorsnever got them). Random inputs per case are at least the old expected share.task: each step appears in 5,252 to 7,302 of its own random scripts' steps. The old uniform share was at most 5,208. Under the old scheme, steps thatinteresting()'s fixed bytes landed on got more (openandreleasedabout 34k, via 0x00 and 0xff), and that was an artifact of position.CPU
Node-side CPU for every affected differential fixture (all 69
langmodules,stock,codec,task), same translated outputs, old vs new: 129 s vs 148 s user. Re-runningintsandhints, where the gap showed, gave equal times both ways (12.1 vs 12.3 s, 2.9 vs 3.0 s), so the difference is host noise.taskwent from 11.6 s to 8.0 s andstockfrom 3.2 s to 4.5 s (boundaries for all 17 cases). Net: about neutral.Impact
opsis aMap, and the newwide/inputexports are read bydifferential.ts.codec'sharness::casesnow returns(name, case)pairs, and its snapshot changes to match.Alternatives
task's scripts: any script that mixes in the whole step list changes when a step is added. Getting every step back to the old ~4.4k scripts containing it, each with its own stream, would cost about 8x the CPU.langboundary inputs too: 242 cases x 1,365 inputs is about 9xlang's inputs. Its callers already name the full-width inputs their cases read.Choices for review
taskdrops the boundary scripts its first eight steps got. Steps take one-byte arguments, and those scripts were mostlyopenandreleasedwith arguments 0x00 and 0xff, which the random scripts'interesting()bytes already produce for every step. Optingtaskintowidewould cost about 45k more scripts.task, a step's scripts no longer mix in other non-driver steps (for examplesumbesideheld). That cross-step mixing is what made the inputs unstable.cases) now run after the generated ones instead of before the random ones. Both sides still run the same order.Follow-ups
Vecwhose capacity stays implicit (grown by pushes, or made exact byvecExact) still reports it shrinking when its length does. For example,Vec::new(), six 1280-byte pushes, thencleargives capacity 0 in TS where native keeps 8.capacity'sKnownonly checks capacity against a reserved floor, so the fixture does not see this. Suggested as a quest: pin the implicit capacity before any step that drops the length.go/tests/fixtures.rsstill picks unnamed cases (match pick % n) from one stream. Its spike fixtures have fixed case lists, so it is left as is here. Its doc comment no longer claims to mirror rust2-ts. Suggested as a quest if the Go spike continues.Review
gpt-6.1-sol, medium effort, viaquest review. Round 1 on7bb9c70d: no findings. Round 2 onc8733ce2(adds thedequeToVecfix and a merge of main): no findings.401830741d4c4ea5d288c530cb13866ebf4ada8eadds only a conflict-free merge oforigin/main(feat(ts): translate the rest of a trait object in a struct's last field #519) on top ofc8733ce2.just cipassed on it.🤖 Generated with Claude Code