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>
71 lines
2.4 KiB
TOML
71 lines
2.4 KiB
TOML
# apps/abacus — inline reverse-proxy that enforces a hard, receipted per-agent
|
|
# spend budget by calling the LIVE mint-server over HTTP.
|
|
#
|
|
# This is its OWN standalone cargo workspace, mirroring `apps/mint`, `apps/relay`
|
|
# and `apps/vend`, so that `cargo build --workspace` from the repo root never
|
|
# pulls Abacus into the `apps/desktop` GPUI/Metal build graph. The root
|
|
# `Cargo.toml` excludes this directory defensively; `apps/abacus` is NOT a root
|
|
# member.
|
|
#
|
|
# Build/test from here ONLY: cd apps/abacus && cargo check (never the repo root)
|
|
#
|
|
# HARD RULE: Abacus is a REAL service. It enforces a per-agent budget via Mint
|
|
# allowances/holds by calling the live mint-server through injectable transport
|
|
# TRAITS (fake mint-server only in tests, real reqwest client in prod). Every
|
|
# enforced request produces a hold->capture with a Mint receipt — the
|
|
# system-of-record for agent spend.
|
|
[workspace]
|
|
resolver = "2"
|
|
members = ["crates/*"]
|
|
|
|
[workspace.package]
|
|
version = "0.1.0"
|
|
edition = "2021"
|
|
license = "MIT"
|
|
|
|
[workspace.dependencies]
|
|
# --- shared serde / domain deps ---
|
|
serde = { version = "1.0.228", features = ["derive"] }
|
|
serde_json = "1.0.149"
|
|
thiserror = "2.0.18"
|
|
ulid = "1.2.1"
|
|
async-trait = "0.1.89"
|
|
|
|
# --- async runtime ---
|
|
tokio = { version = "1.52.3", features = ["full"] }
|
|
|
|
# --- HTTP server stack (abacus-proxy) ---
|
|
axum = "0.7"
|
|
tower = { version = "0.5", features = ["util"] }
|
|
tower-http = { version = "0.6", features = ["trace", "cors"] }
|
|
tracing = "0.1"
|
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
|
anyhow = "1"
|
|
subtle = "2"
|
|
hmac = "0.12"
|
|
sha2 = "0.10"
|
|
hex = "0.4"
|
|
sqlx = { version = "0.8", default-features = false, features = [
|
|
"runtime-tokio",
|
|
"tls-rustls",
|
|
"postgres",
|
|
"macros",
|
|
"migrate",
|
|
] }
|
|
|
|
# --- HTTP clients (abacus-mint-client / abacus-upstream) ---
|
|
reqwest = { version = "0.12", default-features = false, features = [
|
|
"json",
|
|
"rustls-tls",
|
|
] }
|
|
|
|
# --- AITP-402 payment seam (address resolution + hold-backed spend bridge) ---
|
|
# The proxy reuses this / a Mint HTTP client to talk to the live mint-server.
|
|
aitp-client = { path = "../agent-runtime/crates/aitp-client" }
|
|
|
|
# --- internal path deps (the Abacus crate graph) ---
|
|
abacus-core = { path = "crates/abacus-core" }
|
|
abacus-mint-client = { path = "crates/abacus-mint-client" }
|
|
abacus-upstream = { path = "crates/abacus-upstream" }
|
|
abacus-testkit = { path = "crates/abacus-testkit" }
|