13 Commits

Author SHA1 Message Date
8f47a691ba fix(abacus): close second unbound-master-key path on receipt lookup
GET /v1/receipts/:request_id (require_ingress_or_admin_key) still accepted
the bare ABACUS_API_KEY directly with zero per-agent binding, documented at
the time as an intentional exception to the 2026-11-05 per-agent-key fix
(f4fb4fb3/7119565f) that scoped /v1/proxy and /v1/budget. Two real problems:
anyone holding the master secret (meant only for deriving per-agent keys)
got full cross-agent receipt visibility, widening that secret's blast
radius beyond ABACUS_ADMIN_API_KEY's intended scope; and a properly
provisioned agent -- which per the per-agent model only ever holds its OWN
derived key, never the master secret -- could not use the endpoint its own
doc comment says exists for "an agent reading its own spend."

require_ingress_or_admin_key now accepts the same per-agent derived key
require_api_key does (bound to X-Abacus-Agent) or the admin key; the bare
master secret no longer authenticates any route directly. get_receipt adds
an ownership check (receipt.agent_id must match the authenticated agent,
unless admin), with a mismatch reporting the same 404 as "never existed" --
no cross-agent request-id enumeration.

cargo build --workspace clean; full workspace test suite green including 3
new regression tests (cross-agent denial, admin cross-agent read, bare
master key rejected); cargo clippy -p abacus-proxy --all-targets -D warnings
confirmed pre-existing-only (git stash/clippy/pop) on hold_reaper.rs, untouched
by this diff.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-06 22:24:38 +03:00
7119565f89 docs(abacus): document per-agent key contract, fix dead apps-vision link
README still described X-API-Key as the single ABACUS_API_KEY secret clients
present directly — now explains the per-agent derived-key contract added by
the require_api_key fix (formula, an openssl one-liner against the example
agent, and which routes still take the bare master key).

Also fixes the "Full plan" link to docs/apps-vision/abacus.md: that file does
not exist and has no history anywhere in this repo (git log --all turns up
nothing), so the link was dead. Replaced with an honest pointer to this
README plus the owner's cross-portfolio plans/railyard.md instead of
fabricating a vision doc that was never written.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-05 00:20:04 +03:00
f4fb4fb318 fix(abacus): cryptographically bind X-Abacus-Agent to a per-agent ingress key
ABACUS_API_KEY was ONE shared ingress secret for the whole deployment: any
caller holding it could set X-Abacus-Agent to a DIFFERENT configured agent's
id and spend from that agent's treasury/allowance under that agent's own
per_request_max_micros (handler.rs run_flow, admin.rs::own_budget), or read
its budget policy/live allowance headroom via GET /v1/budget — isolation only
existed between the deployment and the outside world, never between agents.

require_api_key now recomputes hex(HMAC-SHA256(ABACUS_API_KEY, agent_id)) for
the X-Abacus-Agent the caller claims and compares it, constant-time, to the
presented X-API-Key. The operator keeps ABACUS_API_KEY to itself and issues
each agent only its own derived key, so an agent that knows only its key
cannot derive (or forge) another agent's — HMAC preimage resistance — closing
the cross-agent impersonation hole at the auth layer, before LocalStore's or
PostgresProductStore's resolve() ever runs its bare agent_id lookup.

Verified against the real build_router (not a stub): a throwaway example
wired FakeBudgetRepo with two agents and proved agent A's derived key is
rejected (401) when claiming to be agent B, the raw master key alone is
rejected (401) on agent-scoped routes, and A's own key + own id still works
(200) — then the example was deleted before this commit per no-test-files.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-05 00:19:49 +03:00
3f05180387 docs: Turnstile + Abacus deployed live on railyard-box (2026-10-28)
Both already had compose profiles, Caddy site files and a reserved Postgres
role/db from an earlier next-wave prep -- just never filled in, built or
started. Wired real Mint accounts (payee address for Turnstile; agent,
treasury and provider payee for Abacus), real admin/API tokens, and real
relay-priced config, then built and started both containers for the first
time. Added public DNS A records via the real write-scoped
CLOUDFLARE_DNS_API_TOKEN and enabled both Caddy sites.

Verified live end-to-end against the real deployed containers, on loopback
and over the real public hostname: Turnstile's unpaid POST /v1/echo and MCP
tools/call both return a real 402/-32402 AITP challenge with the real payee;
Abacus's real agent correctly 402s insufficient_funds against the real
zero-balance Mint treasury (cross-checked directly against Mint's own
balance endpoint) and the kill switch rejects an over-cap request with zero
Mint calls (confirmed via /v1/admin/overview before/after).

