Skip to content

docs(skills): soak an oracle before it is ready or wired into CI - #304

Open
schiller-manuel wants to merge 1 commit into
docs/random-runs-after-a-changefrom
docs/soak-before-ready
Open

schiller-manuel wants to merge 1 commit into
docs/random-runs-after-a-changefrom
docs/soak-before-ready

Conversation

@schiller-manuel

Copy link
Copy Markdown
Contributor

Stacked on #264 (docs/random-runs-after-a-change, head 4a24455). This PR extends #264's paragraph in step 7 of oracles-design, so review and merge #264 first, then retarget this PR to main. The diff here is against #264.

A random-only false failure can surface late. In a downstream project, a law failed on correct production because of a model bug. The model removed a declaration that binds no names, and the driver did not. It failed in about 1 of 27 default random runs and in every run at a multiplier of 100. The fixed seed and the gap check (fixed seeds only) never hit it, and neither did 40 random runs on another day. A reviewer found it with a multiplier of 10. Once CI ran the oracle with a random seed on every run, this would have been a flaky job. The feedback asked for a soak mode (N random campaigns at a raised <PREFIX>_RUNS_MULTIPLIER) and for skills that require a soak before an oracle is declared ready or wired into CI.

This PR is docs only. A plain loop of the test command already prints what a soak mode would report (see "Why no soak mode" below).

What changed

  • oracles-design step 7. docs(skills): run the random campaign several times before a production change is done #264's paragraph ("Before you call a production change done, run the random campaign several times") now also covers an oracle called ready. It gains two bullets:
    • The budget. 10 runs at a multiplier of 10, before a new or changed oracle is called ready and before CI runs it with a random seed. The reason uses the finding's shares. 40 runs miss a 1-in-27 failure about one time in five ((26/27)^40 ≈ 0.22). 10 runs at 10 draw as many random histories as 100 default runs, and miss it about one time in 40 ((26/27)^100 ≈ 0.023). A law that fails one default run in 100 still passes that soak about one time in three (0.99^100 ≈ 0.37), so the bullet says when to raise the budget. It also gives the time cost.
    • The recipe. A loop of the test command with its logs in a mktemp -d directory, and two greps. One prints each failing unit's Replay: line. The other prints how many runs each law failed in. The bullet says why several runs beat one long run: a unit stops at its first failure, and the multiplier does not stretch a test's timeout (timeoutOf in oracle-property.ts). It also says that the multiplier lengthens the fixed-seed campaigns too.
    • docs(skills): run the random campaign several times before a production change is done #264's last bullet (keep the counterexample as a constructed history) now names soak and CI failures, and ends with "fix what was wrong, the model or production, and soak again".
  • oracles-design step 9. A new evidence item, Soak: the budget, and each failing law with its share and replay line.
  • oracles-explore step 5. When the gaps are closed, soak the oracle before presenting it as ready. A soak failure is handled like a first red run: replay, constructed history, fix, soak again. Step 6's "what you built" names the soak's result.
  • oracles-setup step 7. A new paragraph, "Soak before CI draws random seeds": soak an oracle file before CI runs it with the test command, and wire it in only once the soak passes. A random CI failure is replayed, then kept as a constructed history. Step 8's report names the soak.

Evidence

A probe package built on origin/main 0175017, with this repository's dist/ and CLI. It lived in a gitignored scratch directory and has been deleted. prune(declarations, used) is correct: it keeps a declaration that binds a used name or binds no name. The oracle's model has the downstream bug: !names.every(unused) removes a declaration with no names. The grammar draws an empty names with weight 1 in 5,500 (fc.oneof), and the oracle has runs: 100 and fixedSeeds: [1]. Sampling 1,000,000 histories with fc.sample, the model and production disagree on 1 history in 2,639.

