About
Give your AI agent a leash a quantum computer can't loosen. An AI agent that pays or trades holds a key, and today that key is classical; a limit means nothing if the same key can raise it. Leash splits the power across three keys. The agent's key spends and acts only inside a mandate: caps, a recipient allowlist, an expiry, and owner-signed routes with rate floors. The owner's classical key can only freeze. The owner's ML-DSA-87 key signs every mandate, and QoreChain's pqcVerify precompile checks the signature on chain, so starting or loosening anything is something a leaked or quantum-broken classical key can never do.
What it does: the agent pays, swaps, wraps and uses ERC-4626 vaults through a guard contract that measures what it actually received and enforces the owner's rate floor. The owner describes the leash in plain English and a deterministic compiler (not a model) turns it into a mandate and lists the gaps the chain does not cover. An MCP server with 15 tools and a skill let Hermes Agent, Claude Code and Cursor use it, and a monitor can freeze the guard with a stop-only key.
Proof, not promises: on qorechain-diana a real ML-DSA-87 signature was accepted by pqcVerify, five adapter actions and an MCP swap ran as real transactions, the Q-Day drill passed 15 of 15, 800 random hostile calls on the live guard produced 0 violations, and the tests caught 179 of 181 deliberate contract breaks. Verify it yourself with one read-only command (pnpm verify, 22 checks) or in your browser at leash.kierkegaard.space/try.
Honest limits: testnet only (pqcVerify is not on mainnet yet), unaudited, our own test router because QoreSwap's address is not published, no price oracle behind rate floors, and no bridging.
How it's made
Architecture (Solidity 0.8.28, Foundry). LeashGuard.sol (v1) handles payments: spend() is agent-only and enforces the recipient allowlist, per-payment cap, a fixed 24-hour daily bucket and the expiry; freeze() is callable by the owner's secp256k1 key or the agent and can only reduce power; applyMandate(mandate, signature) is the only way to start or loosen anything: it reads the owner's registered key with pqcKeyStatus (0x0a02), verifies the ML-DSA-87 signature with pqcVerify (0x0a01) over abi.encodePacked(domain, chainid, guard, nonce, keccak256(mandate)), then increments the nonce, so a signature cannot be replayed on another chain or guard, reused or altered. LeashGuardV2.sol adds execute(adapter, target, data, value) for swaps, wraps and ERC-4626 vaults along owner-signed routes (adapter, target, tokenIn, tokenOut, minimum output per input). The guard does not trust call data; it measures: the input is charged to the same caps as payments, the output must return to the guard, the guard's balance of the output token must rise by at least amountIn times the rate floor, no other listed token may fall, and approvals are exact and reset to zero. Three stateless adapters decode calls: V2-style routers, WETH-style wrapped native tokens, ERC-4626 vaults. Tooling (TypeScript, viem, @qorechain/sdk, @qorechain/evm): policy.ts is a deterministic plain-English grammar that reads caps and value flows ('swap A for B on 0x.. at no worse than R B per A'), refuses anything it cannot parse exactly and lists gaps; attack.ts and attack-v2.ts are the Q-Day drills; monitor.ts applies rules (unexplained outflow, bursts, expiry, cap burn) and can auto-freeze with a stop-only classical key; the MCP server (15 tools) and a skill let agent harnesses use all of it; testnet.ts registers the ML-DSA-87 keys, opens hybrid-signed scoped EVM windows, deploys, signs and applies mandates and runs the drills. Verification, eight layers (docs/VERIFICATION.md): 79 Foundry tests including fuzz tests and 8 stateful invariants (15,360 random calls each); automated mutation testing of all five contracts (tools/mutate.py): 179 of 181 mutants killed, the two survivors are equivalent changes, and the first round killed only 64.6%, which exposed real gaps we then closed; Slither static analysis with no high-severity findings; an 800-call randomized attack campaign against the live guard with an independent oracle, 0 violations; 30 TypeScript tests; the Q-Day drill (15 of 15 on the real testnet, 16 of 16 locally); pnpm verify, 22 read-only checks including that the deployed bytecode equals the source; and real transactions: a real ML-DSA-87 mandate with routes accepted by pqcVerify, five adapter actions, and an MCP client making a real swap through the guard. What was hard: the EVM lane only admits a registered account with an open window, opening a window advances the nonce, and a scoped window refuses deployment, so ordering matters. Honest limits: on testnet the blocked drill rows are simulated calls; the testnet run uses our own test router and test tokens because QoreSwap's router address is not published; rate floors have no price oracle; the native AMM cannot be called from a contract; bridging is not guarded because no bridge route is live; the guard is not audited.