Skip to content

test(efficiency): make the ledger-agreement test hermetic - #40

Merged
HackPoint merged 2 commits into
mainfrom
agents/hermetic-ledger-test
Oct 11, 2026
Merged

HackPoint merged 2 commits into
mainfrom
agents/hermetic-ledger-test

Conversation

@HackPoint

Copy link
Copy Markdown
Owner

What

the_recorded_ledger_agrees_with_itself now asserts its invariants on a fixture ledger built in a temp dir with the production schema (connect_db), instead of reading the developer's own lumen.db. The body moved unchanged into assert_ledger_agrees(conn); the two swallowed-error unwrap_or queries now expect, and an empty ledger now fails rather than passing silently.

Why

On a clean main it failed on the maintainer's machine (565 of 2,547 eligible reads bypassed the optimizer, via the fail-open guards, per #30). That is a fact about one person's usage, not the code, and an always-red local test teaches people to ignore red.

Coverage

  • Healthy fixture covers: saved = full - returned in both eras, clamped and signed losses, a builtin read recorded by two hooks (so the de-dup is load-bearing), and below-threshold / unmeasurable / uncovered-kind reads.
  • One should_panic test per assertion (saving > file, clamp in signed era, negative in clamped era, losses swamping the headline, leak share, empty ledger) proves each guard can fail.
  • Auditing the real ledger is opt-in: LUMEN_TEST_REAL_LEDGER=1 (prints a skip message otherwise). With it set on the maintainer's machine it still reproduces the original failure.

Not touched: the_recorded_savings_are_priced_and_their_provenance_is_known also reads the real ledger; it passes here, left out of scope.

Local CI (all green)

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets --exclude Lumen -- -D warnings
  • cargo test -p lumen-core -p lumen-cli -p lumen-daemon -p lumen-mcp -p lumen-stats --all-targets --no-fail-fast

Closes #35

HackPoint and others added 2 commits October 11, 2026 19:16
… not the developer's own

the_recorded_ledger_agrees_with_itself read ~/Library/Application Support/io.speedata.lumen
and failed on a clean main (565 of 2,547 eligible reads bypassed the optimizer, through the
fail-open guards). Its invariants now run on a ledger built in a temp dir with the production
schema, with one test per assertion proving it can fail. Auditing the real ledger is opt-in
via LUMEN_TEST_REAL_LEDGER=1.
@HackPoint
HackPoint merged commit 0d5cf4a into main Oct 11, 2026
26 of 27 checks passed
@HackPoint
HackPoint deleted the agents/hermetic-ledger-test branch October 13, 2026 07:21
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.

the_recorded_ledger_agrees_with_itself depends on the developer's own ledger

1 participant