The engine trusts Decimal for every money path, and docs/verification.md said so without checking it: Kani cannot explore Decimal arithmetic, and the bridge tests only tie the Decimal kernel to the i64 one. This adds a property test that compares the operations the books use against num-rational/num-bigint, an independent exact reference: checked_add and checked_sub over signed line amounts (1e15 at up to ten places), 1,000-line sums, checked_mul while the true product fits 28 digits (including the top of the line range and FX-style rates), round_dp_with_strategy for every strategy the workspace uses at every scale 0..=28, rescale's half-away rounding, normalize, comparison and equality across scales (1.0 = 1.00), and from_str/to_string round trips at every scale. It also pins the one inexact edge: when a product's scale does not fit, checked_mul rounds to 28 decimal places, ties to even, rather than failing; None comes only when the integer part cannot fit. That case is reachable through Ledger::add_line_fx, whose foreign amount and rate are unbounded positive Decimals (the base amount is then rounded to the currency's minor unit). No property failed: 256 cases by default, PROPTEST_CASES=5000 passed, plus hand cases at 28-digit mantissas, scale 28 and negative ties. The two dev-dependencies are test-only and already in the lockfile (through proptest and the PDF stack); they are the exact reference the whole check rests on. Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
46 lines
1.6 KiB
TOML
46 lines
1.6 KiB
TOML
[package]
|
|
name = "ledger-core"
|
|
version = "0.1.0"
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
repository.workspace = true
|
|
description = "Canonical double-entry bookkeeping semantics: the engine everything else is built on."
|
|
|
|
[dependencies]
|
|
rust_decimal = { version = "1", features = ["serde"] }
|
|
thiserror = "2"
|
|
chrono = { version = "0.4", features = ["serde"] }
|
|
serde = { version = "1", features = ["derive"] }
|
|
serde_json = "1"
|
|
# company.timezone: IANA names, with the zone database built in so every
|
|
# computer reads a name the same way.
|
|
jiff = { version = "0.2.35", default-features = false, features = ["std", "tz-system", "tzdb-bundle-always"] }
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[dev-dependencies]
|
|
criterion = "0.8.2"
|
|
proptest = "1"
|
|
# `tests/decimal_exact.rs`: an independent exact reference (arbitrary
|
|
# precision rationals) for `Decimal`, the one numeric type the money paths
|
|
# trust. Test-only, like every dev-dependency here.
|
|
num-bigint = "0.4"
|
|
num-rational = "0.4"
|
|
# bookspec examples are TOML (tests/bookspec.rs), run on the engine's own
|
|
# store (a dev-dependency only: the store depends on this crate), each in
|
|
# a directory of its own.
|
|
toml = "1"
|
|
# The specification lives in its own repository (P13 step 6, D-34, D-65),
|
|
# pinned to a commit.
|
|
bookspec-checker = { git = "https://git.swaits.com/swaits/bookspec", rev = "74f2853d5f0db0066147c17fed8033cfe3d83a24" }
|
|
bookspec-runner = { git = "https://git.swaits.com/swaits/bookspec", rev = "74f2853d5f0db0066147c17fed8033cfe3d83a24" }
|
|
ledger-package = { path = "../ledger-package" }
|
|
ledger-import = { path = "../ledger-import" }
|
|
ledger-store = { path = "../ledger-store" }
|
|
tempfile = "3"
|
|
|
|
[[bench]]
|
|
name = "books"
|
|
harness = false
|