DST harness + README alignment for frozen-snapshot periods#24
Merged
Conversation
Adds a state-machine driver (`tests/dst.rs`) that runs randomized sequences of Ingest / Flush / RollupTick / CompactTick / Restart / ClosePeriod against a parallel reference model, asserting raw sum == model after every step and raw == rollup at the end. 64 cases per run; failures shrink to a minimum-length op trace. README updates: closed-period endpoint now documented as returning frozen snapshot + pending adjustments + net total (was "state + total" from the lifecycle-only PR), plus a "Period lifecycle" subsection and a Status bullet calling out the DST harness. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
tests/dst.rs— a Deterministic Simulation Testing harness that drives random sequences ofIngest / Flush / RollupTick / CompactTick / Restart / ClosePeriodagainst a parallel reference model. After every step it asserts §19.5 (raw sum per account matches the model); at the end of each sequence it does a final flush + rebuild_rollups + tick + compact and asserts §19.8 (raw == rollup). 64 cases per run; failures shrink to a minimum-length op trace.GET /periods/{YYYY-MM}endpoint now returnsfrozen+pending_adjustments+net_totalfor closed periods, not juststate + total. Adds a Period lifecycle subsection and a Status bullet for the DST harness.Notes
RollupTickon an empty DB, advancing the watermark past hour 0 before any events arrived) is checked in viatests/dst.proptest-regressionsso CI replays it before generating novel cases. The fix in the harness is to callrebuild_rollups(0, i64::MAX)before the final reconciliation tick — same primitive operators use in production when rollups drift.Test plan
cargo test— all 145 tests pass (139 existing + 1 DST + new properties)cargo build --releaseclean🤖 Generated with Claude Code