{"openapi":"3.1.0","info":{"title":"Mentat API","version":"0.1.0","summary":"The permission and audit layer for coding agents.","description":"Mentat is the permission and audit layer for coding agents. It holds a team's decisions as a graph (rules, the assumptions they rest on, and scoped exceptions), derives contradictions between them on every read, and tells an agent what governs a file before it edits it. When two active decisions disagree about a file, Mentat returns a block naming both authors rather than picking a side.\n\n**No signup.** `POST /api/workspaces` creates a workspace and returns a bearer token of the form `mtk_...`. The token is shown exactly once and is the only credential for that graph; lose it and the graph is unreachable. Send it as `Authorization: Bearer mtk_...` on every operation marked with `bearerAuth`.\n\n**MCP.** `POST /mcp` is a stateless Model Context Protocol server over Streamable HTTP, answering each JSON-RPC 2.0 request with a single JSON body and never issuing a session id. With a workspace token it operates on that workspace. Without an Authorization header it serves the read-only demo graph, so an agent can try it with no credential at all. A header that is present but malformed is rejected with 401 rather than silently falling back to the demo.\n\n**Public endpoints.** `/api/health`, `/api/demo/*` (a fresh copy of the seed graph per request, nothing persisted) and the precedent ledger need no token. Rate limits are fixed-window: workspace creation 10 per hour per IP, the demo 120 per minute per IP, and `/mcp` 600 per minute per token or IP. Request bodies are capped at 16 MiB on `/api/graph/replace`, `/api/graph/ingest` and `/api/graph/compile`, and at 2 MiB everywhere else; a larger body is refused with 413 before anything parses it.\n\n**Human gate.** Extracted decisions always land as `proposed`. Only an explicit call to promote one makes it govern files; nothing is promoted automatically.","contact":{"name":"Mentat","url":"https://trymentat.pages.dev/contact"},"license":{"name":"Proprietary. All rights reserved."}},"externalDocs":{"description":"Documentation at https://trymentat.pages.dev/docs and the developer guide at https://trymentat.pages.dev/developers.","url":"https://trymentat.pages.dev/docs"},"servers":[{"url":"https://trymentat.pages.dev"}],"tags":[{"name":"Meta","description":"Discovery and health."},{"name":"Workspaces","description":"Create a workspace and manage its settings.","externalDocs":{"url":"https://trymentat.pages.dev/developers"}},{"name":"Graph","description":"The authenticated decision graph."},{"name":"Precedent","description":"Anonymised cross-organisation outcomes."},{"name":"Demo","description":"Read-only public demo over the seed graph."},{"name":"MCP","description":"The Model Context Protocol endpoint."}],"paths":{"/api":{"get":{"operationId":"getApiIndex","summary":"API root index","description":"A small JSON index of the API: where the OpenAPI document, human docs, MCP endpoint, llms.txt, and health check live, plus a list of every documented operation.","tags":["Meta"],"security":[],"responses":{"200":{"description":"The index.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiIndex"}}}},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/":{"get":{"operationId":"getApiIndexTrailingSlash","summary":"API root index (trailing slash)","description":"Identical to `GET /api`, served at the trailing-slash form as well.","tags":["Meta"],"security":[],"responses":{"200":{"description":"The index.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiIndex"}}}},"500":{"$ref":"#/components/responses/InternalError"}}}},"/openapi.json":{"get":{"operationId":"getOpenApiDocument","summary":"This OpenAPI document","description":"The OpenAPI 3.1 description of this API, with `servers` set to the origin the request reached. CORS-open and cached for five minutes.","tags":["Meta"],"security":[],"responses":{"200":{"description":"An OpenAPI 3.1.0 document.","content":{"application/json":{"schema":{"type":"object"}}}},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/openapi.json":{"get":{"operationId":"getApiOpenApiDocument","summary":"This OpenAPI document (under /api)","description":"Identical to `GET /openapi.json`, served under the `/api` prefix as well.","tags":["Meta"],"security":[],"responses":{"200":{"description":"An OpenAPI 3.1.0 document.","content":{"application/json":{"schema":{"type":"object"}}}},"500":{"$ref":"#/components/responses/InternalError"}}}},"/.well-known/mcp/server-card.json":{"get":{"operationId":"getMcpServerCard","summary":"MCP server card","description":"The MCP server card (SEP-1649 and SEP-2127 shapes in one document): transport, endpoint, supported protocol versions, optional bearer auth, and the full tool list. Generated from the same constants the MCP endpoint runs on.","tags":["Meta"],"security":[],"responses":{"200":{"description":"The server card.","content":{"application/json":{"schema":{"type":"object","required":["name","version","remotes","serverInfo","transport","capabilities","tools"],"additionalProperties":true}}}},"500":{"$ref":"#/components/responses/InternalError"}}}},"/.well-known/mcp/server-cards.json":{"get":{"operationId":"getMcpServerCardPlural","summary":"MCP server card (plural path)","description":"Identical to `GET /.well-known/mcp/server-card.json`, at the plural filename proposed by SEP-2127.","tags":["Meta"],"security":[],"responses":{"200":{"description":"The server card.","content":{"application/json":{"schema":{"type":"object","required":["name","version","remotes","serverInfo","transport","capabilities","tools"],"additionalProperties":true}}}},"500":{"$ref":"#/components/responses/InternalError"}}}},"/.well-known/mcp.json":{"get":{"operationId":"getMcpManifest","summary":"MCP manifest","description":"Identical to `GET /.well-known/mcp/server-card.json`, at the shorter manifest path some clients probe.","tags":["Meta"],"security":[],"responses":{"200":{"description":"The server card.","content":{"application/json":{"schema":{"type":"object","required":["name","version","remotes","serverInfo","transport","capabilities","tools"],"additionalProperties":true}}}},"500":{"$ref":"#/components/responses/InternalError"}}}},"/.well-known/api-catalog":{"get":{"operationId":"getApiCatalog","summary":"API catalog (RFC 9727)","description":"A linkset (`application/linkset+json`) naming the REST API and the MCP endpoint, each with its machine-readable description and human documentation.","tags":["Meta"],"security":[],"responses":{"200":{"description":"The linkset.","content":{"application/linkset+json":{"schema":{"type":"object","required":["linkset"],"properties":{"linkset":{"type":"array","items":{"type":"object","additionalProperties":true}}}}}}},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/health":{"get":{"operationId":"getHealth","summary":"Health check","description":"Liveness plus the service version, and whether conflict adjudication runs on Claude (an Anthropic key is configured) or on the deterministic path.","tags":["Meta"],"security":[],"responses":{"200":{"description":"The service is up.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","const":true},"service":{"type":"string","const":"mentat"},"version":{"type":"string","const":"0.1.0"},"adjudicator":{"type":"string","enum":["claude","deterministic"]},"time":{"type":"string","format":"date-time"}},"required":["ok","service","version","adjudicator","time"]}}}},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/workspaces":{"post":{"operationId":"createWorkspace","summary":"Create a workspace and get its token","description":"Creates a workspace with no account. The response carries the bearer token (`mtk_...`) exactly once; store it, because it is the only credential for the graph and cannot be recovered. Optionally cold-start the graph from an existing instruction file (parsed into `proposed` decisions) or load the demo graph with `seed: true`. The body may be omitted entirely. Rate limited to 10 per hour per IP.","tags":["Workspaces"],"security":[],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":80,"description":"Defaults to `workspace`."},"repo":{"type":"string","maxLength":200,"description":"Repository name, informational."},"instructions":{"type":"string","maxLength":200000,"description":"Contents of an existing AGENTS.md or CLAUDE.md, parsed into proposed decisions. Ignored when `seed` is true."},"seed":{"type":"boolean","description":"Load the demo graph instead."}},"additionalProperties":false}}}},"responses":{"201":{"description":"Created. `token` is never shown again.","content":{"application/json":{"schema":{"type":"object","properties":{"workspace":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","name","createdAt"]},"token":{"type":"string","pattern":"^mtk_","description":"The bearer token."},"seeded":{"type":"integer","description":"Decisions loaded at creation."},"message":{"type":"string"},"mcp":{"type":"object","properties":{"claudeCode":{"type":"string","description":"A ready-to-run `claude mcp add` command."},"json":{"type":"object","additionalProperties":true,"description":"An `mcpServers` config block for editors."}},"required":["claudeCode","json"]}},"required":["workspace","token","seeded","message","mcp"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/workspaces/me":{"get":{"operationId":"getWorkspace","summary":"Describe the current workspace","description":"The workspace the token belongs to, with decision counts by status and counts of assumptions and exceptions.","tags":["Workspaces"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"The workspace.","content":{"application/json":{"schema":{"type":"object","properties":{"workspace":{"$ref":"#/components/schemas/Workspace"},"counts":{"type":"object","properties":{"decisions":{"type":"integer"},"active":{"type":"integer"},"proposed":{"type":"integer"},"questioned":{"type":"integer"},"assumptions":{"type":"integer"},"exceptions":{"type":"integer"}},"required":["decisions","active","proposed","questioned","assumptions","exceptions"]}},"required":["workspace","counts"]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/workspaces/me/precedent":{"post":{"operationId":"setPrecedentOptIn","summary":"Opt in or out of cross-organisation precedent","description":"Off by default. When enabled, resolved conflicts may be contributed as anonymised records built only from closed vocabularies. The response lists exactly what is shared and what never leaves the workspace.","tags":["Workspaces","Precedent"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean"}},"required":["enabled"]}}}},"responses":{"200":{"description":"The new setting and the consent terms.","content":{"application/json":{"schema":{"type":"object","properties":{"precedentOptIn":{"type":"boolean"},"shares":{"type":"array","items":{"type":"string"}},"neverShares":{"type":"array","items":{"type":"string"}}},"required":["precedentOptIn","shares","neverShares"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/workspaces/events":{"get":{"operationId":"listWorkspaceEvents","summary":"List the workspace event log","description":"The append-only audit log, newest first: recordings, promotions, amendments, broken assumptions, blocks, and so on.","tags":["Workspaces"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"limit","in":"query","required":false,"description":"Maximum events to return. Truncated to an integer and capped at 500; a non-positive or non-numeric value falls back to 100.","schema":{"type":"integer","minimum":1,"maximum":500,"default":100}}],"responses":{"200":{"description":"Events, newest first.","content":{"application/json":{"schema":{"type":"object","properties":{"events":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string"},"actor":{"type":"string"},"subjectId":{"type":"string"},"payload":{"description":"Event-specific JSON."},"createdAt":{"type":"string","format":"date-time"}},"required":["kind","actor","subjectId","payload","createdAt"]}}},"required":["events"]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph":{"get":{"operationId":"getGraph","summary":"Read the whole graph with derived conflicts","description":"The full decision graph plus every live conflict derived from it on this read (conflicts are never stored), the pipeline trace, assumptions ordered by staleness, and the coherence score.","tags":["Graph"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"The graph view.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GraphView"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/replace":{"post":{"operationId":"replaceGraph","summary":"Replace the whole graph","description":"Whole-graph replace, used by the CLI to sync a committed `.mentat/graph.json`. Last write wins. At most 5000 decisions, and glob scopes that escape the repository root are rejected.","tags":["Graph"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"graph":{"type":"object","properties":{"decisions":{"type":"array","maxItems":5000,"items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"constraint":{"type":"string"},"scopes":{"type":"array","items":{"type":"object","properties":{"level":{"type":"string","enum":["glob","module","symbol","semantic"]},"value":{"type":"string","minLength":1}},"required":["level","value"]}}},"required":["id","constraint","scopes"],"additionalProperties":true},"description":"Decisions in the shape of the `Decision` schema."},"assumptions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1}},"required":["id"],"additionalProperties":true}},"exceptions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"decisionId":{"type":"string"}},"required":["id","decisionId"],"additionalProperties":true}},"modules":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"default":{}},"semanticCache":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"default":{}}},"required":["decisions","assumptions","exceptions"]}},"required":["graph"]}}}},"responses":{"200":{"description":"Counts of what was written.","content":{"application/json":{"schema":{"type":"object","properties":{"counts":{"type":"object","properties":{"decisions":{"type":"integer"},"assumptions":{"type":"integer"},"exceptions":{"type":"integer"}},"required":["decisions","assumptions","exceptions"]}},"required":["counts"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/resolve":{"post":{"operationId":"resolvePath","summary":"What governs this file","description":"Resolve the decisions that govern a repository path, most specific first, with any blocking conflicts and lower-confidence questions. A non-empty `block` means an agent must stop and report both decisions to the user.","tags":["Graph"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"file_path":{"type":"string","minLength":1,"description":"Repository-relative path."},"symbols":{"type":"array","items":{"type":"string"},"description":"Fully qualified symbols being touched."}},"required":["file_path"]}}}},"responses":{"200":{"description":"The resolution.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Resolution"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/tools/{name}":{"post":{"operationId":"callGraphTool","summary":"Call an MCP tool over plain HTTP","description":"Runs one of the MCP tools against this workspace without a JSON-RPC envelope. The body is the tool's arguments object; see `tools/list` on `/mcp` for each tool's input schema. An unknown tool or a tool-level error returns 400 with `isError: true`.","tags":["Graph"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"name","in":"path","required":true,"description":"The tool name.","schema":{"type":"string","enum":["relevant","record","conflicts","resolve","assumptions","break_assumption","compile","coherence","watch_assumption","check_assumptions","enforce","amend","history","queue"]}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"description":"Tool arguments."}}}},"responses":{"200":{"description":"The tool result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolResult"}}}},"400":{"description":"The tool reported an error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolResult"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/decisions":{"post":{"operationId":"createDecision","summary":"Record a decision","description":"Records a decision as `proposed`. Set `activate: true` only when a human is typing the rule in themselves, which makes it `active` at once; extracted decisions must go through `promoteDecision` instead.","tags":["Graph"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"constraint":{"type":"string","minLength":8,"maxLength":500,"description":"The rule, one imperative sentence."},"justification":{"type":"string","maxLength":2000,"default":"","description":"Why the rule exists."},"scopes":{"type":"array","items":{"type":"string","minLength":1},"default":[],"description":"Globs such as `src/routes/**`, or `module:orders`."},"assumption":{"type":"string","maxLength":300,"description":"A premise the rule rests on, recorded as an assumption."},"statement_type":{"type":"string","enum":["code_inferable","structural","infrastructure","intent_oriented","process"]},"author":{"type":"string","maxLength":80},"activate":{"type":"boolean","description":"Record straight to `active`."}},"required":["constraint"]}}}},"responses":{"201":{"description":"Recorded.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ToolResult"},{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string","enum":["active","proposed"]}},"required":["status"]}]}}}},"400":{"description":"Validation failed, or the record tool refused.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/Error"},{"$ref":"#/components/schemas/ToolResult"}]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/decisions/{id}":{"patch":{"operationId":"amendDecision","summary":"Amend fields of a decision","description":"Changes one or more fields in place. The decision keeps its id and revision history; each changed field becomes an append-only amendment carrying the required `reason`. Returns the conflicts that now touch the decision.","tags":["Graph"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Decision id.","schema":{"type":"string","minLength":1}}],"requestBody":{"required":true,"description":"`reason` plus at least one field to change.","content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","minLength":1,"maxLength":500,"description":"Why, in the author's words."},"constraint":{"type":"string","minLength":8,"maxLength":500},"justification":{"type":"string","maxLength":2000},"scopes":{"type":"array","items":{"type":"string","minLength":1}},"polarity":{"type":"string","enum":["require","forbid","permit","prefer"]},"statement_type":{"type":"string","enum":["code_inferable","structural","infrastructure","intent_oriented","process"]},"rests_on":{"type":"array","items":{"type":"string","minLength":1},"description":"Assumption ids."}},"required":["reason"],"minProperties":2}}}},"responses":{"200":{"description":"Amended, or nothing changed because every field already held that value.","content":{"application/json":{"schema":{"type":"object","properties":{"changed":{"type":"boolean"},"revision":{"type":"integer"},"amendments":{"type":"array","items":{"$ref":"#/components/schemas/Amendment"}},"message":{"type":"string"},"cost":{"type":"object","properties":{"pairsTotal":{"type":"integer"},"pairsAffected":{"type":"integer"},"saved":{"type":"number"}},"required":["pairsTotal","pairsAffected","saved"]},"conflicts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"blocking":{"type":"boolean"},"incompatibility":{"type":"string"}},"required":["id","blocking","incompatibility"]}}},"required":["changed","amendments"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"The amendment was refused.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/decisions/{id}/promote":{"post":{"operationId":"promoteDecision","summary":"Promote a proposed decision to active","description":"The one mandatory human gate: a proposed decision governs nothing until this is called. Refused when the decision is not `proposed`, or when an assumption it rests on is broken. Returns any conflicts the promotion just created.","tags":["Graph"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Decision id.","schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"Promoted.","content":{"application/json":{"schema":{"type":"object","properties":{"promoted":{"type":"string"},"newConflicts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"confidence":{"type":"number"},"blocking":{"type":"boolean"},"other":{"$ref":"#/components/schemas/Decision"},"incompatibility":{"type":"string"}},"required":["id","confidence","blocking","other","incompatibility"]}}},"required":["promoted","newConflicts"]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"Not proposed (`not_proposed`, with the current `status`) or `refused` because a premise is broken.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/decisions/{id}/history":{"get":{"operationId":"getDecisionHistory","summary":"Amendment history of a decision","description":"Every amendment to one decision, oldest first, plus a rendered text diff.","tags":["Graph"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Decision id.","schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"The history.","content":{"application/json":{"schema":{"type":"object","properties":{"decision":{"type":"object","properties":{"id":{"type":"string"},"constraint":{"type":"string"},"revision":{"type":"integer"}},"required":["id","constraint","revision"]},"amendments":{"type":"array","items":{"$ref":"#/components/schemas/Amendment"}},"rendered":{"type":"string"}},"required":["decision","amendments","rendered"]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/decisions/{id}/reject":{"post":{"operationId":"rejectDecision","summary":"Reject and delete a decision","description":"Removes the decision from the graph and records the rejection.","tags":["Graph"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Decision id.","schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"Rejected.","content":{"application/json":{"schema":{"type":"object","properties":{"rejected":{"type":"string"}},"required":["rejected"]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/assumptions/{id}/break":{"post":{"operationId":"breakAssumption","summary":"Mark an assumption broken","description":"Breaks the assumption and cascades: every active decision resting on it becomes `questioned`.","tags":["Graph"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Assumption id.","schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"The cascade.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Cascade"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/assumptions/{id}/verify":{"post":{"operationId":"verifyAssumption","summary":"Mark an assumption verified","description":"Re-verifies the assumption and restores decisions that were questioned because of it. An unknown id is a no-op that returns empty lists.","tags":["Graph"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Assumption id.","schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"Decisions restored.","content":{"application/json":{"schema":{"type":"object","properties":{"restored":{"type":"array","items":{"$ref":"#/components/schemas/Decision"}},"notices":{"type":"array","items":{"type":"string"}}},"required":["restored","notices"]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/assumptions/{id}/monitor":{"put":{"operationId":"setAssumptionMonitor","summary":"Attach a metric monitor to an assumption","description":"Lets an assumption break itself when a metric crosses a threshold. The assumption holds while `value <comparator> threshold`. `configured` reports whether the provider can actually be sampled in this deployment.","tags":["Graph"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Assumption id.","schema":{"type":"string","minLength":1}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string","enum":["prometheus","static"],"default":"prometheus"},"query":{"type":"string","minLength":1,"maxLength":2000,"description":"Query in the provider's language."},"comparator":{"type":"string","enum":["lt","lte","gt","gte","eq","neq"]},"threshold":{"type":"number"},"unit":{"type":"string","maxLength":16},"breaches_before_breaking":{"type":"integer","minimum":1,"maximum":20,"default":2,"description":"Consecutive breaching samples before the assumption breaks."}},"required":["query","comparator","threshold"]}}}},"responses":{"200":{"description":"Monitor attached.","content":{"application/json":{"schema":{"type":"object","properties":{"assumptionId":{"type":"string"},"monitor":{"$ref":"#/components/schemas/Monitor"},"configured":{"type":"boolean"}},"required":["assumptionId","monitor","configured"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"500":{"$ref":"#/components/responses/InternalError"}}},"delete":{"operationId":"removeAssumptionMonitor","summary":"Detach the monitor from an assumption","description":"Removes the monitor and returns the assumption to manual verification.","tags":["Graph"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Assumption id.","schema":{"type":"string","minLength":1}}],"responses":{"200":{"description":"Monitor removed.","content":{"application/json":{"schema":{"type":"object","properties":{"assumptionId":{"type":"string"},"monitor":{"type":"null"}},"required":["assumptionId","monitor"]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/monitors/check":{"post":{"operationId":"checkMonitors","summary":"Sample every monitored assumption","description":"Samples each monitor once and applies the result: breaks premises past their breach count and restores recovered ones. An unreadable metric never breaks an assumption. Intended for a scheduled job.","tags":["Graph"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Verdicts for this round. `configured` is omitted when nothing is monitored.","content":{"application/json":{"schema":{"type":"object","properties":{"checked":{"type":"integer"},"verdicts":{"type":"array","items":{"$ref":"#/components/schemas/MonitorVerdict"}},"questioned":{"type":"array","items":{"type":"string"},"description":"Decision ids."},"restored":{"type":"array","items":{"type":"string"},"description":"Decision ids."},"notices":{"type":"array","items":{"type":"string"}},"configured":{"type":"boolean"}},"required":["checked","verdicts","questioned","restored","notices"]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/enforce":{"get":{"operationId":"planEnforcement","summary":"Compile checkable decisions into CI config","description":"Generates CI rules from `code_inferable` and `structural` decisions only. Every other decision that governs the directory is listed in `skipped` with the reason it was not compiled.","tags":["Graph"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"directory","in":"query","required":false,"description":"Repository-relative directory. Must not escape the repository root.","schema":{"type":"string","default":"."}}],"responses":{"200":{"description":"The enforcement plan.","content":{"application/json":{"schema":{"type":"object","properties":{"directory":{"type":"string"},"rules":{"type":"array","items":{"$ref":"#/components/schemas/EnforcementRule"}},"skipped":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"constraint":{"type":"string"},"statementType":{"$ref":"#/components/schemas/StatementType"},"reason":{"type":"string"}},"required":["id","constraint","statementType","reason"]}},"files":{"type":"object","additionalProperties":{"type":"string"},"description":"Generated config files keyed by relative path."}},"required":["directory","rules","skipped","files"]}}}},"400":{"description":"`invalid_scope`: the directory escapes the root.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/queue":{"get":{"operationId":"getConflictQueue","summary":"Open contradictions as tracked work","description":"Live conflicts as work items, each owned by both authors and never ranked, aged from the first time an agent was blocked, with coherence metrics alongside.","tags":["Graph"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"The queue.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/WorkItem"}},"overloaded":{"type":"boolean"},"oldestDays":{"type":"number"},"medianAgeDays":{"type":"number"},"metrics":{"$ref":"#/components/schemas/CoherenceMetrics"}},"required":["items","overloaded","oldestDays","medianAgeDays","metrics"]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/queue/route":{"post":{"operationId":"routeConflictQueue","summary":"Notify owners of open conflicts","description":"Sends one private notification per owner per unrouted conflict, capped; past the cap a digest is produced instead. With no notifier configured this is a dry run that reports what it would have sent.","tags":["Graph"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"What was delivered.","content":{"application/json":{"schema":{"type":"object","properties":{"transport":{"type":"string"},"delivered":{"type":"array","items":{"type":"object","properties":{"recipient":{"type":"string"},"ok":{"type":"boolean"},"detail":{"type":"string"}},"required":["recipient","ok","detail"]}},"digest":{"anyOf":[{"type":"string"},{"type":"null"}]},"suppressed":{"type":"integer"},"dryRun":{"type":"boolean"}},"required":["transport","delivered","digest","suppressed","dryRun"]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/metrics":{"get":{"operationId":"getMetrics","summary":"Coherence metrics","description":"Queue metrics plus the number of active decisions, monitored assumptions, and the coherence score from 0 to 100.","tags":["Graph"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Metrics.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/CoherenceMetrics"},{"type":"object","properties":{"decisions":{"type":"integer"},"monitoredAssumptions":{"type":"integer"},"coherence":{"type":"number","minimum":0,"maximum":100}},"required":["decisions","monitoredAssumptions","coherence"]}]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/decay":{"post":{"operationId":"applyDecay","summary":"Question decisions resting on stale assumptions","description":"Applies the decay clock: manually verified assumptions unverified for too long are questioned, and the decisions on them with them. Intended for a scheduled job.","tags":["Graph"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"The cascade.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Cascade"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/compile":{"post":{"operationId":"compileAgentsMd","summary":"Compile an AGENTS.md for a directory","description":"Renders the decisions governing a directory into AGENTS.md markdown. Pass the current file as `replacing` to get line and token deltas. Nothing is written to the repository.","tags":["Graph"],"security":[{"bearerAuth":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"directory":{"type":"string","default":".","description":"Repository-relative directory."},"replacing":{"type":"string","maxLength":500000}}}}}},"responses":{"200":{"description":"The compiled file.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompileResult"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/graph/ingest":{"post":{"operationId":"ingestTranscript","summary":"Extract proposed decisions from a transcript or file","description":"Extracts candidate decisions from an agent session (`jsonl` or `chat`), an instruction file, or an ADR. Everything lands as `proposed`; nothing governs a file until a human promotes it.","tags":["Graph"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"content":{"type":"string","minLength":1,"maxLength":2000000},"format":{"type":"string","enum":["jsonl","chat","instructions","adr"],"default":"jsonl"},"id":{"type":"string","maxLength":120,"default":"session","description":"Source identifier."},"author":{"type":"string","maxLength":80}},"required":["content"]}}}},"responses":{"200":{"description":"Proposals added.","content":{"application/json":{"schema":{"type":"object","properties":{"extracted":{"type":"integer"},"added":{"type":"integer"},"duplicates":{"type":"integer"},"proposals":{"type":"array","items":{"type":"object","properties":{"decision":{"$ref":"#/components/schemas/Decision"},"assumption":{"anyOf":[{"$ref":"#/components/schemas/Assumption"},{"type":"null"}]},"evidence":{"type":"string"},"inventedScope":{"type":"boolean"}},"required":["decision","assumption","evidence","inventedScope"]}},"message":{"type":"string"}},"required":["extracted","added","duplicates","proposals","message"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/precedent/ledger":{"get":{"operationId":"getPrecedentLedger","summary":"Public precedent ledger","description":"Counts only: how many organisations and records have contributed, by axis. Aggregates are served only once 5 distinct organisations have contributed.","tags":["Precedent"],"security":[],"responses":{"200":{"description":"The ledger.","content":{"application/json":{"schema":{"type":"object","properties":{"contributors":{"type":"integer"},"records":{"type":"integer"},"byDimension":{"type":"object","additionalProperties":{"type":"integer"}},"floor":{"type":"integer"},"servable":{"type":"boolean"},"note":{"type":"string"}},"required":["contributors","records","byDimension","floor","servable","note"]}}}},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/precedent/{dimension}":{"get":{"operationId":"getPrecedent","summary":"How other teams resolved disagreements on an axis","description":"Aggregate outcomes for one axis. Below 5 distinct contributing organisations the answer is `summary: null` with a count, never a smaller aggregate.","tags":["Precedent"],"security":[],"parameters":[{"name":"dimension","in":"path","required":true,"description":"The axis.","schema":{"$ref":"#/components/schemas/Dimension"}},{"name":"concepts","in":"query","required":false,"description":"Comma-separated concept keys to narrow by. Each must match `^[a-z_]{2,40}$`; anything else is silently dropped.","schema":{"type":"string"}}],"responses":{"200":{"description":"A summary, or the reason none is served.","content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"summary":{"$ref":"#/components/schemas/PrecedentSummary"},"sentence":{"type":"string"}},"required":["summary","sentence"]},{"type":"object","properties":{"summary":{"type":"null"},"contributors":{"type":"integer"},"floor":{"type":"integer"},"message":{"type":"string"}},"required":["summary","contributors","floor","message"]}]}}}},"400":{"description":"`unknown_dimension`, with the `allowed` list.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"unknown_dimension"},"allowed":{"type":"array","items":{"$ref":"#/components/schemas/Dimension"}}},"required":["error","allowed"]}}}},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/precedent/contribute":{"post":{"operationId":"contributePrecedent","summary":"Contribute one resolved conflict, anonymised","description":"Requires the workspace to have opted in. Send a conflict id and what happened; the anonymised record is built server-side from closed vocabularies and echoed back exactly as stored. No constraint text, justification, author, scope, or repository ever leaves.","tags":["Precedent"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"conflict_id":{"type":"string","minLength":1},"action":{"type":"string","enum":["except","supersede","retire","unresolved"]},"days_to_resolve":{"type":"number","minimum":0,"maximum":3650,"default":0},"reversed_later":{"type":"boolean","default":false},"surviving_scope_is_broader":{"type":["boolean","null"],"default":null}},"required":["conflict_id","action"]}}}},"responses":{"200":{"description":"Stored.","content":{"application/json":{"schema":{"type":"object","properties":{"contributed":{"$ref":"#/components/schemas/PrecedentRecord"}},"required":["contributed"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"`not_opted_in`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"422":{"description":"`not_publishable`: the record failed the privacy check.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/demo/graph":{"get":{"operationId":"getDemoGraph","summary":"The demo graph with derived conflicts","description":"The seed graph, read-only, evaluated at a fixed clock so the numbers are stable. Same shape as `getGraph`.","tags":["Demo"],"security":[],"responses":{"200":{"description":"The graph view.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GraphView"}}}},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/demo/resolve":{"post":{"operationId":"resolveDemoPath","summary":"What governs a file in the demo graph","description":"Same as `resolvePath`, against the read-only seed graph.","tags":["Demo"],"security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"file_path":{"type":"string","minLength":1,"maxLength":400}},"required":["file_path"]}}}},"responses":{"200":{"description":"The resolution.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Resolution"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/demo/derive":{"post":{"operationId":"deriveDemoConflict","summary":"Test two rules for a contradiction","description":"The playground. Two rules in, the full three-stage pipeline out (scope intersection, axis and direction, adjudication), including the stage that ruled the pair out. Nothing is stored.","tags":["Demo"],"security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"a":{"type":"object","properties":{"constraint":{"type":"string","minLength":6,"maxLength":400,"description":"The rule, one sentence."},"justification":{"type":"string","maxLength":600,"default":""},"scope":{"type":"string","minLength":1,"maxLength":200,"default":"**","description":"Comma-separated scopes. A bare value is a glob; prefix with `module:`, `symbol:` or `semantic:` for other levels."},"author":{"type":"string","maxLength":60,"default":"engineer a"}},"required":["constraint"]},"b":{"type":"object","properties":{"constraint":{"type":"string","minLength":6,"maxLength":400,"description":"The rule, one sentence."},"justification":{"type":"string","maxLength":600,"default":""},"scope":{"type":"string","minLength":1,"maxLength":200,"default":"**","description":"Comma-separated scopes. A bare value is a glob; prefix with `module:`, `symbol:` or `semantic:` for other levels."},"author":{"type":"string","maxLength":60,"default":"engineer b"}},"required":["constraint"]}},"required":["a","b"]}}}},"responses":{"200":{"description":"The trace.","content":{"application/json":{"schema":{"type":"object","properties":{"decisions":{"type":"object","properties":{"a":{"$ref":"#/components/schemas/Decision"},"b":{"$ref":"#/components/schemas/Decision"}},"required":["a","b"]},"stages":{"type":"array","items":{"type":"object","properties":{"stage":{"type":"string","enum":["scope","dimension","adjudication"]},"label":{"type":"string"},"passed":{"type":"boolean"},"detail":{"type":"string"},"deterministic":{"type":"boolean"},"skipped":{"type":"boolean"}},"required":["stage","label","passed","detail","deterministic"]}},"conflict":{"anyOf":[{"type":"object","properties":{"id":{"type":"string"},"confidence":{"type":"number"},"blocking":{"type":"boolean"},"dimension":{"$ref":"#/components/schemas/Dimension"},"incompatibility":{"type":"string"},"scopeOverlap":{"type":"string"},"sharedObjects":{"type":"array","items":{"type":"string"}}},"required":["id","confidence","blocking","dimension","incompatibility","scopeOverlap","sharedObjects"]},{"type":"null"}]},"trace":{"$ref":"#/components/schemas/PipelineTrace"},"adjudicator":{"type":"string"}},"required":["decisions","stages","conflict","trace","adjudicator"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/demo/break":{"post":{"operationId":"breakDemoAssumption","summary":"Preview a broken-assumption cascade","description":"Breaks an assumption in a fresh copy of the seed graph and returns the result. Nothing is written.","tags":["Demo"],"security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"assumption_id":{"type":"string","minLength":1}},"required":["assumption_id"]}}}},"responses":{"200":{"description":"The cascaded graph.","content":{"application/json":{"schema":{"type":"object","properties":{"graph":{"$ref":"#/components/schemas/Graph"},"questioned":{"type":"array","items":{"$ref":"#/components/schemas/Decision"}},"notices":{"type":"array","items":{"type":"string"}},"conflicts":{"type":"array","items":{"$ref":"#/components/schemas/LiveConflict"}},"coherence":{"$ref":"#/components/schemas/CoherenceScore"}},"required":["graph","questioned","notices","conflicts","coherence"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/demo/compile":{"get":{"operationId":"compileDemoAgentsMd","summary":"Compile the demo AGENTS.md","description":"Compiles the seed graph for a directory and returns it beside the legacy instruction file it replaces.","tags":["Demo"],"security":[],"parameters":[{"name":"directory","in":"query","required":false,"description":"Repository-relative directory.","schema":{"type":"string","default":"src/routes"}}],"responses":{"200":{"description":"The compiled file.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/CompileResult"},{"type":"object","properties":{"replacing":{"type":"string"}},"required":["replacing"]}]}}}},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/demo/decay":{"get":{"operationId":"getDemoDecay","summary":"Preview the decay clock on the demo graph","description":"What applying the decay clock to the seed graph would question.","tags":["Demo"],"security":[],"responses":{"200":{"description":"The cascade.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Cascade"}}}},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/mcp":{"post":{"operationId":"mcpRequest","summary":"Model Context Protocol (JSON-RPC 2.0)","description":"Stateless Streamable HTTP MCP server. POST one JSON-RPC 2.0 message or a batch of up to 32; each is answered with a single JSON body and no session id is ever issued. With a workspace bearer token it operates on that workspace; with no Authorization header at all it serves the read-only demo graph. A notification-only payload gets 202 with no body. Rate limited to 600 per minute per token or IP.","tags":["MCP"],"security":[{},{"bearerAuth":[]}],"parameters":[{"name":"MCP-Protocol-Version","in":"header","required":false,"description":"Negotiated protocol version. Unsupported values are rejected with 400.","schema":{"type":"string","enum":["2025-11-25","2025-06-18","2025-03-26"]}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/JsonRpcRequest"},{"type":"array","items":{"$ref":"#/components/schemas/JsonRpcRequest"},"maxItems":32}]}}}},"responses":{"200":{"description":"JSON-RPC response, or an array of them for a batch.","headers":{"MCP-Protocol-Version":{"description":"The protocol version in use.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/JsonRpcResponse"},{"type":"array","items":{"$ref":"#/components/schemas/JsonRpcResponse"}}]}}}},"202":{"description":"Accepted. The payload held only notifications."},"400":{"description":"Unparseable JSON, not a JSON-RPC message, an oversized batch, or an unsupported protocol version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JsonRpcResponse"}}}},"401":{"description":"The Authorization header is malformed or the workspace token is unknown. Remove the header to use the demo graph.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JsonRpcResponse"}}}},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}},"get":{"operationId":"mcpGetStream","summary":"Server-initiated stream (not supported)","description":"Always 405. Mentat never pushes unsolicited messages, so it opens no SSE stream; POST JSON-RPC instead.","tags":["MCP"],"security":[],"responses":{"405":{"description":"Method not allowed.","headers":{"Allow":{"schema":{"type":"string","const":"POST, OPTIONS"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/JsonRpcResponse"}}}},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}},"delete":{"operationId":"mcpDeleteSession","summary":"End a session (not supported)","description":"Always 405 with no body. The server is stateless and issues no sessions.","tags":["MCP"],"security":[],"responses":{"405":{"description":"Method not allowed.","headers":{"Allow":{"schema":{"type":"string","const":"POST, OPTIONS"}}}},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}},"options":{"operationId":"mcpPreflight","summary":"CORS preflight","description":"CORS preflight for browser-based clients. The endpoint is open to any origin; access is still governed by the bearer token.","tags":["MCP"],"security":[],"responses":{"204":{"description":"Preflight accepted.","headers":{"Access-Control-Allow-Origin":{"schema":{"type":"string","const":"*"}},"Access-Control-Allow-Methods":{"schema":{"type":"string"}},"Access-Control-Allow-Headers":{"schema":{"type":"string"}}}},"500":{"$ref":"#/components/responses/InternalError"}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"mtk_ workspace token","description":"The token returned once by `POST /api/workspaces`. Send `Authorization: Bearer mtk_...`."}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string","description":"Machine-readable code, e.g. `invalid_request`, `unauthorized`, `not_found`, `rate_limited`, `refused`, `internal_error`."},"message":{"type":"string","description":"Human-readable explanation, when one is given."}},"required":["error"],"additionalProperties":true},"StatementType":{"type":"string","enum":["code_inferable","structural","infrastructure","intent_oriented","process"],"description":"How enforceable a constraint is. Only `code_inferable` and `structural` are ever machine-checked; the rest are surfaced as context."},"DecisionStatus":{"type":"string","enum":["proposed","active","questioned","superseded","retired"]},"AssumptionStatus":{"type":"string","enum":["holding","questioned","broken"]},"Dimension":{"type":"string","enum":["data_access","dependency_direction","logging","error_handling","concurrency","naming","deployment","testing","auth","performance","api_contract","state_management","formatting","security","documentation","other"],"description":"The axis a rule constrains."},"Polarity":{"type":"string","enum":["require","forbid","permit","prefer","unknown"]},"Scope":{"type":"object","properties":{"level":{"type":"string","enum":["glob","module","symbol","semantic"]},"value":{"type":"string","description":"A glob, module name, qualified symbol, or natural language predicate."}},"required":["level","value"]},"Decision":{"type":"object","properties":{"id":{"type":"string"},"constraint":{"type":"string","description":"The rule, one imperative sentence."},"statementType":{"$ref":"#/components/schemas/StatementType"},"dimension":{"$ref":"#/components/schemas/Dimension"},"polarity":{"$ref":"#/components/schemas/Polarity"},"justification":{"type":"string"},"author":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"status":{"$ref":"#/components/schemas/DecisionStatus"},"confidence":{"type":"number","minimum":0,"maximum":1},"source":{"type":"string","enum":["agent_transcript","pr_review","adr","instruction_file","slack","manual"]},"sourceRef":{"type":"string"},"scopes":{"type":"array","items":{"$ref":"#/components/schemas/Scope"}},"restsOn":{"type":"array","items":{"type":"string"},"description":"Assumption ids."},"supersedes":{"type":"array","items":{"type":"string"},"description":"Decision ids."},"evidence":{"type":"string","description":"The sentence an extracted decision came from."},"revision":{"type":"integer","minimum":0}},"required":["id","constraint","statementType","dimension","polarity","justification","author","createdAt","status","confidence","source","sourceRef","scopes","restsOn","supersedes"]},"Monitor":{"type":"object","properties":{"provider":{"type":"string","enum":["prometheus","static"]},"query":{"type":"string"},"comparator":{"type":"string","enum":["lt","lte","gt","gte","eq","neq"]},"threshold":{"type":"number"},"unit":{"type":"string"},"breachesBeforeBreaking":{"type":"integer","minimum":1},"lastCheckedAt":{"type":"string","format":"date-time"},"lastValue":{"type":"number"},"consecutiveBreaches":{"type":"integer","minimum":0}},"required":["provider","query","comparator","threshold"]},"Assumption":{"type":"object","properties":{"id":{"type":"string"},"statement":{"type":"string"},"status":{"$ref":"#/components/schemas/AssumptionStatus"},"lastVerifiedAt":{"type":"string","format":"date-time"},"verificationMethod":{"type":"string","enum":["test","manual","monitor","none"]},"monitor":{"$ref":"#/components/schemas/Monitor"}},"required":["id","statement","status","lastVerifiedAt","verificationMethod"]},"Exception":{"type":"object","properties":{"id":{"type":"string"},"decisionId":{"type":"string"},"scopes":{"type":"array","items":{"$ref":"#/components/schemas/Scope"}},"reason":{"type":"string"},"author":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"expiresAt":{"type":"string","format":"date-time"}},"required":["id","decisionId","scopes","reason","author","createdAt","expiresAt"]},"Amendment":{"type":"object","properties":{"id":{"type":"string"},"decisionId":{"type":"string"},"field":{"type":"string","enum":["constraint","justification","scopes","polarity","statementType","restsOn"]},"before":{"type":"string"},"after":{"type":"string"},"author":{"type":"string"},"at":{"type":"string","format":"date-time"},"reason":{"type":"string"},"revision":{"type":"integer","minimum":1}},"required":["id","decisionId","field","before","after","author","at","reason","revision"]},"Graph":{"type":"object","properties":{"decisions":{"type":"array","items":{"$ref":"#/components/schemas/Decision"}},"assumptions":{"type":"array","items":{"$ref":"#/components/schemas/Assumption"}},"exceptions":{"type":"array","items":{"$ref":"#/components/schemas/Exception"}},"modules":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"description":"Module name to path prefixes."},"semanticCache":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"description":"Resolved semantic predicates to the globs they expanded to."},"amendments":{"type":"array","items":{"$ref":"#/components/schemas/Amendment"}}},"required":["decisions","assumptions","exceptions","modules","semanticCache"]},"Conflict":{"type":"object","properties":{"id":{"type":"string"},"a":{"$ref":"#/components/schemas/Decision"},"b":{"$ref":"#/components/schemas/Decision"},"confidence":{"type":"number","minimum":0,"maximum":1},"evidence":{"type":"object","properties":{"scopeOverlap":{"type":"object","properties":{"a":{"$ref":"#/components/schemas/Scope"},"b":{"$ref":"#/components/schemas/Scope"},"explanation":{"type":"string"}},"required":["a","b","explanation"]},"dimension":{"$ref":"#/components/schemas/Dimension"},"polarityA":{"$ref":"#/components/schemas/Polarity"},"polarityB":{"$ref":"#/components/schemas/Polarity"},"sharedObjects":{"type":"array","items":{"type":"string"}},"incompatibility":{"type":"string"}},"required":["scopeOverlap","dimension","polarityA","polarityB","sharedObjects","incompatibility"],"additionalProperties":true},"reachedStage":{"type":"string","enum":["scope","dimension","adjudication"]},"suppressedBy":{"$ref":"#/components/schemas/Exception"}},"required":["id","a","b","confidence","evidence","reachedStage"]},"LiveConflict":{"allOf":[{"$ref":"#/components/schemas/Conflict"},{"type":"object","properties":{"blocking":{"type":"boolean","description":"True when confidence is high enough that an agent must stop."}},"required":["blocking"]}]},"PipelineTrace":{"type":"object","properties":{"pairsConsidered":{"type":"integer"},"survivedScope":{"type":"integer"},"survivedDimension":{"type":"integer"},"conflicts":{"type":"integer"},"undetermined":{"type":"integer"},"elapsedMs":{"type":"number"}},"required":["pairsConsidered","survivedScope","survivedDimension","conflicts","undetermined"]},"Resolution":{"type":"object","properties":{"path":{"type":"string"},"constraints":{"type":"array","items":{"type":"object","properties":{"decision":{"$ref":"#/components/schemas/Decision"},"matchedBy":{"type":"object","properties":{"scope":{"$ref":"#/components/schemas/Scope"},"specificity":{"type":"number"}},"required":["scope","specificity"]},"questioned":{"type":"boolean"},"questionedReason":{"type":"string"},"assumptions":{"type":"array","items":{"$ref":"#/components/schemas/Assumption"}},"suppressedBy":{"type":"array","items":{"$ref":"#/components/schemas/Exception"}}},"required":["decision","matchedBy","questioned","assumptions","suppressedBy"]},"description":"Governing decisions, most specific first."},"block":{"type":"array","items":{"$ref":"#/components/schemas/Conflict"},"description":"Non-empty when the agent must stop."},"questions":{"type":"array","items":{"$ref":"#/components/schemas/Conflict"},"description":"Conflicts below the block threshold, surfaced as questions."},"trace":{"$ref":"#/components/schemas/PipelineTrace"}},"required":["path","constraints","block","questions","trace"]},"CoherenceScore":{"type":"object","properties":{"score":{"type":"number","minimum":0,"maximum":100},"grade":{"type":"string","enum":["A","B","C","D","F"]},"components":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","enum":["conflicts","freshness","grounding","precision"]},"label":{"type":"string"},"value":{"type":"number","minimum":0,"maximum":1},"weight":{"type":"number"},"detail":{"type":"string"}},"required":["key","label","value","weight","detail"]}},"actions":{"type":"array","items":{"type":"string"}}},"required":["score","grade","components","actions"]},"StaleAssumption":{"type":"object","properties":{"assumption":{"$ref":"#/components/schemas/Assumption"},"days":{"type":"number","description":"Days since last verified."},"status":{"$ref":"#/components/schemas/AssumptionStatus"}},"required":["assumption","days","status"]},"GraphView":{"type":"object","properties":{"graph":{"$ref":"#/components/schemas/Graph"},"conflicts":{"type":"array","items":{"$ref":"#/components/schemas/LiveConflict"}},"trace":{"$ref":"#/components/schemas/PipelineTrace"},"assumptions":{"type":"array","items":{"$ref":"#/components/schemas/StaleAssumption"},"description":"Most overdue first."},"coherence":{"$ref":"#/components/schemas/CoherenceScore"}},"required":["graph","conflicts","trace","assumptions","coherence"]},"Cascade":{"type":"object","properties":{"questioned":{"type":"array","items":{"$ref":"#/components/schemas/Decision"},"description":"Decisions whose status changed as a result."},"notices":{"type":"array","items":{"type":"string"}}},"required":["questioned","notices"]},"CompileResult":{"type":"object","properties":{"directory":{"type":"string"},"markdown":{"type":"string","description":"The generated AGENTS.md content."},"ruleCount":{"type":"integer"},"contextCount":{"type":"integer"},"dropped":{"type":"integer","description":"Rules dropped because the cap was hit."},"unresolved":{"type":"integer","description":"Conflicts inside this directory."},"stats":{"type":"object","properties":{"lines":{"type":"integer"},"approxTokens":{"type":"integer"},"replacedLines":{"type":"integer"},"replacedApproxTokens":{"type":"integer"}},"required":["lines","approxTokens"]}},"required":["directory","markdown","ruleCount","contextCount","dropped","unresolved","stats"],"additionalProperties":true},"EnforcementRule":{"type":"object","properties":{"decisionId":{"type":"string"},"target":{"type":"string","enum":["dependency-cruiser","eslint","mentat-check"]},"name":{"type":"string"},"comment":{"type":"string"},"rule":{"type":"object","additionalProperties":true}},"required":["decisionId","target","name","comment","rule"]},"WorkItem":{"type":"object","properties":{"conflictId":{"type":"string"},"owners":{"type":"array","items":{"type":"string"},"description":"Both authors, never ranked."},"dimension":{"$ref":"#/components/schemas/Dimension"},"incompatibility":{"type":"string"},"openedAt":{"type":"string","format":"date-time"},"ageDays":{"type":"integer"},"state":{"type":"string","enum":["fresh","ageing","stale"]},"blocking":{"type":"boolean"},"blockedCount":{"type":"integer"},"path":{"type":"string"}},"required":["conflictId","owners","dimension","incompatibility","openedAt","ageDays","state","blocking","blockedCount"]},"CoherenceMetrics":{"type":"object","properties":{"openConflicts":{"type":"integer"},"medianAgeDays":{"type":"number"},"oldestDays":{"type":"number"},"resolvedAllTime":{"type":"integer"},"medianTimeToResolveDays":{"anyOf":[{"type":"number"},{"type":"null"}]},"reversalRate":{"anyOf":[{"type":"number"},{"type":"null"}]},"blocksAvoided":{"type":"integer"},"byAction":{"type":"object","additionalProperties":{"type":"integer"}}},"required":["openConflicts","medianAgeDays","oldestDays","resolvedAllTime","medianTimeToResolveDays","reversalRate","blocksAvoided","byAction"]},"MonitorVerdict":{"type":"object","properties":{"assumptionId":{"type":"string"},"outcome":{"type":"string","enum":["holding","breaching","broken","recovered","unavailable"]},"value":{"type":"number"},"breaches":{"type":"integer"},"message":{"type":"string"}},"required":["assumptionId","outcome","breaches","message"]},"ToolResult":{"type":"object","properties":{"content":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","const":"text"},"text":{"type":"string"}},"required":["type","text"]}},"structuredContent":{"type":"object","additionalProperties":true},"isError":{"type":"boolean"}},"required":["content"]},"Workspace":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"repo":{"anyOf":[{"type":"string"},{"type":"null"}]},"precedentOptIn":{"type":"boolean"}},"required":["id","name","createdAt","repo","precedentOptIn"]},"PrecedentRecord":{"type":"object","properties":{"dimension":{"$ref":"#/components/schemas/Dimension"},"polarities":{"type":"array","prefixItems":[{"$ref":"#/components/schemas/Polarity"},{"$ref":"#/components/schemas/Polarity"}],"minItems":2},"concepts":{"type":"array","items":{"type":"string"}},"outcome":{"type":"string","enum":["broader-kept","narrower-kept","carved-out","both-kept","unresolved"]},"action":{"type":"string","enum":["except","supersede","retire","unresolved"]},"daysToResolveBucket":{"type":"string","enum":["same-day","under-a-week","under-a-month","longer"]},"reversedLater":{"type":"boolean"},"contributorDigest":{"type":"string","description":"One-way digest of the workspace."}},"required":["dimension","polarities","concepts","outcome","action","daysToResolveBucket","reversedLater","contributorDigest"]},"PrecedentSummary":{"type":"object","properties":{"dimension":{"$ref":"#/components/schemas/Dimension"},"concepts":{"type":"array","items":{"type":"string"}},"contributors":{"type":"integer","minimum":5},"total":{"type":"integer"},"outcomes":{"type":"object","additionalProperties":{"type":"integer"}},"reversalRate":{"type":"object","additionalProperties":{"type":"number"}},"modal":{"anyOf":[{"type":"object","properties":{"action":{"type":"string","enum":["except","supersede","retire","unresolved"]},"share":{"type":"number"}},"required":["action","share"]},{"type":"null"}]}},"required":["dimension","concepts","contributors","total","outcomes","reversalRate","modal"]},"JsonRpcRequest":{"type":"object","properties":{"jsonrpc":{"type":"string","const":"2.0"},"id":{"description":"Omit for a notification, which is answered with 202 and no body.","anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]},"method":{"type":"string","description":"`initialize`, `ping`, `tools/list`, `tools/call`, `resources/list`, `prompts/list`, or a `notifications/*` method."},"params":{"type":"object","additionalProperties":true}},"required":["jsonrpc","method"]},"JsonRpcResponse":{"type":"object","properties":{"jsonrpc":{"type":"string","const":"2.0"},"id":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"}]},"result":{"description":"Present on success."},"error":{"type":"object","properties":{"code":{"type":"integer"},"message":{"type":"string"},"data":{}},"required":["code","message"]}},"required":["jsonrpc","id"]},"ApiIndex":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"version":{"type":"string"},"openapi":{"type":"string","format":"uri"},"docs":{"type":"string","format":"uri"},"developers":{"type":"string","format":"uri"},"mcp":{"type":"string","format":"uri"},"llms":{"type":"string","format":"uri"},"health":{"type":"string","format":"uri"},"endpoints":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string"},"path":{"type":"string"},"operationId":{"type":"string"},"summary":{"type":"string"}},"required":["method","path","operationId","summary"]}}},"required":["name","description","version","openapi","docs","developers","mcp","llms","health","endpoints"]}},"responses":{"BadRequest":{"description":"The request body or parameters failed validation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Unauthorized":{"description":"Missing, malformed, or unknown workspace token. Send `Authorization: Bearer mtk_...`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"No entity with that id in this workspace.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"RateLimited":{"description":"Too many requests in the current fixed window.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"PayloadTooLarge":{"description":"The request body is over the limit for this route: 16 MiB for graph replace, ingest and compile, 2 MiB everywhere else.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"InternalError":{"description":"Unhandled server error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}