No application code changed -- the deploy itself is ops on railyard-box
(/etc/products/{turnstile,abacus}.env, /srv/railyard/{turnstile,abacus}/*.json),
not tracked in this git repo. Docs-only commit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-28 20:50:59 +03:00
c69b2305dc fix(deploy): trimmed build contexts, vend mint deps, shared-plane doc matches the stack
- apps/{vend,turnstile,abacus}/Dockerfile.dockerignore: per-Dockerfile ignore
  files so repo-root builds upload only the workspaces they compile
- apps/relay/ui/Dockerfile.dockerignore: the gateway .dockerignore excludes ui/
  and pnpm-lock.yaml, which the Relay UI image needs
- apps/vend/Dockerfile: copy apps/mint (vend-mint-client path-depends on
  mint-core/mint-protocol); the builder stage failed without it
- apps/DEPLOY-SHARED-PLANE.md: rewritten to match infra-box
  stacks/railyard/docker-compose.yml (docker compose profiles, host ports
  3100-4000, one Postgres with Relay observability in Postgres, no ClickHouse,
  abacus + relay-ui, env matrix, basic_auth/SSH access for the console)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 04:14:56 +03:00
0e8c4474aa feat(mint): payout preflight and durable payouts, reconciliation, KYC, statements, operator console
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 00:05:57 +03:00
33ee4bd8df feat: operator /admin consoles for vend, abacus, turnstile (reuse each service's real auth)
- vend-server GET /admin: tenants/apps/keys/usage/users via existing /v1/control (Bearer admin token)
- abacus-proxy GET /admin: receipt lookup by request_id (X-API-Key; only authed read endpoint — labeled)
- turnstile-demo GET /admin: tool catalog + settlement lookup (open endpoints; no challenge-list — labeled)
- same include_str! vanilla-JS pattern as rago /admin; HTML-escaped; noindex; no new auth path
- honest: surfaced only real endpoints, no fabricated views; cargo check 0 all three

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-09-23 10:47:35 +03:00
caelum0x
886d26e9d2 feat(railyard): deployable shared plane — Dockerfiles (relay/mint/abacus) + rago seeds + deploy doc
relay/mint/abacus production Dockerfiles + .dockerignore; relay catalog.json
(fail-closed startup pricing); abacus pricing extended (Anthropic/OpenRouter/Relay);
mint docker-compose + rebuilt SDK dist; rago seed fixtures (autogtm/menivor/
opentypesafe) + import.sh; apps/DEPLOY-SHARED-PLANE.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-09-23 00:21:04 +03:00
45ae36c004 feat(menivor): franchise service wiring for Menivor (P2)
- abacus: config-driven multi-provider pricing (ABACUS_PRICING_CONFIG) +
  structured-content token estimate for vision/tool-call payloads (T23)
- mint: real KycGate interface (Persona/Stripe Identity, config-gated) +
  ERC-20 USDC transfer with 6-decimal scaling replacing native-ETH payout (T20)
- rago: reel billable metrics + emit helpers + server-side credit/cap check;
  fix stale GoCardless/Adyen NotImplemented docstring (T22)
- relay: operator catalog in tensorzero.toml + /v1/passport/generate route (T21)

Owner-gated: KYC provider keys, relay model credentials.
2026-09-21 17:11:41 +03:00
894359e5ff feat(railyard): per-app completion pass — money-correct settlement + crate cores
- rago: exactly-once prepaid settlement (deterministic idempotency, unique partial index + in-tx ON CONFLICT guard) — closes the double-charge risk
- mint: double-entry + reserve conservation verified (14 tests)
- ledgerline: atomic settlement outbox + partial recovery index (37 tests)
- abacus: hard per-agent budget enforcement + kill-switch (54 tests)
- vend: crash reaper / in-flight session reconciliation
- turnstile/agent-runtime/ranguard/rit/game-economy/context-passport/rithub: core advanced + tests
2026-09-07 17:17:54 +03:00
aad9583fce fix(abacus): clamp hold capture to the reserved ceiling
When an enforced request succeeds but its actual cost exceeds the priced
est_max reserve, settle() passed the over-estimate straight to
capture_hold, which Mint rejects with CaptureExceedsHold. That error
escaped before the HoldGuard was disarmed, aborting settlement: the hold
was stranded armed, no receipt was written, and the agent was billed
nothing for a successful call (the reaper later released the hold for
free) — a metering/revenue-leak bug. Actual can legitimately exceed the
reserve because the prompt-token estimate is a chars/4 heuristic and the
default completion ceiling can under-count real usage.

Clamp the capture to guard.reserved_micros: bill up to the reserved
ceiling (never more — it is physically held, never zero), warn on the
under-reservation so pricing can be revisited, and let the successful
response settle normally. Adds regression tests for the over-reserve and
under-reserve capture paths against the invariant-enforcing fake Mint.
2026-08-26 19:42:51 +03:00
a3951146e1 feat(railyard): Hold-reaper + pluggable HoldStore seam (orphaned-hold cleanup) 2026-08-25 19:55:08 +03:00
a853ab7edf Railyard: extract AI settlement+model rail from videogen (mint/relay/agent-runtime/vend/abacus/turnstile/ledgerline/prism) 2026-08-24 20:10:29 +03:00