Skip to content

SOW 2 week 3: before the mainnet opt-in (signed terms on Stellar, the run's RPC, the mainnet job rules) - #41

Merged
dzakwannajmi merged 2 commits into
mainfrom
sow2/w3-signed-terms
Nov 21, 2026
Merged

dzakwannajmi merged 2 commits into
mainfrom
sow2/w3-signed-terms

Conversation

@dzakwannajmi

Copy link
Copy Markdown
Collaborator

Two commits, both on the payment path. Nothing here pays on mainnet: the mainnet opt-in is not part of this version, and its switches still refuse.

fix(core): on Stellar, sign only the checked authorization, built through the run's RPC (4de705b)

  • The caps, the pin and the plan were checked on the terms Wasit hands the x402 client, while the Stellar client signs the authorization entries the RPC's simulation returns. The payer's signer is now gated (packages/core/src/guard/signed-terms.ts): each preimage is decoded, and the key signs only one transfer of the checked amount from the payer to the checked payTo, on the checked asset and the run's network, with no sub-invocation, once per payment, expiring no later than the payment's lifetime allows from the run's first ledger reading. A built payment that carries anything but that one signed authorization is discarded unsent.
  • On stellar:testnet the client builds and simulates through the run's RPC (the one whose network is checked and the settlement is read from) instead of the SDK's default. It accepts only https, so an http:// RPC is refused in the preflight and, in wasit run, before the service starts. stellar:pubnet still gets no RPC from Wasit.

feat(core): the rules of a mainnet job in GitHub Actions (d669b33)

  • mainnetJobRefusals / assertMainnetJob (packages/core/src/guard/ci-mainnet.ts): started by hand, on the default branch, on a GitHub-hosted runner; a deployed service (no service.start, no local baseUrl); no node_modules before Wasit; WASIT_MAINNET_PAYER_SECRET the only key variable. Outside GitHub Actions none applies. Exported for the opt-in and called by nothing yet.
  • --mainnet and the Action's mainnet: true still refuse, and now also name the runner rule on a runner that is not GitHub-hosted.

Results can change on upgrade (CHANGELOG [Unreleased]): a Stellar payment the simulation asks to sign for anything else is ERROR (setup) with nothing signed, as is a testnet token whose transfer needs further authorized calls; an http:// RPC on a Stellar payment run is refused.

Tests (local, npm run build && npm test): cli 277, core 930, server 30, Action 196, 0 failures; typecheck core, cli, server clean. The gate is tested through the real @x402/stellar client against a stood-in RPC (another payee, amount or contract, a sub-invocation, two entries for the payer, a stretched ledger). Each condition of the gate, the RPC rule and the job rules was removed one at a time: 30 + 6 + 17 mutations, all caught.

Docs for these changes (docs/CHECKS.md, the CLI README) wait for the release that ships them.

…ough the run's RPC

The caps, the pin and the plan were checked on the terms Wasit hands the
x402 client, while the Stellar client signs the authorization entries the
RPC's simulation returns. The payer's signer is now gated: each preimage is
decoded and the key signs only one transfer of the checked amount from the
payer to the checked payee, on the checked asset and the run's network, with
no sub-invocation, once per payment, expiring no later than the payment's
lifetime allows from the run's first ledger reading. A built payment that
carries anything but that one signed authorization is discarded unsent.

On stellar:testnet the client now builds and simulates through the run's
RPC, the one whose network is checked and the settlement is read from,
instead of the SDK's default. It accepts only https, so an http RPC is
refused in the preflight and, in wasit run, before the service starts.
stellar:pubnet still gets no RPC from Wasit.

Tests: the preimage check, the gate and the anchor; the real x402 Stellar
client against a stood-in RPC (other payee, amount, contract, a
sub-invocation, two entries, a stretched ledger); the binding after signing;
the wiring in preparePayment; the https rule in core, the CLI and the MCP
server. Every mainnet-optin network must belong to a gated adapter.
Inside one job, code that ran earlier as the runner's user can reach every
later step (PATH, files on disk, a process left running), so no check in
the job holds against it. The rules refuse the workflows where such code
would be: a mainnet run in GitHub Actions is started by hand, on the
default branch, on a GitHub-hosted runner; it tests a deployed service (no
service.start, no local baseUrl); nothing was installed before Wasit (no
node_modules in the workspace or the config's directory); and
WASIT_MAINNET_PAYER_SECRET is the only key variable. Outside GitHub Actions
none applies. They stop a wrong workflow; the key itself belongs in a
GitHub environment limited to the default branch, with a required reviewer.

This version has no mainnet opt-in: assertMainnetJob is exported for it and
called by nothing yet. --mainnet and the Action's mainnet input still
refuse, and now also name the runner rule on a runner that is not
GitHub-hosted.

Tests: each rule alone, all together, no echo of a key, an odd event or
ref, local hosts as the URL parser writes them, and the runner rule in the
CLI and the Action.
@vercel

vercel Bot commented Nov 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
wasit Ready Ready Preview Nov 21, 2026 9:54am UTC

@dzakwannajmi
dzakwannajmi marked this pull request as ready for review November 21, 2026 10:00
@dzakwannajmi
dzakwannajmi merged commit 16171a6 into main Nov 21, 2026
5 checks passed
@dzakwannajmi
dzakwannajmi deleted the sow2/w3-signed-terms branch November 21, 2026 10:00
@dzakwannajmi dzakwannajmi changed the title Stellar: sign only what was checked, through the run's RPC; the rules of a mainnet job SOW 2 week 3: before the mainnet opt-in (signed terms on Stellar, the run's RPC, the mainnet job rules) Nov 21, 2026

This branch was successfully deployed

1 active deployment
Preview — d669b336 Deployed Nov 21, 2026 by vercel[bot]
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