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>
30 lines
1.8 KiB
Plaintext
30 lines
1.8 KiB
Plaintext
-------------------------- MODULE ledger_model --------------------------
|
|
(***************************************************************************)
|
|
(* Concrete TLC model instance of `ledger.tla`. This module exists only *)
|
|
(* because TLC's .cfg grammar can't assign a function-valued CONSTANT *)
|
|
(* (`ReserveFloor`) as a literal directly -- the standard TLA+/TLC idiom *)
|
|
(* for that is a small "MC" module like this one that EXTENDS the real *)
|
|
(* spec, declares the model-value constants, and defines the function *)
|
|
(* literal as an ordinary operator that the .cfg file then points *)
|
|
(* `ReserveFloor` at via `<-`. Everything that is actually checked lives *)
|
|
(* in ledger.tla; this file only wires up concrete constants so TLC has a *)
|
|
(* finite model to run. *)
|
|
(***************************************************************************)
|
|
EXTENDS ledger
|
|
|
|
CONSTANTS t1, t2, h1, h2
|
|
|
|
(* Two tenants with DIFFERENT reserve floors -- t1 has a positive floor *)
|
|
(* (so the headroom-gated DEBIT/HOLD branch is actually exercised and can *)
|
|
(* actually reject something), t2's floor is zero (the "no protected *)
|
|
(* capital" case `create_tenant` explicitly allows). *)
|
|
(* *)
|
|
(* NOTE: deliberately NOT written as the record literal *)
|
|
(* `[t1 |-> 2, t2 |-> 0]` -- that syntax's domain is the STRING set *)
|
|
(* {"t1", "t2"}, not the model-value set {t1, t2}, which would make *)
|
|
(* `ReserveFloor \in [Tenants -> Nat]` false. This is an explicit function *)
|
|
(* over the model values themselves. *)
|
|
ReserveFloorDef == [t \in {t1, t2} |-> IF t = t1 THEN 2 ELSE 0]
|
|
|
|
===========================================================================
|