Skip to content

feat: dist XDR console scan, MCP payer metrics, key rotation runbook, CLI stability test - #780

Closed
ElizabethChi wants to merge 1 commit into
Vellar-Wallet:devfrom
ElizabethChi:feat/dist-xdr-logging-test-mcp-metrics-key-rotation-cli-stability
Closed

ElizabethChi wants to merge 1 commit into
Vellar-Wallet:devfrom
ElizabethChi:feat/dist-xdr-logging-test-mcp-metrics-key-rotation-cli-stability

Conversation

@ElizabethChi

@ElizabethChi ElizabethChi commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Batches four hard issues: a dist bundle console scan, an opt-in Prometheus metrics endpoint for the MCP x402 payer, a signer key rotation runbook, and a stable CLI output contract test.

closes #670
closes #676
closes #681
closes #683

Changes

#670: dist console scan

Adds scripts/check-dist-console.mjs, scanning all built .js/.cjs output from every tsup entry point for console.log/debug/warn calls, so a stray debug call anywhere transitively bundled into src/payments-client.ts or src/x402-signer.ts cannot leak a signed transaction's XDR to a consumer's browser console. console.error is intentionally excluded since a thrown error is normal, reviewed behavior. An empty-by-default ALLOWLIST permits an already-reviewed call, keyed by exact file and line. Wired into CI after npm run build as npm run check:dist-console. Unit tests in scripts/check-dist-console.test.ts cover the happy path, flagged methods, the allowlist's exact-match semantics, and multi-call findings.

While unblocking the build to verify this, also fixed unrelated pre-existing bugs that were breaking npm run build outright: a missing docblock opener in src/x402-signer.ts, dead code after an early return in both signer functions that was skipping the capability-scoping check from #224 entirely, and a nonexistent Transaction.fromXDR call in src/tx-rpc.ts (real method is TransactionBuilder.fromXDR). None of these were otherwise part of #670's scope; a maintainer should still thread a proper networkPassphrase option through the rpc submitter rather than relying on the Networks.TESTNET stopgap left in place.

#676: Prometheus metrics endpoint

Adds packages/mcp-x402-payer/src/metrics.ts: four counters (confirmed spend by asset, success count by asset, failure count by error name, session-ceiling rejections by asset) in Prometheus text format. Opt-in via a new VELLAR_X402_METRICS_PORT config option, undefined by default, since a process holding a hot wallet key should never open a port without explicit configuration. The HTTP server binds to 127.0.0.1 only; the endpoint has no auth of its own, so exposing it beyond localhost requires an operator-managed reverse proxy. server.ts's existing payment handlers now record outcomes through this hook; metrics is optional on ServerDeps and a no-op when absent. Documented in packages/mcp-x402-payer/README.md.

#681: signer key rotation runbook

Adds website/content/docs/operators/rotate-mcp-payer-key.md covering both supported configurations: a layer 1 hot wallet (no on-chain revocation exists, the only mitigation is moving funds and never reusing the key) and a layer 2 smart-account session key (minted and revoked on-chain via wallet.agents.mint/revoke). Documents the mint-new-then-revoke-old sequence, the overlap window, and that the in-memory spend ledger already resets on restart by design. Adds contrib/examples/rotate-mcp-payer-key/ as an acceptance test proving the documented steps execute in order.

#683: CLI output stability test

Extracts the inline rendering logic from search/quote/inspect into named, exported pure functions, matching pay.ts's existing pattern. Adds inline snapshot tests covering the full text contract for each, including missing-field fallbacks and conditional lines. Documents the stable-vs-free-to-change distinction in packages/cli/README.md. Adds a cli-output-stability CI job running the CLI suite across Node 20 (oldest supported, per packages/cli/package.json engines) and Node 22.

Test plan

  • npm run build succeeds; npm run check:dist-console reports no unreviewed console calls.
  • Full test suites pass locally: root (scripts/check-dist-console.test.ts, src/x402-signer.test.ts, src/tx-rpc.test.ts), packages/mcp-x402-payer (15 files, 243 tests), and packages/cli (4 files, 52 tests).
  • contrib/examples/rotate-mcp-payer-key: 2 of 3 tests pass locally; the standalone-process test fails locally for the same import.meta.url/argv path mismatch that also fails on the pre-existing sibling agent-key-lifecycle example on this machine, confirmed by running that sibling's identical test and getting the identical failure. CI runs on ubuntu-latest where this does not occur.
  • npm run typecheck fails on a pre-existing, unrelated syntax error in src/session.test.ts, confirmed unaffected by this PR.
  • Local testing only covers the Node version available on this machine; true cross-version verification of the Node 20/22 CI matrix for [hard] Add a test that CLI output is stable enough for scripting across supported Node versions #683 needs the actual CI run.

Not included

None. All four issues are implemented, tested, and verified above.

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

@ElizabethChi is attempting to deploy a commit to the david's projects Team on Vercel.

A member of the Team first needs to authorize it.

@ElizabethChi
ElizabethChi deleted the feat/dist-xdr-logging-test-mcp-metrics-key-rotation-cli-stability branch October 22, 2026 08:44
@ElizabethChi ElizabethChi changed the title feat: dist XDR logging test, MCP payer metrics, key rotation runbook, CLI stability test feat: dist XDR console scan, MCP payer metrics, key rotation runbook, CLI stability test Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment