Skip to content

feat(oracle-gaps): write a partial report when the run's process dies in its mutant phase - #300

Open
schiller-manuel wants to merge 1 commit into
fix/gap-done-error-remedyfrom
feat/gap-partial-report-on-error
Open

schiller-manuel wants to merge 1 commit into
fix/gap-done-error-remedyfrom
feat/gap-partial-report-on-error

Conversation

@schiller-manuel

Copy link
Copy Markdown
Contributor

Stacked on #252.

This PR is stacked on #252 (fix/gap-done-error-remedy), because both PRs change the same done line. Review #252 first. After it merges, this PR's diff is only the partial report.

When the run's own process dies in the mutant phase, the run no longer loses the mutants it had already judged. Before this PR, a worker thread's native crash under --pool threads ended the run with exit 3 and no summary.md and no results.json. The judged mutants were kept only in <out>/results.jsonl, which is undocumented and which no line of the stream names.

What changed

  • check.mjs: the first line of results.jsonl, written when the mutant phase starts, records what a report needs:

    • the process id;
    • the id of every mutant the run will judge, in the order the completed report lists them;
    • the report's other fields: the run identity, options, baseline, excluded, nondeterministic, and what the summary renders under.

    Results are still appended per mutant, as before. The shared fields are now built once (reportFields, renderFields), and the completed results.json and summary.md use them, so neither changes.

  • ending.mjs: new partialEnding(out, pid, cause). When results.jsonl exists and starts with the header of this pid, it writes results.json with:

    • status: "partial";
    • cause (for example the run's process exited with SIGTRAP);
    • the run's usual fields;
    • the judged results, in report order;
    • unjudged, the ids of every mutant it did not judge.

    It also writes summary.md (via renderReport). A torn last row is ignored.

  • report.mjs: renderReport({ …, partial }) adds one line under the inputs. The counts that follow are of the judged mutants only:
    **Partial report**: the run's process exited with SIGTRAP after 4 of 7 mutants were judged. Not judged: sut.ts:M5, sut.ts:M6, sut.ts:M7.

  • index.mjs (supervisor): when the run's process ends without writing its own ending and without being stopped, it calls partialEnding. If a report was written, the done line ends with ; partial report <out>/summary.md.

  • Unchanged:

    • A run that dies before its mutant phase gets no report: its results.jsonl header does not exist, or belongs to another pid.
    • A stopped run (SIGINT, SIGTERM) gets no partial report.
  • Docs: the setup skill's list of done lines, and the native-crash entry in the explore skill's problems list.

A stopped run has no partial report either. The issue suggested reusing one for stops, but none exists today, so this PR adds none for them. I can extend it to stops if you want; that would change law 13's stopped done line.

How the oracle sees it (oracle first)

  • Law 12 (report-shaped ending) is extended. partialBreach checks, for a stopped run whose process ended by itself on POSIX:
    • When the process died after its baseline (partialOwed, a crash), results.json has status partial and the done line's cause.
    • Each judged mutant is one of the run's mutants, appears once, and has the outcome the model owes it. The model's mutants are paired to ids through the completed run, which is checked against the model by site.
    • No stop-witness mutant that the model owes killed is judged. That is the copy that crashed.
    • unjudged is exactly the run's other ids, in the completed report's order.
    • summary.md's lines that say the report is partial are exactly [partialNote(...)]. The driver keeps only those lines in the trace: the rest of the summary holds the run id and baseline times, which made the determinism unit differ between two runs of the history.
    • An abort, which strikes before any baseline, leaves no report.
  • Law 15: the done line must equal crashLine(signal, pool, report), with the summary's path for a crash.
  • History: a native crash under each pool (from fix(oracle-gaps): name the step that avoids a native crash in the done error line #252) now has three owned functions before the stop witness. Its crash runs go without --only, so the run judges mutants before the witness's copy crashes.
  • New POSIX-only state: a partial report held a judged mutant. It was reached on the fixed seed, with 4 judged mutants in the scratch probe below.
  • Seven new calibrations, bound to that history. Each must be rejected under the named law:
    • a crashed run writes no partial report (12)
    • a partial report drops a judged mutant (12)
    • a partial report gives a judged mutant another outcome (12)
    • a partial report counts a crashed copy's mutant as killed (12)
    • a partial report's summary has no partial line (12)
    • a crashed run's done line does not name its partial report (15)
    • an abort before the baseline writes a partial report (12)

Evidence

Probe on the base (#252's head; main behaves the same apart from the step text). It uses a scratch package whose test runs process.kill(process.pid, 'SIGTRAP') under the last function's mutants, with --pool threads --contexts 1:

exit 3
oracle-gaps: done error, the run's process exited with SIGTRAP: a native crash, ...
out/: results.jsonl run-<pid>-5.jsonl state.json stream.log   (no results.json, no summary.md)

The same probe on this branch:

exit 3
oracle-gaps: done error, the run's process exited with SIGTRAP: a native crash, ... or with another Node version; partial report <out>/summary.md
results.json: partial "the run's process exited with SIGTRAP", 4 results, unjudged [ 'sut.ts:M5', 'sut.ts:M6', 'sut.ts:M7' ]
summary.md:   **Partial report**: the run's process exited with SIGTRAP after 4 of 7 mutants were judged. Not judged: sut.ts:M5, sut.ts:M6, sut.ts:M7.

RED: the extended oracle on #252's production code (check.mjs, ending.mjs, index.mjs and report.mjs checked out from origin/fix/gap-done-error-remedy, cbbb029; this branch's oracle files):

cd packages/oracles
node node_modules/vitest/vitest.mjs --run --config oracle-gaps/vitest.config.mjs gap-report-oracle.property -t "fixed seed 20261105: a native crash under each pool$"
× fixed seed 20261105: a native crash under each pool 44160ms
  Difference: the run whose process exited with SIGTRAP (crash): it wrote no partial report
  Tests  1 failed | 368 skipped (369)

GREEN on this branch (4a66032 before the push), in three runs:

cd packages/oracles
# the native-crash history (fixed seed, random seed, determinism) and its ten calibrations
node node_modules/vitest/vitest.mjs --run --config oracle-gaps/vitest.config.mjs gap-report-oracle.property -t "(: a native crash under each pool$|calibration: (a worker thread's crash ends with no step to take|an abort beside child-process workers names the forks pool as its step|a signal that is no native crash names a native crash's step|a crashed run writes no partial report|a partial report|a crashed run's done line does not name its partial report|an abort before the baseline writes a partial report))"
  Tests  13 passed | 356 skipped (369)      # "a partial report held a judged mutant": 1 (fixed seed), 1 (random seed)

# every outcome class (fixed seed, random seed, determinism)
node node_modules/vitest/vitest.mjs --run --config oracle-gaps/vitest.config.mjs gap-report-oracle.property -t ": every outcome class$"
  Tests  3 passed | 366 skipped (369)

# its two halves (the warm stop, the abort stop), the setupThrows abort history,
# and the history that enters "a partial run of one function"
node node_modules/vitest/vitest.mjs --run --config oracle-gaps/vitest.config.mjs gap-report-oracle.property -t "(: every outcome class, the (warm|abort) stop$|: a declaration fault: setupThrows, then the abort stop$|: a failing owner under a config that --config names$)"
  Tests  12 passed | 357 skipped (369)

The ten calibrations on the crash history are its three from #252 and the seven above; each was rejected under its named law.

Also run, all passing:

  • node scripts/pr-shards.mjs check (7 partitions split their tests exactly)
  • node scripts/e2e-shards.mjs check (5 shards partition the e2e tests)
  • tests/gap-report-history-fingerprint.test.ts (4 passed; no drawn field and no constructed history was added, so neither history-fingerprint.json nor constructed-order.json changes)
  • root build, lint:check, format:check and typecheck

Design grammar: no trigger fired. The check adds one function for one law, and the model adds two small rules (partialOwed, partialNote).

Overlap

Limits

  • POSIX and supervised runs only. win32 runs the oracle's history without its crash. An unsupervised run (the win32 path before fix(oracle-gaps): supervise the check on win32; log each CLI run in the e2e driver #79) has no supervisor to write the report.
  • --daemon: the daemon's process dies, the CLI starts a new daemon, which reruns the check and resets results.jsonl. After three deaths the run still ends as an internal error, whose ending overwrites results.json. No partial report is written there.
  • The oracle pairs only operator mutants with the model. The history has no authored mutants. An authored id in a partial report is still checked to be one of the run's ids, and to be judged or unjudged exactly once.
  • The crash's leftover capture file, <out>/run-<pid>-<n>.jsonl, stays, as it did before this PR.
  • A stopped run is unchanged (see above).
  • Authored mutants: the run appends only operator results as they are judged, so a crash in the authored phase lists every authored mutant as unjudged, even one already judged. No history has authored mutants beside a crash.
  • A crash under several contexts, and one during the selection checks before any mutant is judged (whose partial report judges none), are not generated. These limits are added to the law's limits text.

Design note: retrying a crashed unit (not in this PR)

The feedback also asked to retry a crashed worker once before giving up. This PR does not do that:

  • Under threads, a native crash kills the whole process, every worker thread with it. A retry would mean the supervisor restarts the run and resumes it from results.jsonl. It cannot tell which mutant crashed: a context runs up to four mutants per batch, and any of them could be the one. A resume would have to rerun that batch's mutants one at a time, or skip them all.
  • Under forks, a crash ends only its worker, and the run goes on. The crashed mutants are reported as setup-error, whose directive (a driver's import) is misleading for a native crash. Whether that should become a crashed class of its own is for you to decide.

Laws for approval

A delta to law 12 (report-shaped ending):

  • Old: a run that does not complete ends with a refusal (exit 2) or an internal error (exit 3, error.log).
  • New, added: for every supervised POSIX run whose own process ends after its baseline without writing its ending and without a stop, the output directory holds a partial report:
    • results.json, with status: "partial", the cause its done line names, each judged mutant with the outcome a completed run gives it, and unjudged. unjudged lists exactly the other mutants, in the order of the completed report, and includes every mutant whose copy crashed.
    • summary.md, holding the **Partial report**: <cause> after <n> of <m> mutants were judged. Not judged: <ids>. line.
    • The done line ends with ; partial report <summary.md>.
    • A run whose process ends before its baseline leaves no report.
  • Authority: none adopted yet. This is proposed in answer to downstream feedback. The wording of the line and the field names are open.

🤖 Generated with Claude Code

… in its mutant phase

A native crash of a worker thread under --pool threads (or any signal or exit
that skips the run's own ending) used to lose every mutant already judged. The
first line of results.jsonl now records the run's pid, the ids of every mutant
in report order and the report's other fields; when the run's process ends
without its ending and without a stop, the supervisor writes results.json with
status "partial", the cause, the judged results and the unjudged ids, and a
summary.md with a Partial report line. The done line names that summary.

Law 12 is extended (partialBreach) with seven calibrations on the native-crash
history, which now has three owned functions before the stop witness.

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

changeset-bot Bot commented Nov 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4a66032

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 Patch

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

@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: c4f45753-1261-42e9-9ee1-589ea192e74f

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

@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-25T17:01:26.844689Z 4a66032 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

Copy link
Copy Markdown
Contributor Author

CI on 4a66032: 56 pass, 2 fail. Neither failure is caused by this PR:

  • Windows gap report end-to-end oracle (fixed seed, 2/10) fails in fixed seed 20261105: every outcome class. This shard also fails on main.
  • Gap report end-to-end oracle (random seed, 3/4) fails in random seed: a daemon pause that cannot engage: "the check during the mid-run edit reported src/sut.ts#devBuild:return-undefined:... as neither cold run did" (the mutant crashed with "the helper this run read is not strict"). The same seed fails identically on fix(oracle-gaps): name the step that avoids a native crash in the done error line #252's head (cbbb029), so the failure predates this PR. This PR changes only the contents of results.jsonl, which nothing but the new partialEnding reads. Replay:
cd packages/oracles
ORACLE_SEED=-227923415 ORACLE_PATH=0 ORACLE_PROPERTY='oracle-gaps.report' ORACLE_UNIT='random seed: a daemon pause that cannot engage' \
  node node_modules/vitest/vitest.mjs --run --config oracle-gaps/vitest.config.mjs gap-report-oracle.property -t 'random seed: a daemon pause that cannot engage$'

That is a random-seed counterexample in the mid-run edit law (law 9), and it belongs in its own issue with a constructed history.

🤖 Generated with Claude Code

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