Skip to content

feat(oracle-gaps): --diff-base judges only the mutants on changed lines - #292

Merged
KyleAMathews merged 2 commits into
fix/gap-diff-base-unknown-revfrom
feat/gap-diff-base-limits-run
Dec 2, 2026
Merged

KyleAMathews merged 2 commits into
fix/gap-diff-base-unknown-revfrom
feat/gap-diff-base-limits-run

Conversation

@schiller-manuel

Copy link
Copy Markdown
Contributor

Stacked on #290 (fix/gap-diff-base-unknown-rev). Review that first. This PR's own commit is the last one.

oracle-gaps --diff-base <rev> now does what a downstream project expected it to do: the mutant phase runs only the mutants on lines changed since <rev>, so you get feedback fast after a change. On main (and on #290), the flag only adds inDiff to each result. Every mutant still runs (#285 measured 13 of 13).

What changed

  • check.mjs: the selection happens right after keyAndSelect, before the baseline. With --diff-base, every selected operator mutant gets inDiff from its line, and so does every selected authored mutant, from the line its edit lands on. Only the ones marked true stay in the run. A does-not-apply authored mutant has no line, so it is not judged. The baseline still runs every test file that the run without the option runs. With --only, the selection is the intersection, and the baseline runs the owners of what is left (G5). diffLines is computed lazily per source, so an authored mutant's file is diffed too.
  • The run says it is partial in three places:
    • the stream, once, before the baseline: oracle-gaps: note --diff-base <rev>: <n> of <m> mutants are on changed lines; the others are not judged in this run. <m> counts what the run without the option would judge.
    • summary.md: the same sentence, under the totals.
    • results.json: through the existing mechanism, run.inputs. It now ends ; a partial run (--only, --sample, or --diff-base), where an --only or --sample run's said (--only or --sample). options.diffBase holds { rev, commit } (feat(oracle-gaps): --diff-base refuses an unknown revision and judges only changed lines #290).
  • report.mjs: diffNote, the one sentence that both the stream and summary.md print. renderReport takes it as judgedOnly.
  • index.mjs: the usage comment says what --diff-base does.
  • The authored-mutant patching (applyAuthored), which --only's owner set and step 6 each did, now happens once, in chosen.

Evidence

All commands run in packages/oracles.

Law 16 of the end-to-end oracle, changed. #290 owed the same mutants and outcomes as the run without the option. Now the run owes only the mutants on changed lines: their keys, operator and authored, come from the model's commit (diffBaseOf, unchanged). Each is marked inDiff: true and judged as the full run judged it. The baseline files equal the full run's, and the run owes the note once, the sentence in summary.md, and a partial run in run.inputs. The tracked constructed history gains an authored mutant.

  • RED on feat(oracle-gaps): --diff-base refuses an unknown revision and judges only changed lines #290's head (480dd17): node node_modules/vitest/vitest.mjs --run --config oracle-gaps/vitest.config.mjs gap-report-oracle.property -t "fixed seed 20261105: a check with --diff-base" failed both:
    • a check with --diff-base on changed and unchanged lines: the run with --diff-base marked src/sut.ts#authored:a2 inDiff undefined, owed false
    • a check with --diff-base and an untracked source: the run with --diff-base judged other mutants or outcomes than the run without it judged on the changed lines
  • GREEN: -t "a check with --diff-base|calibration: a run with --diff-base": 13 passed in 48 s. That is the 6 history units and 7 calibrations, each rejected under diff base:
  • Neighbors, since the authored selection moved: -t "fixed seed 20261105: (a failing owner under a config that --config names|two authored mutants|a stale authored mutant and a reformat|an ambiguous authored mutant|generated)": 5 passed. gap-report-classify: 282 passed. The history canary and both shard checks pass.
  • pnpm run build, lint:check, format:check, and typecheck pass at the root.

Wall time on a package with many mutants (r15-diffbase/measure.sh). The scratch package holds 30 functions of 11 mutants each (330 mutants), and each function has its own oracle. One line of f0 was changed since HEAD (a - b * 2 to a - 2 * b). Each run is cold, on an 18-core Mac, twice:

[before --diff-base HEAD] (#290) exit 0, 9.5s wall; mutant phase: 330 mutants in 7.0s; 330 mutants, 324 killed, 6 gaps
[after  --diff-base HEAD]        exit 0, 1.7s wall; mutant phase: 5 mutants in 0.4s; note --diff-base HEAD: 5 of 330 mutants are on changed lines; the others are not judged in this run; 5 mutants, 4 killed, 1 gaps
[after, no --diff-base]          exit 0, 8.9s wall; mutant phase: 330 mutants in 6.9s; 330 mutants, 324 killed, 6 gaps
second round: 9.3s / 1.7s / 9.8s

Every run's baseline printed baseline all 2 oracle files pass. What is left of the 1.7 s is mostly the baseline and the start. On a package whose mutants cost seconds each, the saving is the share of mutants on unchanged lines.

Daemon and evidence reuse (r15-diffbase/probe-daemon.sh, same package):

[--daemon]                         9.3s; 330 mutants; run 00dff14c0df5; evidence reused 0,   computed 363
[--daemon --diff-base HEAD]        0.2s;   5 mutants; run 08dca4e29684; evidence reused 9,   computed 0
[--daemon --diff-base HEAD]        0.2s;   5 mutants; run 08dca4e29684; evidence reused 9,   computed 0
[--daemon]                         0.3s; 330 mutants; run 00dff14c0df5; evidence reused 363, computed 0

The daemon parses each request's arguments itself (commitOf runs there) and runs git diff on each check, so an edit between checks moves the selection. Evidence is keyed by each unit's inputs and not by the selection, so a diff-base check reuses a full check's units and the other way round. The note reaches stderr and stream.log through the daemon too. The run identity includes options.diffBase, so a partial run never shares its id with a full one.

Beside --only and --sample (same package): --only with 3 ids on the changed line and 1 elsewhere noted 3 of 4 mutants are on changed lines and ran 3, with the baseline of their one owner file. --sample 3 --diff-base HEAD noted 0 of 3: the sample is drawn first (keys and the sample are as without the option), then limited.

Changeset: .changeset/gap-diff-base-limits-run.md (minor).

Overlap

Limits

  • Law 16 runs --diff-base HEAD cold, beside no --only or --sample, in a history without the witness module, with lines replaced in place. The daemon, the --only intersection, and --sample beside it are shown by the probes above, not by the oracle.
  • A does-not-apply authored mutant has no line, so a --diff-base run does not report it, even when the change is what made its find stale. The full check still does.
  • --sample n --diff-base samples first, so it can judge nothing (0 of 3 above).

Laws for approval

This changes what an existing flag means, so it needs the maintainers' decision.

  1. Law 16, changed. For every run with --diff-base <rev>, the run judges exactly the mutants, operator and authored, whose line changed since that commit (every line of an untracked source included). Each is marked inDiff: true and judged as the run without the option judges it. The baseline runs every test file the run without it runs. The run notes --diff-base <rev>: <n> of <m> mutants are on changed lines; the others are not judged in this run once on its stream and in summary.md, and run.inputs says it is a partial run.

    The two choices.

    • (a) Change --diff-base, as this PR does.
    • (b) Add a new flag, for example --changed-only, that limits the run, and keep --diff-base as a marker only.

    Recommended: (a). It fits the existing options. --only and --sample already choose what runs, and the run marks itself partial. A third option that chooses by revision belongs with them. --diff-base has no description in the usage text, no README or skill entry, and its only effect was a field that nothing reads. With (b), --changed-only would need --diff-base beside it to name the revision, which makes two options for one choice and one more refusal (--changed-only without --diff-base). The cost of (a) is that a full run with every mutant marked by inDiff is no longer possible. A full check and a --diff-base check of the same tree give the same information, and the daemon makes the second one nearly free.

  2. The baseline of a --diff-base run runs every test file, as asked for here. --only runs only its mutants' owners (G5). Running only the owners of the changed lines' mutants would be faster still, but it would not show a change that breaks an unrelated oracle file. This PR keeps every file.

  3. Open question: should a --diff-base run whose changed lines hold no mutant refuse, as fix(oracle-gaps): --only refuses a selection that judges nothing #236 proposes for an --only that judges nothing? It completes with 0 of <m> today.

🤖 Generated with Claude Code

@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: 100a5dc4-5e97-4170-a63c-3619f77e7996

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

🦋 Changeset detected

Latest commit: 4349d20

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/oracles Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another 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-25T13:58:50.134078Z 7c07930 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.

schiller-manuel and others added 2 commits December 1, 2026 16:35
With --diff-base <rev>, the mutant phase runs only the operator and
authored mutants on lines changed since <rev>. The baseline still runs
every test file. The run notes `--diff-base <rev>: N of M mutants are on
changed lines; the others are not judged in this run` on its stream and
in summary.md, and its inputs say it is a partial run, as --only and
--sample runs do. Law 16 of the end-to-end oracle changes to match.

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

An authored mutant whose find occurs zero or several times has no line, so
the --diff-base run dropped it from the report, though law 5 makes
does-not-apply a gap and the run without the option reports it. Every
--diff-base run now keeps those, marked inDiff false, and the note's count
still counts only the mutants on changed lines.

Law 16 and its model say so. The end-to-end oracle gains a constructed
history with a does-not-apply authored mutant, one with an authored mutant
on a changed line, and one with both marks in one function. Calibrations
drop a does-not-apply mutant, drop or unmark an authored mutant on a changed
line, and mark an unchanged line of a changed function.

RED on the #292 head before this change: the does-not-apply history fails at
the diff base checkpoint (the run judged other mutants than the run without
the option). GREEN after it: all 26 law 16 units pass, including the new
calibrations.

Not changed: a multi-line authored find is still judged by its first line
(law 16 says "whose line changed"; a decision is pending). Its history needs
a grammar field, which needs a history-fingerprint.json update, so it waits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@KyleAMathews
KyleAMathews force-pushed the feat/gap-diff-base-limits-run branch from 7c07930 to 4349d20 Compare December 1, 2026 23:59
KyleAMathews added a commit that referenced this pull request Dec 2, 2026
…e span rule and --only and daemon coverage

With --diff-base <rev> the mutant phase judges only the operator and authored
mutants on changed lines, and the baseline still runs every test file that the
run without the option runs. Folded from #292 into #290's branch.

- A mutant is on a changed line when any line from its first to its last is in
  the diff (the authored case is witnessed by a constructed history).
- An authored mutant that does not apply is reported on every run with the
  option, as law 5 requires for a gap.
- --only with --diff-base keeps the baseline of every selected mutant's owners;
  the diff narrows only the judged set (RED before this change: the baseline
  ran only the changed-line owners).
- The note counts changed-line mutants in <n> and the run without the option
  (same --only or --sample) in <m>.
- The diff runs set psMissing false, so an emptied PATH does not refuse them
  (CodeRabbit on #290; probe: --diff-base HEAD exits 2 with an empty PATH).
- commitDiffBase stages its base files with --force, so a global excludes file
  cannot stop the base commit (CodeRabbit on #290; probe: git add exits 1 on an
  ignored file).
- Law 16 is adopted (2026-12-01, Kyle Mathews, KyleAMathews). The changeset is
  one entry for the combined change.

The grammar gains authoredSpan, drawn last; both lists in
history-fingerprint.json gain one appended line and no earlier line changes.

Co-authored-by: Isaac <no-reply@databricks.com>
@KyleAMathews
KyleAMathews merged commit 4349d20 into fix/gap-diff-base-unknown-rev Dec 2, 2026
56 of 59 checks passed
@KyleAMathews
KyleAMathews deleted the feat/gap-diff-base-limits-run branch December 2, 2026 00:43
@KyleAMathews

KyleAMathews commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

This pull request was folded into #290. Its commits are on fix/gap-diff-base-unknown-rev at 7430baf, and #290's title and description now cover the whole --diff-base change. It was merged into that branch (4349d20) by its maintainer before this comment, so it was not closed here.

This comment was written by Isaac.

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.

2 participants