How vindyang/straitsx-888 works
Purpose and workspace
This monorepo implements mandated AI-agent payments over x402/XSGD. Its core security boundary is pre-signing policy enforcement: an authorization is evaluated against an on-chain mandate and runtime constraints before the isolated signer can produce an EIP-3009 signature. Node/TypeScript services run in a pnpm workspace; Solidity contract work uses Foundry. Shared wire contracts and conventions live in packages/contracts/src/index.ts, packages/contracts/src/validation.ts, and packages/contracts/registry.json.
User and service entry points
The human entry point is the Next.js dashboard, with pages and API façade under services/dashboard/app/page.tsx, services/dashboard/app/api/run/route.ts, and services/dashboard/app/api/mandates/route.ts. It proxies/operator-controls runs, mandates, revocation, receipts, and ledger views.
The agent-facing entry point is the orchestrator HTTP service: services/agent-orchestrator/src/main.ts, services/agent-orchestrator/src/app.ts, and services/agent-orchestrator/src/routes/run.ts. Checkout-specific requests enter through services/agent-orchestrator/src/routes/checkout.ts.
Agent execution and checkout orchestration
The orchestrator owns the payment-run lifecycle and coordinates downstream dependencies. Its main pipeline is services/agent-orchestrator/src/run/pipeline.ts, with run state in services/agent-orchestrator/src/run/store.ts. It discovers/validates merchant offers before issuing payment actions via services/agent-orchestrator/src/discovery/discover.ts.
For card/MCP-driven checkout, services/agent-orchestrator/src/card-gateway/pay-and-issue.ts and services/agent-orchestrator/src/checkout/checkout-worker.ts form a separate adapter boundary. Post-issuance checks capture spend evidence and constrain checkout domains in services/agent-orchestrator/src/post-issuance/capture-spend-attestation.ts and services/agent-orchestrator/src/post-issuance/assert-checkout-domain.ts.
Policy and durable decision record
Policy service is the authorization gate between orchestration and signing: services/policy-service/src/app.ts, services/policy-service/src/matcher.ts, and services/policy-service/src/signing.ts. Its staged checks verify mandate liveness, policy hash, chain/asset, recipient, amount, budget window, validity, and intent binding/match under services/policy-service/src/checks/index.ts.
Ledger service provides the durable operational record used by policy, dashboard, and orchestrator: services/ledger-service/src/app.ts, services/ledger-service/src/store.ts, and services/ledger-service/src/index.ts. The precise backing store is not evident from the tree; callers must treat it as the decision/audit boundary rather than independently reconstructing state.
Chain custody, mandates, and signing
packages/contracts-sol/src/MandateRegistry.sol is the on-chain mandate registry, deployed on Avalanche Fuji and mainnet. Its generated client ABI/registry must flow through packages/contracts/registry.json and scripts/sync-registry.ts, not hand edits.
services/chain-gateway/src/app.ts, services/chain-gateway/src/chain.ts, and services/chain-gateway/src/routes/mandate.ts are the exclusive JSON-RPC boundary for mandate reads, balances, settlement, and revoke transaction construction. No other component should open chain RPC connections.
services/signer-service/src/app.ts, services/signer-service/src/sign/pipeline.ts, and services/signer-service/src/keys/kms-key-source.ts isolate key access and signing. Policy is its only intended caller; AWS KMS is the production custody dependency. README notes the current service may still be an explicit stub, so readiness must verify actual signing capabilities rather than health alone.
Trust boundaries and control flow
All internal calls require X-Internal-Token and fail closed. The intended path is: dashboard/agent request → orchestrator → policy checks using ledger and chain gateway → policy calls signer → signed x402 authorization is used for settlement → evidence/receipts return through orchestrator/dashboard. The signer is network-isolated from orchestrator and dashboard; chain access is centralized in chain-gateway.
Human control is represented by on-chain mandate revocation, assembled through services/chain-gateway/src/routes/build-revoke.ts and surfaced by services/dashboard/app/api/revoke/[mandateId]/route.ts. A revoked mandate should block future authorization before signatures exist.
Deployment and infrastructure
AWS infrastructure is layered: account/IAM/audit bootstrap in infra/bootstrap/main.tf, shared foundation in infra/foundation/main.tf, A/B services in infra/module-ab/main.tf, and independently deployable Module C integration in infra/module-c-integration/main.tf plus infra/module-c/main.tf. Module C container publishing/deployment is driven by scripts/publish-module-c-images.sh and scripts/deploy-module-c.sh.
Material external services are Avalanche C-Chain RPC, deployed MandateRegistry, XSGD token contracts, AWS KMS, and merchant/card MCP surfaces. Container entry points include services/agent-orchestrator/Dockerfile and services/dashboard/Dockerfile.
Main entry points: pipeline.ts Payment Run Pipeline · pay-and-issue.ts Card / MCP Checkout · app.ts Chain Gateway · route.ts Dashboard API Façade
Components 20
Entry Points
- Next.js Dashboard · Operator views and controls runs, mandates, receipts, and ledger.
services/dashboard/app/page.tsx - Dashboard API Façade
services/dashboard/app/api/run/route.ts - Agent Orchestrator API
services/agent-orchestrator/src/app.ts
Execution
- Payment Run Pipeline
services/agent-orchestrator/src/run/pipeline.ts - Run State
services/agent-orchestrator/src/run/store.ts - Offer Discovery
services/agent-orchestrator/src/discovery/discover.ts - Card / MCP Checkout
services/agent-orchestrator/src/card-gateway/pay-and-issue.ts - Spend Evidence Checks · Captures spend attestations and restricts checkout domains.
services/agent-orchestrator/src/post-issuance/capture-spend-attestation.ts
Authorization & Custody
- Policy Service · Only pre-signing policy decision path.
services/policy-service/src/app.ts - Mandate & Intent Checks · Checks liveness, policy, asset, recipient, limits, validity, and intent.
services/policy-service/src/checks/index.ts - Decision Ledger · Authoritative operational decision and audit boundary.
services/ledger-service/src/store.ts - Isolated Signer · Network-isolated signer; policy is its intended caller.
services/signer-service/src/sign/pipeline.ts - AWS KMS
services/signer-service/src/keys/kms-key-source.ts
Chain Boundary
- Chain Gateway · Centralizes mandate reads, balances, settlement, and revoke construction.
services/chain-gateway/src/app.ts - MandateRegistry · On-chain mandate registry on Avalanche Fuji and mainnet.
packages/contracts-sol/src/MandateRegistry.sol - Contract Registry · Generated ABI and deployment registry; not hand edited.
packages/contracts/registry.json - Avalanche C-Chain RPC
Deployment
- Core Service Infrastructure
infra/module-ab/main.tf - Module C Integration · Independently deployable integration module.
infra/module-c-integration/main.tf
Other components
- Merchant / Card MCP
Connections 21
- Next.js Dashboard → Dashboard API Façade: operator actions
- Dashboard API Façade → Agent Orchestrator API: proxy runs and views
- Dashboard API Façade → Chain Gateway: revoke request
- Agent Orchestrator API → Payment Run Pipeline: start payment run
- Payment Run Pipeline → Run State: persist lifecycle
- Payment Run Pipeline → Offer Discovery: discover and validate offer
- Payment Run Pipeline → Policy Service: request authorization
- Payment Run Pipeline → Card / MCP Checkout: card/MCP checkout
- Card / MCP Checkout → Merchant / Card MCP: checkout interaction
- Card / MCP Checkout → Spend Evidence Checks: issued payment
- Spend Evidence Checks → Decision Ledger: spend evidence
- Policy Service → Mandate & Intent Checks: evaluate
- Mandate & Intent Checks → Decision Ledger: read decision state
- Mandate & Intent Checks → Chain Gateway: verify mandate and chain state
- Policy Service → Isolated Signer: authorized signing only
- Isolated Signer → AWS KMS: key access
- Chain Gateway → Avalanche C-Chain RPC: JSON-RPC only
- Chain Gateway → MandateRegistry: read, settle, revoke
- Contract Registry → MandateRegistry: generated ABI/deployment data
- Core Service Infrastructure → Agent Orchestrator API: deploys core services
- Module C Integration → Card / MCP Checkout: deploys integration