2 Commits

Author SHA1 Message Date
7085e7af38 docs: verify TLA+ ledger spec via TLC and libFuzzer WAL harness locally
- Installed OpenJDK 27 (brew) and ran TLC (tla2tools.jar 2.19) against
  docs/formal/ledger_model.tla for real in this environment. Confirmed:
  896,001 states generated, 50,000 distinct, depth 13, no error found
  across TypeOK/SafetyReserveFloor/SafetyHeldNonNegative and the
  HoldsResolve liveness property. Matches the numbers already in
  docs/formal/README.md exactly, as expected for an exhaustive BFS over
  a deterministic finite transition system -- no modeling bugs in the
  spec or in services/ledger-core/src/ledger.rs.
- Confirmed (and then discarded) that ledger.tla cannot be run directly
  via a plain .cfg -- TLC's .cfg grammar rejects function/record literal
  syntax for CONSTANTS outright, independently verifying why
  ledger_model.tla's EXTENDS-based model-value indirection exists.
- Installed LLVM (brew) and built+ran services/wal/fuzz's libFuzzer
  harness for wal_read_next() via its documented CC auto-detect fix.
  30s smoke run: 216,303 execs (~6,977/s), 78 new corpus units, zero
  crashes/leaks/ASan/UBSan findings -- no bug in wal.c's frame parser.
- make build && make test pass clean across C/Rust/Go/SDK with no
  regressions.
2026-10-19 13:47:16 +03:00
13abc31645 feat(ration): observability, infra-as-code, security hardening, and test depth
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>
2026-10-19 12:25:58 +03:00