Pramanagentic commerce control plane
27 August to 5 September 2026. Repository.
What I ownedEverything. Solo build: architecture, mandate format, policy engine, ledger, two-phase executor, evaluation harness, tests and the decision log.
Architecture, drawn
Problem
An AI agent that can spend money is an agent that can be talked into spending it wrongly. Praman sits between the agent and the payment rail and decides, without asking any model, whether a purchase is allowed. The purchase intent carries only a SKU and a quantity. It has no price field, so a compromised merchant page has nothing to inject into the amount. Price resolves server-side from a trusted catalog after the intent is validated against a mandate the human signed.
Architecture
Three primitives do the work. An Ed25519 human-signed mandate carries merchant and category allowlists, per-transaction and cumulative caps, and velocity and denial-rate limits. A pure, deterministic policy engine evaluates each intent against the mandate and returns one of 19 closed reason codes. There is no LLM anywhere in the authorization path.
An append-only, hash-chained, Merkle-checkpointed ledger records every outcome. Immutability is enforced by a Postgres trigger, and spend is derived by replaying the ledger rather than read from a mutable balance.
Execution is two-phase under a per-mandate advisory lock, because a database transaction and an external payment call cannot be made atomic. The reservation is recorded before the call and the settlement after it, so a crash in between leaves a recoverable state, not a lost or doubled charge.
Decisions
- No price in the intent
- If the agent cannot state a price, nothing the agent reads can change the price. The amount comes from the catalog, never from the conversation.
- No model in the authorization path
- The model proposes, the policy engine decides. Authorization is a pure function of intent, catalog and mandate, so it is testable, replayable and immune to prompt injection by construction.
- Spend is replayed, not stored
- A mutable balance is a second source of truth that can drift from the ledger. Replaying costs one query and removes the whole class of bugs.
Measured, not asserted
- Policy containment, dev and held-out splits
- 100%
- False refusals on 12 benign cases
- 0
- Injection ablation, 21 runs per arm, proposals influenced
- 0 defended, 2 undefended
- Money moved, either arm
- 0 of 21
Bugs worth telling
- Razorpay does not enforce receipt uniqueness
- The documentation says receipts are unique. The API does not enforce it. Praman now enforces uniqueness on its own side before any call goes out.
- Refusals leaked the mandate
- The engine's refusal text named the limit that was hit, which told a probing agent exactly where the ceiling was. Refusals now carry a reason code only.
- NaN read as permitted
- Every comparison with NaN is false, so a malformed amount passed every cap check. Inputs are now validated as finite integers before evaluation.
Honest limits
- TRUNCATE bypasses the append-only triggers.
- Merkle checkpoints are not externally anchored.
- The denial-rate cap is per window, so slow probing remains possible.
- Test mode only. There is no HTTP API layer.
Scale
- Single-purpose commits
- 142
- Lines of TypeScript
- ~8,800
- Packages and apps
- 9 + 4
- Test files
- 20
- Decision log entries
- 24
Stack
- TypeScript
- Node.js
- PostgreSQL
- Ed25519 signatures
- Razorpay API