Repository navigation
Commit babf94e
test(db): move two oracles onto oracleProperty with constructed histories (#2383)
* test(db): move the grouped result key oracle onto oracleProperty with constructed histories
The campaign combined a raw fc.assert with a reach floor of 5, so whether
each state was entered depended on the seed. Each of the three states now
has a constructed history that splices its steps at the front of a generated
history, and the rest of each history stays random. The campaign runs on
oracleProperty: resolve turns index-named moves and deletes into row ids, the
model replays the plan independently, the driver observes the published rows
and size at each checkpoint, reach is a predicate of the model's groups, and
the check compares groups, key count, and key stability.
Evidence
- Law: unchanged. A grouped result publishes one key per group, a string or
number, shared by no two groups, and a surviving group keeps its key.
Authority: the TKey constraint and InvalidKeyError; maintainer decision
(2026-10-27) that grouped keys match the declared key type.
- Reach: three declared states, each named by one constructed history. Counts
printed by the framework, including constructed histories: fixed seed
92604118 gives 50 nullish, 37 lookalike, 61 kept; random seed -1510560228
gives 53, 23, 63.
- RED: none observed. Five seeds (1 to 5) on the unconverted file all passed
the reach check, so no seed-dependent failure was seen. The old file is at
HEAD~1; this commit does not claim a RED result.
- GREEN: default run 6 of 6 pass. Seeds 1 to 5, 6 of 6 each. A temporary
runs: 1 edit (reverted before commit) also passes 6 of 6 at seeds 1 to 5.
- Mutant (production): createPublicGroupKey encodes a non-string primitive as
String(value) instead of the reserved namespace. Five of six tests fail,
but as driver errors (CollectionOperationError "key null already exists",
"changed by 2 rows in one flush"), not as a law verdict. The kill is real;
the verdict is not yet a named law.
- Mutant (builder): the lookalike builder replaced by identity. The framework
rejects it: "constructed history ... did not enter lookalike-groups-published".
- Limits: reach counts above are campaign totals, so random-only counts are
not separated. Dates, -0, objects, multi-field groups are outside this owner
(unchanged). The mutant kill comes through a driver error, so the check
does not yet name the law for that defect.
Co-authored-by: Isaac <no-reply@databricks.com>
* test(db): name the law that a production publication error breaks in the grouped key oracle
The driver let a production error escape the campaign, so the framework
reported it as a setup error and the mutant that makes two groups share a key
was caught only as a crash. The driver now records the error at the checkpoint
where it was raised, as { error: { name, message } }, and the check returns a
violation of "publishing a valid grouped change raises no error". Collection
ids carry a per-process serial, so the message is stripped of it, which keeps
two runs of one history identical for the determinism test.
Evidence
- Law: unchanged in substance. Authority: the one-result-row-per-key invariant
in the grouped result key oracle's opening prose; the same key-type and
uniqueness laws as before. The new law names the error case only.
- Reach: unchanged (three constructed histories, one per state; default run
printed the same counts in the previous commit's evidence).
- RED: production mutant on the parent of this commit (group-by.ts,
createPublicGroupKey encodes null as String(value)): four tests failed as
driver errors, reported as setup errors.
- GREEN: default run 6 of 6; seeds 1 to 5, 6 of 6 each.
- Mutant after the change: same production mutant; four tests now fail with the
named verdict "production raised CollectionOperationError ..." and
"production raised Error: Live query result key null changed by 2 rows in one
flush", law "publishing a valid grouped change raises no error". Production
file restored and verified identical afterward.
- Limits: a surviving mutant that produces a wrong grouped result without
raising still goes through the key and count checks, which are unchanged.
Co-authored-by: Isaac <no-reply@databricks.com>
* style(db): format the grouped result key oracle with prettier
Formatting only, after the error-observation change: prettier reflows the
Step union, the try block, and a long check line. No behavior change.
Co-authored-by: Isaac <no-reply@databricks.com>
* test(db): move the proxy array callback campaign onto oracleProperty with a split model and driver
The callback campaign was one raw fc.assert whose campaign body computed the
native expected row, the draft's actual row, and the reach state together, so
the model and the driver were fused in observeArrayCallbacks. The campaign now
has three separate parts with the same law and comparisons:
- driveArrayCallbacks runs the draft one step at a time and observes what the
draft exposes (the call record, the row rebuilt from its recorded changes,
the change records, and the baseline). A production error is recorded as an
observation and the check names it.
- modelArrayCallbacks replays the same steps on a plain row. It decides the
expected views and does not touch the draft.
- judgeCallbacks compares each observed view with the model's view, in the
same order as before: call, row, changes, baseline.
The zero-sign write reach is a predicate of the model's views, and one
constructed history splices a forEach with a zero delta at the front of a
generated history, so the state is entered in every campaign. The three
calibrations (lost write, extra visit, wrong peer) move to the framework's
calibrations. The fixed and baseline tests keep their unit form and run the
same driver, model, and comparison through observeArrayCallbacks and
assertArrayCallbacks.
Evidence
- Law: unchanged in content, now stated as the oracle law. Authority:
packages/db/src/proxy.ts; the maintainer decision (2026-10-29) that -0 and 0
are distinct row values.
- Reach: zero-sign-write entered by 129 histories in the fixed-seed campaign
and 128 in the random campaign (framework counts, constructed history
included).
- RED: none observed. On the unconverted file, seeds 1 to 5 all passed, so no
seed-dependent failure was seen.
- GREEN: default run 48 of 48; seeds 1 to 5, 48 of 48 each.
- Builder mutant (constructed history replaced by identity): framework rejects
with "constructed history ... did not enter zero-sign-write".
- Production mutant (src/proxy.ts getChanges returns {} unconditionally,
restored and verified): 27 of 48 tests fail with the named verdict
`proxy.callback-history violated at checkpoint "step 0" (law: the row rebuilt
from the draft's recorded changes is the native row)` on a shrunk history
{"values":[-0],"steps":[...]}.
- Limits: the baseline and fixed-delta tests remain unit-style in this file
(pre-existing; they call the shared helpers); the proxy driver's error
branch has no mutant that exercises it yet; the coverage map has no
reach statement for this owner, so none changed.
Co-authored-by: Isaac <no-reply@databricks.com>
* test(db): fix the grouped result key oracle's review findings (D3-1 to D3-7, D3-10)
Replay manifest (D3-1): group-result-key.groups now matches the framework's
random-seed test name, "group-result-key.groups > random seed". oracle-replay.test.ts
passes 116 of 116.
Lint (D3-2): the import members are sorted; eslint is clean on both files.
Distinct keys (D3-3): the distinct-key count and the live size are compared with
the model's group count, not with the rows of the same snapshot. A calibration
shares one key between two groups and the check rejects it.
Every checkpoint observed (D3-4): the check compares the observation count with
the model's checkpoint count, so an empty or truncated trace fails under
"every checkpoint of a history is observed". A calibration drops the last
checkpoint.
Production errors (D3-5, D3-6): the driver catches only the production calls
(preload, each write and commit, each snapshot read). The error is observed as
its normalized Error, which keeps the stack and cause; the check returns a
violation of "publishing a valid grouped change raises no error" with the
original Error as the verdict's cause. Cleanup runs outside these catches, so a
teardown failure is a setup error. The error helpers are shared with the proxy
oracle in tests/oracle-error-observation.ts.
Calibrations (D3-7): one per verdict branch (unsupported key type, shared key,
surviving group changes its key, publication raises, last checkpoint dropped),
each checked by the framework to be rejected by its named law.
Check name (D3-10): the grouped-key comparison is named judgeGroups and is the
declared check. The driver has no declareOracle slot (check, model, grammar
only), so it is declared through oracleProperty's driver field.
Evidence
- Law: unchanged in substance; the new law names the checkpoint count and the
error case. Authority: as before (TKey, InvalidKeyError, maintainer decision
2026-10-27), and the opening prose of this file.
- Reach: unchanged. Fixed seed 92604118: nullish 50, lookalike 37, kept 61.
Random seed: nullish 50, lookalike 25, kept 59 (framework counts, constructed
histories included).
- RED on this oracle's previous state: the distinct-key check compared the
collection with itself, so a shared key was never rejected. The new
"two groups share a key" calibration is that RED: it is rejected now and was
never rejected before.
- GREEN: default 11 of 11; seeds 1 to 5, 11 of 11 each.
- Production mutant (createPublicGroupKey encodes null as String(value)):
four tests fail with the named verdict "publishing a valid grouped change
raises no error" and the production error text as the difference.
- Calibrations: five, each rejected by its named law.
- Replay: oracle-replay.test.ts 116 of 116. eslint clean; lint:changed clean.
- Limits: the reach counts mix constructed and random histories. The shared
error module is also used by the proxy oracle in the next commit.
Co-authored-by: Isaac <no-reply@databricks.com>
* test(db): fix the proxy callback oracle's review findings (D3-4, D3-5, D3-8, D3-9)
Observation count (D3-4): the check compares the number of observed steps with
the model's, so a truncated or empty trace fails under "every step of a history
is observed". A calibration drops the last step.
Errors (D3-5): the draft's error is observed as the shared normalized Error and
gets its own law, "a draft's callback raises no error", with the Error as the
verdict's cause. The local error helpers are gone; the shared module is
tests/oracle-error-observation.ts.
Driver (S3-style): only the draft calls (the callback and getChanges) are
inside the catch. Building the row from the recorded changes is outside it.
Constructed history (D3-8): the builder keeps the generated step's method and
pins only its target and delta to 0 over a leading -0, so every callback
method can enter zero-sign-write.
Fixed histories (D3-9): the baseline case (two steps must leave the input row
unchanged) and the per-method fixed deltas (8 methods, 3 targets, 3 delta pairs)
are histories.fixed, run through the same driver, model, and check. The
hand-written baseline test and its helpers observeArrayCallbacks and
assertArrayCallbacks are deleted.
Smaller fixes: the lost-write calibration tests the difference directly, the
reach comment states that the state describes the history, and the calibrations
include a dropped last step.
Evidence
- Law: unchanged in content. Authority: packages/db/src/proxy.ts; the
maintainer decision (2026-10-29) that -0 and 0 are distinct row values.
- Reach: zero-sign-write, 129 histories in the fixed-seed campaign and 127 in the
random campaign (framework counts, constructed history included).
- RED: for D3-4, the old check never compared counts, so a truncated trace
passed. The "last step dropped" calibration is that RED: it is rejected now.
- GREEN: default 113 of 113; seeds 1 to 5, 113 of 113 each.
- Production mutant (getChanges returns {} unconditionally): 67 of 113 tests
fail with the named law "the row rebuilt from the draft's recorded changes is
the native row".
- Builder mutant (constructed history replaced by identity): rejected by the
framework's generability check ("built a history the arbitrary cannot
generate"), not by the reach check.
- Known limit: a builder that keeps the -0 prefix but omits the zero-sign step
passed the default campaign, because random tail steps can still enter the
state. The reach check is therefore not deterministic for this builder design.
Recorded here; a stronger builder (pin the -0 change in the generated history
itself) is a follow-up, not part of this commit.
- Replay and eslint: clean. lint:changed clean.
Co-authored-by: Isaac <no-reply@databricks.com>
---------
Co-authored-by: Test <test@test.com>
Co-authored-by: Isaac <no-reply@databricks.com>1 parent a86aa43 commit babf94e
5 files changed
Lines changed: 718 additions & 330 deletions
File tree
- docs/contributing
- packages/db/tests
- query
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
581 | 581 | | |
582 | 582 | | |
583 | 583 | | |
584 | | - | |
| 584 | + | |
585 | 585 | | |
586 | 586 | | |
587 | 587 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1142 | 1142 | | |
1143 | 1143 | | |
1144 | 1144 | | |
1145 | | - | |
1146 | | - | |
1147 | | - | |
1148 | | - | |
| 1145 | + | |
1149 | 1146 | | |
1150 | 1147 | | |
1151 | 1148 | | |
| |||
0 commit comments