Documentation ยท Pythagoras ยท Audit
Stoicism Precision Audit
v0.7.11 โ Pythagoras ยท stamped against H.1.20
Every Stoicism point earned is preserved exactly. Forever.
The Ancient Holdings Hub stores, computes, and audits every Stoicism balance using arbitrary-precision decimal arithmetic. No floating-point drift. No accumulation noise. No rounding loss. Replay the events log on any other instance running the same code and migrations โ you'll arrive at byte-identical balances.
Numerical contract
| Quantity | Decimals | Notes |
|---|---|---|
| server_score | 6 | stays f64 โ input, not balance |
| tunneler_fee_promile | 1 (= 2-dec percent) | capped + enforced server + UI |
| Stoicism balances | 12 exact | decimal.js, TEXT-stored |
| BASE_POINTS_PER_SEC | exact const = 0.001 | spec-locked |
| tick duration | exact const = 60s | spec-locked |
Smallest non-zero per-tick accrual under this contract:0.001 ร 60 ร 1e-6 (server_score) ร 1e-4 (1-dec promile / 1000) = 6e-12Fits in 12 decimals exactly, by design.
Test suite โ final acceptance gate
โ 90/90 tests passing
npm test ยท 10 files ยท ~3s runtime
- 31 unit tests on the decimal core (lib/stoic-decimal.ts) โ every helper, every edge case.
- 8 property tests with fast-check, 1000 random cases each, proving 5 mathematical invariants.
- 14 integration tests on the schema migration (056).
- 6 dual-write tests verifying every accrual path produces matching decimal results.
- 5 read-path tests verifying the read swap to decimal columns.
- 5 drift tests with random scenarios (1000 random tips, mixed warmup cycles, 500 Tunneler-fee ticks, mining bonuses, daily mint).
- 1 reproducibility test โ replay 1000+ synthetic events twice on fresh DBs, asserts byte-identical state.
- 2 performance tests โ 500-node tick in ~250ms (0.4% of the 60s budget).
- 6 fee-precision tests โ validator accepts integer + 1-decimal, rejects 2- and 3-decimal.
- 3 sanity tests confirming the test harness itself works.
Five proven invariants
- Round-trip safety:
fromDb(toDb(x)).equals(x)โ any Stoicism value survives canonical 12-decimal TEXT round-trip exactly. - Conservation:
floor(x) + frac(x) === xโ exact mint math; no fractional Stoicism leaks duringfloor(). - Associativity:
(a + b) + c === a + (b + c)โ f64 fails this for tiny values; Decimal honours it. - Commutativity:
a + b === b + a. - Identities:
x + 0 === x,x ร 1 === x,x ร 0 === 0.
Lint guard
scripts/check-stoicism-precision.ts scans lib/ and worker/ for any reference to the dropped legacy REAL column names. Wired into npm run prebuild โ the build fails if anyone reintroduces them. Status: clean.
Sign-off
All gates green. Pythagoras is ready for production.
Source-controlled audit record: docs/stoicism-audit-report.md in the repo commits this audit alongside the code that produced it.
โ back to Releases ยท The Stoic System