# How an x402 payment works, step by step, from a real 402 response URL: https://engineering.561.group/how-an-x402-payment-works/ Published: 2026-10-21 Summary: Decode a live x402 v2 challenge header by header: the 402, PAYMENT-REQUIRED, the signed EIP-3009 authorization, settlement and the receipt. ## How an x402 payment works, step by step, from a real 402 response An x402 payment is an ordinary HTTP exchange with one extra round trip. The client asks for a resource, the server answers `402 Payment Required` with a base64 `PAYMENT-REQUIRED` header describing the price, the client signs a USDC transfer authorization and repeats the request with a `PAYMENT-SIGNATURE` header, and the server settles the payment through a facilitator and returns the resource with a `PAYMENT-RESPONSE` receipt. This article decodes a real challenge from the Red Cup seller at market.561.group, captured on 2026-10-22 at 00:30 UTC, so every field below is observed rather than invented. ### What is the first request, and what does the seller answer? The client sends a normal request. We use one of the cheapest offers, an RFC 6901 JSON Pointer lookup that costs $0.0012: ```bash curl -s -i -X POST https://market.561.group/v1/data/json-pointer \ -H 'content-type: application/json' \ -d '{"value":{"a/b":[1,null]},"pointer":"/a~1b/1"}' ``` The response starts like this (other headers omitted): ```http HTTP/2 402 content-type: application/json cache-control: no-store payment-required: eyJ4NDAyVmVyc2lvbiI6MiwiZXJyb3IiOiJQYXltZW50IHJlcXVpcmVkIiwi... ``` Three details matter. The status is `402`. The body is the placeholder `{}`; the real challenge is in the header, so a client that only reads bodies learns nothing. And `cache-control: no-store` keeps intermediaries from caching a quote. ### What is inside the PAYMENT-REQUIRED header? Decode the header to see the challenge: ```bash curl -s -i -X POST https://market.561.group/v1/data/json-pointer \ -H 'content-type: application/json' \ -d '{"value":{"a/b":[1,null]},"pointer":"/a~1b/1"}' \ | grep -i '^payment-required' | cut -d' ' -f2 | tr -d '\r' | base64 -d | jq . ``` The decoded JSON, abbreviated to the load-bearing fields: ```json { "x402Version": 2, "error": "Payment required", "resource": { "url": "https://market.561.group/v1/data/json-pointer", "mimeType": "application/json", "serviceName": "json-pointer", "tags": ["json", "rfc6901", "json-pointer"] }, "accepts": [ { "scheme": "exact", "network": "eip155:8453", "amount": "1200", "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "payTo": "0x…(the seller's receiving address)", "maxTimeoutSeconds": 300, "extra": { "name": "USD Coin", "version": "2" } } ], "extensions": { "bazaar": { "...": "..." }, "sign-in-with-x": { "...": "..." } } } ``` Reading it field by field: | Field | Meaning | | --- | --- | | `x402Version: 2` | Protocol version. v2 uses the `PAYMENT-REQUIRED`, `PAYMENT-SIGNATURE` and `PAYMENT-RESPONSE` headers. | | `scheme: "exact"` | The buyer authorizes exactly this amount; no more, no less. | | `network: "eip155:8453"` | A CAIP-2 chain identifier. 8453 is Base mainnet. | | `amount: "1200"` | Atomic units of the asset. USDC has 6 decimals, so 1200 is $0.0012. | | `asset` | The USDC contract on Base (Circle's token), not a symbol. | | `payTo` | Where the money goes. A buyer must not simply trust this field; see [Never trust the payee](https://engineering.561.group/verify-x402-payee-buyer-side/). | | `maxTimeoutSeconds: 300` | How long a signed authorization may remain valid. | | `extra.name`, `extra.version` | The EIP-712 domain parameters of the token, needed to sign correctly. | The `extensions` object carries optional features. `bazaar` describes the input and output of the endpoint with a JSON Schema so a discovery index or an agent can see how to call it, and `sign-in-with-x` offers a wallet-login challenge, covered in [Sign-in-with-X](https://engineering.561.group/x402-sign-in-with-x/). The amounts are exact integers; the seller never converts between dollars and atomic units on the buyer's behalf, because rounding in a payment path is a defect. ### How does the client sign a payment? USDC on Base implements EIP-3009 `transferWithAuthorization`. The buyer does not send a transaction. It signs an EIP-712 typed message that authorizes a transfer of exactly `amount` from the buyer to `payTo`, with a random 32-byte nonce and a validity window. The signature goes into a JSON payload that echoes the `accepted` requirement, base64-encoded as the `PAYMENT-SIGNATURE` header. Because the buyer signs rather than submits, the buyer needs no ETH for gas; a facilitator submits the transfer. In code, the official client library does this for you. In outline: ```js // Outline using the official x402 packages (see their docs for exact imports) const client = /* x402 client registered with an exact-EVM scheme and your signer */; const paymentPayload = await client.createPaymentPayload(paymentRequired); const header = encodePaymentSignatureHeader(paymentPayload); // repeat the original request with: PAYMENT-SIGNATURE:
``` A careful buyer inserts three checks between "read the challenge" and "sign": that the `payTo` equals an address the buyer's owner approved in advance, that `amount` is below a budget, and that the resource URL is the one requested. The Red Cup buyer library enforces all three and also detects *quote drift* (a second challenge that differs from the first accepted one) before signing. ### What does the seller do with the signature? The seller's middleware decodes the header and asks a facilitator to verify it: is the signature valid for this payer, is the nonce unused, does the balance cover the amount, does the requirement match what the seller issued? Our seller uses the Coinbase CDP facilitator. If verification succeeds, the seller runs its handler. Only if the handler returns a success status does it ask the facilitator to settle, which submits the EIP-3009 transfer on Base. A handler that fails or throws causes the authorization to be cancelled instead (see [Refuse before you charge](https://engineering.561.group/refuse-before-you-charge-x402/)). The successful response carries the resource and a `PAYMENT-RESPONSE` header containing the settlement result, including the network transaction hash. That receipt is what the buyer records. The Red Cup buyer calls `beforePayment` with the exact signed request before it is sent, and `onSettlement` with the facilitator's report before the delivery is read, so the buyer's own books show the intent even if the connection dies. ### What if the connection drops after the buyer pays? The signature is single-use: the facilitator will reject a second submission of the same nonce. For ordinary API calls the buyer simply pays again for a new computation, which costs a fraction of a cent. For expensive digital goods the seller offers the [X-Payment-Recovery](https://engineering.561.group/x402-payment-recovery-header/) mechanism so the same signed request returns the same purchased bytes. ### How do I try this without spending anything? Everything up to the signature is free. The unsigned probe above costs nothing and moves no funds. If you want to inspect any x402 v2 resource safely, the Apache-2.0 [x402 boundary reference](https://github.com/561-group/x402-boundary-reference) includes `observePublicX402Resource`, which fetches a public resource, refuses redirects and non-HTTPS targets, validates the challenge against the official schema, and returns a content-addressed digest of what it saw, all without paying or signing. To list what the market sells, read [`/.well-known/x402`](https://market.561.group/.well-known/x402) (130 resources at the time of writing) or the richer [`/v1/catalog`](https://market.561.group/v1/catalog). ### What should I remember? An x402 challenge is a quote written by the seller, not an authorization from the buyer. The seller's address, the amount and the asset are all claims; the buyer's software decides which claims to honor. The rest of this series is about making both sides of that exchange careful: start with [what a seller should do beyond the spec](https://engineering.561.group/x402-seller-design/). --- # How this site is built: TUFTE, llms.txt, JSON-LD and a build that refuses broken pages URL: https://engineering.561.group/how-this-site-is-built-tufte/ Published: 2026-10-21 Summary: How a Markdown folder becomes pages, llms.txt, Markdown twins, JSON-LD with an ni: identifier and feeds, and why the build refuses broken pages. ## How this site is built: TUFTE, llms.txt, JSON-LD and a build that refuses broken pages This site is generated by TUFTE, the Tiling User Form Topology Engine, from a flat directory of Markdown files. Each file with `visibility: public` becomes a page with structured data, a Markdown twin, an entry in `llms.txt` and `llms-full.txt`, three feeds and a sitemap line, and a file that breaks the rules is refused rather than published. The details below come from the engine's documentation (version 0.16.0) and from inspecting the build output of this very article on 2026-10-22. ### What is TUFTE, and what does it publish? TUFTE is the Group's graphical interface engine for web servers and platforms. It renders documents as tiles with a stable reading order, and the same package exports a *publication application*: given a catalog of admitted cells (documents) and a site description, it renders article pages, home and archive indices, search, error pages, feeds and machine-readable artifacts from one set of route declarations. Per its documentation, "a static publisher consumes the same route declarations; it does not carry a second rendering path", so what the build writes is what the server would serve. The source executes as plain JavaScript, with no TypeScript build or generated runtime copy. Static pages without enhancement emit no framework JavaScript. The engine's source repository is not public at the time of writing, so this article describes its documented behavior and output, not code you can clone. ### How does a Markdown file become a page? A file in `content/` has a front matter block that the catalog checks: ```yaml --- title: "Specific, keyword-forward title" summary: "A 120-160 character claim, never 'This article...'" date-created: 2026-10-21 type: article status: active visibility: public tags: [x402, agent-payments, http-402] --- ``` The file name is the URL: `content/x402-seller-design.md` becomes `https://engineering.561.group/x402-seller-design/`. The catalog refuses a cell that lacks a title or an ISO `date-created`. This site's acceptance rule is explicit: only cells with `visibility: public` are published. Another file in the same directory, a draft with `status: potential` and no `visibility` field, is reported as "withheld" on every build. The engine's documentation describes why this is a consumer decision: "A corpus being readable does not make every document publishable." The `includeCell` predicate runs before any route is projected, and only a literal `true` admits a cell. ### Which files does each page produce? For this article the build wrote these artifacts (names relative to the site root): | Artifact | Purpose | | --- | --- | | `/how-this-site-is-built-tufte/index.html` | The page, with canonical URL, Open Graph and Twitter tags, JSON-LD | | `/how-this-site-is-built-tufte/index.md` | A Markdown twin, advertised with `` | | `/llms.txt` | Site intro and one line per article with its summary, per [llmstxt.org](https://llmstxt.org/) | | `/llms-full.txt` | Every published article as Markdown in one file (about 100 KB for the first twelve pages) | | `/feed.rss.xml`, `/feed.atom.xml`, `/feed.json` | Three feeds, each with the organizational author | | `/sitemap.xml` | Every page with a `` taken from the article's date | | `/search/` and a generated index | Client-side search with no server | | `/robots.txt` | Allows all, and names GPTBot, OAI-SearchBot, ChatGPT-User, ClaudeBot, Claude-SearchBot, PerplexityBot, Google-Extended, Applebot-Extended, CCBot and Bingbot explicitly | The robots file is a statement, not a technical necessity: `User-agent: *` with `Allow: /` already permits those crawlers, but naming them removes doubt about whether an AI crawler is welcome. We allow them because the purpose of these pages is to be read, quoted and cited. The `llms.txt` header on this site is built from `site.json`: a one-line description as a blockquote, an introductory paragraph, then sections of links ("Machine interfaces", "561 Group") that we authored, then the article list. The Markdown twin is rebuilt from each cell's parsed blocks. Front matter is dropped; wikilinks and citations are resolved to plain links and labels. One imperfection we observed: the twin begins with the title as a heading and then repeats it as the first heading of the body. It does not affect the HTML. ### What structured data does each page carry? Every article has a JSON-LD graph. From the live page for [the seller-design article](https://engineering.561.group/x402-seller-design/): ```json {"@id":"https://engineering.561.group/x402-seller-design/","@type":"Article", "headline":"What an x402 seller should do that the spec doesn't require", "datePublished":"2026-10-21","inLanguage":"en","wordCount":1469, "keywords":"x402, agent-payments, http-402, seller-engineering, usdc", "publisher":{"@type":"Organization","name":"Red Cup Engineering","url":"https://engineering.561.group/"}, "author":{"@type":"Organization","name":"Red Cup Engineering","url":"https://engineering.561.group/"}, "isPartOf":{"@id":"https://engineering.561.group/#website"}, "identifier":"ni:///sha-256;eYeU9-p__RrwPbHiZnrC57lHyutIZuOVM1uKEXxajHU"} ``` Three decisions here are deliberate. **Organizational authorship.** The site declares `author` as an Organization in `site.json`. The engine's rule is "`site.author` wins; front-matter `authors:` is read only when the site declares none", and a site that declares an author "never emits a name from a source paper". Our articles are attributed to the engineering company, with the `publisher` chain running up to the parent organization, the 561 Group, through `parentOrganization` and `sameAs` links. **A content address as identifier.** The `identifier` is the RFC 6920 `ni:` name of the cell, the same kind of name described in [Content-addressed names](https://engineering.561.group/content-addressed-names-ni-rfc-6920/). The JSON feed uses the same style of `id` per item. A reader or agent can attach evidence to the cell's name rather than to a URL that might later serve different words. **Fediverse attribution.** Each page head carries `fediverse:creator` and a `rel="me"` link naming the organization's ActivityPub identity. The handle `@engineering@engineering.561.group` is declared in `site.json`. At the time of writing, a WebFinger request to this site for that account does not yet return a JSON resource: the actor is being launched separately, and the tags are forward-declared. The design of the provider is in [ActivityPub publication provider](https://engineering.561.group/activitypub-publication-provider/). For scholarly material, the engine adds Google Scholar's Highwire `citation_*` tags and Dublin Core `DC.*` tags when a cell is a `paper`, a theorem-like type, or sets `scholarly: true`, using the cell's `doi`, `pdf`, `abstract` and `keywords`. These articles are `type: article`, so they do not emit Highwire tags. ### What does the build refuse? The build reports a count in one line, for example: ``` engineering.561.group: 12 accepted, 1 withheld, 0 refused, 141 artifacts ``` "Refused" is the interesting column. While preparing these articles we tripped two of its checks by accident: - `refused mt: unknown citation key "foo"`: a body cited `[@foo]` and the front matter's `references` map had no such entry. The page was not published with a dangling citation. - `refused mt: heading level skips from h1 to h3`: a body that began with a second-level heading, where the engine's convention is a first-level title that the page then renders one level down. Both are the engine enforcing the document's accessibility and citation contracts instead of emitting HTML that looks acceptable and is not. The same discipline runs through the rest of the Group's publishing: a draft is not a publication, and a commit is not a deployment. ### What are the honest limits? The build output is a set of static files. Nothing about producing them proves they are deployed, indexed or cited; the engine's documentation distinguishes source, package, installed host and independent receiving as separate facts, and so do we. Publishing the machine-readable surfaces does not guarantee that a search engine ranks the page or that an answer engine quotes it. We cannot observe either, and report no such results. And the engine is early software: the Markdown twin duplicates its heading, the engine's source is private, and the math rendering described in [Math on the web without JavaScript](https://engineering.561.group/mathml-without-javascript-markdown/) is a capability of the Markdown package that this site's publication pipeline does not yet apply to its own pages. If you want a starting point, the Apache-2.0 [x402 boundary reference](https://github.com/561-group/x402-boundary-reference) and the other public repositories under the [Red Cup Engineering organization](https://github.com/red-cup-engineering) are the places to read code today. The [article index](https://engineering.561.group/start-here/) groups everything published here. --- # Math on the web without JavaScript: LaTeX to MathML in Markdown, with prices left alone URL: https://engineering.561.group/mathml-without-javascript-markdown/ Published: 2026-10-21 Summary: Render LaTeX in Markdown to MathML server-side with temml, keep TeX as an annotation, and use Pandoc's dollar rules so $9.00 and $12.00 never become math. ## Math on the web without JavaScript: LaTeX to MathML in Markdown, with prices left alone The Markdown package in the 561 Group's engineering tree, version 0.5.6, renders LaTeX to MathML on the server using the temml library, with no client script, and attaches the original TeX to every formula as an `application/x-tex` annotation. Inline `$…$` math is opt-in per document and follows Pandoc's rules, so a sentence containing "$9.00 and $12.00" or "$5 and $6" is never mistaken for a formula. This article shows the real output of the renderer for each case. ### Why render math as MathML instead of with JavaScript? Most sites that show equations load a client-side library that finds TeX in the page and typesets it after load. That costs a script download, shifts the layout when the equations appear, shows raw TeX to anything that does not run the script (including some crawlers and every plain-text projection), and hides the formula from assistive technology until the library finishes. MathML is the web platform's own format for mathematics, and current Chrome, Firefox and Safari render it natively. Producing it at build time means the equation is in the HTML the server sends. Readers get it with no script, a crawler sees the structure, and a screen reader can use the markup. The temml library, a pure-JavaScript TeX-to-MathML converter, runs in the build, not in the reader's browser. The package pins `temml` 0.14.0. ### What does the renderer emit? The delimiters `$$…$$`, `\[…\]` (display) and `\(…\)` (inline) are always on. Rendering `\(a_i\)` produces: ```html ai a_i ``` and `\[ E = mc^2 \]` produces a display block: ```html
E=mc2 E = mc^2
``` (Line breaks added for display; these are outputs from running the 0.5.6 source.) Inline math is a `span.math.math-inline`, display math is a `div.math.math-display` (or a `span` with the same classes when it sits inside running text), and every rendering has the `` wrapper with the TeX in an ``. Why keep the TeX? Because MathML is verbose and lossy as a quotation. A reader who wants to copy the formula into their own document wants `E = mc^2`, not twelve elements. A search or answer engine that extracts text from the page can take the annotation, which is the author's own notation. And an editor that reopens the page can round-trip it. In the parsed representation used for tables of contents and plain-text exports, a math node carries `tex` and `text` fields, both the TeX source, so headings and other text projections read the TeX instead of a tree of MathML elements. ### How do prices avoid becoming math? A dollar sign is both the currency symbol and the most common inline math delimiter. A renderer that treats every pair of `$` as math turns "costs $9.00 and $12.00" into an italicized, spaceless run, which is a real defect in any commerce or finance text, and the market this team operates quotes `$9.00` and `$12.00` for publications and `$0.0012` for API calls. The package solves it in two layers. 1. **Inline dollar math is off unless a document asks.** A document turns it on with front matter `math: true`, and the caller passes that flag to the parser. Without it `$` is never interpreted, so prices stay prices on every page that did not opt in. The always-on delimiters, `$$`, `\[` and `\(`, do not collide with ordinary currency. 2. **When it is on, Pandoc's `tex_math_dollars` rules apply.** The opening `$` must be followed by a non-space character, the closing `$` must be preceded by a non-space character and must not be followed by a digit, and `\$` is a literal dollar. We ran the 0.5.6 parser with `math: true` over four strings. Each result is the rendered HTML: | Input | Output | | --- | --- | | `It costs $5 and $6 in total.` | `

It costs $5 and $6 in total.

` (no math) | | `Totals: $9.00 and $12.00.` | `

Totals: $9.00 and $12.00.

` (no math) | | a sentence with the inline code span `$x$` | the `$x$` element, untouched | | `Pythagoras: $x^2+y^2=z^2$ holds.` | a `span.math.math-inline` with the MathML of x² + y² = z² | With `math` not set the last input stays literal: `

Pythagoras: $x^2+y^2=z^2$ holds.

`. The first row is the one that matters. In "$5 and $6", the first `$` is followed by `5`, but the candidate closing `$` is preceded by a space, so it cannot close, and the text is left alone. The trade-off is real. Under these rules a closing dollar sign immediately followed by a digit does not close a formula, so `$x$2` stays literal, and a formula may not have a space just inside either delimiter. They are the cost of safety, and they are the same costs Pandoc users already know. ### What gets skipped? The scanner does not look inside inline code spans, fenced code blocks, link URLs or autolinks, so a code sample showing `$x$` is displayed as written. Display blocks may span lines but not a blank line. Math inside `**strong**` or `*emphasis*` is not parsed; those spans remain literal text. This is a limit, not a feature: if you need bold math, put the bold inside TeX with `\mathbf{}`. ### What happens when the TeX is wrong? TeX that temml refuses renders as a `` element holding the source, and `renderBody` never throws on it. Rendering `$$\frac{1}{$$` gives: ```html
\frac{1}{
``` A reader sees the offending source and the rest of the page survives. The renderer also runs temml with `trust: false` and `strict: 'ignore'`, so a formula cannot invoke URL-loading or HTML-injecting commands. That matters because math is the only HTML the renderer does not escape: it is the one place where the output contains markup derived from user text. The package's comment states it directly, "TeX renders to MathML through temml; it is the only HTML not escaped." ### Is there a breaking change to know about? Yes. Before 0.5.6, the `$$…$$`, `\[…\]` and `\(…\)` delimiters rendered as literal text. After it they render as math. If an existing document used `\(` in prose without meaning math, it will now be parsed. The package's release note flags it as a behavior change, and so do we. ### Is this running on this site? Not yet. This site's publication pipeline uses the engine described in [How this site is built](https://engineering.561.group/how-this-site-is-built-tufte/), and when we built a test page containing `$$…$$` and `math: true` through that pipeline, the delimiters came through as text and no MathML was produced. We say so because it would be easy to write about equations on a page that cannot show one. The capability exists in the Markdown package and we verified its output directly; wiring it into this particular publication path is separate work, and we will not claim it until a page here renders an equation. ### Why does this matter to answer engines? A formula stored as an image is invisible to a language model. A formula stored as client-rendered TeX is visible only if the crawler runs the script. A formula stored as MathML with its TeX annotation is visible as structure and as the author's notation, in the HTML the server sent. The same logic motivates the rest of the publishing stack: put the meaning in the markup, keep a plain-text twin, and let the page stand on its own ([how this site is built](https://engineering.561.group/how-this-site-is-built-tufte/)). For the four-valued logic operations that would be natural to typeset, see [Belnap's logic as an API](https://engineering.561.group/belnap-four-valued-logic-api/). --- # What an x402 seller should do that the spec doesn't require URL: https://engineering.561.group/x402-seller-design/ Published: 2026-10-21 Summary: Eight seller behaviors beyond the x402 spec, each running on a live endpoint: refuse before charging, recover purchases, pin payees, one catalog. ## What an x402 seller should do that the spec doesn't require An x402 seller that only returns HTTP 402 and settles a signature is compliant but fragile. A production seller should also refuse bad input before it charges, never keep a payment when its handler fails, quote the same price twice, let a buyer recover an interrupted purchase, and describe itself to machines once. Red Cup Engineering operates one such seller, [market.561.group](https://market.561.group/), with 130 per-call offers priced in USDC on Base, and this article lists what it does beyond the protocol minimum. ### What does the x402 specification actually require of a seller? x402 revives the long-reserved HTTP status code 402 Payment Required. In version 2 of the protocol a seller answers an unpaid request with `402` and a base64 JSON `PAYMENT-REQUIRED` header listing what it will accept (scheme, network, asset, amount, payee, timeout). The buyer signs a payment authorization, repeats the request with a `PAYMENT-SIGNATURE` header, and the seller asks a facilitator to verify and settle it. A successful answer carries a `PAYMENT-RESPONSE` header with the settlement receipt. The [step-by-step walkthrough](https://engineering.561.group/how-an-x402-payment-works/) decodes a real challenge from our seller. That is the contract. It says nothing about what happens when the buyer's JSON is malformed, when your handler throws after the buyer has signed, when the buyer's connection drops after settlement, or when a buyer is an autonomous agent that cannot read your documentation. Those are seller-engineering questions, and the answers decide whether an agent that tried your API once will try it again. Our seller is built on the official `@x402/core` and `@x402/evm` packages. It does not replace the protocol; it wraps it with the policies below. ### Which behaviors does a seller add beyond the spec? | # | Behavior | One-line rule | Article | | --- | --- | --- | --- | | 1 | Refuse before charging | A request that can never succeed gets 400 or 422, never 402 | [Refuse before you charge](https://engineering.561.group/refuse-before-you-charge-x402/) | | 2 | Cancel settlement on handler failure | If the handler returns 4xx or 5xx, the signed payment is cancelled | same | | 3 | Price from the body, deterministically | The same body quotes the same amount on both legs of the exchange | [Per-byte x402 pricing](https://engineering.561.group/x402-per-byte-pricing/) | | 4 | Recoverable purchases | A buyer can repeat the same signed request and receive the same bytes | [X-Payment-Recovery](https://engineering.561.group/x402-payment-recovery-header/) | | 5 | Buyer-side payee pinning | The buyer never takes the payee from the seller's own challenge | [Never trust the payee](https://engineering.561.group/verify-x402-payee-buyer-side/) | | 6 | Sign-in-with-X on the 402 | A returning wallet can prove who it is without paying again | [Sign-in-with-X](https://engineering.561.group/x402-sign-in-with-x/) | | 7 | One catalog, many machine faces | MCP, A2A, ActivityPub, OpenAPI, llms.txt and x402 discovery from one source | [One catalog, five faces](https://engineering.561.group/x402-one-catalog-machine-interfaces/) | | 8 | Honest evidence labels | A 402, a settlement, a delivery and a customer acceptance are four different facts | below | #### Why refuse before charging? An agent pays by signing a spend authorization. If the seller discovers only after payment that the JSON was invalid, the agent has either lost money or depends on a refund process nobody specified. The cheapest fix is ordering: validate the request body against the offer's published schema first, and only a request that passes earns a 402 challenge. On our seller, a malformed body to `POST /v1/data/json-pointer` returns `400` with `{"error":"request body must be valid JSON"}`, and a schema violation returns `400` with `application/problem+json`. Neither carries a `PAYMENT-REQUIRED` header. The full evidence, including the exact responses, is in [Refuse before you charge](https://engineering.561.group/refuse-before-you-charge-x402/). #### Why cancel settlement when the handler fails? In the fetch-based server in the Red Cup x402 engine, the handler runs after the payment verifies and before it settles. If the handler throws, or returns a status of 400 or above, the engine calls the payment library's cancellation path with a reason (`handler_threw` or `handler_failed`) and returns the failure to the buyer. The signed authorization is never submitted. A seller that settles first and fails afterwards has taken money for nothing. A seller that fails first does not. #### Why must a price be deterministic? Some offers are priced by the size of the request. If the quote depended on a wall clock, a traffic counter or a client-supplied `Content-Length`, the amount signed by the buyer could differ from the amount the seller expects when the signature comes back. Our seller derives the price from the canonical JSON bytes of the admitted body, so the same body produces the same amount on the unpaid probe and on the paid retry. We measured the live quotes and tabulate them in [Per-byte x402 pricing](https://engineering.561.group/x402-per-byte-pricing/). #### Why make purchases recoverable? Networks fail between settlement and delivery. For the digital goods on our seller that carry `recovery` in the catalog (seven priced publications and a briefing), the buyer generates a random 32-byte token, sends it as `X-Payment-Recovery`, and can later repeat the identical signed request to receive the original bytes. The signature alone is not a credential, because it becomes public on the chain. Details and the status codes (400, 409, 410, 503) are in [Repeat purchases with X-Payment-Recovery](https://engineering.561.group/x402-payment-recovery-header/). #### Why should a buyer pin the payee? A 402 challenge is written by the party asking for money. A buyer that spends whatever address the challenge names can be redirected by any compromised or malicious seller. The Red Cup buyer library requires an independently authorized `expectedPayTo` before it probes or signs, and refuses a challenge naming anyone else. The seller's own receiving script uses the same discipline through `X402_EXPECTED_PAY_TO`. See [Never trust the payee in a 402 challenge](https://engineering.561.group/verify-x402-payee-buyer-side/). #### Why attach sign-in-with-X to the challenge? Some wallets have been granted access out of band: a subscriber, a partner, a paid-up customer. The x402 extension `sign-in-with-x` lets the seller include an EIP-4361 style challenge inside the 402 so such a wallet can prove control of its address instead of paying. Our implementation issues stateless nonces from an HMAC, accepts a proof for five minutes, and binds it to the resource URL. See [Sign-in-with-X](https://engineering.561.group/x402-sign-in-with-x/). #### Why publish one catalog in five formats? An agent might find a seller through an MCP server, an A2A agent card, an ActivityPub actor, an `llms.txt`, or the x402 `/.well-known/x402` document. We maintain a single catalog file and project it. Every format therefore agrees on price, route and input schema, and none can drift. See [One catalog, five machine faces](https://engineering.561.group/x402-one-catalog-machine-interfaces/). #### What does "honest evidence labels" mean? The seller's own documentation keeps four facts apart: an unsigned 402 challenge proves only that the route is configured; a facilitator success is an observation, not proof of an on-chain transfer; a delivered HTTP status is not buyer acceptance; and traffic is not independent customer demand. We do not claim revenue or customer counts in these articles because none of those observations establishes them. Neither should your dashboard. ### How can I verify these claims myself? Every behavior above can be exercised without spending anything, because an unpaid request reveals the challenge and the refusals: ```bash # 1. The machine-readable offer list (130 resources) curl -s https://market.561.group/.well-known/x402 | head -c 600 # 2. A malformed body is refused before any payment challenge curl -s -i -X POST https://market.561.group/v1/data/json-pointer \ -H 'content-type: application/json' -d '{"nope":' | head -n 12 # 3. A valid body earns a 402 with a PAYMENT-REQUIRED header curl -s -i -X POST https://market.561.group/v1/data/json-pointer \ -H 'content-type: application/json' \ -d '{"value":{"a/b":[1,null]},"pointer":"/a~1b/1"}' | grep -i '^HTTP\|^payment-required' | cut -c1-120 ``` The first returns a JSON list of resources, the second a `400`, the third a `402` with a long base64 header. If any of these differ from what we describe here, the live seller is authoritative and we want to know. ### Where is the code, and what is its license? The payment-boundary reference is public under Apache-2.0: [561-group/x402-boundary-reference](https://github.com/561-group/x402-boundary-reference). It builds an explicit exact-EVM x402 v2 boundary for an Express route and inspects a public challenge without paying. The buyer library `x402-exact-purchase-service` is public under MIT at [red-cup-engineering/x402-exact-purchase-service](https://github.com/red-cup-engineering/x402-exact-purchase-service). The full seller engine, `@red-cup-engineering/x402-services-section` (version 0.10.9 at the time of writing), is distributed from the house registry rather than public npm; the articles describe its behavior from source and from the live endpoint. ### What are the honest limits? The recoverable-purchase store claims no crash-exactly-once production: the caller still owns cross-process exclusion and idempotence of the effect after settlement. Usage-based (`upto`) pricing exists in the engine but the market catalog remains on the fixed `exact` scheme. A listing in a directory or a 402 on a route is not a purchase, and a purchase we make from ourselves is not demand. We say so in the code's own documentation, and repeat it here. --- # Red Cup Engineering: x402 sellers, agent-facing web infrastructure and content-addressed evidence URL: https://engineering.561.group/ Published: 2026-10-20 Summary: Articles on x402 seller engineering, Belnap four-valued HTTP, content-addressed names, ActivityPub and publishing from the 561 Group's engineering company. ## Red Cup Engineering: x402 sellers, agent-facing web infrastructure and content-addressed evidence Red Cup Engineering is the engineering company of the [561 Group](https://561.group/). It builds web infrastructure whose customers are software agents: a seller that charges per call over HTTP 402, a status page that reads answers in Belnap's four truth values, names for data that do not depend on how it was spelled, and a publisher that speaks ActivityPub. The articles below explain each design with live endpoints, real headers and status codes, and code from the source, and they say what is not yet established. ### How do I build an x402 seller that agents can trust? x402 revives HTTP status 402 so software can pay per request in USDC. Our reference seller at [market.561.group](https://market.561.group/) offers 130 paid operations on Base (`eip155:8453`). These articles are the engineering behind it, in the order we suggest reading: 1. [How an x402 payment works, step by step, from a real 402 response](https://engineering.561.group/how-an-x402-payment-works/): decode a live `PAYMENT-REQUIRED` header field by field. 2. [What an x402 seller should do that the spec doesn't require](https://engineering.561.group/x402-seller-design/): the eight behaviors that separate a demo from a seller. 3. [Refuse before you charge](https://engineering.561.group/refuse-before-you-charge-x402/): validate first, answer 400, 415 or 422 with no challenge, and cancel settlement when the handler fails. 4. [Per-byte x402 pricing](https://engineering.561.group/x402-per-byte-pricing/): $0.0012 up to 4 KiB of canonical JSON, then 100 atomic units per band, with live quotes tabulated. 5. [Repeat purchases with X-Payment-Recovery](https://engineering.561.group/x402-payment-recovery-header/): repeat the same signed request and receive the same purchased bytes. 6. [Never trust the payee in a 402 challenge](https://engineering.561.group/verify-x402-payee-buyer-side/): the buyer takes the payee from its own authority. 7. [Sign-in-with-X on an x402 402](https://engineering.561.group/x402-sign-in-with-x/): stateless wallet login that rides on the payment challenge. 8. [One catalog, five machine faces](https://engineering.561.group/x402-one-catalog-machine-interfaces/): MCP, A2A, ActivityPub, `llms.txt` and x402 discovery compiled from one source. ### What does it mean to read HTTP in four values? A status page that says only "up" or "down" hides the interesting answers. A `402` or `403` means a server answered and refused, which is neither up nor down. These two articles treat answers and evidence as Belnap's four values: true, false, both and neither. - [Reading HTTP in four values](https://engineering.561.group/http-status-four-valued-belnap/): the seven-line rule behind the live estate reading at [561.group/estate.json](https://561.group/estate.json), with the current counts. - [Belnap four-valued logic as an API](https://engineering.561.group/belnap-four-valued-logic-api/): knowledge and truth joins, negation and conflation, with full tables and the per-call endpoints. ### How do I name data so that its spelling does not matter? - [Content-addressed names: RFC 6920 ni: URIs over canonical CBOR](https://engineering.561.group/content-addressed-names-ni-rfc-6920/): the semiotic content address, with hashes you can reproduce in a terminal, and the list of our own addresses that do not yet conform. ### How is this publication built, and how does it reach answer engines? - [How this site is built: TUFTE, llms.txt, JSON-LD and a build that refuses broken pages](https://engineering.561.group/how-this-site-is-built-tufte/): the publication engine behind these pages, its machine surfaces and its refusals. - [Math on the web without JavaScript](https://engineering.561.group/mathml-without-javascript-markdown/): LaTeX to MathML at build time, with TeX kept as an annotation and prices left alone. ### How does an organization publish into the fediverse? - [ActivityPub for a publication](https://engineering.561.group/activitypub-publication-provider/): a Fedify provider with WebFinger, NodeInfo 2.1, signed inboxes and no unsigned mode, and what is and is not live. - [Paraconsistent federation](https://engineering.561.group/activitypub-paraconsistent-inbox/): an inbox that records a `Create` and a `Delete` as a contradiction instead of letting arrival order decide. ### Which reusable resources can I select? Begin with the capability you need and its actual input, output, version and receiving condition. The dependency order is **Data → Code → Networking → Systems**: code uses admitted data, networking composes code and data into communication, and systems combine those capabilities for an actual receiver. A published package, a deployed process and a successfully used service establish different facts. | Need | Resource | | --- | --- | | Charge per request over x402 | The x402 services section, reference boundary public at [561-group/x402-boundary-reference](https://github.com/561-group/x402-boundary-reference) | | Buy from an x402 seller with a pinned payee | [x402-exact-purchase-service](https://github.com/red-cup-engineering/x402-exact-purchase-service) | | Present structured material on the web | TUFTE, the web-page-tiling engine | | Build or host a web application | computer-web-platform | | Use an admitted inference provider | computer-inference-engine | | Qualify and fabricate source from an admitted work order | computer-systems-fabrication-engineering-services-section | [Resource JSON](https://engineering.561.group/resources.json) records the exact package names, selected versions and canonical source references. Several of these repositories are not public. Registry downloads and repository references require the owner's authorization, and public navigation grants no additional access to source repositories, private knowledge or paid services. ### Where do I go next in the Group? [Science](https://science.561.group/) · [Engineering](https://engineering.561.group/) · [Operations](https://operations.561.group/) · [Services](https://services.561.group/) · [Market](https://market.561.group/) · [Bazaar](https://bazaar.561.group/) · [Shop](https://shop.561.group/) ### What is here for software agents and readers following updates? This site publishes [`/llms.txt`](https://engineering.561.group/llms.txt), [`/llms-full.txt`](https://engineering.561.group/llms-full.txt) with every article as Markdown, and a Markdown twin at `index.md` under each article. [Resource JSON](https://engineering.561.group/resources.json) lists resource identities, access requirements and media types, and [Discovery JSON](https://engineering.561.group/discovery.json) identifies navigation, search and feeds. Search with [Search](https://engineering.561.group/search/), or follow [RSS](https://engineering.561.group/feed.rss.xml), [Atom](https://engineering.561.group/feed.atom.xml) or [JSON Feed](https://engineering.561.group/feed.json). To buy per-call operations, start from the market's [x402 discovery document](https://market.561.group/.well-known/x402) or [catalog](https://market.561.group/v1/catalog). This publication exposes readable documents and JSON; it does not advertise a tool-execution endpoint. --- # Paraconsistent federation: an ActivityPub inbox that keeps contradictions instead of last-writer-wins URL: https://engineering.561.group/activitypub-paraconsistent-inbox/ Published: 2026-10-17 Summary: An ActivityPub inbox that treats activities as claims and joins them in Belnap's knowledge order, so Create and Delete conflict instead of racing. ## Paraconsistent federation: an ActivityPub inbox that keeps contradictions instead of last-writer-wins A conventional ActivityPub server applies each inbound activity as it arrives, so a later `Delete` erases an earlier `Create` and two peers that disagree fight until one lands last. The Red Cup ActivityPub provider instead treats every signature-verified inbound activity as a *witnessed claim*, with polarity "for" or "against" and the activity's id as evidence, and folds claims with the Belnap knowledge join. A thing that one peer created and another deleted is reported as **contradicted**, with both witnesses, and the result is identical whatever order the activities arrived in. We ran the module to confirm both properties; the output is below. ### What is wrong with last-writer-wins in the fediverse? ActivityPub delivers activities to an inbox asynchronously, from multiple servers, with no global clock. A `Delete` from a moderator on one server and an `Update` from the author on another can arrive in either order at a third server. If the third server applies them in arrival order, its state depends on network timing, and two servers that received the same activities in different orders diverge permanently. The usual remedies add timestamps (which are claims by the sender), vector clocks (heavy), or an authority (which is the thing federation avoids). A different remedy is to stop pretending the inbox is deciding anything. An inbox receives *testimony*. The testimony may conflict. The honest state of a record that was created by one account and deleted by another is not "deleted" or "exists" but "told both ways, by these two witnesses". That is exactly the fourth value in Belnap's logic, introduced in [Reading HTTP in four values](https://engineering.561.group/http-status-four-valued-belnap/), and the same algebra the market sells in [Belnap's logic as an API](https://engineering.561.group/belnap-four-valued-logic-api/). ### How does an activity become a claim? The `./inbound` module of `@red-cup-engineering/activitypub-services-section` reads an already-verified activity. Signature and proof verification belong to Fedify, before this module sees the activity; the module is described as pure, with no clock and no network. It maps each activity to a subject, a polarity and claims, with the activity's own `id` as the citation: | Activity | Polarity | Claim | | --- | --- | --- | | `Create`, `Update` | for | the object's fields (an `Update` is a fresh witness, "monotone, not overwrite") | | `Delete` | against | the object's fields, or `exists: true` for a bare IRI or tombstone | | `Follow`, `Accept`, `Like`, `Announce`, `Block`, `Dislike` | for | a membership cell on the actor (`follows`, `accepted`, `likes`, `announces`, ...) | | `Undo` of a `Delete` | for | the object is back | | `Undo` of anything else | against | the wrapped claim, inverted | | `Reject` | against | the rejected activity's membership cell | An activity that cannot be placed (no subject, an unhandled type) becomes a *refused* batch with its reason, never a silent drop. At the inbox boundary, `receiveInbound` returns `400` for a non-ActivityStreams body or an unplaceable activity, and `202` with the observation otherwise, which matches ActivityPub's rule that a successful inbox POST is `202 Accepted` with asynchronous processing. ### How are claims combined? `settleObservations` turns each observation into a cell of subject, predicate and object, with its `for` and `against` witness sets, and hands them to the content-addressed cell set of the Group's evidence library, which performs the Belnap knowledge join: duplicate, concurrent and opposite tellings merge by union of witnesses. The module then partitions the cells: ```js if (witnessed.for.length > 0 && witnessed.against.length > 0) { out.contradicted.push({ ...base, affirmedBy: citations(witnessed.for), deniedBy: citations(witnessed.against) }); } else if (witnessed.for.length > 0) { out.affirmed.push({ ...base, citation: citations(witnessed.for) }); } else { out.denied.push({ ...base, citation: citations(witnessed.against) }); } ``` (Excerpt from `inbound.mjs`, abridged.) A claim told only "for" is affirmed; only "against" is denied; both is contradicted with the lists `affirmedBy` and `deniedBy`. Nothing is overwritten and nothing is discarded. The module's own comment states the guarantee: the fold "is commutative, associative and idempotent so delivery order cannot matter." ### What does a run show? We ran the module on 2026-10-22 with two activities about one note: a `Create` by an author at one origin and a `Delete` by a moderator at another. ```js const note = { id: 'https://a.example/notes/1', type: 'Note', content: 'hello' }; const create = { '@context': 'https://www.w3.org/ns/activitystreams', id: 'https://a.example/activities/1', type: 'Create', actor: 'https://a.example/actors/alice', object: note }; const del = { '@context': 'https://www.w3.org/ns/activitystreams', id: 'https://b.example/activities/9', type: 'Delete', actor: 'https://b.example/actors/mod', object: note }; ``` `receiveInbound(create)` returned status `202`. Settling `[create, del]` produced two contradicted cells, one for the note's `content` and one for its `type`: ```json { "affirmed": [], "denied": [], "contradicted": [ { "subject": "https://a.example/notes/1", "predicate": "content", "object": "hello", "affirmedBy": ["https://a.example/activities/1"], "deniedBy": ["https://b.example/activities/9"] }, { "subject": "https://a.example/notes/1", "predicate": "type", "object": "Note", "affirmedBy": ["https://a.example/activities/1"], "deniedBy": ["https://b.example/activities/9"] } ] } ``` We then settled `[del, create]` in the opposite order and compared the serialized results. They were identical. The output states what each peer told the inbox, preserves both activity ids as evidence, and does not claim to know whether the note "really" exists. ### What does the outbox do with a contradiction? `./outbox-projection` is the mirror. A subject's settled algebra becomes a `Create` activity, flagged `_contested` when any of its cells is contradicted, and the actor's outbox is an `OrderedCollection`, newest first. A downstream reader sees that the claim is disputed instead of receiving a confident-looking state that depended on a race. ### Why would anyone want this? Three reasons, in increasing order of strangeness. 1. **Moderation transparency.** If a deletion is a claim with a witness, a server can show "removed by X, contested by Y" rather than hiding the dispute. The decision procedure, whether a human or a policy resolves a contradiction, lives outside the inbox and can be audited against the preserved witnesses. 2. **Convergence without coordination.** Because the join is commutative, associative and idempotent, two servers that have received the same set of activities hold the same settled state, whatever order or duplication occurred. That is the property conflict-free replicated data types provide, obtained here by reading activities as evidence. 3. **A common substrate.** The same cell, evidence and join machinery reads HTTP probes, citation checks and federated activities. An agent that knows what `contested` means in one place knows it in all of them. ### What does this not do? It does not decide anything. A contradicted cell stays contradicted until a policy outside this module acts, and it does not tell you whose claim should win. It does not verify activities, since Fedify does that first. It does not infer truth: the module only reads what was admitted. Its mapping from activity type to polarity is a modeling choice; for example an `Update` is treated as another affirmative witness, not an overwrite, so a corrected field appears as a second object value for the same predicate and is not merged into one. ### How does this relate to the wider transport design? The provider is the protocol layer of a larger design the Group calls ActivityPub++, a specification draft whose idea is that one actor has one public ActivityPub face, and its activities carry a CloudEvents envelope whose data is an A2A agent message with a single content-addressed CBOR part. The market's own outbox (130 `Offer` activities whose objects are `application/sen+cbor` documents named by `ni:` addresses) is a read-only instance of the same shape ([One catalog, five machine faces](https://engineering.561.group/x402-one-catalog-machine-interfaces/)). That nesting is design-in-progress, not a ratified standard, and we say so. For how the provider itself is assembled and what is live today, see [ActivityPub publication provider](https://engineering.561.group/activitypub-publication-provider/). --- # Repeat x402 purchases with X-Payment-Recovery: get the same bytes after a dropped connection URL: https://engineering.561.group/x402-payment-recovery-header/ Published: 2026-10-14 Summary: How an x402 seller returns an already-paid response when the buyer repeats the same signed request with a private X-Payment-Recovery token. ## Repeat x402 purchases with X-Payment-Recovery: get the same bytes after a dropped connection If a buyer pays for an x402 resource and the connection dies before the bytes arrive, the buyer should repeat the identical request with the identical `PAYMENT-SIGNATURE` and a private `X-Payment-Recovery` token, and the seller should return the original purchased response rather than a second charge or an error. The Red Cup seller at market.561.group implements this for its digital goods: seven priced publications and the Koios intelligence briefing, each marked with a `recovery` object in the public catalog. The mechanism reuses one idea, that an EIP-3009 authorization is single-use, to make a retry safe. ### Why does a plain x402 retry fail? A buyer's payment is a signed EIP-3009 authorization with a random nonce. Once the facilitator has settled it on chain, that nonce is spent. If the buyer's HTTP client times out after settlement and simply retries with the same signature, the facilitator rejects it as already used, and an unprepared seller turns that into an error. The buyer has paid and holds nothing. If instead the buyer signs a new authorization, it pays twice. For a $0.0012 JSON lookup the buyer shrugs and pays again. For a $9.00 or $12.00 publication, or a $0.25 briefing that changes daily, losing the response is a real defect. That is the case recovery covers. It is deliberately opt-in: the seller's stateless computations "do not opt in and retain no customer responses". ### How do I know an offer is recoverable? The seller declares it in the catalog. For the Koios briefing, `GET https://market.561.group/v1/catalog` returns this on the offer: ```json "recovery": { "method": "repeat-same-signed-request", "requiredHeader": "X-Payment-Recovery", "token": "32 random bytes as 64 lowercase hex characters, saved privately before payment", "preserves": "exact-purchased-response" } ``` Eight offers carry it at the time of writing: seven publications from $9.00 to $12.00 and the briefing at $0.25. ### What does the buyer send? Before signing anything, the buyer generates a 32-byte random token and encodes it as 64 lowercase hex characters. It then sends: ```http GET /v1/koios/briefing/current HTTP/1.1 Host: market.561.group PAYMENT-SIGNATURE: X-Payment-Recovery: 3f9c…(64 hex characters, random, private) ``` The buyer saves the token **together with the exact signed request, before sending it**. The Red Cup purchase command writes both to a file with mode 0600 and sends only afterwards; if the process dies, `--resume` replays the saved request without needing the private key: ```bash purchase-market-publication \ --url https://market.561.group/v1/koios/briefing/current \ --max-amount-atomic 250000 \ --output ./briefing.json \ --recovery-file ./briefing.purchase.json # after an interruption: purchase-market-publication --resume ./briefing.purchase.json ``` The `--max-amount-atomic 250000` is the buyer's own ceiling in atomic USDC. The command refuses a challenge above it. ### Why is the signature not enough to recover? An EIP-3009 payment authorization is published on the chain when it settles. Anyone can read the payer, nonce and signature from the transaction. If the signature were the only credential, any observer could replay it and download the purchased content. The recovery token is the part that never leaves the buyer, so only the buyer who made the original request can retrieve the result. The seller therefore refuses a signed request on a recoverable offer unless the token is present and well formed. We can show that on the live endpoint without paying. A garbage `PAYMENT-SIGNATURE` header and no token yields: ```bash curl -s -i https://market.561.group/v1/koios/briefing/current -H 'PAYMENT-SIGNATURE: Zm9v' # HTTP/2 400 # {"error":"recoverable purchases require a valid X-Payment-Recovery token"} ``` while the same request with no payment header at all returns the normal `402` challenge. ### How does the seller bind the retry to the original purchase? The engine's recovery module (`paid-response-recovery.mjs` in the Red Cup x402 engine) computes two digests from the request: - an **identity** that is the SHA-256 of `{network, asset, from, nonce}` for the EIP-3009 authorization, lower-cased: the payment's natural key; and - a **credential digest** that is the SHA-256 of the signature, the recovery token and the accepted payment terms (`scheme`, `network`, `asset`, `amount`, `payTo`): a value that changes if the signature or token changes, so a different credential reusing the same nonce is rejected. It also digests the request itself, the method, the URL and the body bytes, without storing the body. Before settlement, an atomic conditional write reserves that authorization for exactly one request digest in the private store. The seller stores the prepared response bytes there before settlement, keyed by the identity. Raw payment signatures and submitted request bodies are not retained. On a retry, the middleware checks for a completed purchase before it contacts the facilitator, because the facilitator would reject the spent nonce. The outcomes are these: | Situation | Status | Meaning | | --- | --- | --- | | Purchase complete | original status (200) | The original bytes, with the original `PAYMENT-RESPONSE` receipt, even if the publication has since changed or disappeared | | Purchase still settling | 503 with `Retry-After: 2` | Repeat the exact request shortly | | Authorization already bound to a different request | 409 | The nonce was used for another URL, method or body | | Authorization expired without settlement | 410 | Two independent Base providers say it never settled; the buyer may create a new authorization | | Token missing or malformed | 400 | Refused before payment | | Recovery store unavailable | 503 | Retry; the buyer is not charged by this path | Note that the `410` rule is deliberately conservative. The seller asks two independent Base RPC providers and only then declares the authorization dead, because telling a buyer to sign again while the first payment is still in flight would cause a double spend. ### What if the seller crashed after the payment was mined? If the worker stops after the transfer is mined but before it saved the receipt, recovery corroborates the authorization's nonce and the exact USDC transfer in the successful receipt through two Base RPC providers and then completes the same purchase. An unavailable or conflicting chain observation never grants access. Recovery covers Base EIP-3009 authorizations valid for at most one hour and responses up to 16 MiB. ### What does the buyer library do differently? The Red Cup buyer (`x402-exact-purchase-service`, MIT) can form a durable signature separately from sending it: `authorizeQuotedHttpPayment` returns a replayable `PAYMENT-SIGNATURE` after checking resource, representation and term drift, and the library documents that the buyer "must durably retain it in a private original recovery record before sending." It treats the signature as sensitive for the same reason: whoever holds the signature and the token can retrieve the purchase. See [Never trust the payee in a 402 challenge](https://engineering.561.group/verify-x402-payee-buyer-side/) for the checks that run before signing. ### What are the honest limits? The seller's documentation says it plainly: the reference reservation "deduplicates concurrent retention calls within one boundary process", while the caller still owns cross-process exclusion, durable append atomicity, recovery and idempotence of the effect after settlement. This boundary "does not claim crash-exactly-once production." Recovery also does not make a delivery an acceptance: a recovered response proves the seller can return the bytes it prepared, not that the buyer read them. And recovery is for digital goods whose bytes can be stored; the stateless computation offers intentionally keep nothing. ### How do I add this to my own seller? 1. Mark specific routes recoverable in your own catalog and publish the header name and token format, as above. 2. Store the prepared response durably *before* asking the facilitator to settle. 3. Key the record by `{network, asset, payer, nonce}` and bind it with an atomic conditional write to one request digest. 4. Check for a completed record *before* calling the facilitator. 5. Return 409, 503 and 410 as in the table and never tell a buyer to sign again until chain evidence says the first authorization failed. For the surrounding set of seller behaviors, return to [what an x402 seller should do beyond the spec](https://engineering.561.group/x402-seller-design/). --- # Per-byte x402 pricing: deterministic workload bands in atomic USDC URL: https://engineering.561.group/x402-per-byte-pricing/ Published: 2026-10-14 Summary: How a seller prices x402 calls by canonical JSON size: $0.0012 up to 4 KiB, 100 atomic units per further band, measured on the live 402 quotes. ## Per-byte x402 pricing: deterministic workload bands in atomic USDC An x402 seller can price a call by the size of its input without a quote token, a price table or a second round trip, provided the price is a pure function of the admitted request body. The Red Cup seller charges $0.0012 for the first 4,096 bytes of canonical JSON and 100 atomic USDC units ($0.0001) for each further started 4,096-byte band, and the same body therefore produces the same amount on the unpaid probe and on the paid retry. We tested this against the live `402` responses on 2026-10-22 and tabulate the measurements below. ### What is the pricing rule? The 69 standards and conversion offers in the market catalog (JSON, CSV, CBOR, XML, HTML, TOML, YAML, URI templates, MIME types, HTTP dates, multihash and more) publish a *workload tariff* in their catalog entry. For the JSON Pointer offer the live catalog says: ```json "pricing": { "mode": "canonical-json-byte-bands", "includedBytes": 4096, "additionalUnitBytes": 4096, "additionalUnitAtomic": "100", "maximumAtomic": "9600", "minimumAtomic": "1200", "priceBasis": "starting-price", "settlementDecimals": 6, "quote": "native-x402-payment-required", "metering": "UTF-8 bytes of canonical JSON after input admission; whitespace and alternate escaping do not change the price" } ``` In words: the minimum is 1,200 atomic units, which is $0.0012 because USDC has six decimals. Each started band of 4,096 bytes beyond the included 4,096 adds 100 atomic units. The `quote` field says the amount is delivered in the standard x402 payment requirement, not in a custom header. For a body of *n* canonical bytes: `amount = 1200 + 100 × ceil(max(0, n − 4096) / 4096)` atomic units. ### What do the live quotes show? We sent unpaid `POST /v1/data/json-pointer` requests with a string value of increasing length and decoded `accepts[0].amount` from the `PAYMENT-REQUIRED` header. No payment was signed. The *n* column is the exact request body size in bytes (compact JSON). | Body bytes (n) | Bands beyond 4,096 | Quoted amount (atomic) | In dollars | | --- | --- | --- | --- | | 43 | 0 | 1,200 | $0.0012 | | 3,033 | 0 | 1,200 | $0.0012 | | 4,083 | 0 | 1,200 | $0.0012 | | 4,113 | 1 | 1,300 | $0.0013 | | 5,033 | 1 | 1,300 | $0.0013 | | 9,033 | 2 | 1,400 | $0.0014 | | 20,033 | 4 | 1,600 | $0.0016 | | 60,033 | 14 | 2,600 | $0.0026 | | 65,033 | 15 | 2,700 | $0.0027 | Every row matches the formula. Two more probes tested the "canonical" claim: - A 5,033-byte body pretty-printed with indentation and padded with 20,000 trailing spaces, 25,061 bytes on the wire, quoted **1,300**, the same as the compact version. - The same value with each `a` written as the escape `a`, 30,033 bytes on the wire, also quoted **1,300**. So neither whitespace nor alternate escaping moves the price. The meter reads canonical bytes after the body has been admitted, not the `Content-Length` header and not the raw bytes. ### Why derive the price from the body at all? A fixed price is simple, but a JSON conversion of 20 bytes and one of 60,000 bytes do not cost the seller the same. A per-call dynamic price solves it, but only if the buyer can still *know the price before signing*. In x402 the amount in the challenge is what the buyer signs. If the seller computes a different amount when the signed request returns, the verification fails or, worse, the buyer pays more than it saw. The Red Cup seller avoids that failure in three ways: 1. **The body is admitted before the quote.** The seller reads the request through the bounded canonical JSON codec ([Refuse before you charge](https://engineering.561.group/refuse-before-you-charge-x402/)), and only the admitted body enters the x402 adapter's `getBody` method. The official SDK's dynamic price function resolves from that body before verification. 2. **No ambient inputs.** The price is not derived from a buyer-supplied `Content-Length`, an unsigned price field, a traffic counter or a clock. Two identical requests at different times quote identically. 3. **A small-request signature does not buy a large request.** The signed amount covers the exact band; the source documents that a small-request authorization does not buy a larger-request tariff. A 60,000-byte body is quoted at 2,600, and a signature for 1,200 does not satisfy it. There is no separate quote token, repayment loop, price worker or synthetic settlement protocol. The standard `402` is the quote. ### What is the maximum a buyer can be charged? The catalog declares a `maximumAtomic` of 9,600 ($0.0096) for these offers. In practice the input limit is lower than the point where that cap binds: the JSON offers cap input at 64 KiB, which by the formula costs at most 2,700 atomic units ($0.0027). The 65,033-byte probe above was the largest we sent. House capability offers carry the maximum tariff as their spending bound, and a buyer library should compare the challenge's amount against its own configured ceiling before signing, whatever the catalog says. The Red Cup buyer takes `maximumAmount` in atomic units, never a floating-point dollar amount. ### Why use atomic integers instead of dollars? The catalog's `price` field is a human string (`"$0.0012"`) and the challenge's `amount` is an integer string (`"1200"`). The seller treats the integer as authoritative and derives every displayed price from it. Atomic prices and workload bands are exact integers with no dollar conversion and no assumed token decimal count in the engine; a seller may quote an exact native consideration as `{ amountAtomic: "3", asset: "eip155:5615611/erc20:0x…" }`. Floating-point price math in a payment path accumulates rounding error, and a buyer that parses `"$0.0012"` as a float can mis-sum a budget. The engine's spending ceilings are parsed as exact atomic units, and an excess decimal is refused instead of rounded. ### Is this a measurement of cost? No, and the seller says so. The tariff is a commercial workload tariff, not a benchmark of CPU consumption, provider monetary cost, physical energy or demand elasticity. The catalog's own `evidenceScope` field reads: "commercial-workload-tariff; no measured CPU, monetary-cost, physical-energy or customer-demand claim". We have not measured a margin and do not report one. The settlement journal does retain the canonical input byte count and the quoted amount for each paid call, so a future cost study has the denominator it needs. ### Can price depend on usage after the fact? The engine also supports the official `upto` scheme, where the route price is a ceiling the buyer authorizes and the handler reports the actual consideration afterwards (through the `Settlement-Overrides` header in the fetch transport). The shared before-settle hook refuses a non-canonical amount or one above the signed ceiling before any facilitator call, and the internal override header is stripped from every delivered response so a request header can never control settlement. That mode is source-tested with SDK doubles; the market catalog itself remains on the fixed `exact` scheme until an owning declaration and a real meter exist. An elapsed interval is not CPU usage, so we do not bill by one. ### How do I reproduce this? ```bash python3 - <<'PY' import json, urllib.request, base64 def amount(body): req = urllib.request.Request("https://market.561.group/v1/data/json-pointer", data=body, headers={"content-type": "application/json"}, method="POST") try: urllib.request.urlopen(req) except urllib.error.HTTPError as e: return json.loads(base64.b64decode(e.headers["payment-required"]))["accepts"][0]["amount"] for n in (10, 5000, 9000, 60000): body = json.dumps({"value": {"x": "a" * n}, "pointer": "/x"}, separators=(",", ":")).encode() print(len(body), amount(body)) PY ``` The script signs and pays nothing; it reads the `402` and prints the quote. For the rest of the seller's behaviors, see [what an x402 seller should do beyond the spec](https://engineering.561.group/x402-seller-design/), and for a complete decoded challenge, [How an x402 payment works](https://engineering.561.group/how-an-x402-payment-works/). --- # Sign-in-with-X on an x402 402: stateless wallet login for returning agents URL: https://engineering.561.group/x402-sign-in-with-x/ Published: 2026-10-14 Summary: How an x402 seller attaches a CAIP-122 sign-in challenge to its 402, verifies EIP-191 and EIP-1271 proofs with stateless HMAC nonces, and grants wallets access. ## Sign-in-with-X on an x402 402: stateless wallet login for returning agents Sign-in-with-X (SIWX) is an x402 extension that lets a seller put a wallet-login challenge inside its `402 Payment Required` response, so that a wallet which has already been granted access can prove it controls its address instead of paying again. The Red Cup seller attaches this challenge to the 402s we probed (four routes across GET and POST, JSON, publications and chain reads), verifies the proof without storing any session, and decides separately what each proven wallet may use. This article shows the live challenge, the verification rules from source, and the design choices that keep it stateless. ### What does the live 402 contain? Request any paid route without payment and decode the `PAYMENT-REQUIRED` header ([how to decode it](https://engineering.561.group/how-an-x402-payment-works/)). Under `extensions` there is a `sign-in-with-x` entry. Captured from `POST /v1/data/json-pointer` on 2026-10-22 (the nonce and times differ on every request): ```json "sign-in-with-x": { "info": { "domain": "market.561.group", "uri": "https://market.561.group/v1/data/json-pointer", "version": "1", "nonce": "f5c70d9ea35239c9947516baf33ec590", "issuedAt": "2026-10-22T00:30:28.688Z", "expirationTime": "2026-10-22T00:35:28.688Z", "statement": "Sign in to use what this wallet has been granted at market.561.group.", "resources": ["https://market.561.group/v1/data/json-pointer"] }, "supportedChains": [{ "chainId": "eip155:8453", "type": "eip191" }], "schema": { "required": ["domain","address","uri","version","chainId","type","nonce","issuedAt","signature"], "...": "..." } } ``` This is an EIP-4361 ("Sign-In with Ethereum") message template in the CAIP-122 shape the x402 extension specifies: a domain, a URI, a nonce, an issue time and expiry, a human statement, and the resources the proof covers. The client fills in its `address`, signs the message with its wallet, and returns the result as base64 JSON in a `SIGN-IN-WITH-X` request header. ### Why attach login to a payment challenge? x402 assumes anonymous strangers who pay per call. Real sellers also have wallets they know: a partner granted free calls, a subscriber who prepaid, a buyer whose earlier purchase entitles them to a re-download. Without SIWX, the seller must either mint API keys, which defeats the point of wallet-native commerce, or make the entitled wallet pay again. With SIWX the 402 itself says "if you are a wallet we know, here is how to prove it". The agent either pays or signs; both are one round trip from the challenge. The seller's statement is deliberately neutral: it does not promise a grant. Whether a proven wallet is entitled to anything is a separate decision, made from an explicit grants record owned by the deployment. The engine refuses to construct the market with sign-in enabled unless that record is supplied, and disabling sign-in neither reads nor requires it. ### How does the seller issue a challenge without storing it? A common login design stores each nonce, then looks it up on return. That puts a database in the hot path of every unpaid request. The engine instead derives the nonce: ```js function nonceFor(secret, issuedAt, uri) { return createHmac("sha256", secret) .update(`sign-in-with-x\n${issuedAt}\n${uri}`) .digest("hex").slice(0, 32); } ``` (From `sign-in-with-x.mjs` in the Red Cup x402 engine.) The nonce is a keyed hash of the issue time and the resource URI under a deployment secret of at least 16 characters. When a proof comes back, the seller recomputes the HMAC from the `issuedAt` and `uri` in the proof and compares with `timingSafeEqual`. If they match, the seller knows it issued a challenge for exactly this resource at exactly this time, without ever having recorded it. No session table, no cache, no cleanup job. Two further decisions harden the scheme: - **The origin comes from configuration, not the request.** The resource URI is rebased onto the configured origin, because "the Host header is the client's to set, the origin is the deployment's". A client cannot make the seller sign off on `https://evil.example/` by lying about Host. - **The window is five minutes and only for the named resource.** A proof is usable for the challenge's five-minute window, and only for the URI it names. A proof harvested from one route cannot be replayed on another. ### What exactly does the verifier check? `verifySignIn` runs a fixed sequence and returns either `{ verified: true, account, address }` or `{ verified: false, reason }`. The refusal reasons double as documentation: | Check | Refusal reason | | --- | --- | | `domain` equals the configured origin's host | `domain-mismatch` | | `uri` equals the request's resource rebased on the origin | `uri-mismatch` | | `version` is `"1"` and `chainId` matches `eip155:` | `unsupported-chain-or-version` | | `address` is a 20-byte hex address | `malformed-address` | | `issuedAt` is no more than 30 s in the future and within the five-minute window | `outside-window` | | `expirationTime`, if present, is in the future | `expired` | | `notBefore`, if present, has passed | `not-yet-valid` | | the HMAC nonce matches | `unknown-challenge` | | the signature recovers to the address | `bad-signature` | Only after all these does the verifier build the EIP-4361 text byte for byte as the `siwe` library writes it, hash it with the EIP-191 personal-message prefix, and recover the signer address from the 65-byte signature. The account identity returned is the CAIP-10 style string `eip155:8453:0xChecksummedAddress`. ### What about smart-contract wallets? Many agent wallets are contract accounts, which cannot produce a plain secp256k1 signature. For those, EIP-1271 defines an on-chain `isValidSignature` check. The engine does not hard-wire a chain client. If the recovered signer does not equal the address, the verifier calls an injected `verifyContractSignature({ chainId, address, digest, signature })` function if one was supplied, and treats a thrown error as failure. The chain read is therefore the deployment's choice of RPC provider, budget and timeout, not something buried in the library. The cryptography itself (keccak-256, secp256k1 recovery, checksum addressing) comes from the Group's own data-layer package and is exercised by the engine's tests; the verifier does not call out to a third-party service. ### How do I try it? You can see the challenge without any wallet: ```bash curl -s -i -X POST https://market.561.group/v1/data/json-pointer \ -H 'content-type: application/json' \ -d '{"value":1,"pointer":""}' \ | grep -i '^payment-required' | cut -d' ' -f2 | tr -d '\r' | base64 -d \ | jq '.extensions["sign-in-with-x"].info' ``` To answer it, a client would format the message from `info` with its own address, sign it with `personal_sign`, and send `SIGN-IN-WITH-X: base64(JSON)` containing `domain`, `address`, `uri`, `version`, `chainId`, `type`, `nonce`, `issuedAt` and `signature`. The engine's `encodeSignInHeader` and `decodeSignInHeader` do the base64 JSON step and enforce an 8,192-character limit on the header. ### What are the limits? SIWX proves control of an address; it does not say the address is entitled. On this seller, a verified wallet is only as privileged as the grants record, and we do not publish that record. We probed four routes, not all 130, and make no public claim here about how many wallets hold grants. A five-minute proof is replayable inside its window by anyone who sees it, which is why it is scoped to a single resource and carried in a header over TLS; a deployment that needs single-use proofs must add its own nonce store. And EVM only: the verifier rejects non-`eip155` chains. For the other seller policies around the 402, see [what an x402 seller should do beyond the spec](https://engineering.561.group/x402-seller-design/). --- # Belnap four-valued logic as an API: knowledge join, truth join, negation and conflation per call URL: https://engineering.561.group/belnap-four-valued-logic-api/ Published: 2026-10-13 Summary: Eight pay-per-call endpoints implement Belnap's FOUR algebra over x402: join, meet, negate, conflate, convert and census, with truth tables and live examples. ## Belnap four-valued logic as an API: knowledge join, truth join, negation and conflation per call Belnap's four-valued logic (Belnap 1977) has two lattice orders over four values, and an agent combining evidence from several sources needs both of them. The market at market.561.group sells eight small operations over that algebra, each at $0.001 or $0.002 per call over x402: rename a point between naming families, join or meet in the knowledge order, join or meet in the truth order, negate, conflate, and count. All of them refuse unknown names before payment. This article gives the full tables, the live endpoint contracts and the reason one would want a paid logic service at all. ### What are the four values, in the market's names? A point is a pair (told-for, told-against). The extremal family, which the examples below use, names the four points `held` (told for, not against), `denied` (against, not for), `contested` (both) and `unknown` (neither). Belnap's classical names are true, false, both and neither. The same four points have names in three other families, and the conversion offer renames between them without changing the point: | Family | Names | | --- | --- | | extremal | `held`, `denied`, `contested`, `unknown` (for-only, against-only, both, neither) | | truth | `true`, `false`, `both`, `neither` (same order) | | told | `told true`, `told false`, `told both`, `told none` (same order) | | knowledge | `absurd`, `potential`, `active`, `stable` (four more names; use the conversion offer to map them) | Operations that take two points require both to be from the same family, so that an agent cannot silently mix `true` with `held`; it has to call the conversion offer, which says what it does: "Rename one Belnap FOUR point among knowledge, told, truth and extremal families, preserving its told-for/told-against sides. For example held becomes told true." ### Why are there two orders? Information and truth are different axes. In the **knowledge order**, `unknown` is the bottom (nothing known), `contested` is the top (everything told), and `held` and `denied` are incomparable in between. Joining in this order *accumulates evidence*: if one source tells you a claim is held and another tells you it is denied, the accumulated state is `contested`. Meeting in this order keeps only what both sources say. In the **truth order**, `denied` is the bottom and `held` is the top, and `contested` and `unknown` sit between. Joining in this order is a disjunction: a claim is held if either operand holds it. Meeting is a conjunction. Negation swaps `held` and `denied`. A system that checks "is the claim established" by joining in the truth order, and "do my sources conflict" by joining in the knowledge order, will not confuse the two. That separation is why the market sells both rather than one. ### What does each operation compute? With a point written as (for, against): | Offer | Route | Rule | Example from the catalog | | --- | --- | --- | --- | | Knowledge join | `/v1/four/reading-knowledge-join` | (for OR for, against OR against) | held + denied = **contested** | | Knowledge meet | `/v1/four/reading-knowledge-meet` | (for AND for, against AND against) | held and denied = **unknown** | | Truth join | `/v1/four/reading-truth-join` | (for OR for, against AND against) | held and denied = **held** | | Truth conjunction | `/v1/four/reading-truth-meet` | (for AND for, against OR against); empty input is the unit | | | Negation | `/v1/four/reading-negate` | swap for and against | held becomes **denied**; unknown and contested are fixed | | Conflation | `/v1/four/reading-conflate` | exchange unknown and contested; fix held and denied | | | Name conversion | `/v1/four/reading-convert` | rename between families | `{family: told, name: held}` gives **told true** | | Point census | `/v1/four/reading-census` | count up to 14,627 named points by knowledge-family name | | The first two rows' examples are the catalog's own; the other tables below we derived from the rules in the descriptions and checked against those examples. The knowledge join, as a table over the extremal names: | ⊕ | held | denied | contested | unknown | | --- | --- | --- | --- | --- | | **held** | held | contested | contested | held | | **denied** | contested | denied | contested | denied | | **contested** | contested | contested | contested | contested | | **unknown** | held | denied | contested | unknown | and the truth join: | ∨ | held | denied | contested | unknown | | --- | --- | --- | --- | --- | | **held** | held | held | held | held | | **denied** | held | denied | contested | unknown | | **contested** | held | contested | contested | held | | **unknown** | held | unknown | held | unknown | Note that `unknown` is the identity of knowledge join and `denied` is the identity of truth join. Both operations are commutative, associative and idempotent, so the order in which evidence arrives never changes the result. That property is what makes them safe for distributed collection: two nodes that have seen the same evidence in different orders agree. The paraconsistent inbox in [Paraconsistent federation](https://engineering.561.group/activitypub-paraconsistent-inbox/) relies on exactly this. ### How do I call one? Each operation is a `POST` of a small JSON body. Without payment you get the 402 challenge, which shows the quote: ```bash curl -s -i -X POST https://market.561.group/v1/four/reading-knowledge-join \ -H 'content-type: application/json' \ -d '{"left":"held","right":"denied"}' | grep -i '^HTTP\|^payment-required' | cut -c1-80 ``` A paid call to this route returns `contested`, per the catalog's example. A body naming something outside the four families is refused with `400` before any challenge: ```bash curl -s -X POST https://market.561.group/v1/four/reading-negate \ -H 'content-type: application/json' -d '{"name":"maybe"}' # {"type":"urn:561-group:web-server:problem:request-validation","title":"Invalid body", ... "keyword":"enum" ...} ``` The input schema's `name` is an enum of all sixteen accepted names. The offer descriptions require both operands of a binary operation to share a family. In our unpaid probe a mixed body (`held` with `true`) still received a `402`, so that family check is not part of the schema-level refusal we could observe; we did not pay to see the paid result. The catalog gives each offer's body schema and an example under [`/v1/catalog`](https://market.561.group/v1/catalog); an agent can find them through the [MCP face](https://engineering.561.group/x402-one-catalog-machine-interfaces/) with `search_apis` and the query `belnap`. ### Why would anyone pay for a few lines of logic? Honest answer: you probably shouldn't, if you run the algebra locally. The operations are pure and tiny. We list them for three reasons that have nothing to do with computational difficulty. 1. **A reference implementation agents can call.** When two services disagree about what "conflation" means, a shared call settles it. The offers are the specification made executable, and the descriptions state precisely what they do not do: "No witness creation or assertion of truth", "Names are not verified observations or independent witnesses", "This acts on abstract points, not on source witness sets". 2. **The pay-per-call plumbing at the cheapest price point.** At $0.001 an offer exercises the whole x402 path (challenge, validation, signing, settlement) with almost nothing at stake, which makes it a convenient first purchase for an agent that is learning to pay. 3. **Integration with the higher offers.** Other offers return FOUR-valued results directly. The reference check endpoint, `POST /v1/reference-check`, checks up to 25 citation strings against CrossRef, OpenAlex and Open Library, and returns for each item a house FOUR reading: `true` means supported, `false` means the identifier resolves to another work, `both` means sources disagree, and `neither` means nothing found. The book-record offer returns `true` when found and `neither` on refusal. A client can fold many such readings with the knowledge join. ### What do the offers deliberately not do? The catalog's wording is careful, and we repeat it. These operations act on abstract points. They do not create witnesses, assert real-world truth, or collapse to Boolean. A `contested` result means the inputs said both things, not that reality did. Meets and joins over named points are not verified observations, so the algebra gives you a defensible way to *combine what you were told* and no way to know whether you were told the truth. The same restraint appears in how the Group's front page reads [HTTP in four values](https://engineering.561.group/http-status-four-valued-belnap/): the reading reports what was observed and keeps the contradictions. ### Where does this fit? The implementation lives in the Group's data layer (the `readingAs` export and its siblings), the lowest layer in the dependency order data, code, networking, systems. The market offers are a thin payment shell over it. For how a pay-per-call shell is built, see [what an x402 seller should do beyond the spec](https://engineering.561.group/x402-seller-design/). --- # Refuse before you charge: how an x402 API stops billing agents for bad requests URL: https://engineering.561.group/refuse-before-you-charge-x402/ Published: 2026-10-13 Summary: Validate the body and refuse with 400, 415 or 422 before any 402 challenge, and cancel settlement if the handler fails. Real live responses included. ## Refuse before you charge: how an x402 API stops billing agents for bad requests To stop charging agents for bad requests, put validation in front of the payment challenge: an x402 seller should answer a request that can never succeed with `400`, `415` or `422` and no `PAYMENT-REQUIRED` header, and should issue a `402` only for a request it is prepared to fulfil. Then, because handlers can still fail, cancel the signed payment instead of settling it when the handler returns an error. The Red Cup seller at market.561.group does both, and the responses below were captured from the live endpoint on 2026-10-22. ### Why is charging for a bad request a problem specific to agents? A human who pays for a broken download sends an email. An agent that pays for a broken call has already spent: the spend authorization is signed, possibly settled, and the agent's budget is lower by an amount it cannot dispute through any channel the protocol defines. The x402 specification standardizes the challenge and the payment, not the order in which a seller validates things. The default order in many tutorials is the order of middleware: payment first, handler second, validation inside the handler. That order makes every typo a purchase. The order should be the reverse of the order of cost. Checks that cost the seller nothing (is it JSON, does it match the schema, is it within size limits) come first. Quoting comes second. Payment verification and settlement, which involve a facilitator and a chain, come last. ### What does a bad request look like on the live seller? All of these target `POST /v1/data/json-pointer`, whose body schema requires a string `pointer` and a `value`, with no additional properties. None of them returns a `402`. | Request body | Status | Content type | Body (abbreviated) | | --- | --- | --- | --- | | `{"nope":` (truncated JSON) | 400 | `application/json` | `{"error":"request body must be valid JSON"}` | | `{"value":1}` (missing `pointer`) | 400 | `application/problem+json` | issue: `must have required property 'pointer'` | | `{"value":1,"pointer":"/a","extra":true}` | 400 | `application/problem+json` | issue: `must NOT have additional properties` | | `{"value":1,"pointer":5}` | 400 | `application/problem+json` | issue at `/pointer`: `must be string` | | `{"value":1,"value":2,"pointer":""}` (duplicate member) | 422 | `application/json` | `{"error":"duplicate-key at $.value: duplicate object name: \"value\"","code":"duplicate-key","path":"$.value"}` | | any body with `content-type: text/plain` | 415 | `application/problem+json` | `expected application/json` | | `GET` on a POST-only offer | 405 | | | Reproduce the table with curl. This costs nothing: ```bash U=https://market.561.group/v1/data/json-pointer curl -s -i -X POST $U -H 'content-type: application/json' -d '{"value":1,"pointer":5}' ``` Every one of those responses has `cache-control: no-store` and none has a `payment-required` header. Only the well-formed body ```json {"value":{"a/b":[1,null]},"pointer":"/a~1b/1"} ``` reaches the `402`. The refusal bodies are RFC 9457 `application/problem+json` documents with an `issues` array naming the JSON path and the failed keyword, which an agent can read and repair without a human. ### Why do duplicate JSON members get a 422? JSON allows an object to repeat a name, and parsers disagree about which occurrence wins. If a paid offer silently chose one, the buyer would pay for an answer to a question the seller guessed. The Red Cup seller's intake admits received bytes through a bounded canonical JSON codec before quoting or executing anything: duplicate members, malformed UTF-8 or Unicode, and non-finite numbers are refused rather than resolved. The result is `422 Unprocessable`, distinct from the `400` of a syntactically broken body. The distinction is useful to a client: `400` means "fix the document", `422` means "the document parses but the content is ambiguous". The same principle applies to every offer in the catalog. Offers that convert formats refuse unrepresentable inputs before payment: the CSV converter refuses duplicate headers and ragged records, and the FOUR-valued logic offers refuse unknown value names: ```bash curl -s -i -X POST https://market.561.group/v1/four/reading-negate \ -H 'content-type: application/json' -d '{"name":"maybe"}' # HTTP/2 400 ... "keyword":"enum","message":"must be equal to one of the allowed values" ``` Each offer's catalog entry says so in its description: "Unknown names/families refuse before payment" appears in the text of the FOUR offers, and the JSON offers say they "reject duplicate keys, invalid Unicode and non-finite numbers before payment". ### Where is the schema that decides? The decision uses the same input contract that the seller publishes. Each entry of [`/v1/catalog`](https://market.561.group/v1/catalog) carries a `request.bodySchema` and an example, and the [OpenAPI document](https://market.561.group/openapi.json) is derived from that same catalog. So an agent that reads the catalog knows in advance what will be refused, and the seller cannot refuse a body that its own documentation permits. There is no second schema to drift. ### What if the request is valid but the handler fails? Validation cannot catch everything: an upstream data source can be down, a computation can throw. For those cases the engine's fetch server orders the work as: verify the payment, run the handler, and only then settle. If the handler throws, or returns any status of 400 or above, the engine calls the payment library's cancellation hook with a reason, `handler_threw` or `handler_failed`, and passes the handler's error response to the buyer. The facilitator is never asked to move the funds. In the engine source the relevant branch reads: ```js if (handlerResponse.status >= 400) { if (claim !== undefined) await releasePurchase(purchaseStore, claim); await cancellationDispatcher.cancel({ reason: "handler_failed", responseStatus: handlerResponse.status }); // ... return the handler's own error response, minus internal headers } ``` (Excerpt from the Red Cup x402 engine, `fetch-server.mjs`; abridged.) A seller that wants to bill for an honest negative answer must say so. One offer, the Base transaction check, documents that it "returns `found:false` (billably) for a hash the node does not know". That is a successful answer to a question, so it is charged and it is stated in the offer description. ### What are the limits of this approach? Pre-payment validation proves the request is well-formed, not that the seller will succeed. An upstream outage after validation is handled by cancellation, not prevention. Validation itself consumes the seller's compute without payment, which is why bodies are bounded (the JSON offers cap input at 64 KiB, the request carrier at 100 KiB) and why each refusal is cheap and `no-store`. And an unsigned `402` is not a sale; the seller treats a quote, a facilitator success and a delivered response as separate observations. ### How do I apply this to my own x402 route? 1. Publish a JSON Schema for every paid route and validate against it first, with `additionalProperties: false` unless you truly mean otherwise. 2. Parse JSON with a parser that detects duplicate members, and answer `422`. 3. Check `content-type` and answer `415` rather than guessing. 4. Return RFC 9457 problem documents so agents can self-correct. 5. Let the quote follow validation, not precede it. Price from the validated, canonical body ([Per-byte pricing](https://engineering.561.group/x402-per-byte-pricing/)). 6. Cancel, do not settle, when the handler fails. The Apache-2.0 [x402 boundary reference](https://github.com/561-group/x402-boundary-reference) shows how to configure the explicit route set for an Express app; put your validation middleware ahead of the payment middleware. For the rest of the seller's policies, return to [what an x402 seller should do beyond the spec](https://engineering.561.group/x402-seller-design/). --- # Never trust the payee in a 402 challenge: buyer-side x402 payee verification URL: https://engineering.561.group/verify-x402-payee-buyer-side/ Published: 2026-10-13 Summary: An x402 buyer must take the payee from its own authority, not the seller's 402 challenge. How an expectedPayTo check, a budget and quote-drift refusal work. ## Never trust the payee in a 402 challenge: buyer-side x402 payee verification An x402 buyer should never spend to whatever address the seller's `402` challenge names. The challenge is written by the party asking for money, so the buyer's owner must supply the expected payee, network, asset and ceiling independently, before the buyer probes or signs, and the buyer must refuse any challenge that deviates. The Red Cup buyer library enforces this: it requires an independently authorized `expectedPayTo` for every paid request and refuses a challenge naming a different recipient before a signature exists. ### What is the attack? An autonomous agent that pays for APIs is a wallet attached to a language model and an HTTP client. Consider an agent told "buy the weather data from this URL". If its x402 client signs whatever the response asks for, then any party that controls the response can set `payTo` to its own address, raise `amount`, or swap `asset`. The attacker needs no cryptographic break. It needs one of: a compromised seller, a man-in-the-middle on a bad network path, an open redirect, a typo-squatted domain, or a prompt injection that sends the agent to a hostile URL. The payment protocol will faithfully carry a valid signature to the wrong place. The `payTo` in a [real challenge](https://engineering.561.group/how-an-x402-payment-works/) is one field in a JSON document the seller controls. It is a claim. Nothing in the protocol makes the buyer believe it. ### What does the Red Cup buyer require before it signs? The buyer package, `x402-exact-purchase-service` (MIT, public at [github.com/red-cup-engineering/x402-exact-purchase-service](https://github.com/red-cup-engineering/x402-exact-purchase-service)), states the rule in its documentation: > For every paid request, the owner supplies an independently authorized `expectedPayTo` before any network probe or signing. Unknown payees may be observed with the unsigned quote API only; a seller-authored 402 challenge must never select its own recipient as the buyer's spending authority. A challenge naming a different recipient is refused before signing. The owner of the agent, not the agent, supplies four things: | Input | Purpose | | --- | --- | | `network` | The CAIP-2 chain, e.g. `eip155:8453` for Base | | `asset` | The token contract, e.g. USDC on Base | | `maximumAmount` | A ceiling in **atomic units** (a string, never a float) | | `expectedPayTo` | The recipient the owner approved, obtained out of band | The unsigned quote function then sends exactly one probe and admits only a payment requirement that matches all four: ```js import { readHttpPurchaseQuote } from "@red-cup-engineering/x402-exact-purchase-service/http-quote"; const quote = await readHttpPurchaseQuote({ url: "https://merchant.example/compute", method: "POST", body: { size: 3 }, network: "eip155:8453", asset: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", maximumAmount: "10000", // atomic units, not a dollar float expectedPayTo: "0xYourApprovedPayee", // from your own authority, not the 402 fetchImpl: enterpriseEgressSafeFetch, // supplied by the operator }); // quote.requirement and quote.request are inspectable; no signer was opened. ``` (Adapted from the package README; the payee here is a placeholder.) Three details deserve emphasis. **The fetch is supplied, not ambient.** The caller passes an egress-safe `fetchImpl`. The library does not fall back to `globalThis.fetch`, so a signed authorization cannot be sent to an unadmitted endpoint by default. Redirects are not followed. **A quote is not a purchase.** The quote function reports explicitly that no signing, payment, settlement or delivery has occurred. It sends a single unsigned probe, and the package warns that probing with POST is appropriate only for sellers known to be payment-first, since an untrusted non-x402 origin might perform a side effect before returning 402. **Quote drift is refused.** When the owner passes an accepted quote into the purchase, the library binds the URL, HTTP method, a digest of the caller's headers and a digest of the serialized body. Before signing, it requires the new `402` to preserve the *entire* accepted payment requirement: the exact amount, recipient, timeout and token-signing metadata. Request drift is refused before any egress; terms drift is refused before a signature with the error code `X402_QUOTE_DRIFT`. This closes the gap between "I looked at the quote" and "I signed something else". ### Can a facilitator's report override this? No. The package notes that optional recipient, asset or payer fields in a facilitator report cannot contradict the admitted terms, and that a facilitator report is still not independent chain settlement proof. It keeps three observations separate: a settlement report, received bytes, and the requester's acceptance. The buyer exposes `beforePayment`, which receives the exact request and signed payment before transmission, and `onSettlement`, which receives the facilitator's report before the delivery is read. The purchasing enterprise is expected to write both to its own books. If custody of the intent fails before payment, the purchase must stop before the signature crosses the network. If custody fails after settlement, the record must say the charge may have happened. ### How does the seller practise the same rule on itself? The seller side follows the discipline when it checks its own deployment. The market repository's receiving script (`ops/receive-deployment.mjs`) reads `X402_EXPECTED_PAY_TO` and refuses to run if "independently authorized X402_EXPECTED_PAY_TO is missing or malformed". The operator procedure for the directory-seeding script says the signed payment's recipient must match the independently approved value, and "do not derive the recipient from a source-code literal, the 402 challenge, or the seller's own `X402_PAY_TO` variable". A missing or malformed authority refuses before any live discovery fetch, signing attempt or journal creation. The listing reconciler excludes any offer whose advertised payee, asset, network or price differs from the deployed catalog, because "interpreting any HTTP 402 as a valid merchant offer" is exactly the mistake this article warns about. The same pattern applies to chains of purchases. The buyer's service-chain executor runs two to eight separately payable POST cells, but only after validating each cell's origin and independent payee and requiring that the sum of the per-cell maximum charges fits inside the owner's total cap. The seller's own 402 is never approval to spend. ### How can I observe a challenge without paying at all? If you only need to look, use the observation helper in the Apache-2.0 [x402 boundary reference](https://github.com/561-group/x402-boundary-reference). Its `observePublicX402Resource` function takes an HTTPS URL and an egress-safe fetch, refuses localhost, `.local`, credential-bearing URLs and literal IP hosts, refuses redirects, requires exactly status 402 and a bounded `payment-required` header, validates the challenge with the official x402 schema, lower-cases addresses, and returns an immutable record with a content-addressed digest of the normalized challenge. It does not sign, pay, settle or consume the protected response. It leaves DNS, SSRF and egress policy to the hiring enterprise, which is the right place for them. ### What checklist should an agent operator follow? 1. Obtain the seller's payee from a channel the seller's HTTP response cannot influence: a signed registry, your own configuration, a published domain-bound record you verify separately. 2. Configure network, asset and a per-call and total ceiling in atomic units. 3. Probe once, unsigned. Compare every field of the challenge to your configuration. 4. Pin the accepted terms and refuse drift between probe and signature. 5. Persist the intent before the signature leaves the process; persist the settlement report before reading the delivery. 6. Treat the facilitator's report, the received bytes and the acceptance as separate facts. 7. Never let a model decide the payee. Seller-side policies that complement this are in [what an x402 seller should do beyond the spec](https://engineering.561.group/x402-seller-design/), including how a [retried purchase](https://engineering.561.group/x402-payment-recovery-header/) returns the same bytes. --- # One catalog, five machine faces: MCP, A2A, ActivityPub, llms.txt and x402 discovery URL: https://engineering.561.group/x402-one-catalog-machine-interfaces/ Published: 2026-10-13 Summary: One 130-offer catalog compiles into x402 discovery, an MCP server, an A2A agent card, an ActivityPub outbox and llms.txt so agents find the same prices. ## One catalog, five machine faces: MCP, A2A, ActivityPub, llms.txt and x402 discovery Agents discover paid APIs through whatever door their framework opens: an MCP server, an A2A agent card, an ActivityPub actor, an `llms.txt` file, or the x402 `/.well-known/x402` document. The Red Cup seller at market.561.group keeps one authored catalog of 130 offers and compiles every one of those doors from it, so no door can quote a different price, route or input schema than another. This article walks through each face with the live URLs and the one command that produces them all. ### Why not write each discovery document by hand? Every agent-discovery format invites a hand-maintained list. MCP wants tool descriptions, A2A wants skills, `llms.txt` wants links, OpenAPI wants paths, a directory wants resources. A seller with 130 offers and five formats has 650 chances for the price in one place to disagree with the price in another, and an agent that sees two prices will believe the cheaper one and be refused by the 402. The remedy is the oldest one in software: one source, many projections. In the market repository, the only author-editable offer list is `data/catalog.json`. A script, `scripts/compile-catalog.mjs`, derives the compiled declarations, the content identities and the ActivityPub outbox from it. The repository's own documentation is blunt about it: the compiled files are "generated outputs derived by `scripts/compile-catalog.mjs`; neither is a separate author-editable offer catalog", and a hand-edit to a generated file is forbidden by the operating procedure. Offers that are proposed but not yet qualified stay `listed:false` with `saleStatus:"held"` so that no projection can leak a held route into live charging. ### What are the faces, and where do I find each one? | Face | Live URL | What an agent gets | | --- | --- | --- | | x402 discovery | [`/.well-known/x402`](https://market.561.group/.well-known/x402) | `x402Version: 2`, 130 `resources` with URL, method, price, asset, network, input and output schemas | | Catalog | [`/v1/catalog`](https://market.561.group/v1/catalog) | The richest record: schemas, examples, pricing tariff, content-addressed `sku`, `cell` and `law` | | OpenAPI | [`/openapi.json`](https://market.561.group/openapi.json) | OpenAPI 3.1.1 derived from the same catalog used for execution | | A2A agent card | [`/.well-known/agent-card.json`](https://market.561.group/.well-known/agent-card.json) | Protocol 0.3.0 card with 130 skills, one per offer | | MCP | `POST https://market.561.group/mcp` | Three read-only tools: `list_apis`, `search_apis`, `get_api` | | ActivityPub | [`/actors/market`](https://market.561.group/actors/market) | A `Service` actor whose outbox holds 130 public `Offer` activities | | llms.txt | [`/llms.txt`](https://market.561.group/llms.txt) | One line per offer: link, method, price, description | The first five of those are the "faces" in the title; the catalog and OpenAPI are the structured source projections they share. #### The x402 discovery document `/.well-known/x402` is a JSON document of resource descriptions. Each entry has the shape a crawler or a directory needs to list it without calling the endpoint: ```json { "url": "https://market.561.group/v1/data/json-pointer", "method": "POST", "name": "RFC 6901 JSON Pointer", "price": "$0.0012", "pricing": {"mode": "canonical-json-byte-bands", "...": "..."}, "asset": "0x8335…2913", "network": "eip155:8453", "inputSchema": {"...": "..."}, "outputSchema": {"...": "..."} } ``` (Shape from the live document; fields abbreviated. The `asset` is the USDC contract on Base, shortened here.) The advertised price is the starting price; for byte-priced offers see [Per-byte pricing](https://engineering.561.group/x402-per-byte-pricing/). It is a preview. The seller says so everywhere: "the current 402 challenge is authoritative". #### The MCP server The MCP face is stateless and read-only. It answers JSON-RPC at `/mcp`, supports protocol versions `2026-07-28` and `2025-06-18`, requires no session or handshake from modern clients, and exposes three tools annotated `readOnlyHint: true`. It performs no payment, no proxying and has no side effects; its source says so in the header comment. You can list the tools with the legacy version header: ```bash curl -s -X POST https://market.561.group/mcp \ -H 'content-type: application/json' \ -H 'accept: application/json, text/event-stream' \ -H 'MCP-Protocol-Version: 2025-06-18' \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' ``` and search the catalog by capability: ```bash curl -s -X POST https://market.561.group/mcp \ -H 'content-type: application/json' -H 'accept: application/json, text/event-stream' \ -H 'MCP-Protocol-Version: 2025-06-18' \ -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"search_apis","arguments":{"query":"belnap","limit":2}}}' ``` On 2026-10-22 that search returned one structured result: the `FOUR Evidence Name Conversion` offer with its SKU, route `/v1/four/reading-convert`, preview price `$0.001` and the producing package export. The server does not execute offers. It finds them; the agent then makes an ordinary [x402 call](https://engineering.561.group/how-an-x402-payment-works/). Requests are capped at 32 KiB and results at 40 per page. A modern-protocol request with mismatched headers is refused with `HeaderMismatch`, which we saw when we sent the 2026 version without its companion metadata headers: the server validates rather than guesses. #### The A2A agent card The agent card at `/.well-known/agent-card.json` declares `protocolVersion` 0.3.0, `preferredTransport`, no streaming, and 130 `skills`. Each skill has an `id` (for example `publications/the-x402-economy`), a name, a description, tags and example requests. It is a directory entry for agents that discover peers by card. It is not a task endpoint; paying and calling still go through the routes. #### The ActivityPub outbox Following [ActivityPub](https://engineering.561.group/activitypub-publication-provider/) convention, the market has a `Service` actor at `https://market.561.group/actors/market`, WebFinger at `/.well-known/webfinger?resource=acct:market@market.561.group`, and an outbox. The outbox is an `OrderedCollection` with `totalItems: 130` and `first`/`last` links to 13 `OrderedCollectionPage`s. Pages are bounded by item count (12) and by bytes (192 KiB), so a fediverse peer never has to fetch a multi-megabyte first page. Each item is an `Offer` activity addressed to Public whose object is a document of media type `application/sen+cbor`, named by an RFC 6920 content address: ```json { "type": "Offer", "actor": "https://market.561.group/actors/market", "to": "https://www.w3.org/ns/activitystreams#Public", "object": { "type": "Document", "mediaType": "application/sen+cbor", "name": "ni:///sha-256;2Aafngw-StdkoQAmUKatPhGcduQ-oIO3Dyt5csPRT8Q" }, "attachment": { "type": "Link", "name": "A2A Agent Card", "href": "https://market.561.group/.well-known/agent-card.json" } } ``` (The `object.url` field, a base64 data URI carrying the CBOR, is omitted.) The outbox builder refuses to start if an activity is non-public, from a foreign origin, duplicated, or not an `Offer`. See [content-addressed names](https://engineering.561.group/content-addressed-names-ni-rfc-6920/) for what the `ni:` name commits to. #### llms.txt `/llms.txt` lists every offer as a Markdown bullet with its link, `METHOD route`, price per call and description, under a one-sentence blockquote that tells a language model how to obtain a payment challenge. A model with browsing but no protocol support can read it, pick a route and follow the instructions to inspect the 402. ### How does the agreement get enforced? Three mechanisms keep the faces equal: 1. **One compile.** `npm run compile` regenerates the compiled offers, the static Worker imports and the ActivityPub outbox together. A checker, `npm run check:catalog`, verifies that the source catalog and the compiled identities agree. 2. **A receiving audit.** `npm run receive` checks the public release against the admitted seller catalog: fresh `/v1/status` and `/v1/catalog`, the unpaid 402 challenge of each listed route, and the payee, network and asset, with an independently supplied expected payee ([Never trust the payee](https://engineering.561.group/verify-x402-payee-buyer-side/)). 3. **Content addresses.** Each catalog entry carries `sku`, `cell` and `law` as `ni:` names. The same SKU is returned by the MCP `search_apis` result, so a client can confirm that the MCP face, the catalog and the outbox describe the same offer without parsing prose. The faces still can disagree on *availability* in time (a deploy may update the Worker before a cache expires), so the 402 challenge on the route itself is the final authority for price. That is why the previews all say "preview". ### What does this cost the seller to maintain? Almost nothing per format, which is the point. The catalog schema is one JSON Schema (`schemas/offer.schema.json` in the engine). An offer must name the typed operation it sells by its `compute` binding (package, export, argument projection), and may name its input admission and its scientific evidence. A new offer is one catalog entry; the compile step projects it into every face. The engine's `declareCatalog` refuses a route or gateway/operation declared twice. ### What is not claimed? Listing in a directory is not demand. The market's own procedure states that "a listing or HTTP 402 does not establish a customer purchase" and that a self-purchase "is not external demand". We report 130 offers and say nothing about buyers. Start with [what a seller should do beyond the spec](https://engineering.561.group/x402-seller-design/) for the other policies, or follow the [Belnap-valued logic offers](https://engineering.561.group/belnap-four-valued-logic-api/) that the search example found. --- # ActivityPub for a publication: a Fedify provider with WebFinger, NodeInfo, signed inboxes and no unsigned mode URL: https://engineering.561.group/activitypub-publication-provider/ Published: 2026-10-12 Summary: A Fedify-based ActivityPub provider for publications: WebFinger, NodeInfo 2.1, HTTP signatures, Data Integrity proofs and no unsigned inbox mode. ## ActivityPub for a publication: a Fedify provider with WebFinger, NodeInfo, signed inboxes and no unsigned mode Red Cup Engineering's ActivityPub provider turns a list of publications into a fediverse actor. It uses the Fedify library directly for wire parsing, WebFinger, NodeInfo 2.1, HTTP signatures, Data Integrity proofs and delivery, supports `Organization`, `Service`, `Group`, `Application` and `Person` actors, and has no unsigned-admission mode: an inbound activity that fails signature verification is refused. This article describes the provider's design from its source and from a loopback run we did on 2026-10-22, and it states plainly which parts are not yet live for this site. ### Is the engineering actor live? Not as of 2026-10-22. This site declares `@engineering@engineering.561.group` in its metadata (the `fediverse:creator` meta tag and a `rel="me"` link on every page), but when we requested `https://engineering.561.group/.well-known/webfinger?resource=acct:engineering@engineering.561.group`, the response was a 404 page, not a JSON resource descriptor. The organization's actors are being launched separately on Cloudflare Workers. We write about the provider's design here, and we will not describe an account as followable until WebFinger answers. You can check the same thing yourself: ```bash curl -s 'https://engineering.561.group/.well-known/webfinger?resource=acct:engineering@engineering.561.group' ``` For contrast, the market at `market.561.group` does answer an ActivityPub request today: its `Service` actor at `/actors/market` and WebFinger for `acct:market@market.561.group` are live, and its outbox publishes 130 `Offer` activities ([One catalog, five machine faces](https://engineering.561.group/x402-one-catalog-machine-interfaces/)). That actor is a read-only projection; it is a different composition from the signed-inbox provider described below. ### What does the provider own? Per the package documentation, `@red-cup-engineering/activitypub-services-section` (version 0.11.0) "owns ActivityPub, ActivityStreams 2.0, WebFinger, NodeInfo 2.1, signature/proof verification, protocol idempotency, and delivery". The customer supplies four things: the actor description, persistent protocol keys, an accepted-arrival callback and an outbox view. The provider "does not own or reinterpret their" domain theory. And, in one sentence worth quoting: "There is no unsigned-admission mode and no umbrella protocol fallback." Fedify does the protocol work. The house modules around it do the document work: | Module | Job | | --- | --- | | `./as2` | ActivityStreams 2.0 builders for every Vocabulary activity type, notes, articles, actors, tombstones, collections; refuses an actor without `inbox` and `outbox` and a `Block` addressed to Public | | `./recipients` | Delivery targets per ActivityPub 7.1.1 and 5.6: `to`, `bto`, `cc`, `bcc`, `audience`; Public is never delivered to, the author is excluded, own followers are expanded, shared inboxes are deduplicated, and `bto`/`bcc` are stripped before delivery | | `./publication` | A small composition seam for a static site: actor keys plus a `listPublications()` function | | `./inbound` | Reads what was admitted; see [Paraconsistent federation](https://engineering.561.group/activitypub-paraconsistent-inbox/) | | `./journal-custody`, `./flatfile-kv`, `./flatfile-queue` | Durable local state: verified inbox arrivals, followers, outbox and pending deliveries survive a restart | ### How do articles become ActivityPub objects? The publication profile takes records, each with a same-origin `url`, a `title`, rendered HTML `content`, and optionally a summary, dates and tags, and projects them into public `Create{Article}` activities in the actor's outbox: ```js import { createPublicationActivityPubProvider } from "@red-cup-engineering/activitypub-services-section/publication"; import { activityPubApplication } from "@red-cup-engineering/activitypub-services-section/app"; const provider = createPublicationActivityPubProvider({ origin, identifier, actorName, summary, keyPairs, listPublications, }); const app = activityPubApplication(provider); ``` (From the package README.) The profile reuses the provider's WebFinger, NodeInfo, actor and outbox routing. `activityPubApplication(provider)` returns an application with one manifest-visible resource per exact route: WebFinger, NodeInfo, inbox, actor, outbox and post objects, plus followers when follower custody is configured. It deliberately does not claim a broad `/actors/*` prefix, so it cannot swallow a neighboring route. For carriers that are not that application, `matchesActivityPubRequest(request, provider)` exposes the same exact ownership decision, and "intentionally does not match neighboring `/.well-known/*`, `/actors/*`, or site artifact routes". Inbound federation is explicit. Without an `inbox: { onActivity, … }` contract, `POST /inbox` and `POST /actors/{identifier}/inbox` return `405`: "the profile never accepts a remote activity and silently drops it". A publication-only site can therefore stay publication-only, and adds durable inbox custody only when it has a workflow to receive into. ### What does a run look like? We started a local actor on loopback with a freshly generated key, using the provider's documented local-server code path, and queried it. The keys were throwaway and the origin was `http://127.0.0.1:8031`, so this is a protocol demonstration, not federation with a peer. WebFinger returns a standard JRD: ```json {"subject":"acct:alice@127.0.0.1:8031", "aliases":["http://127.0.0.1:8031/actors/alice"], "links":[{"rel":"self","href":"http://127.0.0.1:8031/actors/alice","type":"application/activity+json"}]} ``` The actor document (abbreviated) has `type: "Service"` by default, its `inbox`, `outbox` and `followers` URLs, `preferredUsername`, a `publicKey` for HTTP signatures (fields `id`, `type`, `owner`, `publicKeyPem`) and an `assertionMethod` entry of type `Multikey` with a `publicKeyMultibase` for Data Integrity proofs. NodeInfo 2.1 reports `"protocols":["activitypub"]`, `"openRegistrations":false` and one user. Then we sent an **unsigned** `Create` to the actor's inbox: ```bash curl -s -i -X POST http://127.0.0.1:8031/actors/alice/inbox \ -H 'content-type: application/activity+json' \ -d '{"@context":"https://www.w3.org/ns/activitystreams","id":"http://evil.example/a/1","type":"Create","actor":"http://evil.example/u/x","object":{"type":"Note","id":"http://evil.example/n/1","content":"hi"}}' # HTTP/1.1 401 Unauthorized # Failed to verify the request signature. ``` That is the "no unsigned mode" rule observed. Fedify verifies the HTTP signature before any house code sees the activity, and the activity's Data Integrity proof is verified before the arrival callback fires; the verified activity is then retained as an immutable, content-addressed record ([Content-addressed names](https://engineering.561.group/content-addressed-names-ni-rfc-6920/)). ### What actor types can it publish? The accepted set is `Application`, `Group`, `Organization`, `Person` and `Service`. An organization such as an engineering company publishes as `Organization`; the local run above used the default `Service`. The 561.group apex site's documentation takes a conservative stance for its own actor: the provider must be "a separately keyed, custodied" instance that "must accept only `https://561.group` as its canonical origin", and a provider for `science.561.group` "is not substitutable". Static WebFinger JSON is explicitly "not an ActivityPub server". ### How are followers handled? When the deployment supplies a followers adapter, an inbound signature-verified `Follow` addressed to the actor is retained, the follower is recorded, and a signed `Accept{Follow}` is sent to the follower's inbox. A verified `Undo{Follow}` from the same actor removes the record. The actor advertises a real `followers` collection that returns an `OrderedCollection` with a correct `totalItems` and bare actor URLs, the convention independent implementations follow. Without a followers adapter, none of this is wired and a `Follow` is retained as an ordinary unanswered arrival. Honest limit: broadcasting new posts to the whole followers set is described in the source as not yet wired. It "needs each follower's inbox available at dispatch time". The only follower-bound delivery today is the `Accept`. Outbound follows go through an authenticated `POST /actors/{identifier}/outbox`. The activity must name the current actor exactly and address only the same actor it asks to follow. A public, misaddressed, self-targeted or fan-out `Follow` is refused before immutable outbox retention, and the documentation warns that "an outbox handoff is not evidence the peer accepted a follow". ### How are many sites hosted? A separate package, `@red-cup-engineering/activitypub-server` (0.2.0), is the composition root for hosting. Its `serveActivityPubSites({ sites })` takes already-created providers, one per canonical HTTPS origin, onto one listener. Each provider keeps its own custody, queue, keys, followers, inbox and outbox. "Duplicate or unknown origins refuse rather than falling back to another site's actor." Behind a TLS-terminating proxy, `trustProxy: true` is allowed only when the proxy preserves the public `Host`, supplies the verified scheme, and strips client-supplied forwarded headers; the host refuses to enable it on a non-loopback bind. Several separately keyed actors on one origin is designed but gated: the host refuses to start the mode until a published and installed provider version carries the per-actor credentials. ### What are the honest limits? The loopback run exercised real Fedify signing and verification but not real DNS, TLS or WebFinger-domain federation against an independent host; the package documentation says the same of its own two-process test. The local flat-file queue and inbox scan are for development; a production deployment supplies its own queue and custody. Nothing here claims that any peer has followed, received or replied to an engineering actor. If you want to see inbound federation with a twist (activities treated as claims, not commands), continue to [Paraconsistent federation](https://engineering.561.group/activitypub-paraconsistent-inbox/). --- # Reading HTTP in four values: why a 402 is neither up nor down URL: https://engineering.561.group/http-status-four-valued-belnap/ Published: 2026-10-11 Summary: A status page that reads each HTTP answer as Belnap's true, false, both or neither: 2xx is true, 401/402/403 is both, no answer is false. With live data. ## Reading HTTP in four values: why a 402 is neither up nor down A status page that reports only "up" or "down" loses the most interesting HTTP answers. The 561 Group's front page reads every node it lists in Belnap's four values instead: a 2xx or 3xx answer is told **true**, a 401, 402 or 403 is told **both** (the node answered and refused), no answer, another 4xx or a 5xx is told **false**, and a node nobody has probed yet is told **neither**. The probe is a Cloudflare Worker, its whole decision procedure is a seven-line JavaScript function, and the live reading is public at [561.group/estate.json](https://561.group/estate.json). ### What is Belnap's four-valued logic? Classical logic gives a statement one of two values. Belnap's four-valued logic (Belnap 1977) gives it one of four, by treating "told true" and "told false" as two independent pieces of information that a source may supply. A statement can be told true only, told false only, told both (the sources conflict), or told neither (nothing has been said). Written as pairs, with the first component meaning "told for" and the second "told against": | Value | Told for | Told against | Plain reading | | --- | --- | --- | --- | | true | yes | no | Evidence for, none against | | false | no | yes | Evidence against, none for | | both | yes | yes | Contradictory evidence | | neither | no | no | No evidence either way | Belnap's motivation was a database that receives reports from several sources, some of which disagree and some of which are silent. A computer should not collapse that into true or false: it should say what it was told. That is the same situation a monitoring page is in. ### Why does HTTP need four values? A request has more outcomes than a socket has states. Consider the status codes a probe sees from a healthy paid API. An unauthenticated GET to an x402 route returns `402 Payment Required`, because the server is working exactly as designed. An admin console returns `401` or `403` to an anonymous probe for the same reason. A boolean monitor reads those as "down" and pages someone; an optimistic monitor treats any HTTP response as "up" and misses that the page is unusable to its audience. Neither reading is right. The truthful report is both: the server answered (evidence for existing), and refused (evidence against being usable by this caller). The opposite error also happens. A probe that never returned, because DNS failed or the TCP connection timed out, is not the same as a probe that has not run yet. The first is evidence against; the second is no evidence at all. ### What is the exact rule? The Worker keeps the rule in one small module, `src/told.mjs`, in the 561.group repository ([github.com/561-group/561.group](https://github.com/561-group/561.group)): ```js export function toldOf(status) { if (status === undefined) return "neither"; if (status === null || status >= 500) return "false"; if (status === 401 || status === 402 || status === 403) return "both"; if (status >= 200 && status < 400) return "true"; return "false"; } ``` Here `status` is the HTTP status of the first response (redirects are not followed), `null` means nothing answered, and `undefined` means no reading yet. | Observation | Told | Why | | --- | --- | --- | | 200 to 399 | true | The node answered and served or redirected | | 401, 402, 403 | both | Answered, and refused for lack of payment or credentials | | connection failure or timeout (`null`) | false | No answer is evidence against | | 5xx | false | The node answered that it is broken | | other 4xx (404, 409, 421 ...) | false | The thing asked for is not there as asked | | not probed yet (`undefined`) | neither | No evidence either way | The rule is deliberately small. It is not a claim that 401 is "half down"; it is a claim that two true statements, "something answered" and "this caller was refused", are both worth keeping. ### How is the probe run? `/estate.json` is not a page someone edits. On a cache miss, the Worker sends a `GET` to every node listed in `data/estate.json`, concurrently. Each request does not follow redirects and times out after 4 seconds. The answers are told with `toldOf`, cached for 300 seconds, and returned as JSON with a `revision` hash, a `derivedAt` time, and a `ttlSeconds` field. The home page fetches the JSON and colours each tile by value. Two operational constraints come from the platform, and the repository records both. The Worker's configuration sets `compatibility_flags: ["global_fetch_strictly_public"]`, so that a probe of another `*.561.group` host goes through the public front door the way a visitor's request would, instead of an internal route. And the build refuses more than 45 nodes, because "every probe counts against the Worker's subrequest budget". The reading is therefore bounded: the page cannot silently grow past what the platform lets it measure. ### What does the live reading show? We fetched `https://561.group/estate.json` at `2026-10-22T00:42:23Z`. It listed 33 probes: **25 told true and 8 told false**, with none told both or neither. All eight false readings came from non-2xx answers, not from timeouts: seven were `421 Misdirected Request` (for example `https://flickering.561.group/` and `https://casino.561.group/slots.html`) and one was a `409` from `https://tidepool.561.group/`. Under the rule above, a 4xx other than 401/402/403 is false, so we report false. Whether those nodes are broken, not yet routed, or intentionally unavailable is a different question that the probe does not answer, and it is not our place to guess from a status code. The reading says: at this moment, a GET to that URL did not yield an answer in the sense we require. That result is also a reminder that "both" is rarer than one might think. The rule sees only unauthenticated front pages. A paid API such as [market.561.group](https://market.561.group/) would read both if its probed URL were an x402 route, because the seller answers `402`. The front door of the market answers 200, so it reads true. Choosing *which URL to probe* is itself a statement about what you mean by "up". You can reproduce the reading: ```bash curl -s https://561.group/estate.json | jq -r '.nodes[] | [.told, .status, .host] | @tsv' ``` ### How should I aggregate several probes? If you probe from several places or times, do not average. Join them in the knowledge order: **true joined with false is both**. A node that answers 200 from one region and times out from another is not "50% up"; it is told both, with the two witnesses preserved. A node never probed stays neither, and neither is the identity for join: adding "no evidence" to any reading changes nothing. These are the Belnap lattice operations, and they are available as [paid per-call offers](https://engineering.561.group/belnap-four-valued-logic-api/) for agents that want them as an API. The same idea appears in the Group's ActivityPub provider, which treats an inbound `Create` and a `Delete` for the same object as two witnesses and reports the cell as contradicted instead of letting arrival order decide ([paraconsistent federation](https://engineering.561.group/activitypub-paraconsistent-inbox/)). ### What are the limits? The probe reads one URL per node with one unauthenticated GET from one cloud network. It does not authenticate, does not follow a redirect to see whether the target works, does not measure latency percentiles or correctness, and caches for five minutes. A true reading says that a 2xx or 3xx came back, not that the application is correct. It is not an SLA. The strangeness is the point: by letting a status page say "both" and "neither", it stops lying about the cases a boolean cannot hold. See the full [index of Red Cup engineering articles](https://engineering.561.group/start-here/) for the other places the Group uses four values. --- # Content-addressed names: RFC 6920 ni: URIs over canonical CBOR, with worked hashes URL: https://engineering.561.group/content-addressed-names-ni-rfc-6920/ Published: 2026-09-23 Summary: How the 561 Group names data: an RFC 6920 ni: URI of the SHA-256 of NFC-normalized, deterministic CBOR, so key order and Unicode form never change an address. ## Content-addressed names: RFC 6920 ni: URIs over canonical CBOR, with worked hashes A content address should name a value, not one spelling of it. The 561 Group's draft specification of the *semiotic content address* (SCA) names a piece of data by the RFC 6920 `ni:///sha-256;…` URI of the SHA-256 digest of its **deterministic CBOR** encoding, after Unicode NFC normalization of every string and key. Two JSON objects that differ only in key order, or two strings that differ only in composed versus decomposed accents, then have the same address; hashing the raw JSON text, the common shortcut, gives them different ones. This article works the examples with real hashes you can reproduce in a terminal. ### What is an RFC 6920 ni: URI? RFC 6920 defines "Naming Things with Hashes". Its `ni:` URI scheme names content by a digest. The Group uses the SHA-256 form only, with an empty authority: ``` ni:///sha-256;f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk ``` After `sha-256;` comes the 43-character unpadded base64url encoding of the 32-byte digest. The specification adds one strict rule: the last character must be one of the sixteen canonical final sextets, so four spellings cannot name one digest. A validator that accepts non-canonical padding bits allows aliasing, which defeats the point of a name. You can produce the name above yourself: ```bash ni() { openssl dgst -sha256 -binary | basenc --base64url | tr -d '=' | sed 's|^|ni:///sha-256;|'; } printf 'Hello World!' | ni # ni:///sha-256;f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk ``` That name commits to exact bytes. It is a hash of a file. For structured data it is not yet enough. ### Why isn't hashing the JSON text enough? Take the same two-field object written two ways: ```bash printf '{"name":"x402","version":2}' | ni # ni:///sha-256;W6OZAGyazZCr7el9hfVf59AR6VwuIIE49ET6d2xPcGk printf '{"version":2,"name":"x402"}' | ni # ni:///sha-256;-kcErArIKfOq9rm9ns6QzSPYFnI-eoFAr2qVqiDWnzg ``` They are the same value and two different names. Whitespace, key order and escape choices each mint a new hash. The Group's draft calls out the existing instances in its own tree as defects: `ni:` names minted over `JSON.stringify` output are "valid RFC 6920 names of those bytes, but key-order dependent, so not names of the value". The remedy is to hash a canonical form, in two steps. ### How is a value canonicalized? **Step 1: Unicode NFC.** Every string and every map key is normalized to NFC. A key collision introduced by normalization is rejected rather than merged. The composed `é` (U+00E9) and `e` followed by a combining acute (U+0301) become one string. **Step 2: deterministic CBOR.** The value is encoded with RFC 8949 core deterministic encoding: shortest-form heads, definite lengths, map keys sorted by their encoded bytes, shortest exact floats, no tags. A decoder refuses non-canonical bytes. Our object becomes 20 bytes: ``` a2 64 6e616d65 64 78343032 67 76657273696f6e 02 ``` That is a 2-entry map (`a2`), the 4-character text `name` (`64 6e616d65`) with value the 4-character text `x402` (`64 78343032`), and the 7-character text `version` (`67 76657273696f6e`) with value the integer 2 (`02`). Hash it and name it: ``` ni:///sha-256;S14vjN44zabSMQb8L_7tqK6kAI2gtzu-I_4lb58v930 ``` Written in either key order, the value encodes to those same 20 bytes, and so has that one address. You can check it: ```bash printf '\xa2\x64name\x64x402\x67version\x02' | ni # ni:///sha-256;S14vjN44zabSMQb8L_7tqK6kAI2gtzu-I_4lb58v930 ``` The same holds for Unicode. The value `{"café": 1}` written with a precomposed `é` and with `e` plus U+0301 has one address under this scheme, `ni:///sha-256;1Nl25GfeDsGRq0U2MSY4k-GJX0eSCrT69KwzucuPHZQ`, whereas hashing the JSON text of the two spellings gives two unrelated names. We confirmed our encoder against the reference implementation's published test vectors: the canonical encodings of `null`, `true` and `0` hash to `ni:///sha-256;sLKYi2u-ckus2l6eUkc23gvH2uQcRrQhPFDh011OXxM`, `…J6ve3f6FA0lq3rYjRmyqR9pfY6vSvG-hn2z8tz7P7XA` and `…bjQLnP-zepicpUTmu3gKLHiQHT-zNzh2hRGjBhevoB0` respectively, and the reference's own tests assert that the NFC and NFD spellings of `café` have equal digests. The two-field example above was computed with a short independent encoder, not the reference code, so treat the example addresses as illustrations that you can verify rather than as vectors from the reference suite. ### What does the specification add on top? The draft (version 0.1.0, dated 2026-09-23, status "realized in part") describes three layers. 1. **Carrier commitment (data).** A *semiotic carrier* is a JSON-shaped value: null, booleans, integers, big integers, NFC strings, byte strings, arrays and plain objects with string keys. `semanticId(value)` is the `ni:` name of its canonical CBOR. This layer is implemented and has test vectors. 2. **Semantic identity (code).** The identity of a *typed claim* is the commitment of a normalized envelope with fields `kind`, `version`, `objectKind`, `semanticType`, `normalizationProfile`, `settlementProfile`, `settledBody` and `witnessRoot` (the `ni:` name of the evidence bundle that the settlement consumed). Two envelopes are the same content exactly when their bodies reduce to the same normal form under the same type, kind, profiles and witness root. This layer needs the Group's expression notation and is partly implemented in its runtime. 3. **Proof-path coordinate (code).** A readable resource name whose segments are generating, witnessing or obstructing steps (`A.B`, `A:B`, `A-B`), with a triple of surface, token and claim that must agree. The draft says plainly that "every protocol surface (HTTP route, MCP resource URI, ActivityPub IRI, package export key, filesystem path) is a reading of an address term", and that the requirement that all readings agree "is a formal obligation, not yet a theorem". We include it for completeness; it is research, not a shipped feature. One rule runs through all three: a token is opaque. No consumer decodes an address to learn what it names; it reads the claim or carrier the address commits to and verifies the commitment. ### What does not count as an address? The draft lists its own non-conformances, which is the most credible part of it: - `ni:` names over `JSON.stringify` output (key-order dependent), found in resource reservations and package audits. - `ni:///sha-256;` strings, which are *not* RFC 6920 (hexadecimal instead of base64url) and fail the validator; they appear in a journal of semantic records and tool evidence, and converting them "is a migration of those journals, not a renaming". - Bare `sha256:` strings and `urn:` identifiers, which belong to the protocols that define them (OCI digests, EVM events) and are never house content names. We publish this because a name that cannot be checked is not evidence. If a record says it is addressed, a reader should be able to recompute. ### Where do these addresses appear in public? - **Every offer in the market catalog** carries a `sku`, a `cell` and a `law`, each an `ni:///sha-256;…` name (for example, the JSON Pointer offer's SKU is `ni:///sha-256;fAnZehn7tM6Qdq9XoP2A8cv7zISE0iPitrf0iq9yn5o` in the [live catalog](https://market.561.group/v1/catalog)). - **The ActivityPub outbox** of that market publishes each offer as a document of type `application/sen+cbor` named by its address ([One catalog, five machine faces](https://engineering.561.group/x402-one-catalog-machine-interfaces/)). - **This site.** Each article's JSON-LD includes an `identifier` that is the `ni:` name of its cell ([how the site is built](https://engineering.561.group/how-this-site-is-built-tufte/)). - **Public challenge observations.** The x402 boundary reference returns an `observationDigest` as an `ni:` name over the normalized challenge it saw ([payee verification](https://engineering.561.group/verify-x402-payee-buyer-side/)). - **Six paid content-address offers** create, inspect and verify SHA-2 multihashes and CIDs (base conversion, raw-block CIDs), at $0.0012 per call. They state their limits: "There is no upload, pinning, retrieval or authorship claim", and raw verification refuses DAG and UnixFS. A public consumer of the carrier-address function is the MIT-licensed [cell-identity-verification-service](https://github.com/red-cup-engineering/cell-identity-verification-service), which addresses capability-cell manifests and refuses undefined members, fractional numbers, malformed Unicode, `__proto__` keys, NFC key collisions, cycles and hidden properties. ### What are the caveats? The specification is a draft with a declared stability of "draft". Number handling is its sharpest edge: the written text admits integers, while the current reference implementation also admits finite floats and encodes them as shortest exact floats, so check the version when you depend on a float. A content address proves that two carriers are the same value; it does not prove who made them or that they are true. Semantic identity (layer 2) is meaningful only relative to a normalization profile and a settlement profile, and two envelopes with different profiles do not become equivalent by sharing digest syntax. Finally, several of the repositories involved are not public; we describe behavior from source and tests we ran, and the examples in this article are reproducible without any access. Continue to [evidence in the publishing pipeline](https://engineering.561.group/how-this-site-is-built-tufte/) for where the address meets web publication.