Repository navigation
Conversation
…all oracle ported Laws run the real code as an Effect, so a law can hold a service with its layers, database and TestClock, not only a pure function. Histories come from Effect's own Arbitrary (shrinking, replay tokens); observations are typed values compared by a differ that tells -0 from 0. Each law gets constructed edges (fixed, or built into sampled bases), fixed and random seeds, calibrations and a reach check. The on-call oracle is ported as the proof: the same laws, model and edges. On the code before #3264's fix it fails both original bugs (the long override's own end; an empty interval splitting a gap), the onCallAt one found by a random-seed run with no constructed help.
… cannot hide the ones bounding its shift A service-level law over OnCallSchedulesService (PGlite, a fresh database and TestClock per history) found it on a random seed: the +/-15-day read was sorted from its oldest row and capped at 1,000, so 1,000 expired rows dropped the override that just ended (a layer shift reported starting an hour early) and the next one (the shift reported ending at next Monday's handoff instead of when Ben's override starts, so who_is_on_call skipped him). The read now takes the nearest rows on each side of the instant.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
This comment has been minimized.
This comment has been minimized.
An empty list compiled and built int(0, -1), a range no value satisfies, so the law failed far from the call.
This comment has been minimized.
This comment has been minimized.
A law with work: { ratio } records each judged test's work (mutation sites
evaluated, a count) in Stryker's dry run and fails a mutant doing more than
ratio times that. Counted from Stryker 10's coverage helper plus the active
mutant's hits, the same measure in both modes; counting activeMutant reads
is biased, since an active mutant skips the checks after it at its site.
Off without MAPLE_ORACLE_WORK_FILE or outside Stryker.
…; drop the tanstack one
oncall-effective and oncall-gaps carry work: { ratio: 1 }, as before. Under
Stryker the port now kills 215 of oncall.ts's mutants (180 do not compile,
6 are never reached) with 4 surviving, against 27 without the bound. The
rules header moves into the Effect oracle; the model stays, shared with the
service law.
Maple review🟢 Confidence 10/10 · safe to merge. The narrowed override reads are order-independent ( Adds
Before merge
|
Stacked on #3268 (on #3266, on #3264).
@maple/oracle(lib/oracle) is an Effect-first take on what@tanstack/oraclesgives us: a law, an independent model, and the real code checked against it on generated and hand-built histories. The real code runs as an Effect, so a law can hold a whole service, with its layers, a PGlite database andTestClock. Its first service-level law found a real bug. The on-call oracle now runs on it alone, and the@tanstack/oraclesversion is deleted.The bug it found
OnCallSchedulesServiceread the ±15-day override window sorted from its oldest row, capped at 1,000. With 1,000 expired rows ahead, it dropped the overrides nearest the instant:who_is_on_callreads "next" fromendsAt, so it skipped Ben.A random-seed run found it and shrank it to one schedule with a one-hour override. The fix reads the nearest rows on each side of the instant: past overrides by
endsAtdescending, future ones bystartsAtascending, each capped. This is the same class as the review fixes on #3264, which only covered overrides holding the instant and the newer ones cutting them.Both cases are now hand-built histories. They are red on the old read and green with the fix.
Still open: the org-wide
listread (overlappingOverrides) has the same capped-ascending shape, and no law covers it yet.The library
Oracle.law({ id, statement, authority, limits, histories, resolve, model, run, check, reached, calibrations, work }).runreturns anEffect.checkreturnsOption<Violation>.Oracle.test(law)registers one Vitest suite per law:build: (base) => history) planted into sampled bases;Oracle.testLayer(law, layer)builds the layer fresh for every evaluation, including inside shrinking.Arbitrary, not fast-check.Genaddsint,pick,oneOf,optionanduniqueArray.Diffreports the first difference with its path, and tells -0 from 0. Effect'sEqualtreats -0 and 0 as equal.Work, the work bound: a law withwork: { ratio }fails a change that does more work for the same answers, so a dropped shortcut is caught.MAPLE_ORACLE_WORK_FILE, so plain test runs are unaffected.activeMutantreads: that measure is biased. An active mutant skips the checks of the mutants after it at its site, which hid extra work.On-call, on
@maple/oracleonlyoncall.effect-oracle.test.tscarries the five laws, the model and the hand-built edges, and now the rules header too.oncall-effectiveandoncall-gapskeepwork: { ratio: 1 }.oncall.oracle.test.ts(@tanstack/oracles) is deleted. Its model stays, because the service law shares it.AGENTS.mdand the rootCLAUDE.mdnow say which tool owns what: alert hysteresis and the PromQL printer stay on@tanstack/oracles.oncall.tsfrom before fix(on-call): onCallAt names the real handoff inside a long override, guarded by an oracle #3264's fix, both original bugs fail. A random-seed run found the long-override bug with no hand-built help.Mutation run (StrykerJS)
Stryker 10's Vitest runner works with Vitest 5. It needs a sidecar install with TypeScript 5, because this repo is on TypeScript 7. Its TypeScript checker drops mutants that wouldn't compile, which is the false gap
@tanstack/oraclesreports. The recipe is inlib/oracle/README.md. It is not added as a dependency.Results for
src/oncall.ts:What the bound killed: 38 mutants, each with a count, e.g. "20,363 site evaluations, more than 1 × the unmodified code's 20,360". They're the window filter, the range checks, the merge comparisons, and a rotation index computed with
*for/.The 4 survivors:
toMs - fromMs→toMs + fromMs. This is the render limit inonCallAt's own fix. Any limit at least as long as the span behaves the same.[fromMs, endMs]→[].samePiececomparison.The last three are not yet analysed.
@tanstack/oraclesreported 0 gaps on this file, so these are the remaining difference.The 6 never reached: 5 are in
localTimeOnDay's fallback. The sixth is inabsentParticipants, which no law owns.Evidence
lib/oracle: 5 tests. Typecheck,oxlint -c .oxlintrc.effect.jsonand oxfmt are clean.packages/alerting-core: 398 tests in 10 files pass. That's the 581 before, minus the deleted file's 183.OnCallSchedulesServicesuites pass, 31 tests including the law's 9, across 5 runs with fresh random seeds.🤖 Generated with Claude Code