test: add proptest coverage for EntityEvents and idempotency_guard#130
Draft
nicolasburtey wants to merge 1 commit into
Draft
test: add proptest coverage for EntityEvents and idempotency_guard#130nicolasburtey wants to merge 1 commit into
nicolasburtey wants to merge 1 commit into
Conversation
Adds two property-based test files exercising the framework's core contracts: - tests/proptest_events.rs covers EntityEvents invariants: mark_new_events_persisted_at sequencing, load_first / load_n JSON roundtrip, load_n grouping across multiple entity ids, and iter_all ordering across arbitrary push/extend/mark interleavings. - tests/proptest_idempotency.rs covers the idempotency_guard! macro: stutter idempotency for both already_applied and resets_on forms, full-retry safety for already_applied-only command sequences, extensional dedup-by-first-occurrence, and resets_on alternation. Each property runs 4096 cases. Total runtime ~0.22s release. 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
Adds two property-based test files covering the framework's core contracts.
tests/proptest_events.rs— invariants onEntityEvents:mark_persisted_sequencing— across arbitrary push/extend/mark interleavings, persisted events have contiguous monotonic sequences from 1 and the new-events buffer is drained.load_first_roundtrip— events serialized throughGenericEventand reloaded compare equal in order.load_n_grouping— K entities × M events each: returned count = min(K, n),moreflag matches, no event lost or stitched across ids.iter_all_ordering— invariant after every step:iter_allyields exactly the cumulative push order regardless of when marks occur.tests/proptest_idempotency.rs— theidempotency_guard!macro contract:stutter_is_idempotent—c; c≡cfor any command, bothalready_applied-only andresets_onforms.full_retry_is_noop_for_pure_commands— replaying any sequence ofalready_applied-only commands pushes zero new events. The retry-safety property callers depend on.pure_commands_dedup_by_first_occurrence— extensional pin: stream equals deduplicated first-occurrence subsequence of pushed events.resets_on_allows_alternation— Activate/Deactivate alternations never produce two consecutive identical states (provesresets_onactually resets the scan window).Each property runs 4096 cases. Total runtime ~0.22s in release. No production code touched.
Test plan
cargo test --test proptest_events --test proptest_idempotency --releasepasses locally