{"openapi":"3.1.0","info":{"title":"Lena Code API contract","version":"2026-06-11.m1","description":"API contract. /api/v1/convert is the keyed product conversion API (x-lena-api-key; issue/rotate/revoke at /api/account/api-key with a provider-verified session). /api/convert is the browser/editor conversion path. /api/coverage/* serves cached coverage release snapshots (no live recomputation). /api/chef/process exposes only safe health and usage-limit metadata here; its POST preview/debug contract is internal/admin-only and intentionally omitted from this public document. Source code is processed in-memory only and never logged; per-key usage is metered as billing-neutral daily aggregates (see the privacy policy). An evidenceReleaseId field is NOT yet part of the convert envelope — it lands with the full evidence-envelope alignment, not before the underlying release identity actually exists."},"paths":{"/api/chef/process":{"get":{"operationId":"getChefProcessHealth","summary":"Read chef-process availability and safe usage limits","responses":{"200":{"description":"Health and safe session/plan metadata.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChefProcessHealth"}}}}}}},"/api/openapi.json":{"get":{"operationId":"getOpenApiContract","summary":"Return the generated static OpenAPI contract","responses":{"200":{"description":"OpenAPI 3.1 document generated from shared constants."}}}},"/api/v1/convert":{"get":{"operationId":"getConvertV1Capability","summary":"Availability/limits probe for the keyed conversion API (no auth required)","responses":{"200":{"description":"Runtime, auth header contract, and effective limits."}}},"post":{"operationId":"convertV1","summary":"Convert source code between languages over registered direct adapters (API key required)","description":"Requires the x-lena-api-key header and Content-Length. Honest-partial contract: status reports converted/partial/unsupported-target/no-implemented-route/input-law-fail/adapter-fail. Conversion completeness is derived from fragments and gaps, never from text: fragments with no gaps are complete, fragments with gaps are partial, and no fragments is none. Each fragment separates registered implementation from semantic evidence. The current transform receipt carries no per-invocation semantic oracle, so semanticVerified and its deprecated verified alias fail closed to false; aggregate cell-level courts do not change that verdict. ok is true only for a complete converted result and does not itself claim semantic verification. When at least one indexed top-level form converts, text may contain registered target fragments plus each gap form in its original position as a deterministic target-language comment wrapping that form's original source. gaps and fragments remain authoritative per-form records, ok remains false, and partial text may not compile or run. An unindexed partial can retain fragments and gaps with text null when no ordered assembly is available. When no form converts, text is null. Response headers: x-request-id, x-ratelimit-remaining, x-quota-limit, x-quota-remaining, x-quota-reset.","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConvertV1Request"}}}},"responses":{"200":{"description":"Structured domain outcome (success or honest-partial).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConvertV1Response"}}}},"400":{"description":"E_BAD_REQUEST / E_BINARY — invalid body or binary content."},"401":{"description":"E_UNAUTHORIZED — invalid or missing API key (uniform; failure modes are not differentiated)."},"411":{"description":"E_LENGTH_REQUIRED — Content-Length header is required."},"413":{"description":"E_TOO_LARGE — payload exceeds the input limit."},"429":{"description":"E_RATE_LIMITED / E_QUOTA_EXCEEDED — per-key rate limit or daily cap."},"503":{"description":"E_UNAVAILABLE — auth/quota backend unavailable (fail-closed)."},"504":{"description":"E_TIMEOUT — conversion timed out."}}}},"/api/account/api-key":{"get":{"operationId":"getApiKeyStatus","summary":"Read API key status (prefix/createdAt/lastUsedAt; never the key)","description":"Browser session route (provider-verified OAuth sign-in required).","responses":{"200":{"description":"Key status."},"401":{"description":"Sign-in required."},"403":{"description":"E_PROVIDER_VERIFIED_REQUIRED — passcode sessions cannot manage keys."}}},"post":{"operationId":"issueApiKey","summary":"Issue (rotate) the API key — plaintext is returned exactly once","description":"Browser session route with same-origin enforcement; rotation atomically revokes the previous key.","responses":{"201":{"description":"New key (one-time plaintext)."},"401":{"description":"Sign-in required."},"403":{"description":"E_PROVIDER_VERIFIED_REQUIRED or E_CSRF."},"429":{"description":"E_RATE_LIMITED."}}},"delete":{"operationId":"revokeApiKey","summary":"Revoke the active API key","responses":{"200":{"description":"Revocation result."},"401":{"description":"Sign-in required."},"403":{"description":"E_PROVIDER_VERIFIED_REQUIRED or E_CSRF."}}}},"/api/coverage/exposure":{"get":{"operationId":"getCoverageExposure","summary":"Public coverage measurement model (cached release snapshot)","responses":{"200":{"description":"schemaVersion 1.0 coverage exposure document."}}}},"/api/coverage/exposure/{languageId}":{"get":{"operationId":"getCoverageExposureLanguage","summary":"Per-language coverage rows + node-level proof detail (cached release snapshot)","description":"The same proof the product manual shows: verified acceptance cells and grammar-node provenance for input; registered emitters, their semantic-verified subset, and the target-case horizon for output. These measurement units remain separate.","parameters":[{"name":"languageId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Per-language coverage rows + proof detail.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CoverageLanguageDetail"}}}},"404":{"description":"Unknown language id."}}}},"/api/coverage/guard":{"get":{"operationId":"getCoverageGuard","summary":"Coverage exposure guard summary (cached release snapshot)","responses":{"200":{"description":"Guard summary (pass/red, drift counts)."}}}},"/api/mcp":{"post":{"operationId":"mcpStreamableHttp","summary":"MCP server endpoint (streamable HTTP, JSON-RPC)","description":"Model Context Protocol server. Auth: Authorization: Bearer <Lena API key> (the same key as x-lena-api-key; rotation revokes both surfaces). Six read/transform-only tools + three lena:// resources; tool inventory is served live by the lena://health-public resource and unauthenticated discovery metadata at /.well-known/oauth-protected-resource. Transform tools consume the same shared daily quota as /api/v1/convert.","security":[{"McpBearerAuth":[]}],"responses":{"200":{"description":"JSON-RPC response (streamable HTTP)."},"401":{"description":"Missing/invalid bearer; WWW-Authenticate points at the protected-resource metadata."},"403":{"description":"Disallowed browser Origin."}}}},"/.well-known/oauth-protected-resource":{"get":{"operationId":"getProtectedResourceMetadata","summary":"RFC 9728 protected resource metadata for the MCP endpoint","responses":{"200":{"description":"Resource metadata (Phase 1: API key used as bearer; no authorization servers)."}}}}},"components":{"securitySchemes":{"McpBearerAuth":{"type":"http","scheme":"bearer","description":"Lena API key used as a bearer token for /api/mcp (not an OAuth-issued token; Phase 1). Same key lifecycle as ApiKeyAuth."},"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-lena-api-key","description":"Issued at /api/account/api-key (provider-verified session). Keys are stored as one-way hashes; rotation invalidates the previous key immediately."}},"schemas":{"CoverageLanguageDetail":{"type":"object","required":["schemaVersion","languageId","inputCoverage","outputCoverage","inputDetail","outputDetail","fetchedAt","contractSource"],"properties":{"schemaVersion":{"type":"string","enum":["1.0"]},"languageId":{"type":"string"},"inputCoverage":{"type":"object","description":"The public per-language input row (numerator/denominator the UI shows)."},"outputCoverage":{"type":"object","description":"The public per-language output row with implementation and semantic evidence separated.","required":["languageId","displayName","registeredWriterCellCount","outputSemanticVerifiedCellCount","totalWriterCellCount","routeStatus"],"properties":{"languageId":{"type":"string"},"displayName":{"type":"string"},"registeredWriterCellCount":{"type":"integer"},"outputSemanticVerifiedCellCount":{"type":"integer"},"totalWriterCellCount":{"type":"integer"},"routeStatus":{"type":"string","enum":["input-verified-output-implemented","input-verified-output-semantic-verified","output-implementation-pending-semantic-evidence"]}}},"inputDetail":{"type":"object","required":["verifiedCells","denominatorInventory","axisNote"],"properties":{"verifiedCells":{"type":"array","description":"The numerator, enumerated: one entry per verified acceptance cell. Internal verifier identifiers are never published — only the count.","items":{"type":"object","required":["externalFeatureId","admissionUnitId","verifierRefCount"],"properties":{"externalFeatureId":{"type":"string"},"admissionUnitId":{"type":"string"},"verifierRefCount":{"type":"integer"}}}},"denominatorInventory":{"type":"object","required":["method","inventoryHash","namedNodeTypeCount","namedNodeTypes"],"description":"The denominator, enumerated: the full grammar-node inventory. Methodology is an abstract id; integrity travels via inventoryHash.","properties":{"method":{"type":"string"},"inventoryHash":{"type":"string"},"namedNodeTypeCount":{"type":"integer"},"namedNodeTypes":{"type":"array","items":{"type":"string"}}}},"axisNote":{"type":"string"}}},"outputDetail":{"type":"object","required":["registeredFacets","semanticVerifiedFacets","denominatorBreakdown","implementedFacetGaps","facetUniverseCount","facetDepth","axisNote"],"properties":{"registeredFacets":{"type":"array","description":"Registered direct emitter implementations, including exact-text evidence.","items":{"type":"object","required":["facetKey","adapterId","caseIds","verifierRefCount"],"properties":{"facetKey":{"type":"string"},"adapterId":{"type":"string"},"caseIds":{"type":"array","items":{"type":"string"}},"verifierRefCount":{"type":"integer"}}}},"semanticVerifiedFacets":{"type":"array","description":"Closed-court semantic subset. Exact-target-text evidence is excluded.","items":{"type":"object","required":["facetKey","adapterId","caseIds","verifierRefCount"],"properties":{"facetKey":{"type":"string"},"adapterId":{"type":"string"},"caseIds":{"type":"array","items":{"type":"string"}},"verifierRefCount":{"type":"integer"}}}},"denominatorBreakdown":{"type":"object","required":["mode","registeredTargetCaseCount","acceptedFutureTargetCaseCount","totalDenominator","sourceReport"],"properties":{"mode":{"type":"string"},"registeredTargetCaseCount":{"type":"integer"},"acceptedFutureTargetCaseCount":{"type":"integer"},"totalDenominator":{"type":"integer"},"sourceReport":{"type":"string","description":"Provenance pointer to the measurement report the denominator comes from (also rendered in the product manual)."}}},"implementedFacetGaps":{"type":"array","items":{"type":"string"}},"facetUniverseCount":{"type":"integer"},"facetDepth":{"type":"array","description":"Per-facet within-facet DEPTH for THIS language only (EXEC #301). The facet top-line credits a facet once any operator has registered implementation evidence; this enumerates the implemented sub-features without treating exact-text regression as semantic verification. Never a language-agnostic count.","items":{"type":"object","required":["facetKey","registeredCount","denominator","registered","deferred","excluded"],"properties":{"facetKey":{"type":"string","enum":["binary-operator","unary-operator","control-transfer"]},"registeredCount":{"type":"integer"},"denominator":{"type":"integer","description":"Law sub-feature set minus intentionally-excluded (22 / 3 / 3)."},"registered":{"type":"array","items":{"type":"object","required":["subFeature","group","provenCaseIds"],"properties":{"subFeature":{"type":"string"},"group":{"type":"string"},"provenCaseIds":{"type":"array","items":{"type":"string"},"description":"Implementation-evidence case ids from golden conversion or registered direct-adapter regression."}}}},"deferred":{"type":"array","items":{"type":"object","required":["subFeature","group","reason"],"properties":{"subFeature":{"type":"string"},"group":{"type":"string"},"reason":{"type":"string","enum":["globally-deferred","per-language-not-converted"]}}}},"excluded":{"type":"array","items":{"type":"object","required":["subFeature","group","reason"],"properties":{"subFeature":{"type":"string"},"group":{"type":"string"},"reason":{"type":"string"}}}}}}},"axisNote":{"type":"string"}}},"fetchedAt":{"type":"string"},"contractSource":{"type":"string","description":"Measurement contract provenance id (same source string every coverage endpoint reports)."}}},"ConvertV1Request":{"type":"object","required":["code","targetLanguage"],"properties":{"code":{"type":"string","minLength":1,"description":"UTF-8 source text. Processed in-memory only; never logged or retained."},"sourceLanguage":{"type":"string","minLength":1,"maxLength":64},"targetLanguage":{"type":"string","minLength":1,"maxLength":64}},"additionalProperties":false},"ConvertV1Response":{"type":"object","required":["ok","status","sourceLanguage","targetLanguage","text","fragments","gaps","verification","requestId","schemaVersion"],"properties":{"schemaVersion":{"type":"string","const":"1.1","description":"Conversion envelope schema. Version 1.1 permits honest indexed partial text while retaining fragments and gaps; an unassembled partial may keep text null."},"ok":{"type":"boolean","description":"True only for a complete converted result: one or more fragments and no gaps. Partial and no-output results are false even when text is non-null."},"status":{"type":"string","enum":["converted","partial","unsupported-target","no-implemented-route","input-law-fail","adapter-fail"],"description":"Domain status. converted is the complete state; partial and all failure statuses have ok=false."},"sourceLanguage":{"type":["string","null"]},"targetLanguage":{"type":"string"},"text":{"type":["string","null"],"description":"Complete target text, or honest partial text for a dense indexed root sequence when at least one form converted. Partial text preserves each gap form in place as a deterministic target-language comment wrapping its original source; it may not compile or run and does not make ok true. Null when there is no assembled output, including an unindexed partial that still retains authoritative fragments and gaps."},"fragmentKind":{"type":"string","enum":["compilation-unit","expression","statement","top-level-declaration","member-declaration","function-body-statement"],"description":"Parser context of the returned text. `converted` alone does not mean a whole program: several targets render an expression fragment, which a caller must place where its grammar admits an expression. Absent when the renderer declared no context."},"fragments":{"type":"array","description":"Registered per-construct renders with semantic evidence reported independently. Exact-target-text regression establishes implementation only. For multi-statement root sequences each fragment carries formIndex, the ordinal of its top-level form — together with gap ordinals an agent can reconstruct ordered partial output.","items":{"type":"object","required":["facetKey","text","implemented","semanticVerified","verified"],"properties":{"facetKey":{"type":"string"},"text":{"type":["string","null"]},"implemented":{"type":"boolean","const":true,"description":"A registered direct emitter produced the fragment."},"semanticVerified":{"type":"boolean","const":false,"description":"Fail-closed false because the current transform receipt has no per-invocation semantic oracle. Aggregate cell-level courts do not promote this fragment."},"verified":{"type":"boolean","const":false,"deprecated":true,"description":"Deprecated semantic alias; always equal to semanticVerified and fail-closed false on the current wire."},"formIndex":{"type":"integer"}},"additionalProperties":false}},"gaps":{"type":"array","description":"Unconverted constructs with public reasons. Gaps remain present and authoritative even when text contains source-preserving comment blocks for those forms.","items":{"type":"object","required":["facetKey","reason","message"],"properties":{"facetKey":{"type":["string","null"]},"reason":{"type":"string"},"message":{"type":"string"},"formIndex":{"type":"integer"}},"additionalProperties":false}},"disclosures":{"type":"array","items":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}},"additionalProperties":false}},"verification":{"type":"object","required":["inputLaw","outputAdapters","pairKey","routeSource"],"properties":{"inputLaw":{"type":"string","enum":["pass","fail","not-run"]},"outputAdapters":{"type":"string","const":"registered-direct-only"},"pairKey":{"type":["string","null"]},"routeSource":{"type":"string","const":"output-target-adapter-inventory"}},"additionalProperties":false},"requestId":{"type":"string"}},"additionalProperties":false},"ChefProcessUsageMetadata":{"type":"object","required":["route","plan","tier","authRequired","authenticated","authorized","limits"],"properties":{"route":{"type":"string","const":"chef-process"},"plan":{"type":"string","enum":["free","pro","max"]},"tier":{"type":"string","enum":["anon","non-admin","admin"]},"authRequired":{"type":"boolean"},"authenticated":{"type":"boolean"},"authorized":{"type":"boolean"},"limits":{"type":"object","required":["maxInputBytes","timeoutMs","rate","daily"],"properties":{"maxInputBytes":{"type":"number"},"timeoutMs":{"type":"number"},"rate":{"type":"object","required":["capacity","refillPerSec"],"properties":{"capacity":{"type":"number"},"refillPerSec":{"type":"number"}},"additionalProperties":false},"daily":{"$ref":"#/components/schemas/ChefDailyQuotaSnapshot"}},"additionalProperties":false}},"additionalProperties":false},"ChefDailyQuotaSnapshot":{"type":"object","required":["freeLimit","proLimit","planLimit","remaining","resetSec","countAvailable","storage","degraded"],"properties":{"freeLimit":{"type":"number"},"proLimit":{"type":"number"},"planLimit":{"type":["number","null"]},"remaining":{"type":["number","null"]},"resetSec":{"type":"number"},"countAvailable":{"type":"boolean"},"storage":{"type":"string","enum":["reliable","memory","unavailable"]},"degraded":{"type":"boolean"}},"additionalProperties":false},"ChefProcessHealth":{"type":"object","required":["ok","runtime","authRequired","authenticated","authorized","limits","usage"],"properties":{"ok":{"type":"boolean"},"runtime":{"type":"string","const":"nodejs"},"authRequired":{"type":"boolean"},"authenticated":{"type":"boolean"},"authorized":{"type":"boolean"},"limits":{"type":"object","required":["maxInputBytes","timeoutMs","rate","daily"],"properties":{"maxInputBytes":{"type":"number"},"timeoutMs":{"type":"number"},"rate":{"type":"object","required":["capacity","refillPerSec"],"properties":{"capacity":{"type":"number"},"refillPerSec":{"type":"number"}}},"daily":{"$ref":"#/components/schemas/ChefDailyQuotaSnapshot"}}},"usage":{"$ref":"#/components/schemas/ChefProcessUsageMetadata"}},"additionalProperties":false}}}}