Run Budget Failed Which unit
vitest run (default random seed) ×1 8 of 400 runs (2.0%) random seed: generated, every time
the fixed seed ×1 0 of 400 runs —
oracle-gaps --package . --source src/prune.ts ×1 0 of 5 checks: baseline pass, 6 mutants, 6 killed, 0 gaps, seed (none) —
the same with --seed 42 ×1 0 of 1: 6 mutants, 6 killed, 0 gaps, seed 42 —
soak, ORACLE_RUNS_MULTIPLIER=10 ×10 3 of 10, 3 of 10, and 2 of 10 runs (the last with the skill's recipe, verbatim) random seed: generated
soak, ORACLE_RUNS_MULTIPLIER=100 ×100 10 of 10 runs fixed seed 1 10 times, random seed 9 times

The probe's bug fails about 1 default run in 50, and every run at ×100, as the downstream one did. The gap check never sees it, because its random units are fixed per test name (#276).

What a plain loop prints. This is the recipe from the new bullet, run with <oracle file> replaced, on the buggy model:

soak run 2 failed
soak run 4 failed
Replay: ORACLE_SEED=-137952975 ORACLE_PATH=285:0 ORACLE_PROPERTY='probe.prune' ORACLE_UNIT='random seed: generated' vitest run -t '^probe\.prune(?: | > )random seed: generated$'
Replay: ORACLE_SEED=1963973299 ORACLE_PATH=644:0:0:0 ORACLE_PROPERTY='probe.prune' ORACLE_UNIT='random seed: generated' vitest run -t '^probe\.prune(?: | > )random seed: generated$'
   2 (law: prune)

That is every failing seed with its replay line, and the law's share (2 of 10 runs). It took 4.3 s.

Replay, then keep. I ran one soak replay line (ORACLE_SEED=-1083224269 ORACLE_PATH=499:0 …) twice. Both runs failed with Counterexample: [{"declarations":[[]],"used":[]}] (1 failed | 5 skipped). Kept as a constructed history (state binds nothing), the counterexample failed the fixed seed in 3 of 3 plain runs. The gap check then printed baseline fail tests/prune-oracle.property.test.mjs: 2 of 9 tests failed, with fixed seed 1: a declaration that binds no names failing under (law: prune). With the model fixed, the gap check printed baseline pass … 9 tests and 6 mutants, 6 killed, 0 gaps, and a 10 × ×10 soak had no failing run.

Time cost. Startup dominates the probe: 10 runs took 3 s at ×10 and 3 s at ×100. On this repository's gap-report-classify oracle, a run took 1.1 s at ×1, 2.2 s at ×10 and 14.1 s at ×100 (282 tests, all passing). The multiplied campaign is what grows, so a 10 × ×10 soak of that file takes about 22 s.

Docs only, so there is no changeset. build, format:check, lint:check and typecheck pass at the root.

Why no soak mode

The candidates were (a) a documented recipe with the existing variables, and (b) oracle-gaps --soak <n> or a small separate bin. (b) was to be built only if a loop of the test command could not give the failing seeds and the share without extra work. It can:

  • The failing seeds. Every failing campaign unit already prints Replay: <PREFIX>_SEED=… <PREFIX>_PATH=… <PREFIX>_PROPERTY=… <PREFIX>_UNIT=… vitest run -t '…' (documented in the oracle-property.ts module comment). One grep '^Replay:' collects them.
  • The share per law. A law violation's message carries (law: <name>) (violationError). One grep -o per log, deduplicated per run, then uniq -c, gives the runs each law failed in.
  • A fresh seed and the multiplier. Each plain run draws its own seed (oracleCampaignSeed), and <PREFIX>_RUNS_MULTIPLIER already scales every campaign (oracleRuns).

A --soak mode in oracle-gaps would also have to run outside the mutant machinery and undo the per-test seeding of Math.random that keeps the gap check's random units fixed (#276). It would be this loop with a summary printed after it. The repository's style is composable primitives with no new mode that a documented one-line loop already gives, so the recipe goes in the skill.

Overlap

Limits

  • The probe's bug was built for this purpose. It fails about 1 default run in 50, not the downstream 1 in 27. The downstream numbers (1 in 27, every ×100 run, 40 clean runs, a reviewer at ×10) come from the feedback and were not measured again here.
  • 10 runs at ×10 is a budget, not a proof. It misses a 1-in-27 law about one time in 40, and a 1-in-100 law about one time in three. The skill says to raise the budget when a flaky CI job would cost more.
  • The recipe reads the reporter's printed error messages. A reporter that does not print them gives the greps nothing. A failure with no law (a driver error, or a constructed history that missed its state) still prints a Replay: line but has no (law: …), so it shows only in the first grep. A law name that contains ) is cut short.
  • The claim that the multiplier does not stretch a test's timeout comes from the code (timeoutOf returns options.timeout ?? 120_000). No probe run here reached a timeout.
  • The recipe spells the variable ORACLE_RUNS_MULTIPLIER. A project with its own prefix uses <PREFIX>_RUNS_MULTIPLIER, which docs(skills): run the random campaign several times before a production change is done #264's bullet just above it already names.

For approval

  1. The rule and its budget. Soak with 10 runs at a multiplier of 10 before an oracle is called ready (oracles-design step 7 and step 9, oracles-explore step 5) and before CI runs it with a random seed (oracles-setup step 7).
  2. Docs instead of a soak mode. A loop of the test command, with two greps, instead of oracle-gaps --soak or a separate bin, for the reasons above.
  3. Running the oracle file outside the gap check for the soak. The setup template's "never Vitest alone" does not allow it. docs(skills): run the random campaign several times before a production change is done #264's For approval item 2 asks the same about its repeated runs. If you approve, the template (template 5, or docs(skills): name the printed replay as the one way to run Vitest alone #224's exception) should name the soak too. That change belongs in a follow-up that bumps the template.

🤖 Generated with Claude Code

Extend the random-campaign paragraph of the design skill's step 7 to new
and changed oracles: 10 runs at a run multiplier of 10, as a loop of the
test command whose two greps print each failing unit's replay line and
each law's share of failing runs. Step 9 reports the soak. The explore
skill soaks before it presents an oracle as ready, and the setup skill
soaks an oracle file before CI runs it with a random seed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9463a6aa-28b2-416a-9c61-48d4baa01475

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@changeset-bot

changeset-bot Bot commented Nov 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5fdcd96

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-25T21:31:38.375278Z 5fdcd96 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/TanStack/oracles/@tanstack/eslint-plugin-oracles@304
npm i https://pkg.pr.new/TanStack/oracles/@tanstack/oracles@304

commit: 5fdcd96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant