Skip to content

feat: add LedgerGuard preflight safety rail for agent payments - #7

Open
lw22336599-rgb wants to merge 1 commit into
nmrtn:mainfrom
lw22336599-rgb:feat/ledger-guard-rail
Open

feat: add LedgerGuard preflight safety rail for agent payments#7
lw22336599-rgb wants to merge 1 commit into
nmrtn:mainfrom
lw22336599-rgb:feat/ledger-guard-rail

Conversation

@lw22336599-rgb

Copy link
Copy Markdown

What

Adds an optional rail adapter that reviews every agent payment against the LedgerGuard transaction intent safety engine before anything signs.

Why

blacktea controls how much an agent may spend. LedgerGuard verifies who actually gets paid — recipient is not zero/seed-listed, the decoded transfer matches the declared intent, and unknown calls are never treated safe (fail-closed). The two are complementary layers for AI-agent payments.

How

  • src/rails/ledger-guard.tsledgerGuardReview() (read-only preflight against POST /v1/preflight) and ledgerGuardX402Wallet() (drop-in wrapper around the existing x402Wallet; signing still happens locally via x402-fetch, the private key never leaves the process)
  • src/adapters/index.ts — export both under @nmrtn/blacktea/adapters
  • test/ledger-guard.test.ts — hits the real engine (read-only): normal transfer returns a decision, zero-address recipient is BLOCKED, failClosed=false logs-and-continues

Verification

npm run lint clean, npm run typecheck clean, npx vitest run test/ledger-guard.test.ts 4/4 passing against the live engine. Existing CLI tests fail identically on main (Windows spawn issue, unrelated).

Adds an optional x402 rail wrapper that reviews every payment against
the LedgerGuard transaction intent safety engine before anything signs.

- ledgerGuardReview(): read-only preflight review of the real payment
  against the LedgerGuard engine (/v1/preflight), fail-closed by default
- ledgerGuardX402Wallet(): drop-in x402Wallet wrapper — same RailAdapter
  surface, signing still happens locally via x402-fetch, private key never
  leaves the process
- Tests hit the real engine (read-only, nothing signed, no funds move):
  normal merchant transfer returns a decision, zero-address recipient is
  BLOCKED, failClosed=false logs-and-continues

Complementary positioning: blacktea controls how much an agent may spend;
LedgerGuard verifies who actually gets paid before the wallet signs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant