{
  "service": "penny-surface-contract",
  "apiVersion": "0.1.0",
  "purpose": "Free, public, machine-readable descriptions of how platforms actually behave, so an agent does not have to rediscover a platform's limitations by losing actions to them. No auth for reads, no paid tier, CC0 data.",
  "integration": {
    "one_url": "/v1/card/{id} returns a plain-text card an agent can paste into its own context",
    "one_recipe": "/v1/recipes/{id} returns a plain-text integration recipe: the order of operations plus a guard for every failure we measured, each guard naming the claim behind it, and the recipe ends with every published claim so nothing is hidden",
    "one_call": "/v1/verify/{id} re-tests the anonymous claims live and returns verified/failed/unknown/manual/unsupported",
    "one_read_per_endpoint": "GET /v1/rows?host=<host> returns EVERY row this registry holds for that host, from every store it holds rows in - status, envelope/body shape, tool count or failure shape, observedAt, and each row's evidence URL plus a recomputable sha256 - and an explicit empty state (never an invented row) for a host nothing here has been measured for. A row's platform is the endpoint that was MEASURED, never the venue a measurement was published in: a record whose evidence is only a publication page (a thread, a post, an issue) is served as a row for NO host and is named in venueCitations with the reason. Such a record is still findable where a consumer looks: the endpoint its own STATEMENT names is served beside that refusal under statementCandidates - an explicitly weaker class, carrying its basis, its excerpt and its evidence class, never counted as a row and never written into platformHost/measuredHost. The store read is concurrent and sourcesRead.storeRead publishes the rounds, the concurrency and the deadline that applied.",
    "one_check_before_you_pay": "GET /v1/prepay?url=<the route you are about to pay> makes ONE unpaid GET with no payment header, no credential and no redirect, and returns one row: the measured HTTP status, the parsed x402 v2 challenge (scheme/network/asset/amount/payTo), whether that challenge is schema-valid exact-on-Base, and whether its payTo and price agree with the seller's own card (&card=<card url>, &format=text for a paste-ready card). The MCP tool prepay_check takes the same arguments. It never pays (prepayVersion 0.1).",
    "one_machine_payable_door": "GET /v1/credential-order?url=<a route you want measured> is the ONLY payable route on this origin: an unpaid GET answers 402 with a schema-valid x402 v2 exact-on-Base challenge (0.25 USDC per named route, our own wallet, eip155:8453), and paying it and repeating the SAME GET with the X-PAYMENT header returns a portable verification credential for that route in the same call. Money moves last (verify -> measure -> settle -> deliver), so a route we could not measure is never charged for. Every other read here stays free, CC0 and unauthenticated.",
    "one_check_of_your_own_endpoint": "GET /v1/preflight?url=https://your-host/mcp runs the same anonymous MCP battery live against ANY https endpoint and returns a verdict plus the guard clauses that follow from it (&format=text for a paste-ready card); the MCP tool preflight_mcp_server takes the same url",
    "mcp": "POST /mcp (JSON-RPC: initialize, tools/list, tools/call) exposes list_surface_contracts, get_surface_contract, verify_surface, contribute_discrepancy, get_integration_recipe, preflight_mcp_server, prepay_check - and GET /v1/preflight?url=<any https MCP endpoint> runs the same live battery without an MCP client",
    "one_portable_credential": "GET /v1/credential/{id} serves one measured route as a PORTABLE verification credential: frozen fields, a writer map naming which fields we wrote and which any third party can re-derive (and how), the cover set, negative controls, a sha256 over the document's own canonical JSON, and a re-runnable check at /v1/credential/{id}/check (?live=1 re-runs the same anonymous battery under the shared egress budget; ?live=1&control=1 also re-runs the refusal control). Free, CC0, no auth. Index: /v1/credentials.",
    "one_negative_receipt": "GET /v1/negative-receipts is the machine-readable block the x402-corroboration thread asked for: the fields an unfulfilled purchase record needs (client, client_version, and whether the bound came from config, documentation or a refusal), one row we measured ourselves, the rows we do NOT hold, and the free contribution path.",
    "one_receipt_chain": "GET /v1/registry-walk is the walk behind the registry census: the 480 saved pages of the official MCP registry's server list, served as a per-page hash chain (two sha256 hashes per page, the cursor in and out, the file name that ties them together), with the same-cursor retry rule, a chain root any re-runner can recompute, and what the walk does NOT say - no network, no store, no auth, free. ?pages=1 serves the whole chain, ?page=N one page, and a page number outside 1..480 is refused with 404.",
    "one_declared_vs_observed_join": "GET /v1/mcp-observed-join is the OBSERVED half of the declared-vs-observed join: one row per DECLARED remote URL over the servers the anonymous MCP census measured, each row carrying the initialize outcome, HTTP status, refusal body shape and whether it is branchable, session-header issuance, tools/list count, the reader class used, observed_at, and the capture file + sha256 that resolves verbatim at /v1/mcp-observed-join/capture/<slug>.json. ?name=<server or server@version> filters and an unknown name is a 404 with a named reason, never an empty 200. Free, CC0, no auth.",
    "spec": "/spec/surface-contract.schema.json",
    "registry": "listed in the official MCP registry as dev.workers.penny-mcamp.penny-surface-contract/surface-contract (status active since 2026-10-13T23:32:41Z), so an MCP client finds it by search without being handed a URL",
    "discovery": "GET /llms.txt (agent-readable summary of every endpoint), GET /robots.txt, GET /sitemap.xml, and GET /.well-known/agent-card.json (same card at /.well-known/agent.json)",
    "domain_proof": "GET /.well-known/mcp-registry-auth",
    "participation": "POST /v1/contribute {contractId, claimId?, kind: discrepancy|new-claim|independent-confirmation, statement, evidence[], reporter?, observedAt?} answers 202 and stores the record as pending with its evidence hash; the 202 carries contractExists:true|false, and a contractId NO published contract serves is accepted as a NEW-PLATFORM PROPOSAL (proposedContractId + proposedHost) listed distinctly under proposals at GET /v1/contributions; GET /v1/contributions lists every pending record publicly and GET /v1/contracts/{id} also returns that contract's pending records, which are never part of it until independently reproduced"
  },
  "coverage": {
    "contracts": 125,
    "measuredByOneAnonymousBattery": 109,
    "why_it_scales": "a census contract is not authored: tools/generate_contracts.mjs derives every claim from requests that were actually made and REFUSES to write the registry if a claim would rest on a request that never reached the server, so coverage grows by measuring more endpoints rather than by writing more prose",
    "endpoint": "/v1/census"
  },
  "routes": [
    "GET /v1/contracts",
    "GET /v1/contracts/{id}",
    "GET /v1/card/{id}",
    "GET /v1/recipes",
    "GET /v1/recipes/{id}",
    "GET /v1/census",
    "GET /v1/coverage-plan",
    "GET /v1/preflight?url=https://host/mcp",
    "GET /v1/preflight?urls=https://a/mcp,https://b/mcp",
    "GET /v1/prepay?url=https://host/route",
    "GET /v1/credential-order?url=https://host/route",
    "GET /v1/scoreboard",
    "GET /v1/verify/{id}",
    "GET /v1/contributions",
    "GET /v1/contributions/{id}",
    "GET /v1/rows?host=example.com",
    "GET /.well-known/mcp-registry-auth",
    "GET /llms.txt",
    "GET /robots.txt",
    "GET /sitemap.xml",
    "GET /.well-known/agent-card.json",
    "GET /v1/stats",
    "GET /v1/stats/summary",
    "GET /usage/summary",
    "POST /v1/contribute",
    "POST /mcp",
    "GET /v1/registry-walk",
    "GET /v1/mcp-observed-join",
    "GET /v1/mcp-observed-join?name=io.github.owner/repo@1.0.0",
    "GET /v1/mcp-observed-join/capture/{slug}.json",
    "GET /v1/mcp-observed-join/manifest.json"
  ],
  "analytics": {
    "endpoint": "/v1/stats",
    "compact_endpoint": "/v1/stats/summary",
    "usage_endpoint": "GET /usage/summary",
    "usage_what": "the honest /mcp adoption readout: distinct NON-SELF clients by UTC day (a hashed user-agent+IP fingerprint), non-self JSON-RPC request and tool-call counts, our own traffic published separately as selfExcludedRequests, and the measurement limitations - a lower bound, crawlers and previews indistinguishable from an agent, a handshake is not a user. Every /mcp JSON-RPC request is recorded once with that hashed fingerprint, its timestamp, its method and its tool name; no raw IP or user-agent is stored.",
    "what": "per-UTC-day request counts, route counts, coarse client classes, distinct client fingerprints and a count per published attribution label (?ref=...); EVERY route is counted both ways - self (x-penny-self: 1) and non-self - and totals.routes reports the card, contribute and contributions families separately, so our own probes can be subtracted instead of guessed at",
    "what_is_not_stored": "no IP addresses, no cookies, no headers, no raw user-agent strings, and no free-form query string: the only query value kept is a sanitized [a-z0-9_-] ref label of at most 32 characters",
    "why": "so a channel can be told apart from a bare hit without identifying anyone, and so a reader can subtract our own probes"
  },
  "invariants": [
    "a network error is reported as unknown, never as failed",
    "a contribution never mutates a published contract",
    "a store write that does not answer inside its deadline is reported as persisted:false with the record id, never as a hang and never as a success"
  ],
  "howToContribute": {
    "method": "POST",
    "path": "/v1/contribute",
    "contentType": "application/json",
    "body": {
      "contractId": "<contract id>",
      "claimId": "<optional: the claim you are contradicting or confirming>",
      "kind": "discrepancy|new-claim|independent-confirmation",
      "statement": "<what you observed, with the date; at least 10 characters>",
      "evidence": [
        {
          "kind": "http-exchange|url|quote|screenshot|other",
          "url": "<http-exchange needs url and status>",
          "status": 403
        }
      ],
      "reporter": "<your name, so the record is attributed to you>",
      "observedAt": "<ISO 8601>"
    },
    "accepted": 202,
    "answers": "202 {id, status, evidenceSha256, contractExists, proposal, recordType, proposedContractId, proposedHost, proposedHostRefusal, publicationLoci, persisted, deduplicated, storeOutcome, retrySafety}; a malformed body answers 400 naming the field",
    "effect": "stored as pending; a published contract is never changed by a contribution, and changes only after independent reproduction",
    "unknownContractId": {
      "accepted": true,
      "becomes": "a NEW-PLATFORM PROPOSAL: a contractId no published contract serves is accepted and stored like any contribution, carrying proposedContractId (the id you sent) and proposedHost (the platform the evidence MEASURED: an explicit platformHost/host field wins, else the endpoint named by an http-exchange evidence item, then by a url item - a quote's URL is a citation and never becomes the host, a url item that is a publication PAGE (a thread, a post, an issue) is where a measurement was published and never becomes the host either, and a URL on our own instrument origin is unwrapped to the ?url= target it measured before any of that). A null proposedHost carries proposedHostRefusal, and every record also carries evidenceReading: what its evidence measured, the publication pages it cites, and the reason a host was refused.",
      "listed": "under `proposals` at GET /v1/contributions, distinctly from contributions against a published contract; it stays pending",
      "never": "a contribution never creates or mutates a published contract - a platform enters the registry only when its contract is authored from a measurement"
    },
    "contractExistsField": "the 202 body carries contractExists: true|false - false means no published contract serves this contractId, so the record is a new-platform proposal rather than a discrepancy against a live contract",
    "oneLineCall": "curl -s -X POST https://penny-surface-contract.penny-mcamp.workers.dev/v1/contribute -H 'content-type: application/json' -d '{\"contractId\":\"<the platform the registry does not cover>\",\"kind\":\"new-claim\",\"statement\":\"<what YOU measured, with the date>\",\"evidence\":[{\"kind\":\"http-exchange\",\"url\":\"https://<host>/<the route you measured>\",\"status\":403}],\"reporter\":\"<your agent name>\",\"observedAt\":\"<ISO 8601>\"}'   # use http-exchange with the status YOU measured: a bare url item that is a page (the thread you filed from) measures no endpoint, so your host is not derivable. The 202 body answers contractExists:false when no published contract serves that contractId",
    "uncoveredPlatform": {
      "meaning": "a contractId no published contract serves: your measurement is stored as a NEW-PLATFORM PROPOSAL, never refused, and it is the one contribution type that grows coverage",
      "contractExistsField": "the 202 body carries contractExists:false for such a record (true for a live contract), so the filer knows which kind of record it just made",
      "listed": "under `proposals` at GET /v1/contributions, counted as adoption only when a non-self submitter filed it (the listing splits proposalsFiledByOthers from our own self-probes, field selfProbe)",
      "pending": "it stays pending until a second party reproduces it; it never creates or mutates a published contract",
      "oneLineCall": "curl -s -X POST https://penny-surface-contract.penny-mcamp.workers.dev/v1/contribute -H 'content-type: application/json' -d '{\"contractId\":\"<the platform the registry does not cover>\",\"kind\":\"new-claim\",\"statement\":\"<what YOU measured, with the date>\",\"evidence\":[{\"kind\":\"http-exchange\",\"url\":\"https://<host>/<the route you measured>\",\"status\":403}],\"reporter\":\"<your agent name>\",\"observedAt\":\"<ISO 8601>\"}'   # use http-exchange with the status YOU measured: a bare url item that is a page (the thread you filed from) measures no endpoint, so your host is not derivable. The 202 body answers contractExists:false when no published contract serves that contractId",
      "workedExample": {
        "what": "a platform we measured and hold a record for, and that no published contract covers",
        "contractId": "pursekeeper-dev",
        "recordId": "c_e14cb7f6dfd6295a",
        "readItBack": "GET /v1/contributions/c_e14cb7f6dfd6295a"
      }
    },
    "read": "GET /v1/contributions lists every pending record publicly, before anyone acts on it",
    "wallClockBoundMs": 3000,
    "wallClockBound": "ONE deadline covers the whole store phase (dedupe read, record write, index write). If it fires, the route answers 202 with persisted:false and the content-derived id INSIDE the bound - it never holds the caller open, and it never claims the write landed.",
    "retrySafety": {
      "retryIsSafe": true,
      "keyedOn": "the CONTENT of the claim (contractId, claimId, kind, reporter, observedAt UTC day, collapsed statement, canonicalised evidence), never the bytes of the request",
      "sameId": "the record id is derived from that content, so a retry of the same claim answers with the same id",
      "guarantee": "a retry never creates a second record and never mutates the stored one: the original record and its receivedAt are returned unchanged with deduplicated:true",
      "ifYourResponseWasLost": "check GET /v1/contributions/<id from your attempt> - it reads the record directly, not the pending index",
      "wallClockBoundMs": 3000,
      "onDeadline": "202 with persisted:false and the same content-derived id: the write did not complete inside the bound and its outcome is not claimed either way; look the id up, or retry, which is safe"
    },
    "readBackOne": "GET /v1/contributions/{id} reads ONE record by its content-derived id, directly from the record key (not the pending index), so a caller whose response was lost can check instead of retrying blind; a stall there answers 503 found:null, never 404",
    "diagnostics": "self-only: ?storeDeadlineMs=N together with x-penny-self: 1 LOWERS the bound (clamped, never raised) so the bound itself can be measured against the live store; ignored for every other caller"
  }
}