Skip to content

test(tla): behavior replay for MultiCurrency, AccountStateMachine, PriceDB - #1695

Merged
robcohen merged 1 commit into
mainfrom
feat/tla-replay-more-specs
Jul 2, 2026
Merged

robcohen merged 1 commit into
mainfrom
feat/tla-replay-more-specs

Conversation

@robcohen

@robcohen robcohen commented Jul 2, 2026

Copy link
Copy Markdown
Member

FV backlog: the replay family grows 7 → 10 corpora (+27,028 behaviors at CI bounds) and reaches beyond the core inventory for the first time — the validator and the price database now have model-conformance suites.

Spec Behaviors (CI / escalated) Abstraction
MultiCurrency 10,116 / 374,860 per-currency Conservation over a multi-commodity Inventory; every currency asserted after every step — cross-commodity leaks fail
AccountStateMachine 16,222 / 51,752 in rustledger-validate: every model-legal open/close/post/transfer lifecycle → directives → validate() must return zero errors (E1001/E1002/E1003 enabledness)
PriceDB 690 / 2,710 in rustledger-query: model-set (base, quote) pairs read back via get_latest_price; unset pairs unasserted (impl legitimately derives inverses)

Machinery

  • Interpreters distributed by crate (deps force it); the coverage lint's single-file assumption generalized to the per-crate list.
  • Generator: 3 function-valued delta-derives; PriceDB handles the same-value-overwrite transition (only opCount moves).
  • Escalation-table entries for all three — my own drift guard from test(tla): weekly bounds-escalated corpus replay #1694 demanded them, exactly as designed.
  • DoubleEntry/Interpolation: reasoned exclusions documented in RUST_MAPPING.md (by-construction invariant; highest-effort mapping deferred).

All verified locally incl. escalated bounds; lint green (10 corpora, all cross-references intact); clippy -D warnings + fmt clean.

🤖 Generated with Claude Code

…iceDB

Extends the replay family from 7 to 10 corpora (+27,028 behaviors at CI
bounds), reaching two subsystems beyond the core inventory for the first
time. Interpreters are distributed by abstraction target (crate deps force
this — validate/query depend on core):

- MultiCurrency (10,116 behaviors, core): per-currency Conservation over a
  multi-commodity Inventory; every currency asserted after every step, so
  cross-commodity unit leaks fail.
- AccountStateMachine (16,222, validate): each model-legal open/close/post/
  transfer lifecycle converts to directives and must validate() with zero
  errors — the E1001/E1002/E1003 state machine's enabledness obligation.
- PriceDB (690, query): every model-set (base, quote) reads back via
  PriceDatabase::get_latest_price; model-unset entries not asserted (the
  implementation legitimately derives inverse rates).

Generator: three delta-derives (function-valued states; PriceDB handles the
same-value-overwrite transition where only opCount moves). Coverage lint:
single replay file generalized to the per-crate list. Escalation table:
entries for all three (the drift guard demands them); verified at escalated
bounds too — 374,860 / 51,752 / 2,710 behaviors, all conforming.

DoubleEntry and Interpolation are deliberately NOT replayed — reasoned
exclusions documented in RUST_MAPPING.md (by-construction invariant /
highest-effort mapping deferred).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@robcohen
robcohen requested a review from a team as a code owner July 2, 2026 19:13
Copilot AI review requested due to automatic review settings July 2, 2026 19:13
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Tool Time Memory
rustledger 33.3ms ± 0.6ms 23.7 MB
beancount 903.9ms ± 7.5ms 50.6 MB
Comparison 27.1x faster 2.1x less

vs main branch (2026-07-02)

Metric main this PR Change
Time 39.8ms 33.3ms -16.3% 🟢
10K transactions · 5 runs, 2 warmup · hyperfine
What do these numbers mean?
  • Time: Wall-clock time to parse and validate the ledger (± std dev)
  • Memory: Peak resident set size (RSS)
  • vs main: Compared to latest nightly benchmark on main branch

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Expands the TLA+ behavior-replay conformance test suite from inventory-only coverage into additional crates, adding validator lifecycle and query price-database model conformance, plus updating the associated replay/generation/coverage-check tooling.

Changes:

  • Added new replay corpora coverage for MultiCurrency, AccountStateMachine, and PriceDB, with per-crate replay interpreters in rustledger-core, rustledger-validate, and rustledger-query.
  • Extended the behavior-corpus generator (scripts/tla-behaviors.py) with derives for the three new specs, and added escalated-bounds entries for weekly deep replay.
  • Generalized the coverage lint to accept replay interpreters distributed across crates; added serde_json as needed for new test harnesses.

Reviewed changes

Copilot reviewed 9 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spec/tla/RUST_MAPPING.md Documents the three new replayed specs and (now) their crate-local replay targets.
scripts/tla-escalated-replay.py Adds escalated replay bounds entries for the three new corpora.
scripts/tla-coverage-check.py Updates coverage lint to treat crates/*/tests/tla_behavior_replay.rs as valid replay locations.
scripts/tla-behaviors.py Adds corpus-derivation logic + registry entries for MultiCurrency, AccountStateMachine, and PriceDB.
crates/rustledger-validate/tests/tla_behavior_replay.rs New validator-enabledness replay suite for AccountStateMachine.
crates/rustledger-validate/Cargo.toml Adds serde_json dev-dependency for the new replay test.
crates/rustledger-query/tests/tla_behavior_replay.rs New PriceDatabase replay suite for PriceDB.
crates/rustledger-query/Cargo.toml Adds serde_json dev-dependency for the new replay test.
crates/rustledger-core/tests/tla_behavior_replay.rs Adds MultiCurrency replay suite targeting Inventory per-currency units.
Cargo.lock Records new dev-dependency edges (serde_json) for validate/query crates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread spec/tla/RUST_MAPPING.md Resolved
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 100%
Full AST Match 100%
Total Files 792
What's tested
  • Check: Exit codes and error counts match bean-check
  • BQL: Query results match bean-query
  • Files: ~800 test files downloaded from 10+ beancount repositories

Full results available in workflow artifacts

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@robcohen
robcohen merged commit 4a57560 into main Jul 2, 2026
57 checks passed
@robcohen
robcohen deleted the feat/tla-replay-more-specs branch July 2, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants