Documents a6aad08/83916f8 in BUILD-LOG-2026-10-23.md's "Round 2 of 3"
section (SQLite column encryption + the two live bugs found closing it
out), adds a RUNBOOK.md entry for RATION_LEDGER_ENCRYPTION_KEY now that
it covers both the WAL and SQLite columns, and adds
scripts/record-demo.sh — narrates docs/DEMO-SCRIPT.md's exact sequence
with real pacing, built to be captured with `asciinema rec demo.cast -c
scripts/record-demo.sh` for the hackathon submission's video
walkthrough. Also ignores demo-video/, the gitignored output directory
that script's rendered .mp4/.cast land in (never source, never
committed).
docs/THREAT-MODEL.md's "Known gaps" #3: no operational cross-check
existed between ledger-core's own entry/decision counts and audit-log's
best-effort mirror, even though audit_mirror.rs's mirroring can fail
silently (network blip, audit-log down) with nothing comparing the two
afterward.
`ration audit-check` dials audit-log directly (new Audit client on
clients.go) and, per tenant, fully paginates both ledger-core's
ListEntries/ListAgentDecisions and audit-log's ListRecords (filtered by
SourceKind), reporting any count divergence beyond --tolerance and
exiting nonzero. Verified live against the demo stack: 18/18 tenants
report OK with exact count matches.
Wire the diagnosis path into docs/RUNBOOK.md next to the existing
on-call-style entries.
Phase 2 section 7 (the other half, alongside sdk/go/ration and
sdk/rust/ration-client already pushed in c5297e4/8215fb8): a hand-rolled
internal/httpapi on services/gateway translating JSON <-> the gRPC source
of truth (cards, deposits, bridge funding, activity), documented as a
convenience facade over gRPC, not a parallel implementation. Also folds in
the remaining phase-2 doc updates (ARCHITECTURE/RUNBOOK/THREAT-MODEL/
AIRWALLEX-SETUP/SUBMISSION, ADR 0003/0004) and docker-compose/Makefile/
.env.example wiring from the resumed phase-2 workflow's final agents.
Verified: go build/vet/test clean across all 10 services + both new SDKs,
`make build && make test` clean end to end (C WAL, Rust ledger-core + the
new Rust SDK, every Go module including sdk/go/ration).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Phase 2 sections 2-6 and 8 of docs/SCALE-EXPANSION.md:
- pkg/telemetry + pkg/metrics: OpenTelemetry trace propagation and
Prometheus metrics across every service hop (CLI -> agent -> gateway ->
card-issuance/tenant-registry/auth -> ledger-core), tracing added to
ledger-core itself via services/ledger-core/src/telemetry.rs.
- infra/: otel-collector + Prometheus + Grafana docker-compose stack, a
Terraform ECS Fargate module + dev/staging/prod envs (plan-only, no
apply — real AWS spend is an owner action), and a dev-only mTLS CA
(infra/dev-ca) wired through pkg/mtls + services/ledger-core/src/mtls.rs.
- services/audit-log (from the prior commit) gets its async mirror writer
in services/ledger-core/src/audit_mirror.rs, and services/gateway gets
a per-tenant token-bucket rate limiter (internal/ratelimit).
- Test depth: a Rust proptest suite proving concurrent ApplyEntry never
breaches the reserve floor (tests/apply_entry_proptest.rs, passing), a Go
fuzz seed corpus for the policy envelope (rules_fuzz_test.go), a libFuzzer
harness for the C WAL frame parser (services/wal/fuzz, deliberately not
wired into `make test` per its own Makefile comment - needs a
libFuzzer-bundled clang), and a real chaos test
(scripts/chaos/kill-ledger-mid-write.sh) that SIGKILLs ledger-core
mid-write under concurrent load and verifies via ListEntries that
nothing was lost or double-applied.
- docs/formal/ledger.tla: a TLA+ spec of the ledger state machine (balance
>= reserve_floor safety, HOLD-eventually-resolves liveness) plus a TLC
model config - not run through TLC in this pass, that's a precise
documented TODO, not faked.
- docs/adr/0001-0004, docs/RUNBOOK.md, docs/SLO.md, docs/THREAT-MODEL.md.
Verified: `make build && make test` clean (C WAL, Rust incl. the new
proptest suite, all 10 Go modules) from a cold target.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>