Repository navigation
test(snapshots): fail on any plan change under STRICT_SNAPSHOTS (nightly); regenerate the 48 stale snapshots - #1550
Merged
Merged
Conversation
…nightly; regenerate snapshots (#1541) The snapshot harnesses passed a plan that changed at the committed plan's cost, so a PR that moved a tie left the committed snapshots stale. With STRICT_SNAPSHOTS=1, which the nightly workflow now sets, any difference fails; without it (local runs) the equal-cost pass stays, noted on stderr. Regenerates the 48 snapshots that had gone stale on main: 13 corpus queries and 35 sketch plan workloads, every one at an unchanged cost_per_second.
…flow comments; print runner CPU and toolchain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
chains-10m-5m-3m-10s-mvpselects KLLk = 2863on its 5-minute chain while the committed file saysk = 1404, and the nightly run stays green.STRICT_SNAPSHOTS=1, which the nightlyCorpus snapshotsworkflow now sets, any difference from a committed snapshot fails. Without it (local runs) the equal-cost pass stays, with a note on stderr. The 48 stale snapshots are regenerated from whatmainselects.cost_per_secondexactly.Closes #1541.
Review guide
Base:
main(after #1549). Read first:crates/planner-cli/tests/corpus_snapshots.rs:strict_snapshots,changed_snapshot_passes, and the new testequal_cost_plan_changes_fail_when_strict.crates/planner-cli/tests/sketch_plan_snapshots.rs: the same switch insketch_plans_match_snapshots..github/workflows/corpus-snapshots.yml:STRICT_SNAPSHOTS: 1on the check step.docs/develop_docs/planner-snapshots.md: new "Strict and local runs" section; the "What a snapshot holds" list now matches what the harness writes (it still nameddisplay_name,proven_optimal,search_statusandtumbling_window_retention_ms, which snapshots no longer hold).Mechanical: the 48 regenerated
*.jsonsnapshots (13 undercorpus_snapshots/o11y_bench/, 35 undersketch_plan_snapshots/), written byUPDATE_SNAPSHOTS=1and summarized under Snapshot changes below.Behavior: before → after
The committed
chains-10m-5m-3m-10s-mvp.json(KLLk = 1404on node 1), checked onmain:STRICT_SNAPSHOTS=1 cargo test --release -p asap-planner-cli --test corpus_snapshots -- --ignored sketch_plans_match_snapshotschains-10m-5m-3m-10s-mvp: plan changed at the committed plan's cost; passeschains-10m-5m-3m-10s-mvp: plan changed at .materialized_views[0].plan_id: - "1dbad9b6..." + "e6bedd52...", regenerated file uploadedSTRICT_SNAPSHOTS(fails with STRICT_SNAPSHOTS=1)The first differing path is the view's
plan_id, because the walk visits keys in sorted order andmaterialized_viewssorts beforeselected; the same file also differs at node 1's KLLk(1404 → 2863).This serves correctness of the test suite: a committed snapshot is the plan
mainselects.Interfaces
None in the planner. The test harness gains one environment variable,
STRICT_SNAPSHOTS(any value turns it on), and two private helpers:crates/planner-cli/tests/corpus_snapshots.rsUsage: the nightly workflow runs
cargo test --release --locked -p asap-planner-cli --test corpus_snapshots -- --include-ignoredwithSTRICT_SNAPSHOTS: 1. For each corpus query and each sketch plan workload, the harness plans it withasap_planner --run-until stage3, renders the snapshot, and compares it with the committed file;changed_snapshot_passes(expected, actual, strict = true)returnsfalsefor any changed text, so the test fails, names the first differing line (corpus) or JSON path (sketch plans), and writes the regenerated snapshot and itsasap_plannerdocument for upload. Locally,strict = falsekeeps the equal-cost pass.Algorithm changes
None. Stage 3 selection is unchanged; the tie-break fallback (option 3 of #1541) was not needed, see Decisions.
Decisions and open questions
Needs reviewer decision: None.
Decided (2026-11-28):
The stale snapshots come from code, not machines. Regenerating at fix: seal KLL and Count-Min into view layouts; cost sketch states as held #1518, which last wrote them, reproduces every committed file byte for byte.
Option 1 of [Bug] Snapshot tests pass silently when the selected plan changes at equal cost, so committed snapshots go stale #1541 (strict on CI, lenient locally), as the issue recommends. Rejected: report-only (option 2, easy to miss) and a deterministic Stage 3 tie-break (option 3), because the selection is already deterministic (below).
Determinism check.
mainwas regenerated withUPDATE_SNAPSHOTS=1twice on each of three eval hosts, the second run pinned to 4 cores (taskset -c 0-3). All runs wrote byte-identical snapshots. TheCorpus snapshotsworkflow was also run on this branch (on the GitHub runner, withSTRICT_SNAPSHOTS=1) against the regenerated snapshots: passed with the regenerated snapshots (byte-identical to the eval hosts'). No tie-break or field normalization was added.One switch, set explicitly.
STRICT_SNAPSHOTSalone turns strict mode on; the genericCIvariable does not, so a local shell that happens to exportCIkeeps today's behavior.Is KLL
k = 2863vs1404really equal cost? Yes, a genuine tie, not a cost-model gap. Node 1 builds 5-minute KLL states for 10,000 groups from 667 rows/s: 667 × 300 / 10,000 ≈ 20 rows per state, and the 10-minute merge holds about 40. Belowkrows a KLL never compacts, sokll_view_bytesandkll_open_bytes(crates/cost/src/node/state_bytes/kll.rs) price one level holding every row, whateverkis; the update cost is per row (KLL_UPDATE_OPERATIONS_PER_ROW) and the merge and estimate costs are per byte, so every term is equal. This matchesasap_sketchlib, whose KLL grows its buffer with the rows it holds, not withk; both states are exact. The same holds for the otherkflips below (KLL 2863 → 1404 inmixed-quantiles-raw-retained; KMVk26656 ↔ 106263 in three distinct-count workloads, whose states hold far fewer hashes than eitherk). No issue filed.Verification
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo test --workspace --locked(CI's runner, includes goldens)goldens(within the workspace run)corpus_snapshotsbinary,STRICT_SNAPSHOTS=1 -- --include-ignored(release)pruning_keeps_every_snapshot_optimumagainst the regenerated snapshotschains-10m-5m-3m-10s-mvp.json(k = 1404) restored.materialized_views[0].plan_id; withoutSTRICT_SNAPSHOTSthe same run passesCorpus snapshotsworkflow on this branch (GitHub runner)New test:
equal_cost_plan_changes_fail_when_strict: a snapshot whose plan changes (k1404 → 2863) at the same cost passes without strict mode and fails with it. Written first: against achanged_snapshot_passesthat ignoredstrictit failed (equal_cost_plan_changes_fail_when_strict ... FAILED), then passed with the change.Snapshot changes
All 48 changes were already what
mainselects; none comes from this PR's code. The snapshots were last written by #1518; since then only #1529 changed planning (#1547 and #1548 are docs and a refactor), and regenerating on the commit before #1549 already rewrote the same 48 files, so the cause column says #1529. Its rule 5 removesOneEvaluationtwins, which also moves which of several equal-cost plans the MILP returns. Every file keeps itscost_per_secondexactly, and itsusageexcept one noted below.lifetime{"OneEvaluation": "Memory"}→"None"OneEvaluation, whoseNonetwin costs the sameplan_idchangeskbelow)k1404 → 2863 (5-minute chain and its readers; the 10-second chain stays 1404)chains-10m-5m-3m-10s-mvpk2863 → 1404mixed-quantiles-raw-retainedk26656 → 106263distinct-over-time-5pct-raw-retained,entropy-and-distinct-raw-retainedk106263 → 26656distinct-two-forms-raw-retainedTimeShiftnode no longer "holds 61000 bytes";peak_memory_bytes7808133 → 7747133o11y_bench/q21cost_per_secondunchangedCorpus files:
o11y_bench/q02, q05, q06, q11, q18, q19, q20, q21, q22, q23, q25, q26, q27. Sketch plan files: 35 of the 42 manifest workloads, listed in the diff.Follow-ups