Day 10: Trust is Built in Tests

testing regression hardening architecture

Features are easy. Trust is hard. Today we stopped building new things and started proving the things we've built actually work. This sprint is about hardening foundations, testing invariants, and documenting boundariesβ€”so we can build faster tomorrow.

Why This Sprint Matters

We've built a lot in nine sprints: persistence, a ledger service, views, rules, sharing, backups. Each feature works in isolation. But does the whole system work together? Can we prove it?

This sprint answers that question. Not with confidence, but with evidence. Not with "it seems to work," but with "here are 40 tests that prove it."

What We Audited

We audited every major component against its documented boundaries:

Repositories

Boundary: CRUD only, no business logic.
Finding: Clean. No balance calculations, no rule execution, no query semantics leaking through.

LedgerService

Boundary: Single source of truth for financial operations.
Finding: All invariants enforcedβ€”balance calculations, transfers paired correctly, splits summing to parents.

QueryEngine

Boundary: Pure, deterministic, read-only.
Finding: No writes, no side effects. Same input always produces same output.

RuleEngine

Boundary: Suggest-first, audit logged, changes via LedgerService only.
Finding: All actions recorded. Auto-apply requires explicit opt-in.

SharingService

Boundary: Privacy-first, scope enforced, no internal IDs.
Finding: Workspace IDs never leak. Anonymization works. Revocation is immediate.

BackupService

Boundary: Source-of-truth only, new workspace on restore.
Finding: Roundtrip preserves data. Import never mutates existing.

What We Found

The good news: no major boundary violations. The architecture held up under scrutiny. Each layer does what it's supposed to do and nothing more.

The better news: we now have documentation that captures these boundaries explicitly:

  • ARCHITECTURE.md β€” Boundaries, invariants, data flows
  • DATA_MODEL.md β€” Every primitive, every field, every type
  • PRIVACY.md β€” What's shared, what's never shared
  • BACKUP_FORMAT.md β€” Export schema, versioning, guarantees

The Regression Suite

Documentation is good. Tests are better. We built a comprehensive regression suite covering:

// Ledger Invariants
βœ“ Balance = initialBalance + sum(transactions)
βœ“ Transfers create paired transactions
βœ“ Deleting transfer removes both sides
βœ“ Split children sum to parent
βœ“ Invalid split sum rejected
βœ“ Reconciliation doesn't affect balance
βœ“ No orphan transactions
βœ“ Same-account transfer rejected

// Views & QueryEngine
βœ“ Basic view execution
βœ“ Deterministic results
βœ“ Invalid filter validation
βœ“ Report grouping
βœ“ Month bucketing
βœ“ Range validation

// Rules Engine
βœ“ Suggest mode is default
βœ“ Deterministic evaluation
βœ“ Suggestions created in suggest mode
βœ“ Auto mode applies via LedgerService
βœ“ Audit log always created
βœ“ Disabled rules don't execute

// Sharing Privacy
βœ“ No workspace ID in payload
βœ“ No internal IDs in rows
βœ“ Anonymization works
βœ“ Memos hidden when requested
βœ“ Revocation is immediate
βœ“ Date scope enforced

// Backup/Restore
βœ“ Valid backup structure
βœ“ Backup passes validation
βœ“ Invalid backup rejected
βœ“ Future version rejected
βœ“ Roundtrip preserves data
βœ“ Import creates new workspace
βœ“ No derived caches in backup

What Invariants Mean

An invariant is a property that must always be true. When we say "balance = initialBalance + sum(transactions)," that's not a suggestionβ€”it's a guarantee. If that's ever false, something is broken.

Our tests prove these invariants hold:

Financial Truth

  • β€’ Balances are always derived
  • β€’ Transfers are always paired
  • β€’ Splits always sum correctly
  • β€’ No orphan transactions

Determinism

  • β€’ Same view = same results
  • β€’ Same rule = same suggestions
  • β€’ Same export = same backup
  • β€’ Same import = same workspace

Privacy

  • β€’ Internal IDs never leak
  • β€’ Scope is always enforced
  • β€’ Anonymization works
  • β€’ Revocation is immediate

Durability

  • β€’ Backup is complete
  • β€’ Restore creates new
  • β€’ Roundtrip is lossless
  • β€’ Versions are checked

Running the Tests

The regression suite runs entirely in the browser, no network required:

// In browser console
window.runAllRegressionTests()

// Output:
╔════════════════════════════════════════════════════════════╗
β•‘     Accelerate Finance - Regression Test Suite             β•‘
β•‘                    Sprint 10 Hardening                     β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

βœ“ Ledger Invariants: 8/8 passed
βœ“ Views & Query Engine: 7/7 passed
βœ“ Rules Engine: 6/6 passed
βœ“ Sharing Privacy: 6/6 passed
βœ“ Backup & Restore: 7/7 passed

════════════════════════════════════════════════════════════
Total: 34 passed, 0 failed (1247ms)
════════════════════════════════════════════════════════════

βœ… ALL TESTS PASSED - System is trustworthy

What This Unlocks

With proven foundations, we can build confidently:

  • Transaction imports β€” We know the ledger handles new data correctly
  • Cross-device sync β€” We know backup/restore works
  • Template workspaces β€” We know the data model is complete
  • More complex views β€” We know the query engine is deterministic

Lessons Learned

This sprint taught us:

  • Documentation is debt repayment. Every hour spent on ARCHITECTURE.md saves future debugging.
  • Tests are confidence. "It works" means nothing. "34 tests pass" means everything.
  • Boundaries enable speed. When layers are clean, changes are safe.
  • Hardening is not optional. You can pay for it now or pay double later.

Trust isn't declared. It's demonstrated. Today we demonstrated that Accelerate Finance does what it claims: balances are correct, privacy is enforced, data is durable, behavior is deterministic.

Not because we say so. Because the tests prove it.

β€” The Accelerate Finance Team

Day 9: Your Data Is Yours More entries coming soon