{"openapi":"3.1.0","info":{"title":"Raku Brain API","version":"0.1.0"},"paths":{"/health":{"get":{"tags":["system"],"summary":"Health","description":"Liveness probe — always HTTP 200 if the process is responding.\n\nBody shape splits on bearer-key validity:\n    Unauthenticated: {status, version}.\n    Authenticated:   {status, version, memory:{...}, circuits:{...}}.\n\n`status` is \"degraded\" if and only if the RSS hysteresis state\nmachine is in `killed` — a process-wide, tenant-agnostic condition.\nThe HTTP status code stays 200 in both cases (RKU-58 liveness\ncontract). For the platform-level cycle signal on hard kill, see\n/ready below.","operationId":"health_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}}}}},"/ready":{"get":{"tags":["system"],"summary":"Ready","description":"Readiness probe — registry, model, AND hysteresis must all be green.\n\nReturns 200 with status=\"ready\" once the registry can be queried,\n(in prod) the GLiNER2 model has finished loading, and the RSS\nhysteresis is not in `killed`. Returns 503 with status=\"not_ready\"\nand a reason otherwise.\n\nThe killed-hysteresis branch is the platform-level cycle signal —\nFly's grace_period on /ready gives the process a window to drop\nout of `killed`, and if it can't, Fly cycles the machine. RKU-65\n§4.6.","operationId":"ready_ready_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReadyResponse"}}}}}}},"/api/v1/memories/":{"post":{"tags":["memories"],"summary":"Create Memory","description":"Create a memory with server-side embedding (ADR-10 graceful degradation).\n\nThe happy path computes the embedding and stores it. On a TRANSIENT embedding\nfailure (OpenAI down / circuit open) the memory is still stored with\n`embedding = NULL, needs_embedding = 1` and the response carries\n`pipeline_status.embedding = \"deferred\"` — the backfill worker computes the\nvector later (RKU-65 §5). A persistence failure is the one hard-fail: 503 +\n`Retry-After` (§5.1, §7.3). Returns 409 if the tenant hit the memory limit.","operationId":"create_memory_api_v1_memories__post","security":[{"HTTPBearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemoryCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemoryWriteResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["memories"],"summary":"List Memories","description":"List memories with pagination and optional filters.\n\nOnly currently-valid memories (is_current = 1) are returned — soft-closed\nrows are accessible via GET /memories/{id} but not via list or search.","operationId":"list_memories_api_v1_memories__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}},{"name":"memory_type","in":"query","required":false,"schema":{"anyOf":[{"$ref":"#/components/schemas/MemoryType"},{"type":"null"}],"title":"Memory Type"}},{"name":"tag","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Tag"}},{"name":"created_after","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created After"}},{"name":"created_before","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created Before"}},{"name":"sort_by","in":"query","required":false,"schema":{"type":"string","pattern":"^(created_at|importance|last_accessed)$","default":"created_at","title":"Sort By"}},{"name":"sort_order","in":"query","required":false,"schema":{"type":"string","pattern":"^(asc|desc)$","default":"desc","title":"Sort Order"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemoryListResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/memories/retain":{"post":{"tags":["memories"],"summary":"Retain Memory","description":"Retain a memory through the full 8-step pipeline (Memory Engine v2.0).\n\nADMIT → EMBED → SCORE IMPORTANCE → ASSIGN CONFIDENCE → EXTRACT ENTITIES →\nCONSOLIDATE → RESOLVE CONFLICTS (real since R2.63 sub-build 4; spec slug\n628069ab72e8). Admission may reject/deduplicate without storing — that is a\n200 with ``memory: null`` and ``admission_decision``. External-step failures\ndegrade gracefully (ADR-10); only a libSQL persistence failure is a hard\nfail → 503 + Retry-After (RKU-65 §5.1, §7.3).","operationId":"retain_memory_api_v1_memories_retain_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemoryCreate"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetainResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/api/v1/memories/{memory_id}":{"get":{"tags":["memories"],"summary":"Get Memory","description":"Get a single memory by ID. Updates access tracking.","operationId":"get_memory_api_v1_memories__memory_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"memory_id","in":"path","required":true,"schema":{"type":"string","title":"Memory Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemoryResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"tags":["memories"],"summary":"Update Memory","description":"Update a memory. Re-embeds only if content changes.","operationId":"update_memory_api_v1_memories__memory_id__put","security":[{"HTTPBearer":[]}],"parameters":[{"name":"memory_id","in":"path","required":true,"schema":{"type":"string","title":"Memory Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemoryUpdate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemoryResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["memories"],"summary":"Delete Memory","description":"Soft-close a memory — never deletes, always preserves history.\n\nSets valid_to = tx_to = now and is_current = 0. The row remains readable\nby ID via GET /memories/{id} (history access) but is filtered out of\nlist and search responses. Hard delete is a Phase 2 admin endpoint.\n\nReturns 404 if the memory is already soft-closed (is_current = 0) — we\ntreat a double-delete the same as deleting a nonexistent row rather\nthan re-closing an already-closed row, so clients get a consistent\n404 signal either way.","operationId":"delete_memory_api_v1_memories__memory_id__delete","security":[{"HTTPBearer":[]}],"parameters":[{"name":"memory_id","in":"path","required":true,"schema":{"type":"string","title":"Memory Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/memories/search":{"post":{"tags":["search"],"summary":"Search Memories","description":"Hybrid memory search with vector + FTS5 + RRF scoring.\n\nReturns 200 with empty results if nothing matches (not 404).\nReturns 503 if embedding service is unavailable.","operationId":"search_memories_api_v1_memories_search_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/api/v1/memories/recall":{"post":{"tags":["search"],"summary":"Recall Memories","description":"Graph-enhanced recall — vector + FTS5 + knowledge-graph traversal fused\nwith normalized RRF, every signal filtering is_current=1 (RKU-64), then\ncross-encoder reranked (top 2x-limit, when available) and ranked by the\nshared scoring blend (R2.60). A query-embedding failure surfaces as 503;\na reranker failure degrades to RRF order (response.reranked=False).","operationId":"recall_memories_api_v1_memories_recall_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecallRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecallResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/api/v1/entities":{"post":{"tags":["entities"],"summary":"Create Entity","description":"Create an entity manually.","operationId":"create_entity_api_v1_entities_post","security":[{"HTTPBearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EntityCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EntityResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["entities"],"summary":"List Entities","description":"List entities with pagination and optional type filter.","operationId":"list_entities_api_v1_entities_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}},{"name":"entity_type","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Type"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EntityListResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/entities/{entity_id}":{"get":{"tags":["entities"],"summary":"Get Entity","description":"Get a single entity by ID.","operationId":"get_entity_api_v1_entities__entity_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"entity_id","in":"path","required":true,"schema":{"type":"string","title":"Entity Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EntityResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"tags":["entities"],"summary":"Update Entity","description":"Update an entity (partial).","operationId":"update_entity_api_v1_entities__entity_id__put","security":[{"HTTPBearer":[]}],"parameters":[{"name":"entity_id","in":"path","required":true,"schema":{"type":"string","title":"Entity Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EntityUpdate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EntityResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["entities"],"summary":"Delete Entity","description":"Delete an entity (cascades to relationships and memory_entities).","operationId":"delete_entity_api_v1_entities__entity_id__delete","security":[{"HTTPBearer":[]}],"parameters":[{"name":"entity_id","in":"path","required":true,"schema":{"type":"string","title":"Entity Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/entities/{entity_id}/aliases":{"post":{"tags":["entities"],"summary":"Add Alias","description":"Add an alias to an entity. Idempotent.","operationId":"add_alias_api_v1_entities__entity_id__aliases_post","security":[{"HTTPBearer":[]}],"parameters":[{"name":"entity_id","in":"path","required":true,"schema":{"type":"string","title":"Entity Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AliasAddRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EntityResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/entities/{entity_id}/graph":{"get":{"tags":["entities"],"summary":"Get Entity Graph","description":"1-hop neighbourhood: entity + relationships + neighbours.","operationId":"get_entity_graph_api_v1_entities__entity_id__graph_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"entity_id","in":"path","required":true,"schema":{"type":"string","title":"Entity Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EntityGraphResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/entities/extract":{"post":{"tags":["entities"],"summary":"Extract Entities","description":"Extract entities and relationships from text using GLiNER2.","operationId":"extract_entities_api_v1_entities_extract_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExtractionRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExtractionResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/api/v1/relationships":{"post":{"tags":["entities"],"summary":"Create Relationship","description":"Create a relationship between two existing entities.","operationId":"create_relationship_api_v1_relationships_post","security":[{"HTTPBearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RelationshipCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RelationshipResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["entities"],"summary":"List Relationships","description":"List relationships with optional filters.","operationId":"list_relationships_api_v1_relationships_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}},{"name":"entity_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Entity Id"}},{"name":"relationship_type","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Relationship Type"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RelationshipListResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/relationships/{relationship_id}":{"delete":{"tags":["entities"],"summary":"Delete Relationship","description":"Delete a relationship.","operationId":"delete_relationship_api_v1_relationships__relationship_id__delete","security":[{"HTTPBearer":[]}],"parameters":[{"name":"relationship_id","in":"path","required":true,"schema":{"type":"string","title":"Relationship Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"AdmissionDecision":{"type":"string","enum":["admitted","rejected","deduplicated","merged"],"title":"AdmissionDecision","description":"Outcome of the ADMIT step (Retain pipeline step 1).\n\n`MERGED` is emitted since R2.63 (sub-build 4): the CONSOLIDATE step\nsynthesized the new memory with existing fragments — the response carries\nthe merged memory and `consolidated_from` lists the soft-closed sources."},"AliasAddRequest":{"properties":{"alias":{"type":"string","maxLength":200,"minLength":1,"title":"Alias"}},"type":"object","required":["alias"],"title":"AliasAddRequest","description":"Add an alias to an entity."},"EntityCreate":{"properties":{"name":{"type":"string","maxLength":500,"minLength":1,"title":"Name"},"entity_type":{"type":"string","maxLength":100,"minLength":1,"title":"Entity Type"},"aliases":{"items":{"type":"string"},"type":"array","maxItems":20,"title":"Aliases"},"confidence_score":{"anyOf":[{"type":"number","maximum":1.0,"minimum":0.0},{"type":"null"}],"title":"Confidence Score"}},"type":"object","required":["name","entity_type"],"title":"EntityCreate","description":"Create an entity manually."},"EntityGraphResponse":{"properties":{"entity":{"$ref":"#/components/schemas/EntityResponse"},"relationships":{"items":{"$ref":"#/components/schemas/RelationshipResponse"},"type":"array","title":"Relationships"},"neighbors":{"items":{"$ref":"#/components/schemas/EntityResponse"},"type":"array","title":"Neighbors"}},"type":"object","required":["entity","relationships","neighbors"],"title":"EntityGraphResponse","description":"1-hop neighbourhood: center entity + relationships + neighbours."},"EntityListResponse":{"properties":{"items":{"items":{"$ref":"#/components/schemas/EntityResponse"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total"},"limit":{"type":"integer","title":"Limit"},"offset":{"type":"integer","title":"Offset"},"has_more":{"type":"boolean","title":"Has More"}},"type":"object","required":["items","total","limit","offset","has_more"],"title":"EntityListResponse","description":"Paginated entity list."},"EntityResponse":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"entity_type":{"type":"string","title":"Entity Type"},"aliases":{"items":{"type":"string"},"type":"array","title":"Aliases"},"confidence_score":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Confidence Score"},"created_at":{"type":"string","title":"Created At"},"updated_at":{"type":"string","title":"Updated At"}},"type":"object","required":["id","name","entity_type","aliases","confidence_score","created_at","updated_at"],"title":"EntityResponse","description":"Entity returned by the API. Never exposes tenant_id."},"EntityUpdate":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":500,"minLength":1},{"type":"null"}],"title":"Name"},"entity_type":{"anyOf":[{"type":"string","maxLength":100,"minLength":1},{"type":"null"}],"title":"Entity Type"},"confidence_score":{"anyOf":[{"type":"number","maximum":1.0,"minimum":0.0},{"type":"null"}],"title":"Confidence Score"}},"type":"object","title":"EntityUpdate","description":"Partial update for an entity."},"ExtractionRequest":{"properties":{"text":{"type":"string","maxLength":50000,"minLength":1,"title":"Text"},"memory_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Memory Id","description":"Link extracted entities to this memory"}},"type":"object","required":["text"],"title":"ExtractionRequest","description":"Extract entities and relationships from text using GLiNER2."},"ExtractionResponse":{"properties":{"entities":{"items":{"$ref":"#/components/schemas/ResolvedEntity"},"type":"array","title":"Entities"},"relationships":{"items":{"$ref":"#/components/schemas/ResolvedRelationship"},"type":"array","title":"Relationships"},"entity_count":{"type":"integer","title":"Entity Count"},"relationship_count":{"type":"integer","title":"Relationship Count"},"new_entities":{"items":{"$ref":"#/components/schemas/ResolvedEntity"},"type":"array","title":"New Entities"}},"type":"object","required":["entities","relationships","entity_count","relationship_count","new_entities"],"title":"ExtractionResponse","description":"Result of entity extraction + resolution."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"HealthResponse":{"properties":{"status":{"type":"string","title":"Status"},"version":{"type":"string","title":"Version"},"memory":{"anyOf":[{"$ref":"#/components/schemas/MemoryStatus"},{"type":"null"}],"description":"Process memory snapshot (authenticated callers only)"},"circuits":{"anyOf":[{"additionalProperties":{"type":"string"},"type":"object"},{"type":"null"}],"title":"Circuits","description":"External-service circuit states (authenticated callers only)"}},"type":"object","required":["status","version"],"title":"HealthResponse","description":"Response from /health endpoint.\n\nShape splits on whether a valid bearer token was provided:\n  - Unauthenticated: only `status` and `version` are populated.\n  - Authenticated:   `memory` and `circuits` are also populated with\n    the requesting tenant's view of process state.\n\n`status` is \"ok\" by default; transitions to \"degraded\" only when the\nRSS hysteresis state machine is in `killed` — a process-wide\ncondition that affects all tenants regardless. Per-tenant degradation\nsurfaces via the future `pipeline_status` field on memory responses\n(R2.53b), not here. RKU-65 §10."},"MemoryCreate":{"properties":{"content":{"type":"string","maxLength":50000,"minLength":1,"title":"Content","description":"Memory content text"},"source":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Source","description":"Where this memory came from"},"memory_type":{"$ref":"#/components/schemas/MemoryType","default":"fact"},"importance":{"type":"number","maximum":1.0,"minimum":0.0,"title":"Importance","description":"Importance score 0-1","default":0.5},"metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metadata","description":"Arbitrary JSON metadata"},"tags":{"items":{"type":"string"},"type":"array","maxItems":20,"title":"Tags","description":"Max 20 tags"},"confidence_score":{"anyOf":[{"type":"number","maximum":1.0,"minimum":0.0},{"type":"null"}],"title":"Confidence Score"},"source_type":{"anyOf":[{"$ref":"#/components/schemas/SourceType"},{"type":"null"}]},"evidence_count":{"type":"integer","minimum":0.0,"title":"Evidence Count","default":0},"contradiction_count":{"type":"integer","minimum":0.0,"title":"Contradiction Count","default":0},"confidence_decay_rate":{"anyOf":[{"type":"number","maximum":1.0,"minimum":0.0},{"type":"null"}],"title":"Confidence Decay Rate"},"last_validated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Validated At","description":"ISO-8601: last confidence review"},"valid_from":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Valid From","description":"ISO-8601: when this fact became true"},"valid_to":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Valid To","description":"ISO-8601: when this fact stopped being true"}},"type":"object","required":["content"],"title":"MemoryCreate","description":"Create a new memory. Embedding generated server-side.\n\nInvariants:\n    - content is required and must be 1-50,000 characters\n    - tags are normalised to lowercase and stripped of whitespace\n    - metadata JSON must not exceed 10,000 characters\n    - importance must be between 0.0 and 1.0"},"MemoryListResponse":{"properties":{"items":{"items":{"$ref":"#/components/schemas/MemoryResponse"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total"},"limit":{"type":"integer","title":"Limit"},"offset":{"type":"integer","title":"Offset"},"has_more":{"type":"boolean","title":"Has More"}},"type":"object","required":["items","total","limit","offset","has_more"],"title":"MemoryListResponse","description":"Paginated list response for memories."},"MemoryResponse":{"properties":{"id":{"type":"string","title":"Id"},"content":{"type":"string","title":"Content"},"source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source"},"memory_type":{"type":"string","title":"Memory Type"},"importance":{"type":"number","title":"Importance"},"created_at":{"type":"string","title":"Created At"},"updated_at":{"type":"string","title":"Updated At"},"last_accessed":{"type":"string","title":"Last Accessed"},"access_count":{"type":"integer","title":"Access Count"},"tags":{"items":{"type":"string"},"type":"array","title":"Tags","default":[]},"confidence_score":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Confidence Score"},"source_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Type"},"evidence_count":{"type":"integer","title":"Evidence Count","default":0},"contradiction_count":{"type":"integer","title":"Contradiction Count","default":0},"confidence_decay_rate":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Confidence Decay Rate"},"last_validated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Validated At"},"valid_from":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Valid From"},"valid_to":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Valid To"},"tx_from":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tx From"},"tx_to":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tx To"},"superseded_by":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Superseded By"},"is_current":{"type":"boolean","title":"Is Current","default":true}},"type":"object","required":["id","content","memory_type","importance","created_at","updated_at","last_accessed","access_count"],"title":"MemoryResponse","description":"API response for a single memory.\n\nEXCLUDED always (never add these fields):\n    - embedding vector (RAKU-3 — can be reverse-engineered)\n    - tenant_id (OWASP-MT §3 — no cross-tenant data)\n    - raw metadata (may contain sensitive data)"},"MemoryStatus":{"properties":{"rss_mb":{"type":"number","title":"Rss Mb","description":"Current process RSS in MB"},"rss_limit_mb":{"type":"integer","title":"Rss Limit Mb","description":"Total machine memory in MB"},"rss_percent":{"type":"number","title":"Rss Percent","description":"RSS as percentage of limit"},"hysteresis_state":{"type":"string","title":"Hysteresis State","description":"permitted | skipping | killed | unknown"}},"type":"object","required":["rss_mb","rss_limit_mb","rss_percent","hysteresis_state"],"title":"MemoryStatus","description":"RSS + hysteresis-state snapshot for the authenticated /health response.\n\nReported in megabytes against the machine's total physical memory,\nmachine-read via psutil at request time (R2.61) — tracks Fly.io\nmachine resizes automatically. RKU-65 §10.2."},"MemoryType":{"type":"string","enum":["fact","event","preference","procedure","insight"],"title":"MemoryType","description":"Types of memory that can be stored.\n\nv2.0 taxonomy (migration 005):\n    observation → event, reflection → insight, instruction → procedure.\n    fact and preference unchanged."},"MemoryUpdate":{"properties":{"content":{"anyOf":[{"type":"string","maxLength":50000,"minLength":1},{"type":"null"}],"title":"Content"},"source":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Source"},"memory_type":{"anyOf":[{"$ref":"#/components/schemas/MemoryType"},{"type":"null"}]},"importance":{"anyOf":[{"type":"number","maximum":1.0,"minimum":0.0},{"type":"null"}],"title":"Importance"},"metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metadata"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":20},{"type":"null"}],"title":"Tags"},"confidence_score":{"anyOf":[{"type":"number","maximum":1.0,"minimum":0.0},{"type":"null"}],"title":"Confidence Score"},"source_type":{"anyOf":[{"$ref":"#/components/schemas/SourceType"},{"type":"null"}]},"evidence_count":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Evidence Count"},"contradiction_count":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Contradiction Count"},"confidence_decay_rate":{"anyOf":[{"type":"number","maximum":1.0,"minimum":0.0},{"type":"null"}],"title":"Confidence Decay Rate"},"last_validated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Validated At"},"valid_from":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Valid From"},"valid_to":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Valid To","description":"ISO-8601: when this fact stopped being true"},"superseded_by":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Superseded By","description":"ID of the memory that replaces this one"}},"type":"object","title":"MemoryUpdate","description":"Partial update for a memory.\n\nOnly provided fields are updated. If content changes, embedding is\nregenerated server-side. If content is not provided, embedding is\nNOT regenerated."},"MemoryWriteResponse":{"properties":{"id":{"type":"string","title":"Id"},"content":{"type":"string","title":"Content"},"source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source"},"memory_type":{"type":"string","title":"Memory Type"},"importance":{"type":"number","title":"Importance"},"created_at":{"type":"string","title":"Created At"},"updated_at":{"type":"string","title":"Updated At"},"last_accessed":{"type":"string","title":"Last Accessed"},"access_count":{"type":"integer","title":"Access Count"},"tags":{"items":{"type":"string"},"type":"array","title":"Tags","default":[]},"confidence_score":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Confidence Score"},"source_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Type"},"evidence_count":{"type":"integer","title":"Evidence Count","default":0},"contradiction_count":{"type":"integer","title":"Contradiction Count","default":0},"confidence_decay_rate":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Confidence Decay Rate"},"last_validated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Validated At"},"valid_from":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Valid From"},"valid_to":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Valid To"},"tx_from":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tx From"},"tx_to":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tx To"},"superseded_by":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Superseded By"},"is_current":{"type":"boolean","title":"Is Current","default":true},"pipeline_status":{"$ref":"#/components/schemas/PipelineStatus"},"pipeline":{"$ref":"#/components/schemas/PipelineTiming"}},"type":"object","required":["id","content","memory_type","importance","created_at","updated_at","last_accessed","access_count","pipeline_status","pipeline"],"title":"MemoryWriteResponse","description":"POST /memories response — the created memory plus pipeline status + timing.\n\nSubclasses MemoryResponse so the memory fields stay at the top level (the\nexisting POST client contract is preserved) and adds the two pipeline fields."},"PipelineStatus":{"properties":{"embedding":{"$ref":"#/components/schemas/StepStatus"},"importance":{"$ref":"#/components/schemas/StepStatus"},"entities":{"$ref":"#/components/schemas/StepStatus"},"consolidation":{"$ref":"#/components/schemas/StepStatus"},"conflicts":{"$ref":"#/components/schemas/StepStatus"}},"type":"object","required":["embedding","importance","entities","consolidation","conflicts"],"title":"PipelineStatus","description":"Outcome of each write-pipeline step (RKU-65 §7.4)."},"PipelineTiming":{"properties":{"admission_ms":{"type":"integer","title":"Admission Ms"},"embedding_ms":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Embedding Ms"},"importance_ms":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Importance Ms"},"entities_ms":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Entities Ms"},"consolidation_ms":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Consolidation Ms"},"conflicts_ms":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Conflicts Ms"},"store_ms":{"type":"integer","title":"Store Ms"},"total_ms":{"type":"integer","title":"Total Ms"}},"type":"object","required":["admission_ms","embedding_ms","importance_ms","entities_ms","consolidation_ms","conflicts_ms","store_ms","total_ms"],"title":"PipelineTiming","description":"Per-step wall-clock timing in ms. `None` means the step did not run."},"ReadyResponse":{"properties":{"status":{"type":"string","title":"Status"},"reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reason"}},"type":"object","required":["status"],"title":"ReadyResponse","description":"Response from /ready endpoint."},"RecallFilters":{"properties":{"memory_types":{"items":{"$ref":"#/components/schemas/MemoryType"},"type":"array","title":"Memory Types","description":"Restrict results to these memory types (empty = all)"}},"type":"object","title":"RecallFilters","description":"Filters for the graph-enhanced recall pipeline."},"RecallRequest":{"properties":{"query":{"type":"string","maxLength":2000,"minLength":1,"title":"Query","description":"Recall query text"},"limit":{"type":"integer","maximum":50.0,"minimum":1.0,"title":"Limit","description":"Max results","default":10},"max_hops":{"type":"integer","maximum":3.0,"minimum":1.0,"title":"Max Hops","description":"Graph relationship-hop depth","default":1},"filters":{"anyOf":[{"$ref":"#/components/schemas/RecallFilters"},{"type":"null"}]},"weights":{"anyOf":[{"$ref":"#/components/schemas/SearchWeights"},{"type":"null"}]},"rerank":{"type":"boolean","title":"Rerank","description":"Cross-encoder rerank of the top 2x-limit candidates (falls back to RRF order when the reranker is unavailable — see response.reranked)","default":true}},"type":"object","required":["query"],"title":"RecallRequest","description":"POST body for /api/v1/memories/recall — graph-enhanced retrieval.\n\nFuses three retrieval signals (vector + FTS5 + knowledge-graph traversal)\nwith normalized Reciprocal Rank Fusion, then ranks by the shared scoring\nblend (R2.60 — same formula as /search). ``max_hops`` bounds the\nrelationship expansion from the entities of the lexical/semantic hits."},"RecallResponse":{"properties":{"results":{"items":{"$ref":"#/components/schemas/RecallResult"},"type":"array","title":"Results"},"total":{"type":"integer","title":"Total"},"query":{"type":"string","title":"Query"},"weights_used":{"$ref":"#/components/schemas/SearchWeights"},"reranked":{"type":"boolean","title":"Reranked","description":"True when the cross-encoder actually reranked this response (False = RRF order; rerank disabled, unavailable, or skipped under RSS pressure)","default":false}},"type":"object","required":["results","total","query","weights_used"],"title":"RecallResponse","description":"Graph-enhanced recall results."},"RecallResult":{"properties":{"memory":{"$ref":"#/components/schemas/MemoryResponse"},"score":{"type":"number","title":"Score","description":"Blend: a*recency + b*importance + g*relevance + d*confidence"},"score_components":{"additionalProperties":{"type":"number"},"type":"object","title":"Score Components","description":"Individual signals: relevance, recency, importance, confidence"},"relevance":{"type":"number","title":"Relevance","description":"Normalized RRF relevance in [0, 1]"},"signals":{"items":{"type":"string"},"type":"array","title":"Signals","description":"Which signals matched: vector / fts / graph"}},"type":"object","required":["memory","score","score_components","relevance","signals"],"title":"RecallResult","description":"A recalled memory: blended score, fused relevance, contributing signals."},"RelationshipCreate":{"properties":{"source_entity_id":{"type":"string","minLength":1,"title":"Source Entity Id"},"target_entity_id":{"type":"string","minLength":1,"title":"Target Entity Id"},"relationship_type":{"type":"string","maxLength":200,"minLength":1,"title":"Relationship Type"},"confidence_score":{"anyOf":[{"type":"number","maximum":1.0,"minimum":0.0},{"type":"null"}],"title":"Confidence Score"}},"type":"object","required":["source_entity_id","target_entity_id","relationship_type"],"title":"RelationshipCreate","description":"Create a relationship between two entities."},"RelationshipListResponse":{"properties":{"items":{"items":{"$ref":"#/components/schemas/RelationshipResponse"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total"},"limit":{"type":"integer","title":"Limit"},"offset":{"type":"integer","title":"Offset"},"has_more":{"type":"boolean","title":"Has More"}},"type":"object","required":["items","total","limit","offset","has_more"],"title":"RelationshipListResponse","description":"Paginated relationship list."},"RelationshipResponse":{"properties":{"id":{"type":"string","title":"Id"},"source_entity_id":{"type":"string","title":"Source Entity Id"},"target_entity_id":{"type":"string","title":"Target Entity Id"},"relationship_type":{"type":"string","title":"Relationship Type"},"confidence_score":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Confidence Score"},"created_at":{"type":"string","title":"Created At"}},"type":"object","required":["id","source_entity_id","target_entity_id","relationship_type","confidence_score","created_at"],"title":"RelationshipResponse","description":"Relationship returned by the API."},"ResolvedEntity":{"properties":{"id":{"type":"string","title":"Id"},"text":{"type":"string","title":"Text"},"entity_type":{"type":"string","title":"Entity Type"},"confidence":{"type":"number","title":"Confidence"},"is_new":{"type":"boolean","title":"Is New"}},"type":"object","required":["id","text","entity_type","confidence","is_new"],"title":"ResolvedEntity","description":"Entity resolved against the entity table."},"ResolvedRelationship":{"properties":{"id":{"type":"string","title":"Id"},"source_entity_id":{"type":"string","title":"Source Entity Id"},"target_entity_id":{"type":"string","title":"Target Entity Id"},"relationship_type":{"type":"string","title":"Relationship Type"},"confidence":{"type":"number","title":"Confidence"}},"type":"object","required":["id","source_entity_id","target_entity_id","relationship_type","confidence"],"title":"ResolvedRelationship","description":"Relationship with resolved entity IDs."},"RetainResponse":{"properties":{"memory":{"anyOf":[{"$ref":"#/components/schemas/MemoryResponse"},{"type":"null"}]},"admission_decision":{"$ref":"#/components/schemas/AdmissionDecision"},"pipeline_status":{"$ref":"#/components/schemas/PipelineStatus"},"entities_extracted":{"items":{"$ref":"#/components/schemas/ResolvedEntity"},"type":"array","title":"Entities Extracted","default":[]},"relationships_extracted":{"items":{"$ref":"#/components/schemas/ResolvedRelationship"},"type":"array","title":"Relationships Extracted","default":[]},"contradictions":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Contradictions","default":[]},"consolidated_from":{"items":{"type":"string"},"type":"array","title":"Consolidated From","default":[]},"flagged_conflicts":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Flagged Conflicts","default":[]},"pipeline":{"$ref":"#/components/schemas/PipelineTiming"}},"type":"object","required":["memory","admission_decision","pipeline_status","pipeline"],"title":"RetainResponse","description":"POST /memories/retain response — the full 8-step Retain pipeline outcome.\n\n`memory` is null when the ADMIT step rejects or deduplicates (nothing\nstored). On admission it carries the stored memory plus the per-step\npipeline status, the extracted knowledge-graph slice, and timing.\n\n`contradictions` / `consolidated_from` / `flagged_conflicts` are populated\nsince R2.63 (sub-build 4): CONSOLIDATE + RESOLVE CONFLICTS are real —\ncontradictions rows follow the spec shape {superseded_memory_id, decision,\nmerged_content, explanation}; flagged_conflicts rows are {memory_id,\nexplanation}; consolidated_from lists sources merged away by step 6."},"SearchRequest":{"properties":{"query":{"type":"string","maxLength":2000,"minLength":1,"title":"Query","description":"Search query text"},"limit":{"type":"integer","maximum":50.0,"minimum":1.0,"title":"Limit","description":"Max results","default":10},"min_similarity":{"type":"number","maximum":1.0,"minimum":0.0,"title":"Min Similarity","description":"Min cosine similarity threshold","default":0.5},"memory_type":{"anyOf":[{"$ref":"#/components/schemas/MemoryType"},{"type":"null"}]},"tag":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Tag"},"weights":{"anyOf":[{"$ref":"#/components/schemas/SearchWeights"},{"type":"null"}]}},"type":"object","required":["query"],"title":"SearchRequest","description":"Memory search request using hybrid vector + FTS5.\n\nPOST body for /api/v1/memories/search. Uses POST (not GET) because\nsearch parameters are complex and may exceed URL length limits.\n\nInvariants:\n    - query limited to 2,000 characters\n    - limit capped at 50 (search is expensive — embedding call per query)\n    - min_similarity prevents returning garbage matches"},"SearchResponse":{"properties":{"results":{"items":{"$ref":"#/components/schemas/SearchResult"},"type":"array","title":"Results"},"total":{"type":"integer","title":"Total"},"query":{"type":"string","title":"Query"},"min_similarity":{"type":"number","title":"Min Similarity"},"weights_used":{"$ref":"#/components/schemas/SearchWeights"}},"type":"object","required":["results","total","query","min_similarity","weights_used"],"title":"SearchResponse","description":"Search results with metadata."},"SearchResult":{"properties":{"memory":{"$ref":"#/components/schemas/MemoryResponse"},"score":{"type":"number","title":"Score","description":"Combined weighted score"},"score_components":{"additionalProperties":{"type":"number"},"type":"object","title":"Score Components","description":"Individual score signals: vector, fts, recency, importance"}},"type":"object","required":["memory","score","score_components"],"title":"SearchResult","description":"Single search result with component scores for transparency.\n\nscore_components provides individual signals so callers can understand\nWHY a memory ranked where it did. Currently: vector, fts, recency,\nimportance. May adds: graph, confidence."},"SearchWeights":{"properties":{"alpha":{"type":"number","minimum":0.0,"title":"Alpha","description":"Recency weight","default":1.0},"beta":{"type":"number","minimum":0.0,"title":"Beta","description":"Importance weight","default":1.0},"gamma":{"type":"number","minimum":0.0,"title":"Gamma","description":"Relevance (vector similarity) weight","default":1.0},"delta":{"type":"number","minimum":0.0,"title":"Delta","description":"Confidence weight (v3.3, defaults to 1.0)","default":1.0},"half_life_hours":{"type":"number","exclusiveMinimum":0.0,"title":"Half Life Hours","description":"Recency half-life in hours (default 168 = 7 days)","default":168.0}},"type":"object","title":"SearchWeights","description":"Configurable scoring weights for the memory scoring formula.\n\nscore = alpha * recency + beta * importance + gamma * relevance + delta * confidence\n\nRecency uses exponential decay with a configurable half-life:\n    recency = 2 ^ (-hours_since_last_accessed / half_life_hours)\n\nDefault half-life of 168 hours (7 days) is more conservative than the\nStanford Generative Agents paper (~5.8 days via 0.995^h). Tune per\ndeployment — shorter half-lives for conversational context, longer\nfor reference facts.\n\nv3.3 adds delta (confidence) and half_life_hours. Graph scoring\nadded in May."},"SourceType":{"type":"string","enum":["direct_data","user_stated","system_observed","inference","hearsay","speculation","corrected","external_api","derived"],"title":"SourceType","description":"Confidence source classification (v3.3).\n\nClassifies how a memory was obtained, informing confidence scoring.\nOrdering roughly tracks epistemic strength: direct_data and user_stated\nare high-trust; speculation and hearsay are low-trust."},"StepStatus":{"type":"string","enum":["ok","deferred","skipped_rss","skipped_due_to_degradation","unavailable"],"title":"StepStatus","description":"Per-step outcome in the write pipeline (RKU-65 §7.4)."},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer"}}}}