Payments And Spend Authority
runx has no separate money layer. Paying is an operation on a payment connector, admitted like any other write, and Runx Hosted checks each payment against the authority its parent granted before it signs anything.
Authority term
Which payment operations an agent may call, on which resources, how often, and until when.
Payment authority
The currency, the most one payment may spend, and the one counterparty it may pay, checked before signing.
Rail proof
The redacted evidence that a payment happened, sealed into the execution receipt as the durable truth.
A Payment Is A Governed Connector Call
A payment call must fall inside a live authority term's operations, targets and
scopes, like every other connector write. A payment operation declares
amount: required, so every call carries a typed amount, and the approval gate
shows it. Every mutation needs an idempotency key. The term bounds what may be
called and how often; the amount cap travels with the payment authority below.
The shape below is the contract's (AuthorityTerm in runx-contracts), with
example values and the identity references omitted.
{
"resource_family": "connector",
"verbs": ["write", "read"],
"bounds": {
"operations": ["wallet/evm/payment.x402", "wallet/evm/payment.x402.read"],
"scopes": ["payment.x402", "payment.x402.read"],
"targets": ["https://api.example.com/v1/report"],
"uses": { "total": 20, "per_day": 5 }
},
"expires_at": "2026-11-01T00:00:00Z"
}Use limits are reserved with each attempt, never counted from receipts.
The Cap Is Checked Before Signing
A parent hands a payment its payment authority (payment_authority in the
pay skill): the currency, the most it may spend, and the one resource it may
pay.
{
"term_id": "exec-7f3a…",
"currency": "USD",
"max_amount_minor": 100,
"counterparty": "https://api.example.com/v1/report"
}The hosted x402 buyer compares the provider's payment request with it and refuses, before signing:
- a challenge for more than
max_amount_minor - a currency other than USD, or a counterparty other than the paid resource
- more than one accepted payment, or anything but an exact USDC payment on Base
- a changed resource, payee, or expected amount
A marketplace payment is also bound to the current purchase: its cap must equal the listing's vendor price.
What Attenuation Guarantees
A child term may be no broader than its parent. The comparator is fail-closed: a dimension it cannot compare is not a subset, and the child is not minted. A child carries:
- the same connector instance, never another
- a subset of the parent's verbs
- operations and targets inside the parent's patterns
- a subset of the parent's grant scopes
- use limits no higher than the parent's, in total and per day
- every approval the parent carries; none can be dropped
- an expiry no later than the parent's
The Payment Skills
Each payment skill is a thin graph over one hosted payment connector: the payment, then a readback that must match it.
pay
Pays one x402 challenge from the payer's own EVM wallet (wallet/evm):
settle submits the payment once and readback reads the payment and the
paid resource back.
charge
Quotes a price for one resource, then settles a buyer's x402 payment for it
through the seller's Coinbase CDP account (coinbase/cdp) and reads it back
before the resource is released.
refund
Returns all or part of a settled payment on the same Coinbase CDP rail. The amount it moves counts against the run's authority like any payment.
invoice-pay
Checks one invoice against the authority that may pay it, then pays it
through pay.
What The Runtime Enforces, What Runx Hosted Holds
The split is the trust boundary. A skill names the payment it makes; it never holds a credential or authorizes a payment itself.
The runtime enforces:
- that the call falls inside a live term's operations, targets and scopes
- use limits, reserved with each attempt
- a typed amount on every payment call, shown to the approver
- an idempotency key on every mutation
- the signed receipt
Runx Hosted holds:
- wallet and rail credentials, per tenant
- the challenge check against the payment authority, before signing
- signing and settlement, once per idempotency key
- readback of the payment and the paid resource
Payment runs on x402. A buyer pays from its own EVM wallet through the hosted buyer, and a seller takes payment and refunds it through its own Coinbase CDP account. Other payment methods join as connectors when they are implemented. Every payment connector runs only in Runx Hosted: a payment skill run anywhere else moves no money.
Where Payment Meets Receipts
Provider proof seals into the portable Runx receipt. Payment ledger, reconciliation and recovery state remain authoritative in Cloud and are referenced through bounded evidence; OSS does not reconstruct them.
Read Receipts And Pauses for the inspection model, and Core Concepts for how grants and authority fit together.
Hosted Payment Rail Operations
This section describes Runx Company's hosted marketplace billing and payment control plane. Public skill contracts and operator workflows remain in OSS, while all real payment semantics and execution live here: admission, pricing, reservations, limits, credential custody, SDKs, rail calls, private ledgers, refunds, recovery, reconciliation, and finality. Hosted use does not move an operator queue or product state into Cloud.
runx's own Stripe account takes card top-ups to the balance (see
The Balance). Its webhook, /webhooks/payments/stripe, acts
only on signed events, and the endpoint subscribes to these six:
payment_intent.succeeded, whose PaymentIntent carriesmetadata[runx_purpose]=runx_balance_topupandmetadata[runx_principal_id], credits the top-up;refund.created,refund.updatedandcharge.dispute.funds_withdrawnreverse a credited top-up from the balance;refund.failed, a refund updated tofailedorcanceled, andcharge.dispute.funds_reinstatedrestore what that reversal took.
Tenant marketplace events arrive on the Connect webhook instead.
Discovery and mediated prices
Generic x402 Bazaar discovery is published only for a single-leg offer whose challenge amount is the complete buyer price. A mediated marketplace run has two independently settled legs: its public Runx challenge represents the platform fee, while the vendor amount is prepared and settled separately. Runx therefore keeps mediated offers in its own marketplace discovery and does not project the outer fee as an all-in Bazaar resource price. A future Bazaar projection requires one truthful complete-price contract; it must not infer or flatten the two settlements at the HTTP boundary.
The canonical reconciliation command owns both marketplace settlement rails. It is dry-run by default, selects one globally oldest marketplace batch, and acquires the settlement advisory lock before the batch query. Start with a bounded read:
pnpm payment:reconcile -- \
--older-than 5m \
--marketplace-rail all \
--batch-size 100 \
--provider-call-limit 25Add --tenant <principal_id> or --marketplace-rail x402 to narrow an
investigation. Only add --apply after reviewing the per-intent reason codes.
Apply mode may seal from an existing receipt or persisted provider evidence,
confirm a bound x402 transfer, or release only when a rail explicitly proves no
provider settlement occurred. Missing evidence, identity drift, provider
ambiguity, and expired x402 replay windows remain unresolved.
The deployed payment-reconciler runs this same command with --loop --apply.
Each sweep is bounded by row count and provider-call count, one malformed row
cannot stop later tenants, and failures back off without logging provider
bodies. The JSON record exposes checked/sealed/released/unresolved/error counts,
provider calls, oldest unresolved age, and alert=true after the configured
threshold (23 hours by default). An unresolved one-shot exits with code 2; the
maintenance loop stays alive so later evidence can recover. Between sweeps the
loop sleeps until the oldest open intent reaches --older-than, at most
--max-idle (15 minutes by default, RUNX_PAYMENT_RECONCILE_MAX_IDLE); an
intent that stays open past the cutoff is retried every --interval (30s).
Before migration or payout enablement, take a bounded read-only inventory:
pnpm payment:audit-x402 -- --limit 250 --recovery-window 24hThe audit opens a PostgreSQL read-only transaction and returns only stable
digests of intent, receipt, claim, and credential references. It never reads
encrypted credential payloads, calls a provider, releases a reservation, or
rewrites a receipt. A tenant investigation can add --tenant <principal_id>.
Exit code 2 means findings exist or a class exceeded the requested bound; it is
not permission to remediate. Re-run with a narrower tenant or a larger bounded
limit, then handle each class in the packet's remediation order.
The separate historical_unbound_x402_transfers coverage count inventories
terminal pre-migration rows; it is not an instruction to replay or rewrite
them. Only open or in-flight unbound transfers are actionable findings.
Live rollout remains deliberately gated: keep
RUNX_X402_MARKETPLACE_PAYOUTS_ENABLED=false, audit and back up the current
database, apply the additive migration under explicit approval, deploy the API
and reconciler from one reviewed commit, and run one-shot dry-run
reconciliation before enabling the scheduled apply loop. Enabling payouts is a
separate final decision after a bounded dogfood payout and receipt readback.
For a tenant-scoped canary, keep the deployment-wide flag false and place only
the authenticated tenant principal in
RUNX_X402_MARKETPLACE_PAYOUT_PRINCIPAL_IDS; every payout still requires that
tenant's normal write scope, target binding, identity match, idempotency, and
provider finality. Remove the principal immediately if the canary or readback
does not settle cleanly.
Rollback stops the reconciler and disables payouts first; historical nullable
evidence fields stay in place so unresolved rows are never guessed or erased.
To stop safely, stop only the payment-reconciler service. The API continues to
persist settlement intents and receipts; restarting the service resumes from
that durable state. Roll back the released image and keep x402 payouts disabled
if reconciliation reports identity mismatch, provider-window expiry, or an
unexpected error. Never release, rebroadcast, refund, or rewrite those rows by
hand from this command.
Tenant Rail Credentials
Rail credentials are tenant material, never runx process material. A hosted tenant registers payment credentials through the same governed connect-session flow as every other provider, and the rail executor resolves the active grant for that tenant at call time.
For x402 settlement through Coinbase CDP, the tenant connects the coinbase/cdp
connector, whose credential uses the BYO auth mode cdp_api_key:
{
"credentials": {
"api_key_id": "...",
"api_key_secret": "...",
"wallet_secret": "...",
"x402_pay_to": "0x...",
"x402_network": "base",
"x402_asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
}
}New installations use one ordinary CDP API-key EOA on Base. The same
x402_pay_to receives vendor funding and sends worker payouts or buyer refunds.
Keep a small ETH gas balance and the funded USDC in that EOA. Existing funded
CDP smart-account floats remain supported through their stored x402_owner so
live balances and proven payout history are not stranded. That compatibility
path uses CDP's user-operation sponsorship and does not accept a product-owned
Bundler or Paymaster URL.
wallet_secret is only optional for an inbound-funding-only integration; a
Frantic production credential requires it because rejection refunds and worker
payouts are part of the launch contract. Asset decimals are derived from the
known network/asset pair and any supplied legacy value must match exactly.
The connect layer shape-checks and stores the encrypted credential against the
tenant principal. It does not read CDP_* deploy environment variables and it
does not promote one tenant's wallet into a platform-wide default. Runtime x402
execution must call the tenant credential resolver and fail closed when no
active coinbase/cdp grant exists. The rail reads that grant at whatever
revision of the connector it binds, so a new revision needs no reconnect.
Grant freshness
Connected grants are durable by default. They remain active until the tenant revokes them or the provider rejects the credential. Durability changes no authority: principal, provider, scopes, target, verification, and operation approval checks remain enforced on every use.
RUNX_HOSTED_CONNECTED_GRANT_TTL_SECONDS can issue intentionally temporary
grants when a deployment needs them. Only those grants carry expires_at.
Admitting a bounded grant near the end of its window slides the window forward
with a compare-and-set that touches nothing but the date. Renewal never revives
an already expired bounded grant. The one-time Connect browser session has a
separate short expiry and does not determine the resulting grant lifetime.
Material integrity
A BYO grant is only as good as the encrypted row behind it. A row the running
master keys cannot open is quarantined on the grant (verification_status: failed) at boot and at call time, and a quarantined grant is never admitted,
so a grant with unrecoverable material falls through to the next live grant
instead of failing the rail. Stored material is encrypted with versioned
AES-256-GCM keys bound to its owner and provider, so a row moved to another
owner fails decryption rather than opening.
Inbound verify/settle calls are restricted to the official HTTPS CDP x402
endpoint. Outbound sends use CDP's EOA send transaction REST endpoint with
request-scoped API and Wallet authorization plus a deterministic UUIDv4
X-Idempotency-Key; runx never instantiates the stateful CDP client. A returned
transaction hash is only a broadcast handle. Funding, payout, and refund
receipts seal only with their respective settlement evidence, and historical
refunds spend from the exact pay-to/network/asset/scale sealed on the original
funding receipt rather than a newly selected primary target.
Hosted x402 vendor funding mirrors Stripe Connect funding at the receipt boundary:
POST /v1/payments/x402/fundis Bearer-authed as the venue tenant.- The caller submits the quoted posting terms plus
payment_payloadandpayment_requirements. - runx resolves the tenant CDP credential, verifies the quoted
payTo/network/asset/atomic amount against that credential, then asks the Coinbase x402 facilitator to verify and settle. - On success, runx seals
runx.hosted_funding_receipt.v1withfunding.rail="x402"and the same vendor-funding effect contract Stripe Connect uses.
Non-marketplace products use the governed provider-operation boundary instead
of fabricating a posting. An active coinbase/cdp grant may authorize these
exact capabilities against the product's HTTPS resource target:
payment.x402.merchant.quote,payment.x402.merchant.read, andpayment.x402.merchant.lookupusepayment.x402.merchant.read;payment.x402.merchant.settle,payment.x402.merchant.recover, andpayment.x402.merchant.refundusepayment.x402.merchant.write; andpayment.x402.merchant.refund.readusespayment.x402.merchant.read.
The seller boundary retains signed payment material encrypted at rest, binds one idempotency key to one resource/amount/request digest, and uses row-level leases so a lost facilitator response can be recovered without the product retaining wallet authorization material. Refund reservations lock only their linked payment and enforce the cumulative settled amount. Provider results contain payment/refund references and exact settlement evidence; product orders, fulfilment, admission, and policy remain in the calling product.
Purchase maintenance exposes blocked work only through the admin
reconciliation boundary. GET /v1/admin/purchases/blocked lists exact
run-link and terminal-effect identities; ordinary transient failures use
POST /v1/admin/purchases/requeue. If a refund must be executed outside
the provider idempotency window, the operator first verifies the original
settlement, amount, currency, payer, pay-to account, and final refund transaction
through the owning rail. Only then may
POST /v1/admin/purchases/reconcile-refund record the resulting
provider_event against the exact effect_id and blocked_at value. The route
does not move money, accept credentials, change a terminal winner, or bypass
the purchase store; stale or mismatched work returns a conflict. Missing
commercial binding or contradictory historical receipt evidence stays visibly
quarantined and must never be converted into a fabricated receipt.
Before enabling live hosted payments, run:
RUNX_STRIPE_PAYMENT_WEBHOOK_SECRET=whsec_... \
pnpm payment:live-readinessThe readiness gate is offline and checks the Stripe webhook secret, the
reconcile command, the top-up webhook contract, the tenant-scoped payment
credential catalog (stripe, paypal), Stripe Connect's public
HTTPS API origin when enabled, PayPal's explicit endpoint/environment when
enabled, and that any x402 facilitator override is the exact official CDP HTTPS
endpoint. The owning product's native readiness command must separately read
back its live tenant target, route surface, and product semantics before launch.
For a broader hosted product dogfood gate, run pnpm product:live-readiness;
that composes payment readiness with registry/skill publish readiness. Runtime
health still comes from /v1/system/metrics plus the reconcile JSON output:
webhook 400/401/503 spikes mean ingestion is failing closed, and any non-empty
unresolved array means an operator must inspect the rail before retrying a
mutation.
The Balance
A prepaid balance pays for any paid skill, so a purchase carries no settlement fee. Money crosses a real rail only twice: when it comes in, as a top-up, and when it goes out, as a payout to a seller. Between those, every purchase is a ledger transfer inside runx.
The ledger holds integer micro-USD. Each account's balance is a column, and each transfer moves one amount from one account to another in one transaction, idempotent by its kind and reference:
| Transfer | From | To | When |
|---|---|---|---|
fund | a rail | the buyer's balance | a top-up settles, or the $1 grant |
reverse | the buyer's balance | a rail | a top-up is refunded or disputed |
pay | the buyer's balance | escrow | a balance purchase is admitted |
release | escrow | the seller's earnings | the purchase is fulfilled |
refund | escrow | the buyer's balance | the purchase is refunded |
payout | the seller's earnings | a rail | runx pays the seller |
A purchase pays from the balance as the settlement family runx_balance. It
follows the same purchase as x402: the same quote, states, recovery and
receipt. The receipt names the pay transfer as its payment. An empty balance
refuses the purchase before the seller's run starts, and no money moves. Only
an account buyer can pay from a balance; a purchase owned by a buyer key
pays x402. A seller is never offered its own skill on its balance, since that
would turn the balance into earnings.
Funding:
- Card.
POST /v1/billing/topupwith{ "amount_micro": ... }and an idempotency key charges the card saved through/v1/billing/stripe/setup-intents. Whole cents, at least $0.50. The charge response credits the PaymentIntent, and the webhook credits the same one if the response never arrives; either way it is credited once.- A refund or a dispute takes the money back. The
reversetakes what the balance still holds, up to the amount, once per refund or dispute. Money already spent is runx's loss, never a debt. - Stripe doesn't order its events. If a refund or dispute arrives before its top-up is credited, the PaymentIntent is read from Stripe and credited first.
- When Stripe returns the money, because a refund failed or runx won the dispute, exactly what the reversal took is restored.
- A refund or a dispute takes the money back. The
- The $1 grant. Given once per verified external identity when it signs in. A second runx account on the same GitHub identity gets nothing.
GET /v1/billing/balance returns available_micro, what the principal can
spend, and earnings_micro, what runx owes it as a seller. The CLI has no pay
or top-up command: a purchase happens through runx skill.
Why This Matters
Every other connector answers one question: what may an agent reach. Payment also asks what it may spend, why that was allowed, and how anyone can prove it stayed inside the boundary. runx keeps that boundary explicit and checks it before any money moves, instead of trusting an agent to stop on its own.