feat: add LedgerGuard preflight safety rail for agent payments - #7
Open
lw22336599-rgb wants to merge 1 commit into
Open
feat: add LedgerGuard preflight safety rail for agent payments#7lw22336599-rgb wants to merge 1 commit into
lw22336599-rgb wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.ts—ledgerGuardReview()(read-only preflight againstPOST /v1/preflight) andledgerGuardX402Wallet()(drop-in wrapper around the existingx402Wallet; signing still happens locally via x402-fetch, the private key never leaves the process)src/adapters/index.ts— export both under@nmrtn/blacktea/adapterstest/ledger-guard.test.ts— hits the real engine (read-only): normal transfer returns a decision, zero-address recipient is BLOCKED,failClosed=falselogs-and-continuesVerification
npm run lintclean,npm run typecheckclean,npx vitest run test/ledger-guard.test.ts4/4 passing against the live engine. Existing CLI tests fail identically onmain(Windows spawn issue, unrelated).