Skip to content

Testing infrastructure: tracking #1354

Open

Description

@milindsrivastava1997

Design: docs/design_docs/proposals/testing-infrastructure/README.md (#1353): tests T1–T26, decisions D1–D28, the case.toml spec. This issue holds the implementation plan: one brief per PR, in order.

How to run a PR

Prompt for a fresh agent session:

Implement PR N of #1354. Read its brief and the doc sections it cites. Work in .worktrees/<name> from origin/main. Test only the crates you change, with -j2. Don't push; tell me when it's ready.

  • One agent per PR; at most 3 at once (memory).
  • Each PR is reviewed by an agent that did not write it, then by a person. PR bodies say "Part of Testing infrastructure: tracking #1354, PR N".
  • Wave 1 PRs: separate sessions you can steer. Case-writing PRs: subagents from one coordinating session.

Plan

PR What Depends on
0 Merge #1353 (the design doc) —
Wave 1 (parallel)
1 Golden runner + first Stage 0 cases 0
2 Memo invariants and InvariantViolation 0
3 T14 accuracy property tests 0
4 Printer: 5 significant digits, --summary 0; merge before 1 commits goldens
Wave 2
5 Rule enum, rule flags, rule_fires 1
6 shuffle and rename mutations 1
7 Invariant exit code in the binary and runner 1, 2
8 time_series_metric catalog field 0
9 D18 Stage 3 tie-break 0
10 planner_fuzz writes case directories 1
11+ Case-writing PRs (see Tests) 1, plus as noted
Wave 3
12 Corpus snapshots into the runner (D27) 1, 4
13 CI runs everything in release (D19) 1
14+ Existing-test cleanup, one PR per area —

Briefs

PR 1: golden runner

  • Doc: D5–D8, D15, D25, case.toml spec.
  • Build: crates/devtools/tests/goldens.rs with libtest-mimic (harness = false); cases under crates/devtools/tests/goldens/<area>/<case>/; defaults in goldens/defaults/. Runs asap_planner as a subprocess. Loads case.toml (rejects a missing why, unknown fields). Compares JSON with numbers at a relative tolerance of 1e-4, everything else exact; prints a line diff and the exact command on failure. UPDATE_SNAPSHOTS=1 writes expected.json. Assertions: same_group, different_group only.
  • Not in scope: rule_fires (PR 5), mutations (PR 6), invariant exit code (PR 7). The runner rejects these fields until they land.
  • Done: 3–5 Stage 0 cases (T1) pass; a deliberately wrong expected.json fails with a readable diff.

PR 2: memo invariants

  • Doc: T4, T5, T25, D12, D13, D14.
  • Build: in crates/types/src/stages/logical/memo/mod.rs, schema checks in find_or_add_group / add_candidate, and a consistency check (parents/children agree, no orphan groups or candidates, passes only add) run at each stage boundary, always on. A typed InvariantViolation { check, group, origin }, returned as an error, not a panic.
  • Done: a test per check that builds a violating memo and gets the error; existing per-crate tests still pass. Report the check's runtime on the largest corpus workload.

PR 3: T14 property tests

  • Doc: T14, D17.
  • Build: proptest as a dev-dependency of asap-accuracy. Properties of how ε/δ combine (error_contract, logical_edge, guarantee): monotone, order-independent where it should be, never tighter than an input. Generators include −0.0, NaN, ±Inf, q ∉ [0, 1]. Commit the regressions file.
  • Done: properties pass, or each failure is filed as an issue with its shrunk input.

PR 4: printer number format and --summary

  • Doc: D2, D18, D28.
  • Build: crates/devtools/src/stable_output.rs rounds to 5 significant digits. asap_planner --summary (needs --run-until stage3) prints only plan cost, feasibility and sharing_summary. Regenerate existing snapshots; the PR lists which changed beyond rounding.
  • Done: snapshot tests pass; --summary has one test.

PR 5: rule names

  • Doc: D9, D13, rule_fires in the spec.
  • Build: Rule enum in asap-types (Display/FromStr, snake_case), one per Pass 2 rule (crates/stage1-pass2-reuse-candidates/src/rules/). Each candidate records the Rule that added it; the JSON prints it. asap_planner --only-rules <a,b> and --disable-rule <a>. Runner gains rule_fires / rule_does_not_fire.
  • Done: one golden case per rule showing it fires with --only-rules.

PR 6: mutations

  • Doc: D16, mutations in the spec.
  • Build: a mutations module shared by the runner and planner_fuzz; shuffle (reorder queries, renumber for comparison) and rename (metrics and labels, consistently across workloads and tables). Runner applies the default ["shuffle", "rename"] to every case.
  • Done: all existing cases pass under both; an order-dependent planner change (hand-made, not committed) is caught.

PR 7: invariant exit code

  • Doc: D14.
  • Build: asap_planner exits with a dedicated code on InvariantViolation; the runner fails such a case even under UPDATE_SNAPSHOTS=1; planner_fuzz counts it as a finding.

PR 8: time_series_metric

  • Doc: D11, T2.
  • Build: optional time_series_metric on a --sql-catalog-table table; the SQL frontend lowers that table as Source::TimeSeries { metric }.
  • Done: one T2 golden case: a PromQL and a SQL query with same_group = [["q1", "q2"]].

PR 9: Stage 3 tie-break

  • Doc: D18.
  • Build: in crates/stage3-plan-selection/src/milp/model/mod.rs, a deterministic tie-break between equal-cost plans (e.g. a tiny penalty on canonical ids); check there is no time limit for small workloads.
  • Done: a workload with two equal-cost plans selects the same one across runs and query orders.

PR 10: fuzz findings as cases

  • Doc: D26.
  • Build: planner_fuzz writes case/ (shrunk workload.json, non-default inputs, case.toml with why = "planner_fuzz finding <id>") next to each issue draft.

PR 12: corpus snapshots into the runner

  • Doc: D27.
  • Build: each o11y_bench query becomes goldens/corpus/o11y_bench/qNN/ with --summary; data facts copied into each workload.json by the corpus generator; delete corpus_snapshots.rs.

PR 13: CI in release

  • Doc: D19, T20.
  • Build: .github/workflows/rust.yml runs tests in release. Every #[ignore] test runs in a workflow or is deleted.

Tests (case-writing PRs, Wave 2+)

One PR per line; each adds files under its own goldens/<area>/ only. T8 agents are briefed from docs/design_docs/concepts/, not the rule code.

  • Stage 0: T1 lowering, T6 group properties
  • T3 equivalence within one language
  • T2 PromQL ≡ SQL (needs PR 8)
  • T7 Pass 1 candidates
  • T8 rollup · T8 topk · T8 chains (each needs PR 5; positive and negative cases)
  • T10 Stage 2
  • Stage 3: T22 sharing, T26 plan-changing inputs, T19 plan cost relations
  • Mutations on chosen cases: T9 added query, T13 tighter accuracy, T16 separability, T24 rule removal
  • T11 search differential, T12 propagation (separate harnesses; brief when started)

Follow-ups

  • Which integration-tests files migrate to JSON goldens.
  • Rule-firing coverage and mutation testing (cargo-mutants).
  • Revisit deferring execution oracles (~33 ledger bugs need one).

Activity

  1. zzylol commented on Nov 16, 2026

    @zzylol
    Contributor

    D2 (12 significant digits) may churn goldens.

    While porting the stage printer to the #1207 memo (#1239), reordering code alone, with no change to the cost model or the plan, moved plan costs by up to 3e-11 relative. That is a change in the 11th significant digit, so a 12-digit text comparison would fail on a refactor that changes nothing.

    Illustration (not a measured case): a cost of 0.0085 printed to 12 significant digits is 0.00850000000000; the same cost 3e-11 lower prints as 0.00849999999974.

    Two options:

    1. Compare costs (and other floating-point outputs) with a relative tolerance in the snapshot check, for example |a − b| ≤ 1e-9 · max(|a|, |b|), and keep 12 digits in the file for reading.
    2. Print fewer digits, for example 10, which stays above the observed drift.

    Option 1 keeps the files exact and avoids a near-boundary rounding flip that option 2 still allows. #1239 follows D2 as written (12 digits) for now.

  2. milindsrivastava1997 commented on Nov 16, 2026

    @milindsrivastava1997
    CollaboratorAuthor

    Thanks. Let's do both. Option 1 + print 5 significant digits (based on number of significant digits in AWS cloud pricing)

  3. milindsrivastava1997 commented on Nov 17, 2026

    @milindsrivastava1997
    CollaboratorAuthor

    Execution plan: superseded by the plan and per-PR briefs in the issue body (2026-11-20), after #1239 and #1207 PR 8 merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions