Repository navigation
Commit fe532f4
fix(oracles): never instrument a super() call as a mutation site (#3)
* fix(oracles): never instrument a super() call as a mutation site
The statement-deletion mutant wrapped an expression statement that calls
`super(...)` (`G.m(id) || super(...)`). A derived constructor then ran
with `super` conditional or moved, and with TypeScript's parameter
properties or field initializers it read `this` before `super` and threw
("Must call super constructor..."), so every construction failed with no
mutant active. Expression-position super calls were already excluded;
statement-position ones were not.
The fix excludes a `super(...)` call from `delete-call` in schemata.mjs.
The static oracle gains a derived-class grammar (DERIVED file: a base
class and a derived class whose constructor runs statements before and
after `super('a')`, with and without parameter properties and a field
initializer). Its laws: the source runs as the model says; the
instrumented class with no mutant active runs as its source does; under
every mutant the constructor completes with the base tag; and the model's
expected sites contain no site for the super call.
Law: The static half of the gap report keeps each derived class's super
call unconditional (no mutant removes or moves it; with no mutant active
the instrumented class behaves as its source). Authority: the gap
report's contract that instrumentation with no mutant active does not
change behavior and that a mutant is a legal program variant (the
operator contract in schemata.mjs), and ECMAScript's rule that a derived
constructor calls super before it reads this and before it returns.
Maintainer report G11 (TanStack DB subscription.ts, 2026-11-09).
Reach: 21 generated histories (fixed seed 20261105) and 25 (random seed)
entered `a derived class constructed`, and every derived state
(`a derived class with a parameter property`, `... with a plain parameter`,
`... with a field initializer`, `... with statements before super`,
`... with no statement before super`, `... with a conditional before
super`, `... with a statement after super`, `... reading this after
super`) is reached under both seeds, with two constructed histories
naming them so each is reached on every campaign.
RED: on the parent code (schemata.mjs unchanged, new grammar), the static
oracle fails law `no-mutant behavior` at checkpoint `derived`, fixed seed
20261105 (the shrunk history has `derived: {before: [], after: []}`):
the instrumented class with no mutant active throws "Must call super
constructor in derived class before accessing 'this' or returning from
derived constructor", the source returns labels [] and tag "a". Both
calibrations of the new laws are then also red, because their clean trace
fails.
GREEN: `vitest --run --config oracle-gaps/vitest.config.mjs` (all four
files, 34 tests, exit 0) on the final tree, including the static oracle
with its two new calibrations (`super unconditional`, `no-mutant behavior`)
detected.
Mutant: a hostile "fix" that exempts only a leading `super(...)` statement
(the first statement of the constructor body) leaves a later super call
wrapped. The static oracle rejects it with `no-mutant behavior` (fixed and
random seeds). With no mutant active, the wrapped super call throws in the
TypeScript-emitted class, so the no-mutant law catches it before the
per-mutant law does.
Harness fix found by the end-to-end run: the determinism law compared the
CLI's raw stderr, and a refusal's stack names the CLI copy's directory
(`oracle-gaps-mutant cli #<random>`), which differs per run for a
spaced-path history. The daemon branch already names those directories;
the `cli` observation now names them the same way, in raw and file-URL
form. The law still compares everything else the CLI reports.
Mutant check: the failing determinism run (before the normalization) is the
RED for this harness change; the GREEN is the full run above.
Limits: derived classes are judged only in the static oracle's in-process
run. No test imports the derived file, so the end-to-end oracle does not
run it, and the run transpiles it to CommonJS at ES2022 (other downlevel
targets and Vitest's transform are not run). The mutant switch restates
the contract in schemata.mjs. The grammar has no `super.method()` call,
no super in a value position, and no class of a container other than
`Derived`. Verifying the TanStack DB subscription.ts case itself (~80
oracle files) is not in this change: it needs a run against that checkout.
`createOracleReach` is TanStack DB's; this package declares reach with
`states` and `constructed` histories (oracle-property.ts).
Co-authored-by: Isaac <[email protected]>
* fix(oracles): no super-region mutation sites in derived constructors
Review follow-up to 77a06fd. That commit excluded a `super(...)` statement
from `delete-call`, which left shapes where a mutant still prevents or
delays the call: a `super` in an arrow argument, a `super` as a logical
operand, and a statement before `super` that returns early.
Maintainer decision (2026-11-09): one rule for every shape. A derived
constructor gets no mutation site in its super region, which is its
parameters, the statements before its first statement that calls `super`,
and that statement. An arrow inherits `super`, so its body counts; a
function, method, accessor, or class does not. Statements after the call
keep their sites. `superGuarded` in schemata.mjs implements it.
Law: no mutant, when active, prevents or delays a derived constructor's
super call; with no mutant active the instrumented class behaves as its
source; under every mutant the constructor completes with its base tag,
unless an early return ends it first; statements after super keep their
sites. Authority: the gap report's behavior-preservation and legal-variant
contract (schemata.mjs operator contract), ECMAScript's rule that a derived
constructor calls super before it reads this and before it returns, and the
maintainer decision above.
Grammar (gap-report-model-oracle.mjs): a derived class's before statements
(push, conditional push, early `return {}`), one of four super forms (a
statement; `[0].forEach(() => super('a'))`; `out && super('a')`;
`nothing(n) || super('a')`), and after statements (push, `this.tag` read,
conditional push). The model gives sites only to after statements. The
form filter keeps sources legal TypeScript: a non-statement super needs
plain parameters and no field, since TypeScript emits parameter-property
assignments before the body and requires a root-level super beside a field.
Reach: derive-from-observation (static oracle). Counts from the static run,
fixed seed 20261105 / random seed: constructed 30 / 24; plain parameter
25 / 14; parameter property 5 / 7; field 9 / 7; early return 7 / 6; push
before 9 / 6; conditional push before 7 / 5; push after 19 / 13;
conditional push after 5 / 4; this read after 7 / 6; super as statement
10 / 15; super in an arrow 6 / 3; super after && 6 / 1; super after || 8 / 5.
Plus constructed histories for each form and for the early return.
RED: static oracle, on the 77a06fd schemata.mjs with the new grammar,
fixed seed 20261105: law `super unconditional` at checkpoint `derived`,
"under mutant 21 the class for 0 has tag undefined" (and mutant 30). The
arrow, `&&`, and `||` forms let a mutant skip super; the `&&` and `||`
forms return the `out` array with no error, so only the tag check sees it.
The before-super sites that the rule removes are not separately shown red:
the derived law fails first for them. Two harness defects were also red
before the fix: the grammar's list cap (3 statements) and the form
builds, which the oracle correctly rejected as outside the language.
GREEN: static oracle 11/11 on the final tree (fixed and random seed, with
the calibrations `super unconditional` and `no-mutant behavior` detected).
Full suite (`vitest --run --config oracle-gaps/vitest.config.mjs`): 4
files, 34 tests, exit 0, on this commit's tree.
Mutant: a hostile rule that covers only the super statement, not the
statements before it, is rejected by `super unconditional` (mutant 21 and
23: a forced early return ends the constructor with no tag). The fix is
restored byte-for-byte after the check.
Harness hygiene (e2e, gap-report-oracle.property.test.mjs), no RED of its
own: stderr is named (CLI directory and scratch package) before it is cut
to its last 1500 characters (`readRun`); the daemon's first line reads
that already named text; the scratch directory is resolved with
realpathSync, as the static driver does. Comparison change: the `cli`
observation now names the CLI copy by how.cli and the package directory
before the cut, and the daemon path no longer calls replaceAll on a
possibly undefined copy. No law is relaxed; the normalization is the
determinism law's existing rule for scratch paths.
Simplifications: one `derivedStates` table shared by the reach derivation
and `required`; reach states come from the observed runs and the
instrumented copy's super form, not the plan; `isSuperCall` and
`holdsSuper` are shared; the `no-mutant behavior` calibration uses
`corrupt`; `DERIVED_FN` is no longer exported; the plan carries one
`derived` object (`spec`, `source`, `statements`).
Limits:
- The in-process run transpiles to CommonJS at ES2022; Vitest's transform
(CR-6) and other downlevel targets are not exercised.
- The mutant switch (`switchFor`) is a hand copy of the switch's contract,
not the capture setup's runtime (CR-5): the capture setup imports Vitest
and installs timers and globals on load, so it cannot run in-process.
- The end-to-end oracle instruments the derived file and judges its sites as
unowned, but no test imports or constructs the class; its no-mutant and
super-region behavior is judged only in-process.
- The model special case (CR-8) is kept as written.
- Not generated: super in a method, a nested class, a `super.method()`
call, a constructor default parameter, or a before-super `return`
other than the early-object form.
Co-authored-by: Isaac <[email protected]>
---------
Co-authored-by: Isaac <[email protected]>1 parent 98a9610 commit fe532f4
5 files changed
Lines changed: 561 additions & 24 deletions
File tree
- .changeset
- packages/oracles/oracle-gaps
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
| |||
182 | 189 | | |
183 | 190 | | |
184 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
185 | 223 | | |
186 | 224 | | |
187 | 225 | | |
| |||
315 | 353 | | |
316 | 354 | | |
317 | 355 | | |
| 356 | + | |
| 357 | + | |
318 | 358 | | |
319 | 359 | | |
320 | 360 | | |
| |||
1454 | 1494 | | |
1455 | 1495 | | |
1456 | 1496 | | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
1457 | 1599 | | |
1458 | 1600 | | |
1459 | 1601 | | |
| |||
1584 | 1726 | | |
1585 | 1727 | | |
1586 | 1728 | | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
1587 | 1732 | | |
1588 | 1733 | | |
1589 | 1734 | | |
| |||
1873 | 2018 | | |
1874 | 2019 | | |
1875 | 2020 | | |
| 2021 | + | |
1876 | 2022 | | |
1877 | 2023 | | |
1878 | 2024 | | |
1879 | 2025 | | |
1880 | 2026 | | |
1881 | 2027 | | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
1882 | 2033 | | |
1883 | 2034 | | |
1884 | 2035 | | |
| |||
2263 | 2414 | | |
2264 | 2415 | | |
2265 | 2416 | | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
2266 | 2433 | | |
2267 | 2434 | | |
2268 | 2435 | | |
| |||
2348 | 2515 | | |
2349 | 2516 | | |
2350 | 2517 | | |
2351 | | - | |
| 2518 | + | |
2352 | 2519 | | |
2353 | 2520 | | |
2354 | 2521 | | |
| |||
3208 | 3375 | | |
3209 | 3376 | | |
3210 | 3377 | | |
| 3378 | + | |
3211 | 3379 | | |
3212 | 3380 | | |
3213 | 3381 | | |
| |||
3528 | 3696 | | |
3529 | 3697 | | |
3530 | 3698 | | |
| 3699 | + | |
3531 | 3700 | | |
3532 | 3701 | | |
3533 | 3702 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
| 300 | + | |
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
| 431 | + | |
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| |||
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
456 | | - | |
| 456 | + | |
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
461 | 473 | | |
462 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
463 | 484 | | |
464 | 485 | | |
465 | 486 | | |
| |||
472 | 493 | | |
473 | 494 | | |
474 | 495 | | |
475 | | - | |
| 496 | + | |
476 | 497 | | |
477 | 498 | | |
478 | 499 | | |
| |||
493 | 514 | | |
494 | 515 | | |
495 | 516 | | |
496 | | - | |
497 | | - | |
| 517 | + | |
498 | 518 | | |
499 | 519 | | |
500 | 520 | | |
| |||
640 | 660 | | |
641 | 661 | | |
642 | 662 | | |
643 | | - | |
644 | | - | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
649 | 666 | | |
650 | 667 | | |
651 | 668 | | |
| |||
836 | 853 | | |
837 | 854 | | |
838 | 855 | | |
839 | | - | |
840 | | - | |
841 | | - | |
842 | | - | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
843 | 862 | | |
844 | 863 | | |
845 | 864 | | |
| |||
1656 | 1675 | | |
1657 | 1676 | | |
1658 | 1677 | | |
1659 | | - | |
| 1678 | + | |
1660 | 1679 | | |
1661 | 1680 | | |
1662 | 1681 | | |
| |||
0 commit comments