Re-rendered docs/near-hackathon/media/ration-near-demo-2026-11-11.mp4 with
two surgical caption patches, audio/duration/resolution untouched
(-c:a copy, same 69.84s/1920x1080/-14.6 LUFS):
- t=28.05-28.88: caption read "near Tesnack." (STT mis-transcription of
"near Testnet" that survived the builder's own QC pass) -> "near Testnet."
Confirmed via Deepgram re-transcription of the real narration audio that
the spoken word is "testnet", not the on-screen caption text.
- t=61.38-62.52: caption read "Rations own database." (missing possessive
apostrophe, inconsistent with the matching on-screen slide text
"Ration's own database.") -> "Ration's own database."
Found during an adversarial judge/release-check pass (ffprobe + ebur128 +
frame-by-frame caption review + live NEAR RPC re-verification of every
on-chain claim in the deck/video/docs — all of which checked out as real).
NEAR Hackathon: replace the 4.6s demo video with a 69.8s narrated
version (Deepgram Aura-2 + burned-in captions, -14.5 LUFS / -1.9 dBTP)
covering append -> anchor -> independent raw-RPC re-read -> a real
replay attempt rejected live on-chain, recorded against a freshly
deployed NEAR Testnet account (tx 5YebAM2...ome1t, replay-rejection tx
7v6m81j...469o). Old video kept, not deleted. Adds an 11-slide pitch
deck (PITCH-DECK.md/.pdf/.pptx) mapping the submission to NEAR's own
judging criteria (technical implementation, design, impact,
originality, sustainability, confirmed live from the hackathon FAQ).
soonami Venturethon 11: adds a venture-framed pitch deck
(docs/soonami/PITCH-DECK.md/.pdf/.pptx) covering market, business
model (flagged as an unpriced hypothesis), go-to-market, honest
traction, the 10-day sprint ask, and an explicitly flagged co-founder
placeholder (soonami requires >=2 co-founders; none invented). Reuses
the NEAR demo video per plan.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Judge audit found two real doc issues: (1) the hackathon's literal
eligibility rule ("each README names the other") was only satisfied
via HACKATHON.md, not README.md itself — add an explicit Cred402
cross-reference to a new NEAR Hackathon section in README.md.
(2) X-POST-DRAFT-2026-11-10.md's caption claimed the replay attempt
was tried "on a sibling contract" — per HACKATHON.md's own evidence
(tx 3sWNYB5ddbqT5BaUqQfRJXJi8EfHUSJA7k8vgwDvAzPr) the replay was
resubmitted on the same primary contract/account, not a sibling one.
Also fixed a minor internal-doc date-wording drift in
SUBMISSION-CHECKLIST.md's header.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
SUBMISSION-CHECKLIST.md still said the demo video wasn't recorded, but
commit da8f906 already recorded and committed it. Mark it done and point
at the real artifact. Also add a ready-to-post X caption
(X-POST-DRAFT-2026-11-10.md, mirroring cred402's own draft for the same
hackathon) since none existed yet for this entry.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Records a real, unedited run against a freshly
deployed NEAR Testnet account (ration-demo-23bd92e5.testnet) —
real audit-log append, real on-chain anchor tx
(z8GWsRVxDykJ55rTKgb4dbN9WTH1UGMzk4NhQfogFrt), independently
re-confirmed on-chain. The primary submission account/contract
referenced elsewhere in HACKATHON.md is untouched.
Adds a focused NEAR Hackathon 2026 entry built on Ration's existing,
real audit-log service rather than a Ration-on-NEAR rewrite: a minimal
NEAR smart contract (contracts-near/audit_anchor) storing/verifying
{tenant_id, chain_tip_hash, sequence, occurred_at_unix}, plus a
from-scratch Go NEAR transaction signer and CLI
(services/audit-log/internal/nearanchor, cmd/near-anchor) that reads
audit-log's real local chain tip and anchors it on-chain.
Verified live on NEAR Testnet (account ration-anchor-286ca315f1.testnet):
contract deployed and code_hash-matched, two successful on-chain
anchors, one deliberate replay correctly rejected by nearcore's own
sequence guard, and a real (non-mocked) Go integration test passing
against the live contract. Transaction encoding cross-checked
byte-for-byte against near-api-js. Zero regressions in existing Go/Rust
suites. Full detail and every tx hash in docs/near-hackathon/.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The "Updates since initial submission" section stopped at round 5
(2026-10-29) while the codebase is 32 rounds past that — agent tool
tenant-pinning, mTLS actually enforced, concurrency correctness on every
money-moving path, WAL/FFI crash-safety hardening, and a cross-tenant
ledger idempotency fix all landed since, with zero mention in the one
doc judges are most likely to read end to end.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
docs/DEMO-SCRIPT.md (the one doc a judge actually runs commands from) still
said `make build` produces 4 Go binaries and `scripts/run-demo.sh` starts
audit-log/ledger-core/gateway/agent only — stale since the section-1 split
added auth/tenant-registry/card-issuance/webhook-ingestion, same staleness
class README.md had before today's earlier pass fixed it there. Verified
live: `make build` produces 10 Go binaries, `scripts/run-demo.sh` starts 8
services. Also added a step showing `ration tenant`/`card`/`apikey` — 3
operator command groups built across many rounds today that this doc never
mentioned at all, verified live against the real running stack.
tenant-registry's own gRPC server (CreateTenant/GetTenant/ListTenants)
had no inbound auth check at all, unlike gateway's internal/tenantauth
and ledger-core's src/tenantauth.rs. Since it mints and attaches its
own pre-provisioned operator JWT to every ledger-core call it forwards
regardless of caller identity, ANY network caller to its gRPC port
(published 0.0.0.0:7011 in docker-compose.yml) could onboard unlimited
platform tenants or list every tenant's name/currency/reserve-floor
with no credential whatsoever — a real, newly-live gap since round 9
wired `ration tenant create/list` to this exact RPC surface.
Adds services/tenant-registry/internal/operatorauth (mirrors gateway's
tenantauth credential handling, simplified for the operator-only case),
gated by RATION_TENANT_REGISTRY_REQUIRE_OPERATOR_AUTH (true by
default). `ration tenant create`/`list` now mint and attach their own
operator credential, same pattern the CLI's other commands already use
for gateway/ledger-core.
Verified live against the real bare-metal stack: a throwaway gRPC
client with no credential gets Unauthenticated, a garbage bearer token
gets Unauthenticated, a valid but non-operator (tenant-scoped) API key
gets PermissionDenied, and the real `ration tenant create`/`list`
commands succeed end-to-end with their own minted operator credential.
go build/vet/test clean across tenant-registry and cli, 0 regressions.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
`apikey issue`/`revoke` had no read side: an operator could mint or
revoke a key by key_id, but had no way to discover what key_ids exist
in the first place — only a key_id personally kept from its own
one-time `issue` output could ever be acted on. Adds auth.proto's
ListAPIKeys RPC, apikey.Store.List (sorted, tenant-filterable), the
server implementation, a CLI authclient wrapper, and `ration apikey
list [--tenant <id>]` — never returning the plaintext secret, which is
never stored anywhere after issuance.
Verified live against the real bare-metal 8-service stack
(scripts/run-demo.sh): issue -> list -> simulate-deposit --late ->
agent poll -> status (real recorded bridge-funding decision) ->
revoke -> list again (revoked: true) -> verify-chain (intact).
docker-compose rebuild was blocked by genuine host-disk exhaustion
from concurrent sibling workflows on this shared machine, not by
anything in this diff (pure proto/Go, zero compose/env changes).
Also corrects docs/THREAT-MODEL.md's "Known gaps" items 1, 6, and 7,
which still described tenant-auth, encryption-at-rest, and terminal-
injection as open/off-by-default despite rounds 2-4 actually closing
all three (RATION_GATEWAY_REQUIRE_TENANT_AUTH and
RATION_LEDGER_REQUIRE_TENANT_AUTH both default true, AES-256-GCM is
live on ledger-core's WAL/SQLite, pkg/textsanitize is wired into
cli/tui) — a judge reading the old text would see a security posture
strictly worse than what the code ships. Appends a short, honest
"Updates since initial submission" section to docs/SUBMISSION.md for
the same reason, without touching its original round-1 content.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Closes docs/THREAT-MODEL.md Known-gaps #3's named TODO: ledger-core had
no Prometheus endpoint at all, so a sustained audit-log outage was
only a tracing::warn! log line, nothing alertable. Adds
ledger_core_audit_mirror_spawn_append_failures_total{kind}, served on
GET /metrics at LEDGER_CORE_METRICS_ADDR (default localhost:9099),
pre-registered at zero per kind so absence vs zero is distinguishable.
Wires the new endpoint into docker-compose.yml and the Prometheus
scrape config, which already named this exact gap as the trigger to
add the target. Fixes a render() visibility bug and a test assumption
that unobserved CounterVec label values still emit TYPE/HELP lines,
both left broken by an earlier interrupted pass on this same change.
MarkDepositReceived's ledger credit — the only path by which a deposit's
money becomes spendable headroom — was never mirrored into audit-log,
unlike ApplyEntry's credits and RecordAgentDecision. The claim that
"every money move is mirrored" (README, docs/SUBMISSION.md) didn't
actually hold for it.
Ledger::mark_deposit_received_with_entry now returns the credit
LedgerEntryRecord it produces (mark_deposit_received keeps its original
signature, delegating to the new method and dropping the entry, so
existing callers/tests are unchanged); grpc.rs's MarkDepositReceived
handler mirrors it into audit-log exactly like ApplyEntry's handler
already does.
Also wires audit-log into scripts/run-demo.sh (the bare-metal demo path
every judge following README's Quickstart/docs/DEMO-SCRIPT.md actually
runs) — it was only ever started via docker-compose, so the headline
"audit trail is the point" claim and the standalone verify-chain tool
were never exercised end to end by the documented demo flow. Verified
live: after a seed + simulate-deposit + agent-decision run, verify-chain
now reports real records (6, matching the 6 live Append RPCs audit-log's
own metrics counted) and correctly flags a single flipped byte as a
broken chain at the right sequence.
Closes docs/THREAT-MODEL.md's "A compromised audit-log" Repudiation
gap (item 9's precise TODO): VerifyChain was only exposed as
audit-log's own RPC, so a compromised audit-log process could simply
lie about its own integrity. internal/store.VerifyFile re-derives the
hash chain directly from the on-disk audit.log file, opened strictly
read-only (O_RDONLY, never O_RDWR), with no Store/gRPC involvement —
the same per-record checks replay()/VerifyChain() already perform, but
reporting every failure (corrupt record, broken chain, non-contiguous
sequence) as a result rather than requiring a live, trusted process to
ask.
services/audit-log/cmd/verify-chain wraps it as an operator-run CLI
(`verify-chain [path]`, defaulting to
$RATION_AUDIT_LOG_DATA_DIR/audit.log) that dials nothing and exits
nonzero on any break or unreadable file — safe to wire into a health
check or an out-of-band cron, independent of whether the audit-log
binary itself would lie about VerifyChain's RPC result.
Manually verified end-to-end against a real generated audit.log:
intact chain exits 0, a payload_json edit without hash recomputation
is detected and exits 1 with the exact broken sequence. RED->GREEN
with new store/cmd test suites; added to `make build-go`.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Closes the gateway-facing half of docs/THREAT-MODEL.md's "Known gaps"
item 1 — "no tenant-scoped authorization anywhere, still" — explicitly
named there as the single biggest residual risk in the system.
services/auth's VerifyAPIKey/VerifyJWT RPCs have existed and been
unit-tested since the section-1 split, but nothing called them.
Added internal/authclient (typed gRPC client to auth, mirrors the
existing cardissuanceclient/ledgerclient pattern) and
internal/tenantauth (a grpc.UnaryServerInterceptor that extracts a
request's tenant_id via proto reflection — the same technique
internal/ratelimit already uses — and rejects a mismatch between an
x-api-key/Bearer-JWT credential's verified tenant_id and the request's
own with PermissionDenied, or a missing/invalid credential with
Unauthenticated). Wired into cmd/gateway/main.go's interceptor chain,
gated by RATION_GATEWAY_REQUIRE_TENANT_AUTH (default false, same
opt-in pattern as GATEWAY_MTLS_ENABLED, since the demo/CLI/TUI flows
don't present a credential on every call yet).
Named, not glossed over: GetCard/AdjustCardLimit key off card_id (same
documented gap ratelimit's keyFor already has), StreamActivity is a
streaming RPC outside this interceptor's scope, and cli/tui/agent can
still dial ledger-core directly, bypassing gateway and this check
entirely. docs/THREAT-MODEL.md's gap 1 and every auth-related row it
touches updated to describe exactly this, including the residual TODO.
RED->GREEN with new authclient/tenantauth test suites; full go/rust
suite green.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Closes the mTLS-enabled half of docs/THREAT-MODEL.md's "Known gaps" item 2:
with mTLS disabled (the default) nothing bound a gRPC caller's transport
identity to the source_service string its AppendRequest claimed, so a
compromised agent calling audit-log.Append directly with
source_service: "ledger-core" could forge an entry that looked
authoritative. Added pkg/mtls.PeerCommonName (extracts the verified leaf
cert's CommonName from a gRPC context, ok=false for any non-mTLS peer)
and wired it into audit-log's Append: when a verified identity is
present it overrides the claimed source_service outright, rather than
merely checking it. The mTLS-disabled case is unavoidable and stays
exactly as documented. Full go test suite green across every module;
THREAT-MODEL.md's gap #2 and the earlier-stale gap #4 entry updated to
match what the code actually does today.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
cardsvc.Service.GetCard/AdjustCardLimit wrapped a missing card as a plain
fmt.Errorf(..., airwallex.ErrNotFound), which the gRPC runtime downgrades
to codes.Unknown by default — the gateway's REST facade (services/gateway/
internal/httpapi/cards.go) documented this exact gap as its own TODO: an
unknown card_id surfaced as HTTP 500 instead of 404 for every
GatewayClient caller (TUI, CLI, both SDKs, the REST facade).
grpcserver.Server now wraps cardsvc's not-found error in
status.Error(codes.NotFound, ...) before it leaves card-issuance, so the
existing NotFound->404 mapping downstream works as originally intended.
RED->GREEN with new grpcserver tests; cleared the now-resolved TODOs in
cards.go and updated docs/THREAT-MODEL.md's "Known gaps" list, which
still read webhook rate-limiting/replay-window as open after an earlier
commit had already fixed both. Full go/rust suite green.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
status.go's truncate() only sliced Rationale/Trigger text, never stripping
control characters, before a plain tabwriter write — an adversarial
trigger->prompt->rationale chain could inject ANSI escapes (cursor
manipulation, hidden text) into an operator's terminal, a gap already
precisely documented in docs/THREAT-MODEL.md. Added sanitizeControlChars
(strips C0/C1 incl. ESC, keeps tab/newline/CR for tabwriter layout) and
wired it into printDecisions ahead of truncate. RED->GREEN with new tests;
full go/rust/C suite plus lint baseline otherwise unchanged.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Both were precise TODOs in docs/THREAT-MODEL.md, not speculative hardening:
- Elevation of privilege: VerifySignature now rejects any Airwallex
webhook delivery whose x-timestamp is more than 5 minutes from the
verifier's clock (ErrStaleTimestamp), closing an unbounded replay
window down to Airwallex's own documented delivery tolerance.
- Denial of service: webhook-ingestion gets its own internal/ratelimit
(token-bucket HTTP middleware, source-IP keyed, mirroring gateway's
gRPC-side design per docs/adr/0004) in front of the plain HTTP
webhook listener, tunable via WEBHOOK_INGESTION_RATELIMIT_* env vars.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- 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.
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>
Six services, independently built then integrated:
- services/wal (C): crash-safe write-ahead log, CRC32-checksummed
frames, torn-write recovery via truncate-to-last-valid-frame.
- services/ledger-core (Rust): double-entry ledger over the C WAL via
FFI, reserve-floor enforcement BEFORE any WAL write, idempotent
ApplyEntry, full LedgerCore gRPC service.
- services/gateway (Go): Airwallex Issuing/Global-Accounts client
(mock mode default, live mode ready), the actual rationing math
(reserve floor, 60% bridge cap, 24h velocity cap, partial-over-decline).
- services/agent (Go): deterministic hard-rule policy envelope computed
BEFORE any LLM call; Claude only decides within that pre-approved
envelope; every decision audit-logged even when the LLM call fails.
- services/tui (Go, Bubble Tea) + services/cli (Go, cobra): the only
UI — no web frontend, per explicit direction.
Integration found and fixed three real bugs, not just compile errors:
- proto regen collision shadowing checked-in pkg/pb packages
- ledger-core/gateway address-variable mismatch (stack would never
actually connect on default config)
- the big one: MarkDepositReceived never credited the ledger, so every
tenant's balance was permanently stuck at 0 and bridge-funding could
only ever decline — the core agentic-rationing feature could never
produce a real grant. Fixed at the ledger level with idempotent
mark-and-credit in one WAL frame, covered by 3 new tests.
End-to-end verified live, reproducibly: seed -> simulate a late deposit
-> agent grants a partial bridge with a computed rationale -> second
grant correctly declines once the 24h velocity cap engages. Verified
independently by the orchestrator too: 'make build' and 'make test'
both clean (Rust: 29 tests; Go: all packages; C: WAL test suite).
Airwallex sandbox credentials still pending organizer approval —
tracked as an owner blocker in docs/AIRWALLEX-SETUP.md, not a code gap.