{"openapi":"3.1.0","info":{"title":"Lightmathematics Institute API","version":"1.0.0","summary":"Governed semantic memory for agents: a five-verb continuity loop.","description":"Transport is tRPC over HTTP with the superjson transformer.\n\nThree rules cover almost every first-attempt failure:\n1. Wrap every input as {\"json\": {...}} — in the POST body for mutations, or URL-encoded in the ?input= query parameter for queries.\n2. Mutations (stabilize, preflight, consume) are POST. Queries (status, replay, audit, domains) are GET. Using POST on a query returns HTTP 405.\n3. Every request object is strict: an unrecognised key is a 400, not a warning.\n\nCall order: stabilize → status → preflight → consume → replay. Per-call prices are published at /api/pricing and /.well-known/x402.\nMint a credential with POST /api/register (plain JSON, not superjson-wrapped)."},"servers":[{"url":"https://lightmathlattice.com"}],"security":[{"bearerAuth":[]}],"paths":{"/api/trpc/envelope.stabilize":{"post":{"operationId":"stabilize","summary":"Open a governed operation and receive a Continuation Envelope ($0.08)","description":"Priced endpoint. See /api/pricing for the current per-call price.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["json"],"additionalProperties":false,"description":"tRPC superjson envelope. The procedure input must be nested under \"json\". A bare, unwrapped body is rejected with HTTP 400.","properties":{"json":{"type":"object","required":["operation_type","description","primary_identities"],"additionalProperties":false,"description":"Strict object. Unknown keys are rejected rather than ignored.","properties":{"operation_type":{"type":"string","minLength":1,"maxLength":64,"description":"Short classification of the operation. No control characters.","example":"portfolio_rebalancing"},"description":{"type":"string","minLength":1,"maxLength":512,"description":"One sentence describing the specific action, recorded in the audit trail.","example":"Rebalance the growth sleeve toward semiconductors"},"primary_identities":{"type":"array","minItems":1,"maxItems":32,"description":"Semantic identities this operation depends on.","items":{"type":"string","minLength":1,"maxLength":128,"pattern":"^[a-zA-Z0-9][a-zA-Z0-9 ._:\\-/]*$"},"example":["semiconductor_fabrication_capacity","input_cost_passthrough"]},"scope":{"type":"object","description":"Optional narrowing of the operation context. Accepts ONLY these three keys — any other key is rejected with HTTP 400 \"Unrecognized key\". This is not a free-form metadata bag.","additionalProperties":false,"properties":{"tenant":{"type":"string","maxLength":128,"pattern":"^[a-zA-Z0-9][a-zA-Z0-9._\\-]*$","example":"acme_corp"},"project":{"type":"string","maxLength":128,"pattern":"^[a-zA-Z0-9][a-zA-Z0-9._\\-]*$","example":"growth_sleeve"},"domain":{"type":"string","maxLength":128,"pattern":"^[a-zA-Z0-9][a-zA-Z0-9._\\-]*$","description":"A sealed domain pack name. Enumerate valid values at GET /api/trpc/envelope.domains.","example":"financial_markets"}}},"max_depth":{"type":"integer","minimum":1,"maximum":10,"default":5,"description":"Dependency traversal depth. Subject to your tier ceiling."},"max_nodes":{"type":"integer","minimum":1,"maximum":2000,"default":500,"description":"Upper bound on snapshot size. Subject to your tier ceiling."}}}}}}}},"responses":{"200":{"description":"status \"stabilized\" carries `envelope`; status \"refused\" carries `refusal` with a machine-actionable code. Both are HTTP 200.","content":{"application/json":{"schema":{"type":"object","description":"tRPC superjson response envelope. The payload is at result.data.json.","properties":{"result":{"type":"object","properties":{"data":{"type":"object","properties":{"json":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["stabilized","refused"]}}}}}}}}}}}},"400":{"description":"Schema validation failed. The message names the offending field."},"401":{"description":"Missing or invalid Bearer credential. Mint one at POST /api/register."},"402":{"description":"Payment required for a priced endpoint. Sign the attached x402 terms and retry with a PAYMENT-SIGNATURE header."},"405":{"description":"Wrong HTTP method for this procedure kind. Mutations are POST; queries (status, replay, audit) are GET."},"429":{"description":"Rate limit exceeded for your tier."}}}},"/api/trpc/envelope.status":{"get":{"operationId":"status","summary":"Check whether an envelope is still current (free)","description":"Free endpoint, and a tRPC query: call it with GET.","security":[{"bearerAuth":[]}],"parameters":[{"name":"input","in":"query","required":true,"description":"URL-encoded JSON of the form {\"json\":{...}}. This is a tRPC query procedure: it must be called with GET. A POST answers HTTP 405 METHOD_NOT_SUPPORTED.","schema":{"type":"string"},"example":"{\"json\":{\"envelope_id\":\"env_7f3a9c2e-4b1d-4c8a-9e2f-6d5a3b7c1e04\"}}"}],"responses":{"200":{"description":"\"current\": safe to act. \"affected\"/\"superseded\": call replay with reason request_successor. \"not_found\": stabilize again.","content":{"application/json":{"schema":{"type":"object","description":"tRPC superjson response envelope. The payload is at result.data.json.","properties":{"result":{"type":"object","properties":{"data":{"type":"object","properties":{"json":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["current","affected","superseded","not_found"]}}}}}}}}}}}},"400":{"description":"Schema validation failed. The message names the offending field."},"401":{"description":"Missing or invalid Bearer credential. Mint one at POST /api/register."},"402":{"description":"Payment required for a priced endpoint. Sign the attached x402 terms and retry with a PAYMENT-SIGNATURE header."},"405":{"description":"Wrong HTTP method for this procedure kind. Mutations are POST; queries (status, replay, audit) are GET."},"429":{"description":"Rate limit exceeded for your tier."}}}},"/api/trpc/envelope.preflight":{"post":{"operationId":"preflight","summary":"Request a one-use execution permit (free)","description":"Free endpoint.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["json"],"additionalProperties":false,"description":"tRPC superjson envelope. The procedure input must be nested under \"json\". A bare, unwrapped body is rejected with HTTP 400.","properties":{"json":{"type":"object","required":["envelope_id","action_digest"],"additionalProperties":false,"properties":{"envelope_id":{"type":"string","description":"Envelope handle returned by stabilize.","pattern":"^env_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$","maxLength":64,"example":"env_7f3a9c2e-4b1d-4c8a-9e2f-6d5a3b7c1e04"},"action_digest":{"type":"string","description":"SHA-256 digest of the exact action payload you intend to execute. Exactly 64 lowercase hexadecimal characters. Do NOT prefix with \"sha256:\" — a prefixed value is rejected with HTTP 400.","pattern":"^[0-9a-f]{64}$","minLength":64,"maxLength":64,"example":"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"}}}}}}}},"responses":{"200":{"description":"status \"permitted\" carries `permit` (one use, ~5 minute window); status \"refused\" carries `refusal`. Both are HTTP 200.","content":{"application/json":{"schema":{"type":"object","description":"tRPC superjson response envelope. The payload is at result.data.json.","properties":{"result":{"type":"object","properties":{"data":{"type":"object","properties":{"json":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["permitted","refused"]}}}}}}}}}}}},"400":{"description":"Schema validation failed. The message names the offending field."},"401":{"description":"Missing or invalid Bearer credential. Mint one at POST /api/register."},"402":{"description":"Payment required for a priced endpoint. Sign the attached x402 terms and retry with a PAYMENT-SIGNATURE header."},"405":{"description":"Wrong HTTP method for this procedure kind. Mutations are POST; queries (status, replay, audit) are GET."},"429":{"description":"Rate limit exceeded for your tier."}}}},"/api/trpc/envelope.consume":{"post":{"operationId":"consume","summary":"Retire the permit and receive an action receipt ($0.03)","description":"Priced endpoint. See /api/pricing for the current per-call price.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["json"],"additionalProperties":false,"description":"tRPC superjson envelope. The procedure input must be nested under \"json\". A bare, unwrapped body is rejected with HTTP 400.","properties":{"json":{"type":"object","required":["permit_id","outcome"],"additionalProperties":false,"description":"Note: consume is keyed by permit_id, not envelope_id, and takes no action name — the action was already bound to the permit by preflight.","properties":{"permit_id":{"type":"string","description":"Permit handle returned by preflight. One use only.","pattern":"^perm_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$","maxLength":64,"example":"perm_c3e8a7b2-91d4-4f6a-8b3c-2e7d5a1f9c04"},"outcome":{"type":"string","enum":["success","failure","partial"],"description":"Report honestly. Refusal-respecting behaviour feeds your trust signal."},"outcome_digest":{"type":"string","description":"Optional digest of the action result. Exactly 64 lowercase hexadecimal characters. Do NOT prefix with \"sha256:\" — a prefixed value is rejected with HTTP 400.","pattern":"^[0-9a-f]{64}$","minLength":64,"maxLength":64,"example":"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"},"result_digest":{"type":"string","description":"Alias of outcome_digest. Supply at most one. Exactly 64 lowercase hexadecimal characters. Do NOT prefix with \"sha256:\" — a prefixed value is rejected with HTTP 400.","pattern":"^[0-9a-f]{64}$","minLength":64,"maxLength":64,"example":"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"}}}}}}}},"responses":{"200":{"description":"status \"consumed\" carries `receipt`; status \"error\" carries `code` and `message` (e.g. PERMIT_CONSUMED).","content":{"application/json":{"schema":{"type":"object","description":"tRPC superjson response envelope. The payload is at result.data.json.","properties":{"result":{"type":"object","properties":{"data":{"type":"object","properties":{"json":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["consumed","error"]}}}}}}}}}}}},"400":{"description":"Schema validation failed. The message names the offending field."},"401":{"description":"Missing or invalid Bearer credential. Mint one at POST /api/register."},"402":{"description":"Payment required for a priced endpoint. Sign the attached x402 terms and retry with a PAYMENT-SIGNATURE header."},"405":{"description":"Wrong HTTP method for this procedure kind. Mutations are POST; queries (status, replay, audit) are GET."},"429":{"description":"Rate limit exceeded for your tier."}}}},"/api/trpc/envelope.replay":{"get":{"operationId":"replay","summary":"Re-read an envelope, or obtain a governed successor ($0.08)","description":"Priced endpoint, and a tRPC query: call it with GET. See /api/pricing.","security":[{"bearerAuth":[]}],"parameters":[{"name":"input","in":"query","required":true,"description":"URL-encoded JSON of the form {\"json\":{...}}. This is a tRPC query procedure: it must be called with GET. A POST answers HTTP 405 METHOD_NOT_SUPPORTED.","schema":{"type":"string"},"example":"{\"json\":{\"envelope_id\":\"env_7f3a9c2e-4b1d-4c8a-9e2f-6d5a3b7c1e04\",\"reason\":\"request_successor\"}}"}],"responses":{"200":{"description":"\"replayed\" returns the original envelope (is_original true). \"successor\" returns a fresh envelope and supersedes the original. \"no_successor\" carries `refusal`.","content":{"application/json":{"schema":{"type":"object","description":"tRPC superjson response envelope. The payload is at result.data.json.","properties":{"result":{"type":"object","properties":{"data":{"type":"object","properties":{"json":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["replayed","successor","no_successor"]}}}}}}}}}}}},"400":{"description":"Schema validation failed. The message names the offending field."},"401":{"description":"Missing or invalid Bearer credential. Mint one at POST /api/register."},"402":{"description":"Payment required for a priced endpoint. Sign the attached x402 terms and retry with a PAYMENT-SIGNATURE header."},"405":{"description":"Wrong HTTP method for this procedure kind. Mutations are POST; queries (status, replay, audit) are GET."},"429":{"description":"Rate limit exceeded for your tier."}}}},"/api/trpc/envelope.audit":{"get":{"operationId":"audit","summary":"Retrieve your own envelope and receipt lineage (free)","description":"Free endpoint, and a tRPC query: call it with GET.","security":[{"bearerAuth":[]}],"parameters":[{"name":"input","in":"query","required":false,"description":"URL-encoded JSON of the form {\"json\":{...}}. This is a tRPC query procedure: it must be called with GET. A POST answers HTTP 405 METHOD_NOT_SUPPORTED.","schema":{"type":"string"},"example":"{\"json\":{\"limit\":50}}"}],"responses":{"200":{"description":"Success."},"400":{"description":"Schema validation failed. The message names the offending field."},"401":{"description":"Missing or invalid Bearer credential. Mint one at POST /api/register."},"402":{"description":"Payment required for a priced endpoint. Sign the attached x402 terms and retry with a PAYMENT-SIGNATURE header."},"405":{"description":"Wrong HTTP method for this procedure kind. Mutations are POST; queries (status, replay, audit) are GET."},"429":{"description":"Rate limit exceeded for your tier."}}}},"/api/trpc/envelope.domains":{"get":{"operationId":"domains","summary":"List the sealed domain packs valid for scope.domain (free)","description":"Free tRPC query. Takes no input; call it with GET and no parameters.","security":[],"responses":{"200":{"description":"Domain pack inventory, measured from the deployment."}}}},"/api/mcp":{"post":{"operationId":"mcp","summary":"MCP JSON-RPC endpoint (same five verbs as tools)","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["jsonrpc","method"],"properties":{"jsonrpc":{"type":"string","const":"2.0"},"id":{"type":["string","integer","null"]},"method":{"type":"string","maxLength":64,"example":"tools/call"},"params":{"type":"object","description":"For tools/call: { name: \"lmi_stabilize\" | \"lmi_status\" | \"lmi_preflight\" | \"lmi_consume\" | \"lmi_replay\", arguments: { ...same fields as the tRPC input, NOT superjson-wrapped } }.","properties":{"name":{"type":"string","pattern":"^[a-z0-9_]+$"},"arguments":{"type":"object"}}}}}}}},"responses":{"200":{"description":"JSON-RPC result or error."},"400":{"description":"Schema validation failed. The message names the offending field."},"401":{"description":"Missing or invalid Bearer credential. Mint one at POST /api/register."},"402":{"description":"Payment required for a priced endpoint. Sign the attached x402 terms and retry with a PAYMENT-SIGNATURE header."},"405":{"description":"Wrong HTTP method for this procedure kind. Mutations are POST; queries (status, replay, audit) are GET."},"429":{"description":"Rate limit exceeded for your tier."}}}},"/api/register":{"post":{"operationId":"register","summary":"Mint an API key with no human in the loop (free)","description":"Plain REST, NOT superjson-wrapped. The response carries the key exactly once; store it before continuing.","security":[],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"name":{"type":"string","maxLength":120,"example":"my-agent"},"contact":{"type":"string","maxLength":320}}}}}},"responses":{"201":{"description":"Key minted. Fields: api_key, key_prefix, tier, usage, notice."},"400":{"description":"Body contains a disallowed or malformed field."},"503":{"description":"Key minting temporarily unavailable; retry after 30s."}}}},"/api/pricing":{"get":{"operationId":"pricing","summary":"Machine-readable per-call prices and payment terms (free)","description":"Canonical price source. Identical payload to /.well-known/x402.","security":[],"responses":{"200":{"description":"x402 payment terms with an explicit price per endpoint."}}}},"/api/health":{"get":{"operationId":"health","summary":"Liveness probe (free)","security":[],"responses":{"200":{"description":"{ status: \"ok\" }"}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Authorization: Bearer <api_key>. Keys are minted at POST /api/register and are prefixed lmi_."}}}}