Skip to content

1.04 Money, Currency and Identifier Types: Exit Evidence

Evidence · Step: 1.04 Money, Currency and Identifier Types

Step 1.04 Money, Currency and Identifier Types
Date 2026-11-11
Toolchain Rust 1.96.1, proptest 1.12, cargo-llvm-cov 0.9.1
Result Passed
Deliverable File Contents
Currency crates/core/src/currency.rs Currency from a static ISO 4217 table, ETB first (11 currencies, exponents 0, 2 and 3). Serialised as its code.
Money crates/core/src/money.rs Money { amount: i64, currency } with checked add, subtract and negate only; mixed currencies and overflow are errors. PositiveAmount for line amounts. Exact decimal parsing and formatting. JSON as {"amount": "39.20", "currency": "ETB"}.
IDs crates/core/src/ids.rs AccountId, EntryId, HoldId, ClientId (UUIDv7 only, one canonical text form) and IdempotencyKey (1–128 characters from A–Z a–z 0–9 - _ . :).

Parsing rules (Money::parse): digits with an optional leading - and at most one .; at least one digit on each side of the .; no leading zeros; at most the currency’s number of decimal places, never rounded; no -0, +, spaces or exponents; at most 32 characters.

Design notes:

  • There is no impl Add for money, so a + b does not compile. Only the checked methods exist.
  • crates/core stays free of clocks and randomness. It validates UUIDv7 IDs but does not generate them; the engine will.
  • The scaffold’s AccountId(u128) is replaced by the new UUIDv7 type. The other scaffold types stay until steps 1.05–1.06.
Requirement Test Result
parse(format(x)) == x parse_of_format_is_identity (every i64, every currency) Pass
Checked add and subtract never panic and error on overflow checked_add_matches_wide_arithmetic, checked_sub_matches_wide_arithmetic (compared with i128) Pass
Cross-currency operations always error mixed_currencies_always_error Pass
"0.001" ETB is rejected rejects_invalid_amounts Pass: TooManyDecimals { max: 2 }
"-0" is rejected rejects_invalid_amounts Pass: NegativeZero
i64 max and min boundaries handles_i64_boundaries Pass: both format and parse back; one santim beyond overflows

Other property tests: JSON round trip, parsing never panics on any string, PositiveAmount accepts exactly the positive amounts, UUIDv7 IDs round-trip through text, non-v7 UUIDs are rejected, ID and idempotency key parsing never panic.

In total: 33 tests (21 unit, 12 property).

Criterion Result
100% branch coverage on the money module Pass for all non-test code, measured as region coverage: money.rs, currency.rs and ids.rs have 100% line, function and region coverage outside their test modules. The only missed regions are ? error paths inside the tests themselves. Stable Rust cannot report branch coverage separately (that needs a nightly compiler); region coverage includes every branch arm.
No unwrap Pass: none in the new modules; clippy::unwrap_used is denied workspace-wide
Clippy clean Pass: cargo clippy --workspace --all-targets -- -D warnings

Gate: property tests pass for 1,000,000 cases.

Terminal window
PROPTEST_CASES=1000000 cargo test -p mezgeb-core --release properties
test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 21 filtered out; finished in 129.54s

Result: passed. All 12 property tests ran 1,000,000 cases each with no failure.