Expand description
Post-generation verification: reparse protected output and audit it before publication.
--verify renders SQL to a protected temporary file, then this module
reparses that file with the production parser (Parser::visit_events,
the same visitor the profiler drives) and audits the generated rows against
the declared GenerationPlan. Only if the full VerificationReport
passes does the caller atomically publish the temp file over the real
destination; a failed audit leaves the prior destination untouched.
§What is checked, and how honestly
Every reported check carries a CheckStatus:
CheckStatus::Exact— a machine-checkable invariant evaluated on every row: row counts, arity, non-null, declared character length, integer width, decimal precision/scale, primary-key/unique uniqueness, foreign-key and composite-key membership, planner equations/state invariants (PlannerPredicates from the compiled planners), and cross-table family sums ([FamilySumCheck]s).CheckStatus::Sampled— an approximate distribution comparison against a recorded tolerance. A sampled check is never relabeled exact.CheckStatus::NotChecked— a capability the verifier could not evaluate (e.g. a table whose DDL never appeared). It is reported as its own status and never counted as a silent success.
VerificationReport::passed is true only when no check failed; a
NotChecked capability is surfaced but does not, on its own, fail the run
unless it means a required exact check could not run.
§Bounded membership
Uniqueness and membership indexes hold exact keys in memory under a byte
budget and spill their key bytes to a ProtectedSpool once the budget is
exceeded. Spilled indexes external-sort bounded runs, then use adjacent-key
and linear merge-join checks without retaining an entry per key in memory.
Dense integer key domains stay in memory.
Structs§
- Check
Outcome - One audited invariant and its outcome.
nameis a stable slug (e.g.primary_key:orders,planner_equation:sessions) so callers and tests can locate a specific check;detailnever contains source or generated values. - Distribution
Expectation - An approximate categorical-distribution expectation the verifier compares a
generated column against, labeled
CheckStatus::Sampled. Fractions are of the table’s total rows;toleranceis the maximum absolute deviation any category may drift before the sampled check fails. - Generation
Verifier - Reparses a generated SQL file and audits it against a
GenerationPlan. - Verification
Report - The full audit of a generated SQL file.
Enums§
- Check
Status - How thoroughly a single check was evaluated. A check is never reported under a status stronger than the evidence supports.