Skip to content
Sign in

memory

v0.3.26

Durable cross-session agent memory — named banks of always-injected markdown rules and auto-extracted memories, hybrid BM25 + entity recall, pinning, and supersede-never-delete history. Plain files on disk; every operation is a traced function.

license: Apache-2.0Used in 1 kitagentbm25contextmemoryragrecall

Install

bash
iii call compose::add worker=memory@0.3.26

Run in your project with the iii engine running. Exact versions are immutable and digest-pinned.

Agent-ready brief for v0.3.26
Install, config, dependencies, readme, skills and API reference, all in one place. Fetch as agent-context.md for an LLM to consume.
The same content rendered as discrete blocks below is exposed as a single markdown document at /registry/workers/memory.md?version=0.3.26. Paste it into an LLM prompt or pipe it through curl from a worker.

Install

iii call compose::add worker=memory@0.3.26

Dependencies

Readme

README.md

memory

Durable cross-session agent memory. Named banks hold two kinds of content: rules (markdown documents injected whole into the system prompt) and memories (auto-extracted records recalled on demand). Everything is a plain file you can open, a function you can call, and an event you can watch: memory that acts visibly, not magically.

Install

iii call compose::add worker=memory

A session works in the bank of its repository (or directory), named <name>-<6 hex>, and reads the default bank main under it: your rules there, and your memories about yourself. One with no working directory uses main alone, which materializes on first use. No configuration required; without llm-router extraction degrades to explicit memory::save calls, and without the harness the worker still serves its full RPC surface.

Quickstart

Outside a session the CLI works in the default bank main, the one every repository's sessions read under their own. Save something about yourself, then see exactly what a turn on that topic would be given:

iii call memory::save text="User publishes blog posts on Tuesday mornings" pinned=true 'tags=["blog"]'
iii call memory::recall query="when do I publish articles"

Give the bank a standing instruction — injected into the system prompt of every session using it, or reading it under a repository's bank:

iii call memory::rule::set name=style content="# Style\nFormal register. No em-dashes."

With the harness running there is nothing else to wire: chat normally and memory captures in the background. Say "never start replies with the word Certainly" in a conversation and it lands in the session bank's auto-managed learned rule; state something durable and it appears as a memory after the turn. If memory seems absent, iii call memory::doctor runs a real save→recall roundtrip and names what is degraded.

Configuration

All fields hot-reload through the configuration worker and are editable in the worker's explicit form in the Console's global Settings modal; data_dir reopens the store on the fly. Fields: data_dir, default_bank, inject_rules, inject_memories, recall_in_automation (default off: a session of kind automation gets no recalled memories, only its rules and pinned ones: workflow nodes, kanban dispatches, sentinel investigations and the like, and their sub-agents), retire_expired_after_days (default 30; 0 keeps them: see Work in progress leaves turns), recall_limit, recall_budget_tokens, pinned_limit (default 5), pinned_max_chars (default 1000), extraction_enabled, extraction_model, extraction_window, extraction_timeout_ms, max_memories_per_turn (also the new notes one turn may save), rule_learning_enabled, max_rule_chars, learned_max_chars (default 3000; 0 turns the cap off), decay_half_life_days (default 60; older installs keep their stored 30 — set 60 in Settings to adopt the tuned recall curve), embeddings_enabled, embedding_model.

Extraction model

A pinned extraction_model (provider::id) is used as written, and the router is not asked. Left empty, the model is automatic and resolves on every pass from router::provider::list:

  1. A provider is usable when it is available and signed in, or owns its sign-in (no credential env var, such as openai-codex or claude-code).
  2. Tier 1: the default model of the first usable provider, by provider id.
  3. Tier 2, only when no usable provider declares a chat default: the first chat model router::models::list lists for a usable provider, by provider and then model id.
  4. An id that contains embed or rerank is never picked. With nothing left, the pass fails with an error that names each provider and why it was skipped.

The pick is logged at INFO when it changes, as automatic extraction model model=<provider::id> reason=<provider_default|first_listed_model>. Every failed pass logs a WARN extraction pass failed with the session id and the error, on the queue path and the inline one; a model call's error ends in (model <id>). A pass that leaves a backlog for the queue's retry is not a failure and logs nothing.

Limits: the pick can change shortly after a restart, until every provider has finished its first model refresh. A provider whose sign-in has expired still counts as signed in, so its default can be picked; the WARN then names that model. ADE's settings show the same rule as "Automatic · <model>", and the label matches the worker once both are released. Pin extraction_model to rule all of this out.

Why this shape

  • Files are the source of truth. rules/*.md and memories.jsonl under the data dir. Edit them in any editor; memory::reload (or a restart) picks the edits up. The search index is a RAM-only cache rebuilt from the files at boot, so store and index can never diverge across restarts.
  • Crash-safe by construction. Every mutation appends one fsynced JSONL line before touching RAM. There is no shutdown flush to get wrong. An unwritable data dir is boot-fatal: this worker never silently runs in RAM.
  • Supersede, never delete. Updates append revisions; deletes append tombstones; trashed banks move to .trash/. Any state is recoverable. A correction from memory-consolidate's verify tier appends the new record and the old record's tombstone in one write. A question that matches a superseded memory's words is answered by the live memory that replaced it; the retired text is never injected.
  • Pinning. A pinned memory is shown on every turn that reads its bank, a turn with no message to recall for included, ranks higher in recall, and is untouchable by every automatic path. Only a person pins it (the memory page, REST or the CLI); a pin from inside a turn is refused. Pinned memories open the turn's <memory> message, never the system prompt or the learned rule, under their own cap (see the pre-generate hook below).
  • Tags. Topical labels WITHIN a bank ("iii", "billing") for filtering — organization, not ranking. Set them on save/update, extraction suggests them automatically, and memory::list/memory::recall take a tag filter.
  • Most turns take one LLM call, zero at query time. A pass reads at most 4 runs of new messages, one call per 24,000 bytes; a user message over 24,000 bytes is read in up to 4 pieces of its own. A call whose memories reach max_memories_per_turn is followed by up to 2 more, which list what was kept and ask only for what is missing. Extraction runs in the background after a turn completes. It sees what the bank already holds about the conversation (what recall finds for the excerpt, its slots left over filled by meaning when embeddings are available): a restatement (same text, or a close rewording) never duplicates the known memory, and reinforces it only when the user's own lines say it again (the assistant echoing an injected memory reinforces nothing), and a correction supersedes the memory it corrects (a recoverable tombstone; pinned memories are never touched). In a directory bank it also keeps what the assistant finds out about the project (how to build, test or run it, a pitfall, where something lives), never its plans, advice or own instructions, an answer it hedges ("probably") or offers to check, nor what a web page, an issue, a wiki or other generated docs (even in the repository) or other outside text it relays says. It also reads the user's own instructions for the bank, as the turn reads its rules: every hand-written rule (never learned), then the bank's description, redacted, under max_rule_chars (the budget reaches the rules first, so a description never pushes a rule out). One that says not to keep something ("never remember anything about my health") outranks what extraction would otherwise keep (an instruction to the extraction model, not a filter); none makes it keep what it never keeps (secrets, pasted or outside text, the assistant's plans). The description bounds what lands in the bank itself (under a directory bank, its project items, not the user facts that go up to default_bank), and a rule about anything else (style, tools) changes nothing it keeps. Facts about the person talking are written as "The user …" with the user entity, so recall ranks them for a first-person question (what a turn is given from them is narrower: see the pre-generate row below). The user handle is written so in every language, never as the user's name. The input also lists up to 24 entity handles the bank already uses (those of the memories it lists first, then the bank's most used, then the most used on the memories about the user of the default_bank read under it; never user), and the model reuses one for its thing, even when the excerpt names it another way or in another language, and puts it on nothing else. An entity that spells one of the bank's handles with other separators or case (build cache for build-cache) is written as that handle, with no model call. Recall adds BM25 over the query's content words (English stopwords dropped, each word counted once; a query over 800 bytes keeps its first and last 400) divided by the best score among the banks one ranking merges, to a semantic signal (cosine on an absolute scale, calibrated for text-embedding-3-small and all-MiniLM-L6-v2; any other model inherits text-embedding-3-small's constants) when router::embed is available, then scales the sum by entity match, corroboration, pinning and recency: sub-millisecond at this scale.
  • Rules learn from corrections. Extraction classifies standing instructions (style directives, workflow corrections) separately from memories and appends them to the bank's auto-managed learned rule — correcting the agent in chat reaches every later turn (new sessions in the system prompt, running ones as an appended rules update). Only a rule the user's own lines state (at least half its content words) is kept, so the assistant restating a tool result or web page, or a harness [notification] relaying an event or a child's reply, never makes one; text the user pastes still counts as theirs. Extraction is shown the learned lines already in force, so a restatement in other words is not appended again and a correction replaces the line it corrects and becomes the newest line, matched by its text (a line edited by hand since then stays, and the correction appends; so does one naming a line it shares no word with). Hand-authored rules are never touched; dedup by content fingerprint. A write that takes learned past learned_max_chars (measured as injected) moves its oldest lines to memories tagged demoted-rule, never the newest line; a demoted line stays a memory and is recalled like any other. Rules over the max_rule_chars injection budget are cut (learned keeps its newest lines) or omitted, and the marker counts the hidden lines and names memory::rule::list {"bank":"<bank>"} to read them. rule_learning_enabled turns learning off. Under a directory bank, a rule extraction marks user-scope (reply language, tone, length, formatting) is appended to default_bank's learned rule, so it follows the user into every repository; project rules stay in the directory bank's. A line either bank's learned already holds is not appended again; when the user states it again, it moves to the newest line, only in the bank the item lands in.
  • Secrets are redacted, deterministically. Known key and token shapes (provider API keys, bearer tokens, JWTs, private key blocks, credentialed URLs, password=-style assignments) become [REDACTED:<label>] before anything is stored — memory text, entities, tags, and rules, on every write path — and before the transcript excerpt reaches the extraction model. The memory::on-item-changed event names what was redacted (reason), never the value. A denylist of shapes: an unknown format passes, so the extraction prompt still forbids secrets.
  • Hidden and injected instructions are screened. Invisible characters (zero-width, bidi marks and overrides, tag characters; a joiner between two non-ASCII characters, as in an emoji or Persian, and a Japanese variation selector stay) are stripped on the same paths, labelled invisible_unicode. A memory or rule phrased as a classic prompt injection ("ignore all previous instructions", "act as if you have no restrictions") is refused with invalid_input by memory::save, memory::update and memory::rule::set (on the lines it adds), and dropped by extraction; a negated or hedged mention ("never ignore your instructions") passes. The set is small and English-only on purpose: file names, URLs, paths and imperative style pass, and most extracted text is paraphrased anyway, so it mostly catches agent saves and hand edits.
  • Time-aware. Extraction reads each message with its own date and writes dated events ("tomorrow", "next Friday") as absolute dates; every injected memory carries the date its fact was last stated (an extracted memory takes its message's date; a correction keeps the date of the note it replaces; a pin or tag edit moves nothing), recency ranks by that same date, and the block names the day it was recalled.
  • Work in progress leaves turns. A memory that names a work item (a ticket key such as KAN-158, a pull request such as PR 12 or #1895, or a commit hash), or that a person or agent tagged transient, and was last stated over 7 days ago (fixed) is no longer given to turns: the hook and memory::preview skip it, and an older line it states a change of stays hidden too ("now merged" never brings back "open"), however many expired lines rank above it, and it sets neither the BM25 scale nor the relevance bar of the lines told; a pinned one never expires, so pin a ticket's fact to keep it. That includes a decision or a deadline written with its ticket key ("decided in KAN-156 that …", "KAN-170 is due 2026-12-20"): it leaves turns 7 days after it was stated too. Common standards, zones and colours (UTF-8, SHA-256, UTC-3, #333333) are not work items; a UUID is not a commit. With a kanban worker on the engine, a line whose ticket keys are all closed on its board (in the done or the canceled column) leaves turns at once, the same way, a decision written with its key included; a line that also names an open ticket stays, and a reopened ticket's lines come back; a deleted ticket stays as it was. A key with the board's own id_prefix counts even when that prefix has a digit, one letter or a standard's name (PROJ2-1, K-1, ES-1). The worker keeps the closed keys in memory: the internal memory::on-ticket-changed follows kanban::on-change (a change older than the last one applied to its ticket is dropped, since deliveries are not ordered), and the whole set, deleted tickets included, is read from kanban::ticket::list at boot, every 5 minutes after and as soon as the engine connection comes back (every 60 s until kanban answers, since an observer misses what changed while the worker was down or disconnected) and again on config.updated, so a moved done column counts; a ticket moved while a read is in flight takes that move, judged by the columns just read, and an older read never replaces a newer one. Without kanban nothing changes; pull requests, commits and keys of other trackers still wait the 7 days. Common standards, zones and colours (UTF-8, SHA-256, UTC-3, #333333) are not work items; a UUID is not a commit. Hidden is not yet retired: memory::list, memory::get and memory::recall still return it (an explicit search, and memory-consolidate's dedup reads it), and extraction still lists it as known, so a correction of it supersedes it instead of adding a second line. Once a work-item line was last stated retire_expired_after_days ago (default 30, never before it expires; 0 keeps them forever), an hourly sweep over every bank, starting 5 minutes after boot, retires it: it is tombstoned as memory::delete does, so it leaves recall and list and stays on disk, readable with include_superseded, and memory::on-item-changed reports it deleted with the reason. A busy bank otherwise keeps growing with status no turn is told, and each turn's recall reads all of it. Two kinds stay hidden instead: a line tagged transient, since a recurring status said again word for word ("the user is on call this week") must reinforce it, and a line with a change word ("now", "moved", "replaced"…), since it may still hide the older line whose value it changed ("KAN-158 moved the nightly backup to 04:00 now" over "the nightly backup runs at 02:00"). A line restated or edited after the sweep read it is left for the next sweep. Once retired, the same text word for word is not stored again by extraction, and a turn's memory::save of it is refused (bringing back the retired memory) unless it was the agent's own note, as after a delete; a save from outside a turn brings it back.
  • Honest health. memory::doctor runs a real save→recall→delete roundtrip in a scratch bank (nothing left in .trash), reports sibling reachability (router, session-manager, the state worker that keeps the extraction cursor), probes router::embed, and flags extraction passes that keep failing (a pass that leaves a backlog for the queue to drain is not a failure). Its embeddings-available check is advisory, since lexical-only recall is a supported setup: when router::embed returns no vector, it gives the reason, for example router::embed returned no vector (remote error (provider/not_configured): ...); recall runs lexical-only (BM25 + entities). Recall itself logs one semantic recall unavailable WARN with the reason when query embeds start failing, DEBUG while they keep failing, and one INFO when they answer again. Its extraction-model check names the model extraction calls and why (pinned, automatic ... (provider default) or (first listed model)), or the resolution error. Its extraction-queue check reads engine::queue::topic_stats in the worker's own namespace for the memory-extraction topic and fails while jobs wait in the dead-letter queue, naming the functions that inspect, redrive and discard them and, outside default, the namespace they run in; unreadable stats never fail doctor. On the builtin queue adapter, this needs the queue release that also counts a function queue named like a subscribed topic; until then the check reads no dead-lettered jobs reported. A dead-lettered entry holds the job only: each failure is in the extraction pass failed WARN, with the model when the pass reached the model call. The extraction-passes check keeps only the latest error and clears it after a pass succeeds, so a dead-lettered job can outlive its error there. Its extraction field reports what extraction spent and wrote since boot and in the last pass: model calls, prompt and output tokens, the router's cost when it reports one, what the replies held (returned, every item in their arrays before any check; rules, the rule items among them, which become learned lines and never count as created or dropped; no_array, replies with no JSON array, so a reply the model never shaped is told apart from a real []; the pass asks a piece's first call once more after one, with the input ending in a request for the array alone, and a second reply with no array reads as nothing to keep; continuations, the calls made after one whose memories reached max_memories_per_turn, with continuation_input_tokens and continuation_output_tokens, their part of the tokens; saturated, the pieces that ended at the cap, where the model may have left facts out: the last reply read still reached it after the 2 continuations allowed, or a continuation failed or held no array (logged; what was already returned is kept), or a kept item is one the injection screen refuses, so the piece is not asked again; a long user message counts once per piece it is read in, and a pass that replays a saved plan counts none), memories created, reinforced and superseded, and dropped memories by reason (malformed for an item that did not parse). unsourced_values counts the digit-bearing tokens (a port, a version, a count) of the memories it read found in neither the excerpt nor the memory a correction rewrites, values the model may have changed; it drops nothing. memory::recall names the retrieval mode it ran. Degradation is explicit, never silent.

How it hooks into the harness

Seam What happens
harness::hook::on-pre-generate (args { priority: 100, timeout_ms: 3000, on_error: fail_open }) Injects the session bank's rules into the system prompt once per session (sent verbatim after that; a later rule change arrives as one appended update message, so the prefix stays append-only) and, on each turn's first step, one appended message: first the bank's pinned memories, a turn with no message to recall for included (read under the same banks recall reads, so a pinned memory in another bank is never shown; at most pinned_limit lines within pinned_max_chars characters as rendered, the most recently updated first, the rest skipped and named in memory_pinned_skipped; outside recall_limit and recall_budget_tokens, and never told twice: recall skips a pinned line it ranks, without spending a slot, and a pinned line the window already shows is not sent again), then up to recall_limit recalled memories, or more for a list question (past recall_limit only for "what do you remember about me?" or for siblings: lines on the same two or more question words, each leading with its own subject: "which services use Postgres 16?" gets each sibling, while "kotlin?", "is payments-api down?" and "what should I do now?" keep the count, among the best 4 × recall_limit candidates, until recall_budget_tokens): never an expired work-item or transient memory, nor one whose tickets kanban closed (see Work in progress leaves turns) (see Why this shape); only memories with evidence (a word of the message, or its meaning; the user a pronoun stands for counts only in a question of pronouns alone, "who am I", or of a memory verb asked of "me", "what do you remember about me", "tell me about myself", "do you know who I am?", never "tell me more" or "I know") that stand on their own or with the turn's best match, which counts only in a turn anchored in the bank (two of its words matched, a meaning that stands out, which needs 20 embedded memories in the bank for a z-score (below that, any meaning match anchors the turn, as before), or, without vectors, its best word match: with vectors, "Great, go ahead." gets nothing on its one shared word); a line tagged with entities, none of them a subject the message names (an entity of a candidate line, every word of it among the message words that line matched: payments-api in "whom do I page for payments-api?"), stands only on the words it shares with the message, never on meaning or the turn's best, so "kai is on call for ledger-api", however close in meaning, is not told on its one shared word (untagged and user-only lines are never on another subject); one line per fact (the best-ranked of its rewordings); the newer of a stated change, in the older one's place when only the older matched well enough ("now runs at 04:00" over "runs at 02:00"; a pinned memory is never hidden); a newer note on a told line's subject joins right after it, even with no word of the message ("dana left the company" after "dana is on call for payments-api" when the message names payments-api); and nothing when none qualifies (an automation session, any of those recall_in_automation names, recalls nothing while it is off: its rules and pinned memories still go in, and its header says so and points it at memory::recall; an e2e session recalls like a user's); minus any the window already carries from an earlier turn's block, or a rewording of one (a block compaction dropped no longer counts, so its memories can return). Whether an update is due is read from the window the step sends (its newest <memory update="rules"> message, else the frozen section), so a lost or compacted-away update is sent again and a delivered one never is. Each step is annotated with memory_recall (hit, miss for a recall that ran and injected nothing past the pinned lines, or skipped with memory_recall_skip_reason: memories_off, later_step, automation, no_query, bank_not_created, no_bank, bank_lookup_failed), memory_ids (the pinned lines first, then the recalled ones), memory_pinned_skipped when pinned memories went past the cap, and memory_injected_chars, the characters memory added to the system prompt and appended messages. The section's header says whether the turn is captured: a sub-agent's turn (its session has a parent, or the harness reports a parent for the turn, which turn-end then never extracts; a harness that sends no turn parent is judged on the session record alone), or the user's own while extraction_enabled is off, is told nothing is captured automatically and, where its policy grants memory::save, to save what a later session needs with it; an automation or e2e session is told nothing is captured and is not asked to save, since scripted runs never write into the user's memory
harness::on-turn-completed Queues one background router::complete extraction pass over the turn's new user/assistant messages (all of them, one call per run of 24,000 bytes of excerpt, up to 4 for a longer user message, and up to 2 more after a call whose memories reach max_memories_per_turn; a session's first pass reads at most extraction_window non-empty messages, plus the turn's user message), into the bank the turn was injected with (after a worker restart, the one the hook stamped on the turn's reply); under a directory bank, user-scope items go to default_bank; agent-scope items go to that agent's bank (see Bank selection). A failed or cancelled turn is extracted too (its own bank, not the next turn's); a sub-agent's turn never is, nor an automation or e2e session's (session kind other than user), nor a turn that finished while extraction_enabled was off

What a turn recalls on: the harness attaches a delivery context to the hook call (recall_context). A message the user or an invoking agent sent recalls on its own text, or on the earlier user message it continues when the harness names one ("go on" after "which harbor does the ferry leave from?"). A notification, an unknown delivery, or a context naming another session or turn recalls nothing; the pinned memories, the rules and their per-turn reminder still go in. A harness that sends no context gets recall on the last user message, as before. A question with a fronted slot ("In which city do I live?", "Did I move last year, and in which city?") also counts a line holding the question's words outside the slot ("live"), since the answer need not repeat "city"; a question it cannot read is judged on all its words, as before.

What injection does not catch yet:

  • With an embedder, a memory that shares no word with the message is injected on meaning alone when its meaning stands out in the bank, or, in a bank of fewer than 20 embedded memories (too few for a z-score), once its cosine clears the model's floor, so small talk still brings lines: on the eval's 256-dimension text-embedding-3-small vectors, 16 lines over 8 greetings, 3 over 8 first-person tasks and 5 over 8 follow-ups ("tell me more"); on MiniLM's 384-dimension vectors, 2, 0 and 3. That admission is not calibrated per model, MiniLM included; calibrating it on vectors in the production dimension is the follow-up.
  • In lexical mode, a memory that shares no word with the message is not injected, even when recall ranks it through the user a pronoun stands for: three eval paraphrases are lost this way ("job title" against "senior backend engineer"), and hybrid mode finds all three by meaning.
  • Without vectors, a turn's best word match anchors the turn on its own, so "Great, go ahead." injects a memory about Go: requiring two shared words there loses two needed eval lines ("my current diet", "which units").
  • Only entity tags mark a line as on another subject, and two shared words still admit it: "who is on call for payments-api incidents?" gets "kai is on call for ledger-api incidents" (api, incidents), and an untagged near-miss is still told on meaning. A tagged answer filed under another subject than the one the message names is lost when it shares fewer than two exact words with the message ("how do I deploy ledgerly?" against "Deploys go through make ship", tagged ci, beside a line tagged ledgerly).
  • Two facts with the same values are told as one line when they differ only past their first content word (read past a possessive "user's"), unless their entity tags differ: "Postgres 16 backs the billing service" and "… the ledger service", and, most often, two user facts that both lead with "User", the form extraction writes them in ("User takes 10 mg of zinc every morning" and "… of iron …"). "The billing service runs on Postgres 16" and "The ledger service runs on Postgres 16" are both told, and so are "The user's sister …" and "The user's cousin …".
  • A list question gets its siblings past recall_limit only while every line in the first recall_limit matched the same question words: one line there on other words (a meaning-only match in hybrid mode, a pinned memory, a newer statement in an older line's place) cancels the whole list, and the turn keeps recall_limit lines. Siblings phrased object-first ("Postgres 16 runs search", "Postgres 16 runs billing") or sharing a hyphen prefix ("payments-api", "payments-worker") lead with the same word, so they keep the count too.
  • A newer note joins a told line only when the message names one of the line's entities ("who is on call?" links nothing), only on the line's own subjects (an update naming one more subject, "dana moved to the ledger team", never joins), only through an entity at most 5 memories carry, and only when both memories carry the same entity tag. Every later note on the subject joins, a trivial one included, and a told later line on the subject hides an older update.
  • A handle spelled another way names another subject: in a question about payments-api, a line tagged payment-api or payments api stands only on the words it shares with the message, as a ledger-api line does. Extraction reuses the bank's handles for new memories; one already stored under a variant, or under a translation or the user's name in place of user, keeps it.
  • A "do not remember X" said in chat is not a rule: it needs a hand rule (memory::rule::set). A rule is an instruction to the extraction model, not a filter, and memories stored before it stay until deleted.
  • Extraction reads a user message whole up to 80,000 bytes (80,000 characters of English, fewer in a script that takes more bytes per character), in up to 4 pieces of about 24,000 bytes. Past that it reads the first and last 40,000 bytes and logs the cut at info level. Other lines keep 2,000 bytes (the first and last 1,000). Files attached to a message are read as part of it, so they count toward its 80,000.
  • Nothing retires a work item's state when its work ends: it is hidden from turns 7 days after it was last stated and, unless tagged transient or holding a change word, retired after retire_expired_after_days, and only when it names the item (a ticket key, a pull request or a commit hash) or carries the transient tag. A status written without one ("the login refactor is in review") is injected like any memory. Extraction is still told only "never ephemeral state": prompt variants that named a ticket's or a pull request's state lost durable facts stated beside it in the eval (a pitfall found during a test run, "ledger-api now runs three replicas"), so the prompt is unchanged.
  • memory::preview has no session input, so it shows what a user's session is given, never an automation session's skip.
  • The rules that collapse rewordings and recognize a change are English only: duplicates across languages are not collapsed, and a change without an English change word ("now", "moved", …) keeps both lines, each with its date.

Bank selection, one resolver for injection, extraction and agent calls: turn metadata memory_bank → session metadata memory_bank (session::set-meta) → the parent turn's bank, else the parent session's (a sub-agent works in its parent's bank, walked up) → the bank of the turn's fs_scope.root: <name>-<6 hex>, named after the git repository holding it (its main checkout's folder, so every worktree of a repo shares one bank), else after the directory itself, with a hash of the canonical path so same-named folders never share → configured default_bank (no root, or one that does not exist). A bank the root chose reads default_bank under it (a sub-agent working in it too): its rules first, labelled with its name (learned (main)) so two learned rules never merge, under the one max_rule_chars budget, and its memories whose entities include user in the same recall (a memory::save into default_bank from outside a turn that names no entities gets user, so the memory page and the CLI qualify; one naming others needs user among them; from a turn user is refused). The hook, memory::preview and memory::recall without bank read it alike, and so does memory::preview naming a directory-shaped bank (<name>-<6 hex>), as the console's preview tab does; a memory recalled from it carries its bank, and the hook's memory_banks annotation names the bank of each injected id. Extraction labels each item scope user (holds wherever the user works) or project (the default). Under a directory bank a new user-scope memory is written into default_bank tagged user, and everything else stays in the directory's bank (a user-scope correction of a directory-bank memory included: it stays there and supersedes it; so does a fact the directory's bank already holds, live, pinned or deleted). Extraction lists the layer's memories about the user as already remembered, after the bank's own and at most half as many: a restatement reinforces one where it lives, a user-scope correction supersedes it there, and a project-scope one (an exception that holds only in this repository) is written to the directory's bank, leaving the user's fact standing everywhere else. In a default_bank session a user-scope memory gets user too. A bank named by metadata or by bank is read alone. Project facts saved in main before directory banks are not read under them; read them with bank: "main". A memory::* call without bank inside a turn acts on that turn's bank, and a save or an update from a turn acts only on it (a delete also on a bank read under it, for a memory read there): one naming another bank is refused; outside a session (CLI, console, other workers) it uses default_bank. An invalid name, a deleted bank other than the default, or a parent session that no longer exists means no memory for the session — never another bank — and extraction never brings a deleted bank back. A session-lookup failure injects nothing new (the section the session already has stays) and makes extraction retry. An unknown bank gets the ambient header too: the first extraction or memory::save creates the bank.

A session running as an agent profile (agent_profile in its session metadata, set by harness options.agent and by profile spawns) also reads its profile's bank, agent-<id> (one per profile, across repositories), under any bank no metadata named; a sub-agent reads its own profile's, never its parent's. Its rules come after default_bank's and before the session bank's, labelled learned (agent-<id>), under the same budget, and all its memories join the same recall. The hook (its memory_agent annotation is also the restart stamp), memory::preview and memory::recall without bank read it alike. Extraction lists the agents in the conversation, the session's own profile, then its sub-agents', and labels an item scope agent, with agent naming one of them, when the user tells that agent how to do its role's work, or asks to pass it on: "tell the reviewer to check the tests first" in a tech-lead session lands in agent-reviewer's learned. The learned-rule gate still applies, an item naming no listed agent is dropped, and sub-agent turns stay unextracted. A profile id that makes no valid bank name, or a deleted agent bank, drops only that layer. The bundled general identities, default (which the console preselects), its alias iii-minimal, and iii, read as no profile.

Switching a running session's bank does not rewrite what it already saw: the new bank's section arrives as an appended update that overrides the frozen one, while the earlier bank's section and recalled memories stay visible in the transcript. Start a new session when the two contexts must not mix. Turning inject_rules and inject_memories both off works the same way: a running session keeps its section and is told once that no memory section applies.

The worker also observes session::on-deleted (drops the session's extraction cursor and its .extraction state), kanban::on-change with args { ticket: "summary" } (keeps the board's closed tickets: see Work in progress leaves turns), queue::on-message with args { topic: "memory-extraction", max_retries: 3, backoff_ms: 2000 }, and configuration::on-updated for its own entry. Each finished turn's extraction job goes on the memory-extraction function queue (engine::queue::enqueue), whose worker calls memory::extract-job itself; an error retries the job, then dead-letters it. The worker calls the queue worker's engine::queue::* functions in its own namespace, and a job queued outside default names that namespace, so memory::extract-job is called there. When the enqueue fails (no queue worker in the namespace, the queue not defined yet at boot, or no answer in 5 s), the pass runs inline, with no retries and no dead-letter queue, and logs one WARN extraction job not queued; extracting inline per outage (DEBUG for repeats until a job queues again).

The worker creates every observer at startup, and creates the extraction consumer again each time its id is refused (below). Observed before its owning sibling (harness, session-manager, queue) is up, an observer stays pending and becomes active when the sibling registers the function.

The extraction consumer observes under a stable id: the worker name (memory, or the III_WORKER_NAME its supervisor sets), then :queue: and the topic, preceded by <namespace>/ when the worker has a namespace (memory:queue:memory-extraction by default; an id over 128 bytes becomes the worker name, cut to its first 97 bytes, then :queue:fnv1a64: and a 64-bit FNV-1a digest of the whole id). The queue worker files a subscriber's durable queue under its observer id. When the worker stops, killed or not, the engine keeps its observers suspended for its grace period (observers.observer_grace_ms, 30 s by default) and withdraws them from their functions' workers. A restarted worker, under the same name and namespace, observes the topic under the same id: the engine replaces the suspended observer with the new one, and the queue worker hands the new process every job the previous one left unacked, once. While another observer holds the id (OBSERVER_ID_CONFLICT: the engine has not seen the previous process's connection close yet, another worker holds it until its grace period ends, or the queue worker has not let the previous subscriber go yet), the worker logs the refusal, disposes the refused observer, and observes again 5 s after the refusal, then twice as long each time up to 30 s (5 s, 10 s, 20 s, 30 s, 30 s, ...).

Extraction contract

  • Cursor. The confirmed watermark is state scope memory_cursor, key the session id, value { last_entry_id }. A pass reads session::messages strictly after it; the job's until is an inclusive client-side cut, never a request field. The cursor moves only after a run's writes landed; an empty or trivial run (no model call) still moves it.
  • Runs. A pass splits the delta into runs of at most 24,000 bytes of excerpt (a long turn of tool-only steps, which have no text, is also cut so its entry ids fit the run's source key) and executes at most 4. A user message over 24,000 bytes is a run of its own, read in up to 4 pieces with one plan for the run. Each call may write max_memories_per_turn memories. A call that reaches that number is followed by up to 2 more for the same piece: they list the items already kept and ask only for memories none of them holds (a rule or a repeat in their replies is dropped). A continuation that fails or holds no array keeps what was already returned. Runs the pass does not execute return an error, so the queue retries from the last confirmed run; no prefix or tail is dropped.
  • Source. Each memory a run writes records its session and the run's first and last entry (source.session_id, source.first_entry_id, source.entry_id), so the span it came from can be read again. Records written before spans were kept hold only the last entry. A memory saved from a turn records its session and turn (source.turn_id).
  • Turns. A job carries its turn_id. The pre-generate hook stamps memory_extraction, memory_bank, memory_derived (no name chose the bank) and the layer and agent on each assistant entry, so every run is extracted under its own turn's policy and bank by whichever job reaches it first, not the newest job's. A step of the job's own turn without a stamp (the hook timed out, or its bank lookup failed) runs under the job's bank, resolved again when the job runs; another turn's unstamped step, or one that predates the stamp, counts as OFF. A turn keeps its one opening request; an earlier request that failed before any reply is passed unextracted, unless the harness attested that turn as failed or cancelled with no reply (extraction_history): the request then runs alone under that turn's own bank, or closes unextracted when its policy is unknown or its layer was rotated since. A row that proves less is ignored, so it never stops the cursor. The hook imports that history in the background, and only when a delivery attests such a request the ledger does not hold yet. A job queued without a turn_id is still accepted.
  • Receipts. Before the model call a run's redacted source is saved as the session's pending slot, and the model's decision is saved as a plan keyed by session, bank, turn and ordered entry ids. Each memory effect is appended to memories.jsonl together with a receipt line ({"extraction_receipt": ...}, a SHA-256 of the run's source key, the bank and the item's index in the plan; never a memory) in one write. A retry reuses the plan and skips every effect whose receipt the bank already holds, so a redelivered job adds no second revision or corroboration. An effect whose memory changed since the extraction read it, or whose stored twin the injection screen flags, records a skipped receipt instead; a stored record that predates a redaction pattern is written back redacted. A learned-rule merge is skipped the same way when rules/learned.md changed since it was read (compared redacted); its receipt lives in the run's plan, never in the rule file. A merge that takes learned past learned_max_chars then demotes its oldest lines: each line is saved as a memory first, and the rule is rewritten after, so a crash leaves a line in both places, never in neither. A line that cannot be saved stays in the rule.
  • Events are best-effort and at most once: a crash between a write and its event loses the event.
  • Closed runs. A run captures only what the model reads (each line redacted and cut as above) and a digest of its full text, so no message is too long to extract. A run whose bank was deleted is closed unextracted. A retained run the path no longer holds as recorded (an edit, a fork) is dropped, and its entries run as the path holds them now.
  • Pruning. A run's plan and rule receipts are deleted once the cursor passes the run, or its retained range completes. Acknowledging a range drops the history rows of its entries; a pre-generate import drops every row at or before the cursor. Deleting a session purges its pending slot, ranges, history and plans; trashing a bank purges the plans of runs into it (a run that only teaches its agent keeps its plan and drops that agent's items).

Functions

Function Purpose
memory::bank::create / list / delete Banks as first-class named scopes ("blog" vs "coding" vs "personal"); delete moves to .trash/
memory::save Explicit save: fingerprinted, reinforces on repeat (corroboration only from outside a turn), and brings back a deleted memory of the same text; the text of a memory a newer one superseded is refused (memory_retired, naming the live one), so the correction stays the only live line; called from a turn, it is the agent's note, with that session and turn as its source, under the in-turn rules in Permissions
memory::get / list / update / delete / pin Memory CRUD; delete tombstones; update bumps a revision in the log, and refuses a retired memory (memory_retired, naming the memory that replaced it, so the edit lands on the live one). Update takes two optional fields, as memory::supersede does: expected_memory, the record as the caller read it (the write is refused with invalid_input when the memory changed since), and reason, which rides the event with secrets redacted; memory-consolidate's alias tier sends both. An edit that leaves the text alone never moves when the fact was last stated, and the cap of eight entity handles never drops user. From a turn, update revises only a note saved from a turn, a pinned memory is refused, and pin is refused (Permissions)
memory::recall The exact scorer the hook uses (the hook injects only the hits with evidence, one line per fact and the newer of a stated change; memory::preview shows exactly what it injects); tag narrows to one label; a query matching a superseded memory's words returns the live memory that replaced it, never the retired text (include_superseded lists history too); mode: lexical | semantic returns one raw arm (plain BM25 over the content words, or cosine) for callers that fuse arms themselves, which does not follow a superseded memory to its replacement; when the query was embedded, vector_coverage {covered, live} says how many of the bank's live memories have a vector in the query's model (covered < live while backfill or a re-embed runs)
memory::conversations Search a bank's past conversations for what was said: query (required), bank, limit (1 to 10, default 5). One session::search filtered on the bank the hook stamped on each turn (a person's message takes the stamp of the reply that answers it), then up to limit lines { session_id, entry_id, role, text }, user and assistant messages only, never the calling session's. Each text is redacted whole, then past 1,000 characters cut to a window opening up to 200 characters before the query's longest word (at the head when redaction hid it, earlier when the word sits in the last 800, so the window stays 1,000). retrieval is session-search (no lines means no match), or session-search-unavailable with no lines when session-manager does not answer within 10 s or is too old to filter by bank (a hit without snippet.origin: no hit is returned then). Outside a turn it searches bank, else default_bank, never a bank read under it; from a turn, see Permissions
memory::tags Distinct tags across a bank's live memories with counts (the filter source)
memory::preview Full injection dry-run for a hypothetical chat message, as a user's session gets it: rules section (budgets applied), the pinned memories (score 0, those past the cap in pinned_skipped), then the memories past the relevance cut and token budget (never an expired one, nor one whose tickets kanban closed: see Work in progress leaves turns), appended message verbatim — the hook's exact code path
memory::rule::list / set The always-injected markdown rules; empty content removes. list returns content redacted, as it is injected. set takes an optional expected, the content as last read: the write is refused with rule_changed when the rule holds anything else by then; "" means the rule must not exist yet
memory::supersede Retire one memory in favor of another (tombstone + pointer) — the consolidation seam; reinforce makes it a merge (a non-pinned survivor absorbs the retired record's observations), reason rides the events
memory::doctor End-to-end self-test (roundtrip, sibling reachability, embeddings, recent extraction failures, the extraction model, dead-lettered extraction jobs, extraction cost)
memory::reload Reload every bank from disk after hand-editing files

Every function above is also a REST route through the http worker: the worker observes http::on-request with args { method: "POST", path } per function, the path being the function id with :: as / (POST /memory/save, POST /memory/bank/create). Every route targets memory::rest (internal), which receives the HttpRequest, runs the function with the request's JSON body as its input (an empty body is {}), and returns the HttpResponse: 200 with the function's result, or { error: { code, message } } with 400 (invalid_input, also a body that does not fit the function's input, a stale memory::rule::set, whose message contains rule_changed, and a write on a retired memory, whose message starts with memory_retired and names the live memory that replaced it), 403 (forbidden, a request carrying an agent turn's baggage to a function only a human may call, see Permissions), 404 (bank_not_found, memory_not_found), 500 (storage) or 503 (sibling_unavailable).

curl -X POST localhost:3111/memory/save -H 'content-type: application/json' \
  -d '{"bank":"blog","text":"The blog deploys on Fridays"}'

What memory::conversations does not do:

  • Find a session missing a query word: every word must match somewhere in the session's messages of that bank (as a word's start or with a typo, as session::search reads it).
  • Return more than one line per session: the session's best message, which may hold only some of the query words.
  • Search tool output: only the text of user and assistant messages.
  • Search sub-agent sessions, or automation and e2e sessions.
  • Skip a sub-agent's parent: called from a sub-agent, it skips only the sub-agent's own session, so the live conversation that spawned it can come back.
  • Respect what extraction left out: text extraction refused to keep, or a memory that was deleted, can still come back as a quote from the conversation.
  • Forget with the bank: memory::bank::delete does not delete conversations, so a bank created again under the same name finds them again.
  • Keep repositories apart on the default bank: there it spans every conversation outside a mapped repository.

Change functions

Observe these for live views instead of polling. Both are private (only this worker calls them) and take no args: an observer selects changes with filters on the event. The worker calls each one fire-and-forget when the change happens, and iii delivers the event to every observer whose filters match, unordered.

Function Args Called when Event
memory::on-item-changed none; filter on input.bank, input.event_type a memory is created, updated, superseded, or deleted { event_type: created | updated | superseded | deleted, bank, memory, reason? }: memory is the record as stored after the change, reason is memory::supersede's or memory::update's reason, a correction's reason, or redacted: <labels> (after the caller's reason on an update that has both)
memory::on-bank-changed none; filter on input.bank, input.event_type a bank is created or trashed, or its rules change { event_type: created | trashed | rules-changed, bank }
iii.observe(
  { function_id: 'memory::on-item-changed', filters: { 'input.bank': { $eq: 'blog' } }, capture: ['output'] },
  'blog::on-memory-changed',
)

Storage layout

Compose stores this tree under III_COMPOSE_DIR. A standalone worker uses its process current directory for the same relative default.

<III_COMPOSE_DIR>/data/memory/
  main/
    bank.yaml          # description
    rules/style.md     # always-injected markdown
    memories.jsonl     # append-only memory log (full records, last-wins by id)
    vectors.jsonl      # derived embedding sidecar (rebuildable)
  .extraction/         # in-flight extraction state: pending slots, ranges, plans, history
  .trash/              # trashed banks, timestamped

Recall quality eval

tests/recall_quality.rs scores the production Bank::recall over a synthetic golden bank (tests/recall_quality/golden.json: one persona, 76 memories including 4 paraphrase duplicates, 62 English/Portuguese queries across lexical, paraphrase, identity, temporal-update, dated-event and durable-old categories). It runs in three modes:

  • lexical;
  • hybrid, with cached text-embedding-3-small vectors;
  • hybrid-consolidated, which first replays the semantic consolidation tier's recorded decisions (tests/recall_quality/consolidation.json, from memory-consolidate's judge eval) and scores expectations carried to the survivors.

It reports hit@1/3, MRR@10, nDCG@10 and recall@10 per category and language. The lang:en slice is the primary metric: recall's word rules are English only, so the Portuguese queries stay in the set but nothing is tuned for them. It also counts traps, where a superseded memory outranks the current one, and duplicate pollution, a query whose top 10 holds both members of a dup_of pair. The committed snapshot tests/golden/recall_quality.json makes it a PR gate. The metrics follow trec_eval conventions.

injection_quality, in the same file, scores what the hook injects from that bank: every candidate with its evidence through hooks::select, nothing visible, in lexical and hybrid mode, against tests/golden/injection_quality.json (text-embedding-3-small) and tests/golden/injection_quality-minilm.json (MiniLM). Beside the 62 queries it sends 41 negatives that should inject nothing: 8 greetings, 8 first-person tasks and 8 follow-ups ("tell me more", "sounds good, do it"), none sharing a word with the bank, 9 questions sharing one incidental word with a memory ("Great, go ahead." among them), and 8 near-topic questions. Negatives carry their split (26 dev, 15 test); queries are split by a hash of their id (43 dev, 19 test). In hybrid mode 17 of the 41 inject no unrelated line with text-embedding-3-small and 27 with MiniLM; the snapshot records both, and no floor is set. Per slice it reports needed lines injected, lines recall ranks that the hook dropped, irrelevant lines, duplicates and stale lines. Beyond the snapshot, it fails when:

  • a stale line is injected without the current one, in any mode;
  • a greeting, a first-person task or a follow-up injects anything, in lexical mode;
  • a needed line recall ranks is dropped, other than lexical mode's three reached only through a bare user (none in hybrid mode).
cargo test --test recall_quality -- --nocapture                # report
UPDATE_GOLDENS=1 cargo test --test recall_quality              # re-baseline both evals after an intended change (always scoped)
III_NAMESPACE=<ns> cargo test --test recall_quality -- --ignored embed_golden_set   # re-embed after editing golden.json

Extraction eval

extract::eval runs the production extraction prompt and parser over short excerpts (English, but for the Portuguese status and handle cases), three times each, through a live router::complete. It scores what comes back:

  • capture: each expected item is captured, wrong (its kind, where it lands, the memory it corrects, or the learned-rule gate drops it), or missed;
  • trap hits: anything past the expected items from an excerpt built to hold nothing more: an instruction only the assistant gave, a pasted document or a fetched issue relayed, a cause the assistant only suspects or a claim it restates from a generated wiki page, a harness notice, a transient error, a one-off instruction, task progress, what a correction leaves behind, a work item's state (status: Portuguese excerpts holding a round's verdict, a PR, a branch, a build, a test run, the next fix or a card, three of them beside a pitfall, a how-to or a behaviour that must still be kept, wrong when it still names the ticket, round or PR, and one a deadline). A trap hit that would expire (tagged transient, or naming a ticket, a pull request or a commit) is counted apart from the others (compare traps + transient across runs), and an expected item tagged transient is wrong; a rule never expires. EVAL_CATEGORIES (comma-separated) and EVAL_REPEATS narrow a tuning run. A learned rule the user restates is expected back unchanged, naming itself. It also counts how many of them the learned-rule gate would still let into the bank;
  • placement: what holds for the user wherever they work reaches the default bank, and nothing project-only does; with agents listed, what the user tells one about its role's work reaches that agent's bank (agent landing), and nothing about the user or the project does.

Run it before and after a prompt change; it needs an engine with a router and a provider, and no memory worker. It measures the prompt directory-bank sessions get; EXTRACTION_REPOSITORY=0 measures the one default_bank and named-bank sessions get, without the project-knowledge clause.

III_URL=ws://127.0.0.1:<port> III_NAMESPACE=<ns> EXTRACTION_MODEL=<id> cargo test -p memory --lib extract::eval -- --ignored --nocapture

Engine test

tests/engine.rs registers the worker's functions against an engine and checks that memory::on-item-changed and memory::on-bank-changed register private, with no args and the event as request and response, that a save reaches the observers filtered on its bank (and no others), and that memory::rest answers the http worker's request shape. It skips when no engine answers; III_E2E_REQUIRE=1 makes that a failure.

III_ENGINE_WS_URL=ws://127.0.0.1:<port> cargo test --test engine

tests/queue_restart.rs runs the memory binary against the same engine, with a contract mock of the queue worker's queue::on-message: a killed worker, started again, gets the extraction jobs it left unacked, once each, under the same observer id; and while another worker holds the id, the worker observes again until it is free, 5 s after its first refusal and 10 s after its second. It skips and fails like tests/engine.rs.

III_ENGINE_WS_URL=ws://127.0.0.1:<port> cargo test --test queue_restart

Permissions

The worker enforces three sets of rules itself. First, the human-owned functions memory::bank::create, memory::bank::delete, memory::rule::set, memory::supersede, memory::correct, memory::transcript and memory::reload refuse a call from inside an agent turn with forbidden: calling `<function>` is not allowed from inside an agent turn; it is a console, REST or CLI action (REST 403). A call is from inside a turn when it carries the turn's baggage, iii.session.id: the harness stamps it on every turn step, and every call a worker makes from there passes it on. A request without turn baggage runs: the console's and the CLI's calls carry none, nor does memory-consolidate's scheduled pass (the cron tick, the boot backstop). A memory-consolidate::run started from inside a turn carries that turn's baggage into every memory call it makes, so its memory writes and memory::transcript are refused; each refusal is a bank error, so that pass is not checkpointed and the scheduled pass still runs when due. Learned-rule demotion is the worker's own write and ignores the baggage an extraction job carries.

Second, a memory::save, memory::update, memory::delete or memory::pin from inside a turn is held to the agent's own note, as extraction stays the primary writer. Each refusal is forbidden (REST 403), except the text bound, which is invalid_input:

  • Session kind. Only a user's session and its sub-agents write; an automation or e2e session, a workflow node, or a session session-manager does not know is refused.
  • Bank. Only the turn's own bank: a layer read under it (default_bank under a repository's bank, agent-<id>) or any other bank is read from other places. A delete may also act on a layer, for a memory the turn reads there (forget X of a fact about the user). A save from a turn never brings a deleted bank back. Only the harness's own hook delivery, through this worker's observer, sets the turn's bank; a direct call of memory::hook::pre-generate never changes it.
  • Pin. pinned on a save, the pin flag on an update, and memory::pin are refused; a pinned memory cannot be updated or deleted.
  • Labels. The user entity (the cross-repository layer) and the demoted-rule tag (what promotion may pick) may be neither added nor removed. Learned-rule demotion is exempt.
  • Size. A note is 3 to 500 characters (outside a turn, 3 to 2,000 bytes).
  • Cap. At most max_memories_per_turn new notes per turn, counted by source.turn_id; a re-save of a text the bank holds live is not counted and adds no corroboration (only the user's restatement does); it refreshes the stated time of the turn's own note and leaves a pinned, user, extracted or human-saved memory as it is. A call with a session but no turn id cannot save.
  • Update. Only a note saved from a turn (confidence: stated with a source.turn_id) that is not pinned, about the user or a demoted rule line. Any other memory is deleted and saved again as a note.
  • Delete. Any unpinned memory the turn reads: the tombstone is recoverable.
  • Bringing back. A save of a retired memory's text brings it back only when that memory is a note a turn may update; it is then that turn's note.

Third, memory::conversations from inside a turn reads only the turn's own bank: one naming another bank is refused, and so is a call from an automation or e2e session, a workflow node, or a session session-manager does not know, or from a session with no usable bank. Each refusal is forbidden (REST 403). It needs no approval: the bank filter, this rule and redaction are its gate.

The baggage is caller-supplied and not attested. A call that leaves the turn without it arrives as a human's: a shell or the CLI, an HTTP request to the REST routes, an external MCP client. The http worker passes a request's baggage header on, so a REST request that sends a turn's baggage is refused too.

iii-permissions.yaml is a suggested policy for deployments that run a policy worker (approval-gate reads rules through policy::check_permissions); nothing loads it at run time. It gives agents memory::recall, memory::conversations, memory::save, memory::get, memory::list, memory::update, memory::delete, and denies memory::pin, the seven functions above and the internal seams: memory::hook::pre-generate, memory::on-turn-completed, memory::on-session-deleted, memory::on-ticket-changed, memory::extract-job, memory::on-config-change and the REST adapter memory::rest. The worker itself refuses a direct call of four seams: memory::on-turn-completed, memory::on-session-deleted and memory::on-ticket-changed run only when this worker's own observer delivers them, and memory::extract-job runs only a job this worker queued: it holds each job it puts on the queue until the job succeeds, so a direct call, or a job another caller enqueues or publishes, is refused. memory::hook::pre-generate records a turn's bank only from its observer's delivery; memory::on-config-change and memory::rest rely on the policy alone. memory::transcript returns a memory's source lines, redacted, a long line as its head and tail; memory::correct replaces a memory its source contradicts. Neither has a REST route.

The memory family

Like llm-router and its provider workers, memory is a family of narrow siblings rather than one grown monolith — this worker owns the store, per-turn injection, capture, and recall, and stays deliberately small:

Worker Role Status
memory (this) Banks, rules, memories: storage, harness injection, background capture, hybrid recall, live change functions shipped
memory-consolidate Background hygiene on a schedule: deterministic dedup of near-duplicate memories, a merge of entity-handle aliases, catch-up-on-boot scheduling, and an opt-in verify tier that checks notes against their source transcript. Every write goes through memory::supersede, memory::update or memory::correct, never touches pinned records; every change lands as a memory::on-item-changed event shipped

The split is the point: consolidation can be installed, stopped, or removed without touching stored memory, and this worker never grows a scheduler.

Boundaries

Context-manager compresses one history for one turn; this worker is the durable cross-session sibling its spec reserves (see tech-specs/2026-06-agentic/memory.md). Recall fuses BM25 with a semantic signal when router::embed has an embed-capable provider; memory::recall.retrieval names the mode either way. Consolidation belongs to the memory-consolidate sibling, not here.

Skills

API reference (JSON)

agent-api-reference.json
{
  "functions": [
    {
      "description": "Create a named memory bank: an isolated scope of rules and memories, e.g. one per project or persona; its description tells extraction what the bank is for, narrowing what is kept. Idempotent; sessions select it via metadata `memory_bank`.",
      "metadata": {},
      "name": "memory::bank::create",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "description": {
            "default": null,
            "description": "Human description shown in listings and the console, and told to extraction as what this bank is for: it narrows what is kept.",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "description": "Bank name, `[a-z0-9][a-z0-9_-]{0,63}` (it becomes a folder name).",
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "title": "BankCreateRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "BankInfo": {
            "description": "Summary row for `memory::bank::list` and the console page.",
            "properties": {
              "description": {
                "default": "",
                "type": "string"
              },
              "memories": {
                "description": "Live memory (memory) count.",
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "pinned": {
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "rules": {
                "description": "Rule (always-injected markdown) count.",
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "memories",
              "name",
              "pinned",
              "rules"
            ],
            "type": "object"
          }
        },
        "properties": {
          "bank": {
            "$ref": "#/definitions/BankInfo"
          },
          "created": {
            "description": "False when the bank already existed (create is idempotent).",
            "type": "boolean"
          }
        },
        "required": [
          "bank",
          "created"
        ],
        "title": "BankCreateResponse",
        "type": "object"
      }
    },
    {
      "description": "Delete a memory bank: the folder moves to the store's .trash, recoverable by hand.",
      "metadata": {},
      "name": "memory::bank::delete",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "name": {
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "title": "BankDeleteRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "trashed_to": {
            "description": "Where the bank folder was moved (under the store's `.trash/`).",
            "type": "string"
          }
        },
        "required": [
          "ok",
          "trashed_to"
        ],
        "title": "BankDeleteResponse",
        "type": "object"
      }
    },
    {
      "description": "List every memory bank with memory/rule/pin counts.",
      "metadata": {},
      "name": "memory::bank::list",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "BankListRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "BankInfo": {
            "description": "Summary row for `memory::bank::list` and the console page.",
            "properties": {
              "description": {
                "default": "",
                "type": "string"
              },
              "memories": {
                "description": "Live memory (memory) count.",
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "pinned": {
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "rules": {
                "description": "Rule (always-injected markdown) count.",
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "memories",
              "name",
              "pinned",
              "rules"
            ],
            "type": "object"
          }
        },
        "properties": {
          "banks": {
            "items": {
              "$ref": "#/definitions/BankInfo"
            },
            "type": "array"
          }
        },
        "required": [
          "banks"
        ],
        "title": "BankListResponse",
        "type": "object"
      }
    },
    {
      "description": "Search a bank's past conversations for what was said (session-manager's word search; no LLM): the user's and the agent's messages of the top-level user sessions whose turns ran in that bank, never the calling session, a sub-agent, an automation or test session, or tool output. Every query word must match (as a word's start or a typo away) somewhere in the session's messages of that bank; one line per session, its best message, which may hold only some of the words, redacted, past 1,000 characters cut around the query's longest word. Lines are quotes, not memories: verify them, and memory::save what should be kept. From a turn: only the turn's own bank, and never from an automation or test session. retrieval session-search-unavailable (no lines, NOT \"no match\") means session-manager did not answer or cannot filter by bank.",
      "metadata": {},
      "name": "memory::conversations",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bank": {
            "default": null,
            "description": "Bank whose conversations are searched; omitted: the calling turn's bank, else the configured default. From a turn, only its own bank.",
            "type": [
              "string",
              "null"
            ]
          },
          "limit": {
            "default": null,
            "description": "Lines returned, 1 to 10 (default 5).",
            "format": "uint32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "query": {
            "description": "2 to 5 distinctive words, each matched (as a word's start or a typo away) somewhere in a session's messages of the bank; its line is the session's best message, which may hold only some of them.",
            "type": "string"
          }
        },
        "required": [
          "query"
        ],
        "title": "ConversationsRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "ConversationLine": {
            "description": "One message quoted from a past conversation: not a memory.",
            "properties": {
              "entry_id": {
                "type": "string"
              },
              "role": {
                "description": "`user` or `assistant`.",
                "type": "string"
              },
              "session_id": {
                "type": "string"
              },
              "text": {
                "description": "The message's text, redacted; past 1,000 characters, a window of 1,000 around the query's longest word, with `…` where it was cut.",
                "type": "string"
              }
            },
            "required": [
              "entry_id",
              "role",
              "session_id",
              "text"
            ],
            "type": "object"
          }
        },
        "properties": {
          "bank": {
            "type": "string"
          },
          "lines": {
            "items": {
              "$ref": "#/definitions/ConversationLine"
            },
            "type": "array"
          },
          "retrieval": {
            "description": "`session-search`: the search ran, and no lines means no match. `session-search-unavailable`: session-manager did not answer in time, or cannot filter by bank; no lines then says nothing.",
            "type": "string"
          }
        },
        "required": [
          "bank",
          "lines",
          "retrieval"
        ],
        "title": "ConversationsResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal: replace a memory its source transcript contradicts. One append writes the new record (the old provenance and statement date, plus the reason) and retires the old one into it; `expected_memory` must still match the old record.",
      "metadata": {
        "internal": true,
        "trace_hidden": true
      },
      "name": "memory::correct",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bank": {
            "default": null,
            "description": "Bank; omitted: the calling session's bank, else the configured default.",
            "type": [
              "string",
              "null"
            ]
          },
          "expected_memory": {
            "description": "The snapshot of the memory the correction was judged on, as `memory::supersede` takes it."
          },
          "id": {
            "description": "The memory to correct.",
            "type": "string"
          },
          "reason": {
            "description": "Why, stored on the new record and carried on the events.",
            "type": "string"
          },
          "text": {
            "description": "Its corrected text.",
            "type": "string"
          }
        },
        "required": [
          "expected_memory",
          "id",
          "reason",
          "text"
        ],
        "title": "CorrectRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Confidence": {
            "description": "How a memory entered the store.",
            "oneOf": [
              {
                "description": "Stated directly in the source conversation.",
                "enum": [
                  "extracted"
                ],
                "type": "string"
              },
              {
                "description": "Derived by the extraction model rather than stated verbatim.",
                "enum": [
                  "inferred"
                ],
                "type": "string"
              },
              {
                "description": "Saved explicitly through `memory::save`: by a human (console, REST, CLI), or by an agent from a turn: then `source.turn_id` is set and it is that agent's note, not a fact the user stated.",
                "enum": [
                  "stated"
                ],
                "type": "string"
              }
            ]
          },
          "Memory": {
            "description": "One memory item. Serialized whole as a `memories.jsonl` line; replay is last-wins by `id`, so an update appends a full record with a bumped `revision` and a delete appends a tombstoned record (`invalid_at` set) — history is never destroyed, only superseded.",
            "properties": {
              "confidence": {
                "$ref": "#/definitions/Confidence"
              },
              "corroboration": {
                "default": 0,
                "description": "Times this memory was independently re-observed. Boosts recall rank.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at": {
                "description": "Milliseconds since epoch.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "entities": {
                "default": [],
                "description": "Entity handles used as an exact-match retrieval signal.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "Content fingerprint (`fp` + FNV-1a of the normalized text), so re-ingesting the same source reinforces instead of duplicating.",
                "type": "string"
              },
              "invalid_at": {
                "description": "Set when the memory stopped being true (superseded or deleted). The record stays on disk and remains queryable with `include_superseded: true`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "pinned": {
                "default": false,
                "description": "Pinned memories are never touched by any automatic path (consolidation, decay); only an explicit `memory::pin`/`memory::update` changes them.",
                "type": "boolean"
              },
              "revision": {
                "default": 0,
                "description": "Bumped on every appended revision of this id; replay keeps the highest.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "source": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Provenance"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "stated_at": {
                "description": "When the fact was last STATED (said, re-observed, text edited): an extracted memory takes its message's time, not the pass's. Unlike `updated_at`, pin/tag/entity edits never bump it, so recency, the shown date and \"which statement is current\" go by it. Legacy records load as None.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "superseded_by": {
                "description": "Memory id that replaced this one, when superseded by content.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "tags": {
                "default": [],
                "description": "Topical labels for filtering WITHIN a bank (\"iii\", \"workers\", \"billing\") — organization, not ranking. Normalized lowercase, capped like entities. Old records without the field load as untagged.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "text": {
                "type": "string"
              },
              "updated_at": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "confidence",
              "created_at",
              "id",
              "text",
              "updated_at"
            ],
            "type": "object"
          },
          "Provenance": {
            "description": "Where a memory came from. Every extracted memory points back into session-manager; nothing in memory duplicates the transcript store.",
            "properties": {
              "agent": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "correction_reason": {
                "description": "Set on a record written by `memory::correct`: why the old text was replaced, quoting the source conversation.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "entry_id": {
                "description": "The last entry of the run the memory was extracted from.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "first_entry_id": {
                "description": "The first entry of that run: with `entry_id` it bounds the span of transcript the memory came from. Absent on records written before spans were kept.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "turn_id": {
                "description": "The turn an explicit save was called from (`memory::save` inside a turn).",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "properties": {
          "corrected": {
            "type": "boolean"
          },
          "memory": {
            "anyOf": [
              {
                "$ref": "#/definitions/Memory"
              },
              {
                "type": "null"
              }
            ],
            "description": "The record that now holds the corrected text."
          },
          "skipped": {
            "description": "Why nothing was written: `changed`, `pinned`, `edited`, `no_change`, `text_exists`, `invalid_text` or `flagged`.",
            "type": [
              "string",
              "null"
            ]
          },
          "superseded": {
            "anyOf": [
              {
                "$ref": "#/definitions/Memory"
              },
              {
                "type": "null"
              }
            ],
            "description": "The retired record."
          }
        },
        "required": [
          "corrected"
        ],
        "title": "CorrectResponse",
        "type": "object"
      }
    },
    {
      "description": "Delete a memory (tombstone: sets invalid_at). It leaves recall immediately but stays on disk, readable with include_superseded. From a turn: a memory the turn reads (its bank's, or one recalled from a bank read under it); a pinned memory is refused.",
      "metadata": {},
      "name": "memory::delete",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bank": {
            "default": null,
            "description": "Bank; omitted: the calling session's bank, else the configured default.",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "title": "DeleteRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Confidence": {
            "description": "How a memory entered the store.",
            "oneOf": [
              {
                "description": "Stated directly in the source conversation.",
                "enum": [
                  "extracted"
                ],
                "type": "string"
              },
              {
                "description": "Derived by the extraction model rather than stated verbatim.",
                "enum": [
                  "inferred"
                ],
                "type": "string"
              },
              {
                "description": "Saved explicitly through `memory::save`: by a human (console, REST, CLI), or by an agent from a turn: then `source.turn_id` is set and it is that agent's note, not a fact the user stated.",
                "enum": [
                  "stated"
                ],
                "type": "string"
              }
            ]
          },
          "Memory": {
            "description": "One memory item. Serialized whole as a `memories.jsonl` line; replay is last-wins by `id`, so an update appends a full record with a bumped `revision` and a delete appends a tombstoned record (`invalid_at` set) — history is never destroyed, only superseded.",
            "properties": {
              "confidence": {
                "$ref": "#/definitions/Confidence"
              },
              "corroboration": {
                "default": 0,
                "description": "Times this memory was independently re-observed. Boosts recall rank.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at": {
                "description": "Milliseconds since epoch.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "entities": {
                "default": [],
                "description": "Entity handles used as an exact-match retrieval signal.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "Content fingerprint (`fp` + FNV-1a of the normalized text), so re-ingesting the same source reinforces instead of duplicating.",
                "type": "string"
              },
              "invalid_at": {
                "description": "Set when the memory stopped being true (superseded or deleted). The record stays on disk and remains queryable with `include_superseded: true`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "pinned": {
                "default": false,
                "description": "Pinned memories are never touched by any automatic path (consolidation, decay); only an explicit `memory::pin`/`memory::update` changes them.",
                "type": "boolean"
              },
              "revision": {
                "default": 0,
                "description": "Bumped on every appended revision of this id; replay keeps the highest.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "source": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Provenance"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "stated_at": {
                "description": "When the fact was last STATED (said, re-observed, text edited): an extracted memory takes its message's time, not the pass's. Unlike `updated_at`, pin/tag/entity edits never bump it, so recency, the shown date and \"which statement is current\" go by it. Legacy records load as None.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "superseded_by": {
                "description": "Memory id that replaced this one, when superseded by content.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "tags": {
                "default": [],
                "description": "Topical labels for filtering WITHIN a bank (\"iii\", \"workers\", \"billing\") — organization, not ranking. Normalized lowercase, capped like entities. Old records without the field load as untagged.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "text": {
                "type": "string"
              },
              "updated_at": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "confidence",
              "created_at",
              "id",
              "text",
              "updated_at"
            ],
            "type": "object"
          },
          "Provenance": {
            "description": "Where a memory came from. Every extracted memory points back into session-manager; nothing in memory duplicates the transcript store.",
            "properties": {
              "agent": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "correction_reason": {
                "description": "Set on a record written by `memory::correct`: why the old text was replaced, quoting the source conversation.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "entry_id": {
                "description": "The last entry of the run the memory was extracted from.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "first_entry_id": {
                "description": "The first entry of that run: with `entry_id` it bounds the span of transcript the memory came from. Absent on records written before spans were kept.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "turn_id": {
                "description": "The turn an explicit save was called from (`memory::save` inside a turn).",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "description": "Shared response for update/delete/pin.",
        "properties": {
          "memory": {
            "$ref": "#/definitions/Memory"
          }
        },
        "required": [
          "memory"
        ],
        "title": "MemoryResponse",
        "type": "object"
      }
    },
    {
      "description": "Self-test memory end to end: data-dir writability, a scratch-bank write/read/delete roundtrip, sibling reachability (router, session-manager, state), whether embeddings answer, whether recent extraction passes failed, which model extraction calls and why, how many extraction jobs wait in the dead-letter queue, and what extraction spent (model calls, tokens, the router's cost) and wrote since boot. Reports degraded states explicitly, not a bare process-up health.",
      "metadata": {},
      "name": "memory::doctor",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "DoctorRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "DoctorCheck": {
            "properties": {
              "detail": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "ok": {
                "type": "boolean"
              }
            },
            "required": [
              "detail",
              "name",
              "ok"
            ],
            "type": "object"
          },
          "PassHealth": {
            "description": "How passes have gone since boot, for `memory::doctor`: a pass that fails every time is otherwise only a log line.",
            "properties": {
              "failed_in_a_row": {
                "description": "Passes failed since the last one that succeeded.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "last": {
                "allOf": [
                  {
                    "$ref": "#/definitions/PassTally"
                  }
                ],
                "description": "The latest counted pass."
              },
              "last_error": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "passes": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "pending": {
                "description": "Passes that ended with runs left for the queue's retry: a backlog draining, not a failure.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "total": {
                "allOf": [
                  {
                    "$ref": "#/definitions/PassTally"
                  }
                ],
                "description": "Every counted pass since boot."
              }
            },
            "required": [
              "failed_in_a_row",
              "last",
              "passes",
              "pending",
              "total"
            ],
            "type": "object"
          },
          "PassTally": {
            "description": "What extraction spent and wrote: model calls, the usage the router reported for them, memory effects, and returned memories not written.",
            "properties": {
              "calls": {
                "description": "`router::complete` calls made, failed ones included.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "continuation_input_tokens": {
                "description": "Of `input_tokens`, what the continuations took.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "continuation_output_tokens": {
                "description": "Of `output_tokens`, what the continuations took.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "continuations": {
                "description": "Calls made after one whose memories reached `max_memories_per_turn`, asking the same piece for what it left out; failed ones included. Each is also in `calls`.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "cost_usd": {
                "description": "The router's own cost, summed over the calls that carried one; absent when none did.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              },
              "created": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "dropped": {
                "additionalProperties": {
                  "format": "uint64",
                  "minimum": 0,
                  "type": "integer"
                },
                "description": "Memories the model returned that were not written, by reason, and items that did not parse, as `malformed`. A rule item that parsed is counted in `rules` only.",
                "type": "object"
              },
              "input_tokens": {
                "description": "Prompt tokens the router reported, cached ones included.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "no_array": {
                "description": "Replies with no JSON array (prose, one word, no text); a `[]` reply is not one. A piece's first call is asked once more after one, and a second reads as nothing to keep; a continuation's is not asked again and leaves the piece `saturated`.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "output_tokens": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "reinforced": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "returned": {
                "description": "Items in the replies' arrays before any check: memories, rules and malformed ones.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "rules": {
                "description": "Of `returned`, the rule items: they become learned rule lines, never memories, so `created` and `dropped` never count them.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "saturated": {
                "description": "Pieces that ended at the cap: the last reply read still reached `max_memories_per_turn` and no further call was made or could be read. The model may have left facts out, and nothing else shows that.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "superseded": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "unsourced_values": {
                "description": "Digit-bearing tokens (a port, a version, a count) of the memories past the length and injection checks that neither the excerpt nor the memory a correction replaces writes: values the model may have changed. Counted, never dropped; `total` sums it since boot only.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "calls",
              "continuation_input_tokens",
              "continuation_output_tokens",
              "continuations",
              "created",
              "input_tokens",
              "no_array",
              "output_tokens",
              "reinforced",
              "returned",
              "rules",
              "saturated",
              "superseded",
              "unsourced_values"
            ],
            "type": "object"
          }
        },
        "properties": {
          "checks": {
            "items": {
              "$ref": "#/definitions/DoctorCheck"
            },
            "type": "array"
          },
          "extraction": {
            "allOf": [
              {
                "$ref": "#/definitions/PassHealth"
              }
            ],
            "description": "Extraction passes since boot: how they went, what the model calls cost and what they wrote."
          },
          "ok": {
            "description": "True only when every REQUIRED check passed (the store roundtrip; the rest are reported but advisory).",
            "type": "boolean"
          }
        },
        "required": [
          "checks",
          "extraction",
          "ok"
        ],
        "title": "DoctorResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal: target of the queue::on-message observer on the memory-extraction topic and of the memory-extraction function queue — runs one extraction job; errors propagate so the queue retries and dead-letters instead of losing the pass. A job this worker did not queue is refused, whoever calls it.",
      "metadata": {
        "internal": true
      },
      "name": "memory::extract-job",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "One durable extraction job (the `data` of a queue message).",
        "properties": {
          "agent": {
            "description": "The session's agent profile, its bank read under `bank` (`scope::Resolved::agent`).",
            "type": [
              "string",
              "null"
            ]
          },
          "bank": {
            "description": "The bank the turn was injected with. Absent: resolved when the job runs (the worker never saw the turn, or the job predates this).",
            "type": [
              "string",
              "null"
            ]
          },
          "derived": {
            "description": "The turn's directory chose `bank`: `default_bank` is read under it (`scope::Resolved::layer`).",
            "type": "boolean"
          },
          "session_id": {
            "type": "string"
          },
          "skip": {
            "description": "The turn ran without memory (an invalid or deleted bank): the job only steps the cursor past it.",
            "type": "boolean"
          },
          "turn_id": {
            "description": "The turn that queued the job. Absent on jobs queued before it existed.",
            "type": [
              "string",
              "null"
            ]
          },
          "until": {
            "description": "The turn's last user/assistant entry: the pass reads no further.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "session_id"
        ],
        "title": "ExtractJobInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "ok": {
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ],
        "title": "AckResponse",
        "type": "object"
      }
    },
    {
      "description": "Fetch one memory by id, including superseded/tombstoned records.",
      "metadata": {},
      "name": "memory::get",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bank": {
            "default": null,
            "description": "Bank; omitted: the calling session's bank, else the configured default.",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "title": "GetRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Confidence": {
            "description": "How a memory entered the store.",
            "oneOf": [
              {
                "description": "Stated directly in the source conversation.",
                "enum": [
                  "extracted"
                ],
                "type": "string"
              },
              {
                "description": "Derived by the extraction model rather than stated verbatim.",
                "enum": [
                  "inferred"
                ],
                "type": "string"
              },
              {
                "description": "Saved explicitly through `memory::save`: by a human (console, REST, CLI), or by an agent from a turn: then `source.turn_id` is set and it is that agent's note, not a fact the user stated.",
                "enum": [
                  "stated"
                ],
                "type": "string"
              }
            ]
          },
          "Memory": {
            "description": "One memory item. Serialized whole as a `memories.jsonl` line; replay is last-wins by `id`, so an update appends a full record with a bumped `revision` and a delete appends a tombstoned record (`invalid_at` set) — history is never destroyed, only superseded.",
            "properties": {
              "confidence": {
                "$ref": "#/definitions/Confidence"
              },
              "corroboration": {
                "default": 0,
                "description": "Times this memory was independently re-observed. Boosts recall rank.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at": {
                "description": "Milliseconds since epoch.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "entities": {
                "default": [],
                "description": "Entity handles used as an exact-match retrieval signal.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "Content fingerprint (`fp` + FNV-1a of the normalized text), so re-ingesting the same source reinforces instead of duplicating.",
                "type": "string"
              },
              "invalid_at": {
                "description": "Set when the memory stopped being true (superseded or deleted). The record stays on disk and remains queryable with `include_superseded: true`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "pinned": {
                "default": false,
                "description": "Pinned memories are never touched by any automatic path (consolidation, decay); only an explicit `memory::pin`/`memory::update` changes them.",
                "type": "boolean"
              },
              "revision": {
                "default": 0,
                "description": "Bumped on every appended revision of this id; replay keeps the highest.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "source": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Provenance"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "stated_at": {
                "description": "When the fact was last STATED (said, re-observed, text edited): an extracted memory takes its message's time, not the pass's. Unlike `updated_at`, pin/tag/entity edits never bump it, so recency, the shown date and \"which statement is current\" go by it. Legacy records load as None.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "superseded_by": {
                "description": "Memory id that replaced this one, when superseded by content.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "tags": {
                "default": [],
                "description": "Topical labels for filtering WITHIN a bank (\"iii\", \"workers\", \"billing\") — organization, not ranking. Normalized lowercase, capped like entities. Old records without the field load as untagged.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "text": {
                "type": "string"
              },
              "updated_at": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "confidence",
              "created_at",
              "id",
              "text",
              "updated_at"
            ],
            "type": "object"
          },
          "Provenance": {
            "description": "Where a memory came from. Every extracted memory points back into session-manager; nothing in memory duplicates the transcript store.",
            "properties": {
              "agent": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "correction_reason": {
                "description": "Set on a record written by `memory::correct`: why the old text was replaced, quoting the source conversation.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "entry_id": {
                "description": "The last entry of the run the memory was extracted from.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "first_entry_id": {
                "description": "The first entry of that run: with `entry_id` it bounds the span of transcript the memory came from. Absent on records written before spans were kept.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "turn_id": {
                "description": "The turn an explicit save was called from (`memory::save` inside a turn).",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "properties": {
          "memory": {
            "$ref": "#/definitions/Memory"
          }
        },
        "required": [
          "memory"
        ],
        "title": "GetResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal: target of the harness::hook::on-pre-generate observer — injects the session bank's rules into the system prompt and its pinned and recalled memories as one appended message. Never denies.",
      "metadata": {
        "internal": true
      },
      "name": "memory::hook::pre-generate",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "GenerateInput": {
            "properties": {
              "messages": {
                "default": null,
                "description": "Transcript messages as assembled so far — the window this step sends, persisted notices (earlier rules updates included) replayed in place (schema-free: shapes belong to the router)."
              },
              "system_prompt": {
                "default": "",
                "type": "string"
              }
            },
            "type": "object"
          }
        },
        "description": "Envelope the harness posts to `pre-generate` hooks. Only the fields this worker reads are typed; everything else is ignored.",
        "properties": {
          "generate": {
            "anyOf": [
              {
                "$ref": "#/definitions/GenerateInput"
              },
              {
                "type": "null"
              }
            ]
          },
          "metadata": {
            "default": null,
            "description": "Turn metadata (`harness::send` options.metadata); `memory_bank` here overrides the session-level selection for this turn."
          },
          "parent": {
            "default": null,
            "description": "The turn's parent as `harness::on-turn-completed` will report it ([`TurnCompletedInput`]). Absent on a top-level turn, and on a harness that predates it: the session record alone then decides the header."
          },
          "parent_session_id": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          },
          "recall_context": {
            "default": null,
            "description": "Delivery context the harness attaches to this hook call. Absent on a harness that predates it: recall then reads the last user message. Its `extraction_history` is imported, then dropped before the hook runs."
          },
          "session_id": {
            "default": "",
            "type": "string"
          },
          "step": {
            "default": 0,
            "description": "Step within the turn; 0 is the step that opens it.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "turn_id": {
            "default": null,
            "description": "The turn this step belongs to; its bank is recorded under it.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "PreGenerateInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Mutations": {
            "properties": {
              "append_messages": {
                "items": true,
                "type": "array"
              },
              "system_prompt": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "append_messages"
            ],
            "type": "object"
          }
        },
        "description": "Hook reply: `continue` with optional mutations (never deny — memory is an enrichment, not a gate).",
        "properties": {
          "annotations": {
            "additionalProperties": true,
            "type": [
              "object",
              "null"
            ]
          },
          "decision": {
            "type": "string"
          },
          "mutations": {
            "anyOf": [
              {
                "$ref": "#/definitions/Mutations"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "decision"
        ],
        "title": "HookResponse",
        "type": "object"
      }
    },
    {
      "description": "List a bank's memories page by page, newest first. `include_superseded` shows history too.",
      "metadata": {},
      "name": "memory::list",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bank": {
            "default": null,
            "description": "Bank; omitted: the calling session's bank, else the configured default.",
            "type": [
              "string",
              "null"
            ]
          },
          "include_superseded": {
            "default": null,
            "description": "Include superseded/tombstoned records (the history view).",
            "type": [
              "boolean",
              "null"
            ]
          },
          "limit": {
            "default": null,
            "description": "Page size, default 50, max 500.",
            "format": "uint",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "offset": {
            "default": null,
            "format": "uint",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "tag": {
            "default": null,
            "description": "Only memories carrying this tag.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "ListRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Confidence": {
            "description": "How a memory entered the store.",
            "oneOf": [
              {
                "description": "Stated directly in the source conversation.",
                "enum": [
                  "extracted"
                ],
                "type": "string"
              },
              {
                "description": "Derived by the extraction model rather than stated verbatim.",
                "enum": [
                  "inferred"
                ],
                "type": "string"
              },
              {
                "description": "Saved explicitly through `memory::save`: by a human (console, REST, CLI), or by an agent from a turn: then `source.turn_id` is set and it is that agent's note, not a fact the user stated.",
                "enum": [
                  "stated"
                ],
                "type": "string"
              }
            ]
          },
          "Memory": {
            "description": "One memory item. Serialized whole as a `memories.jsonl` line; replay is last-wins by `id`, so an update appends a full record with a bumped `revision` and a delete appends a tombstoned record (`invalid_at` set) — history is never destroyed, only superseded.",
            "properties": {
              "confidence": {
                "$ref": "#/definitions/Confidence"
              },
              "corroboration": {
                "default": 0,
                "description": "Times this memory was independently re-observed. Boosts recall rank.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at": {
                "description": "Milliseconds since epoch.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "entities": {
                "default": [],
                "description": "Entity handles used as an exact-match retrieval signal.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "Content fingerprint (`fp` + FNV-1a of the normalized text), so re-ingesting the same source reinforces instead of duplicating.",
                "type": "string"
              },
              "invalid_at": {
                "description": "Set when the memory stopped being true (superseded or deleted). The record stays on disk and remains queryable with `include_superseded: true`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "pinned": {
                "default": false,
                "description": "Pinned memories are never touched by any automatic path (consolidation, decay); only an explicit `memory::pin`/`memory::update` changes them.",
                "type": "boolean"
              },
              "revision": {
                "default": 0,
                "description": "Bumped on every appended revision of this id; replay keeps the highest.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "source": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Provenance"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "stated_at": {
                "description": "When the fact was last STATED (said, re-observed, text edited): an extracted memory takes its message's time, not the pass's. Unlike `updated_at`, pin/tag/entity edits never bump it, so recency, the shown date and \"which statement is current\" go by it. Legacy records load as None.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "superseded_by": {
                "description": "Memory id that replaced this one, when superseded by content.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "tags": {
                "default": [],
                "description": "Topical labels for filtering WITHIN a bank (\"iii\", \"workers\", \"billing\") — organization, not ranking. Normalized lowercase, capped like entities. Old records without the field load as untagged.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "text": {
                "type": "string"
              },
              "updated_at": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "confidence",
              "created_at",
              "id",
              "text",
              "updated_at"
            ],
            "type": "object"
          },
          "Provenance": {
            "description": "Where a memory came from. Every extracted memory points back into session-manager; nothing in memory duplicates the transcript store.",
            "properties": {
              "agent": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "correction_reason": {
                "description": "Set on a record written by `memory::correct`: why the old text was replaced, quoting the source conversation.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "entry_id": {
                "description": "The last entry of the run the memory was extracted from.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "first_entry_id": {
                "description": "The first entry of that run: with `entry_id` it bounds the span of transcript the memory came from. Absent on records written before spans were kept.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "turn_id": {
                "description": "The turn an explicit save was called from (`memory::save` inside a turn).",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "properties": {
          "memories": {
            "items": {
              "$ref": "#/definitions/Memory"
            },
            "type": "array"
          },
          "total": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "memories",
          "total"
        ],
        "title": "ListResponse",
        "type": "object"
      }
    },
    {
      "description": "Called when a memory bank is created or trashed, or its rules change. Returns the event: { event_type: created | trashed | rules-changed, bank }. Observe it; filter on input.bank or input.event_type.",
      "metadata": {},
      "name": "memory::on-bank-changed",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "What `memory::on-bank-changed` returns and its observers receive.",
        "properties": {
          "bank": {
            "type": "string"
          },
          "event_type": {
            "description": "`created`, `trashed` or `rules-changed`.",
            "type": "string"
          }
        },
        "required": [
          "bank",
          "event_type"
        ],
        "title": "BankChangedEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "What `memory::on-bank-changed` returns and its observers receive.",
        "properties": {
          "bank": {
            "type": "string"
          },
          "event_type": {
            "description": "`created`, `trashed` or `rules-changed`.",
            "type": "string"
          }
        },
        "required": [
          "bank",
          "event_type"
        ],
        "title": "BankChangedEvent",
        "type": "object"
      }
    },
    {
      "description": "Internal: hot-reload memory from the authoritative configuration when it changes — reopens the store on a data_dir change and swaps the per-call tuning snapshot otherwise.",
      "metadata": {
        "internal": true,
        "trace_hidden": true
      },
      "name": "memory::on-config-change",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "The `configuration::on-updated` event, as `memory::on-config-change` receives it. The handler re-fetches the authoritative configuration (trusting `new_value` from a discoverable bus function would let any caller inject config).",
        "properties": {
          "id": {
            "default": null,
            "description": "Configuration id that changed (advisory; the handler re-fetches).",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "OnConfigChangeEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "ok": {
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ],
        "title": "OnConfigChangeResponse",
        "type": "object"
      }
    },
    {
      "description": "Called when a memory is created, updated, superseded, or deleted in a memory bank. Returns the event: { event_type, bank, memory, reason? } (reason on consolidation changes, and `redacted: <labels>` when secrets or invisible characters were removed on save/update). Observe it for console/live views; filter on input.bank or input.event_type.",
      "metadata": {},
      "name": "memory::on-item-changed",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Confidence": {
            "description": "How a memory entered the store.",
            "oneOf": [
              {
                "description": "Stated directly in the source conversation.",
                "enum": [
                  "extracted"
                ],
                "type": "string"
              },
              {
                "description": "Derived by the extraction model rather than stated verbatim.",
                "enum": [
                  "inferred"
                ],
                "type": "string"
              },
              {
                "description": "Saved explicitly through `memory::save`: by a human (console, REST, CLI), or by an agent from a turn: then `source.turn_id` is set and it is that agent's note, not a fact the user stated.",
                "enum": [
                  "stated"
                ],
                "type": "string"
              }
            ]
          },
          "ItemEvent": {
            "description": "Memory event kinds carried in `event_type`.",
            "enum": [
              "created",
              "updated",
              "superseded",
              "deleted"
            ],
            "type": "string"
          },
          "Memory": {
            "description": "One memory item. Serialized whole as a `memories.jsonl` line; replay is last-wins by `id`, so an update appends a full record with a bumped `revision` and a delete appends a tombstoned record (`invalid_at` set) — history is never destroyed, only superseded.",
            "properties": {
              "confidence": {
                "$ref": "#/definitions/Confidence"
              },
              "corroboration": {
                "default": 0,
                "description": "Times this memory was independently re-observed. Boosts recall rank.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at": {
                "description": "Milliseconds since epoch.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "entities": {
                "default": [],
                "description": "Entity handles used as an exact-match retrieval signal.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "Content fingerprint (`fp` + FNV-1a of the normalized text), so re-ingesting the same source reinforces instead of duplicating.",
                "type": "string"
              },
              "invalid_at": {
                "description": "Set when the memory stopped being true (superseded or deleted). The record stays on disk and remains queryable with `include_superseded: true`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "pinned": {
                "default": false,
                "description": "Pinned memories are never touched by any automatic path (consolidation, decay); only an explicit `memory::pin`/`memory::update` changes them.",
                "type": "boolean"
              },
              "revision": {
                "default": 0,
                "description": "Bumped on every appended revision of this id; replay keeps the highest.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "source": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Provenance"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "stated_at": {
                "description": "When the fact was last STATED (said, re-observed, text edited): an extracted memory takes its message's time, not the pass's. Unlike `updated_at`, pin/tag/entity edits never bump it, so recency, the shown date and \"which statement is current\" go by it. Legacy records load as None.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "superseded_by": {
                "description": "Memory id that replaced this one, when superseded by content.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "tags": {
                "default": [],
                "description": "Topical labels for filtering WITHIN a bank (\"iii\", \"workers\", \"billing\") — organization, not ranking. Normalized lowercase, capped like entities. Old records without the field load as untagged.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "text": {
                "type": "string"
              },
              "updated_at": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "confidence",
              "created_at",
              "id",
              "text",
              "updated_at"
            ],
            "type": "object"
          },
          "Provenance": {
            "description": "Where a memory came from. Every extracted memory points back into session-manager; nothing in memory duplicates the transcript store.",
            "properties": {
              "agent": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "correction_reason": {
                "description": "Set on a record written by `memory::correct`: why the old text was replaced, quoting the source conversation.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "entry_id": {
                "description": "The last entry of the run the memory was extracted from.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "first_entry_id": {
                "description": "The first entry of that run: with `entry_id` it bounds the span of transcript the memory came from. Absent on records written before spans were kept.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "turn_id": {
                "description": "The turn an explicit save was called from (`memory::save` inside a turn).",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "description": "What `memory::on-item-changed` returns and its observers receive.",
        "properties": {
          "bank": {
            "description": "The bank the memory lives in.",
            "type": "string"
          },
          "event_type": {
            "$ref": "#/definitions/ItemEvent"
          },
          "memory": {
            "allOf": [
              {
                "$ref": "#/definitions/Memory"
              }
            ],
            "description": "The memory as stored after the change (a tombstone for `deleted`)."
          },
          "reason": {
            "description": "Why the change happened: `memory::supersede`'s reason, or `redacted: <labels>` when a save or update removed secrets or invisible characters.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "bank",
          "event_type",
          "memory"
        ],
        "title": "ItemChangedEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Confidence": {
            "description": "How a memory entered the store.",
            "oneOf": [
              {
                "description": "Stated directly in the source conversation.",
                "enum": [
                  "extracted"
                ],
                "type": "string"
              },
              {
                "description": "Derived by the extraction model rather than stated verbatim.",
                "enum": [
                  "inferred"
                ],
                "type": "string"
              },
              {
                "description": "Saved explicitly through `memory::save`: by a human (console, REST, CLI), or by an agent from a turn: then `source.turn_id` is set and it is that agent's note, not a fact the user stated.",
                "enum": [
                  "stated"
                ],
                "type": "string"
              }
            ]
          },
          "ItemEvent": {
            "description": "Memory event kinds carried in `event_type`.",
            "enum": [
              "created",
              "updated",
              "superseded",
              "deleted"
            ],
            "type": "string"
          },
          "Memory": {
            "description": "One memory item. Serialized whole as a `memories.jsonl` line; replay is last-wins by `id`, so an update appends a full record with a bumped `revision` and a delete appends a tombstoned record (`invalid_at` set) — history is never destroyed, only superseded.",
            "properties": {
              "confidence": {
                "$ref": "#/definitions/Confidence"
              },
              "corroboration": {
                "default": 0,
                "description": "Times this memory was independently re-observed. Boosts recall rank.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at": {
                "description": "Milliseconds since epoch.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "entities": {
                "default": [],
                "description": "Entity handles used as an exact-match retrieval signal.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "Content fingerprint (`fp` + FNV-1a of the normalized text), so re-ingesting the same source reinforces instead of duplicating.",
                "type": "string"
              },
              "invalid_at": {
                "description": "Set when the memory stopped being true (superseded or deleted). The record stays on disk and remains queryable with `include_superseded: true`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "pinned": {
                "default": false,
                "description": "Pinned memories are never touched by any automatic path (consolidation, decay); only an explicit `memory::pin`/`memory::update` changes them.",
                "type": "boolean"
              },
              "revision": {
                "default": 0,
                "description": "Bumped on every appended revision of this id; replay keeps the highest.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "source": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Provenance"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "stated_at": {
                "description": "When the fact was last STATED (said, re-observed, text edited): an extracted memory takes its message's time, not the pass's. Unlike `updated_at`, pin/tag/entity edits never bump it, so recency, the shown date and \"which statement is current\" go by it. Legacy records load as None.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "superseded_by": {
                "description": "Memory id that replaced this one, when superseded by content.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "tags": {
                "default": [],
                "description": "Topical labels for filtering WITHIN a bank (\"iii\", \"workers\", \"billing\") — organization, not ranking. Normalized lowercase, capped like entities. Old records without the field load as untagged.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "text": {
                "type": "string"
              },
              "updated_at": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "confidence",
              "created_at",
              "id",
              "text",
              "updated_at"
            ],
            "type": "object"
          },
          "Provenance": {
            "description": "Where a memory came from. Every extracted memory points back into session-manager; nothing in memory duplicates the transcript store.",
            "properties": {
              "agent": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "correction_reason": {
                "description": "Set on a record written by `memory::correct`: why the old text was replaced, quoting the source conversation.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "entry_id": {
                "description": "The last entry of the run the memory was extracted from.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "first_entry_id": {
                "description": "The first entry of that run: with `entry_id` it bounds the span of transcript the memory came from. Absent on records written before spans were kept.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "turn_id": {
                "description": "The turn an explicit save was called from (`memory::save` inside a turn).",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "description": "What `memory::on-item-changed` returns and its observers receive.",
        "properties": {
          "bank": {
            "description": "The bank the memory lives in.",
            "type": "string"
          },
          "event_type": {
            "$ref": "#/definitions/ItemEvent"
          },
          "memory": {
            "allOf": [
              {
                "$ref": "#/definitions/Memory"
              }
            ],
            "description": "The memory as stored after the change (a tombstone for `deleted`)."
          },
          "reason": {
            "description": "Why the change happened: `memory::supersede`'s reason, or `redacted: <labels>` when a save or update removed secrets or invisible characters.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "bank",
          "event_type",
          "memory"
        ],
        "title": "ItemChangedEvent",
        "type": "object"
      }
    },
    {
      "description": "Internal: target of the session::on-deleted observer — drops the session's extraction cursor and state. A direct call is refused.",
      "metadata": {
        "internal": true,
        "trace_hidden": true
      },
      "name": "memory::on-session-deleted",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Caller": {
            "description": "Who made an invocation. `worker_id` / `worker_name` are stamped by the engine from the calling connection; `function_id`, `invocation_id` and `parent` are asserted by the calling SDK.",
            "properties": {
              "function_id": {
                "description": "The handler the call was made from; absent for a top-level call.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "invocation_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "parent": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ParentCaller"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The caller of that handler, one level only."
              },
              "worker_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "worker_name": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "InvocationStatus": {
            "enum": [
              "success",
              "error"
            ],
            "type": "string"
          },
          "ObservedError": {
            "description": "What a call failed with: [`Observed::error`], [`Call::error`](crate::Call::error).",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          },
          "ParentCaller": {
            "description": "[`Caller::parent`]: a caller without a parent of its own.",
            "properties": {
              "function_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "invocation_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "worker_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "worker_name": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "SessionDeletedInput": {
            "description": "The `session::on-deleted` event (the field this worker reads).",
            "properties": {
              "session_id": {
                "default": "",
                "type": "string"
              }
            },
            "type": "object"
          }
        },
        "description": "What an observer's target receives when iii delivers: the observed call, per the observer's `capture`.\n\n```rust,no_run # use iii_sdk::{Error, IIIClient, Observed, RegisterFunction}; # use serde_json::Value; # fn demo(iii: &IIIClient) { iii.register_function( \"alerts::payment-failed\", RegisterFunction::new(|event: Observed<Value>| { println!(\"{} failed: {:?}\", event.function_id, event.error); Ok::<_, Error>(()) }), ); # } ```",
        "properties": {
          "activation_id": {
            "type": "string"
          },
          "caller": {
            "anyOf": [
              {
                "$ref": "#/definitions/Caller"
              },
              {
                "type": "null"
              }
            ]
          },
          "duration_ms": {
            "format": "double",
            "type": "number"
          },
          "error": {
            "anyOf": [
              {
                "$ref": "#/definitions/ObservedError"
              },
              {
                "type": "null"
              }
            ]
          },
          "function_id": {
            "type": "string"
          },
          "input": true,
          "invocation_id": {
            "type": "string"
          },
          "metadata": true,
          "namespace": {
            "type": [
              "string",
              "null"
            ]
          },
          "observer_id": {
            "type": "string"
          },
          "output": {
            "anyOf": [
              {
                "$ref": "#/definitions/SessionDeletedInput"
              },
              {
                "type": "null"
              }
            ]
          },
          "started_at_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "status": {
            "$ref": "#/definitions/InvocationStatus"
          }
        },
        "required": [
          "activation_id",
          "duration_ms",
          "function_id",
          "invocation_id",
          "observer_id",
          "started_at_ms",
          "status"
        ],
        "title": "Observed_for_AnyValue_and_SessionDeletedInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "ok": {
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ],
        "title": "AckResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal: target of the kanban::on-change observer — keeps the board's closed (done or canceled) ticket keys, whose memory lines turns are no longer given. A direct call is refused.",
      "metadata": {
        "internal": true,
        "trace_hidden": true
      },
      "name": "memory::on-ticket-changed",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "TicketState": {
            "description": "The ticket's column, the only field of it memory reads.",
            "properties": {
              "status": {
                "default": null,
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "description": "What memory reads of a `kanban::on-change` delivery: a ticket event's name, key, status and time, or `config.updated` (no ticket). The rest of the event is ignored.",
        "properties": {
          "at": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          },
          "event": {
            "default": "",
            "type": "string"
          },
          "ticket": {
            "anyOf": [
              {
                "$ref": "#/definitions/TicketState"
              },
              {
                "type": "null"
              }
            ],
            "default": null
          },
          "ticket_key": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "TicketChangedInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "ok": {
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ],
        "title": "AckResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal: target of the harness::on-turn-completed observer — enqueues one durable extraction job (a single router::complete call) for the finished turn; inline fallback without a queue. A direct call is refused.",
      "metadata": {
        "internal": true
      },
      "name": "memory::on-turn-completed",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Caller": {
            "description": "Who made an invocation. `worker_id` / `worker_name` are stamped by the engine from the calling connection; `function_id`, `invocation_id` and `parent` are asserted by the calling SDK.",
            "properties": {
              "function_id": {
                "description": "The handler the call was made from; absent for a top-level call.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "invocation_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "parent": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ParentCaller"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The caller of that handler, one level only."
              },
              "worker_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "worker_name": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "InvocationStatus": {
            "enum": [
              "success",
              "error"
            ],
            "type": "string"
          },
          "ObservedError": {
            "description": "What a call failed with: [`Observed::error`], [`Call::error`](crate::Call::error).",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          },
          "ParentCaller": {
            "description": "[`Caller::parent`]: a caller without a parent of its own.",
            "properties": {
              "function_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "invocation_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "worker_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "worker_name": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "TurnCompletedInput": {
            "description": "The `harness::on-turn-completed` event (the fields this worker reads).",
            "properties": {
              "parent": {
                "default": null,
                "description": "Set on a sub-agent's turn (its live parent link)."
              },
              "parent_session_id": {
                "default": null,
                "description": "Set on a parentless spawn's turn (its display parent).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "default": "",
                "type": "string"
              },
              "turn_id": {
                "default": null,
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "description": "What an observer's target receives when iii delivers: the observed call, per the observer's `capture`.\n\n```rust,no_run # use iii_sdk::{Error, IIIClient, Observed, RegisterFunction}; # use serde_json::Value; # fn demo(iii: &IIIClient) { iii.register_function( \"alerts::payment-failed\", RegisterFunction::new(|event: Observed<Value>| { println!(\"{} failed: {:?}\", event.function_id, event.error); Ok::<_, Error>(()) }), ); # } ```",
        "properties": {
          "activation_id": {
            "type": "string"
          },
          "caller": {
            "anyOf": [
              {
                "$ref": "#/definitions/Caller"
              },
              {
                "type": "null"
              }
            ]
          },
          "duration_ms": {
            "format": "double",
            "type": "number"
          },
          "error": {
            "anyOf": [
              {
                "$ref": "#/definitions/ObservedError"
              },
              {
                "type": "null"
              }
            ]
          },
          "function_id": {
            "type": "string"
          },
          "input": true,
          "invocation_id": {
            "type": "string"
          },
          "metadata": true,
          "namespace": {
            "type": [
              "string",
              "null"
            ]
          },
          "observer_id": {
            "type": "string"
          },
          "output": {
            "anyOf": [
              {
                "$ref": "#/definitions/TurnCompletedInput"
              },
              {
                "type": "null"
              }
            ]
          },
          "started_at_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "status": {
            "$ref": "#/definitions/InvocationStatus"
          }
        },
        "required": [
          "activation_id",
          "duration_ms",
          "function_id",
          "invocation_id",
          "observer_id",
          "started_at_ms",
          "status"
        ],
        "title": "Observed_for_AnyValue_and_TurnCompletedInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "ok": {
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ],
        "title": "AckResponse",
        "type": "object"
      }
    },
    {
      "description": "Pin or unpin a memory. A pinned memory is shown on every turn that reads its bank, first in the memory message and under a cap (`pinned_limit`, `pinned_max_chars`), ranks higher in recall and is untouchable by every automatic path. Refused from inside a turn.",
      "metadata": {},
      "name": "memory::pin",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bank": {
            "default": null,
            "description": "Bank; omitted: the calling session's bank, else the configured default.",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "string"
          },
          "pinned": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "pinned"
        ],
        "title": "PinRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Confidence": {
            "description": "How a memory entered the store.",
            "oneOf": [
              {
                "description": "Stated directly in the source conversation.",
                "enum": [
                  "extracted"
                ],
                "type": "string"
              },
              {
                "description": "Derived by the extraction model rather than stated verbatim.",
                "enum": [
                  "inferred"
                ],
                "type": "string"
              },
              {
                "description": "Saved explicitly through `memory::save`: by a human (console, REST, CLI), or by an agent from a turn: then `source.turn_id` is set and it is that agent's note, not a fact the user stated.",
                "enum": [
                  "stated"
                ],
                "type": "string"
              }
            ]
          },
          "Memory": {
            "description": "One memory item. Serialized whole as a `memories.jsonl` line; replay is last-wins by `id`, so an update appends a full record with a bumped `revision` and a delete appends a tombstoned record (`invalid_at` set) — history is never destroyed, only superseded.",
            "properties": {
              "confidence": {
                "$ref": "#/definitions/Confidence"
              },
              "corroboration": {
                "default": 0,
                "description": "Times this memory was independently re-observed. Boosts recall rank.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at": {
                "description": "Milliseconds since epoch.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "entities": {
                "default": [],
                "description": "Entity handles used as an exact-match retrieval signal.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "Content fingerprint (`fp` + FNV-1a of the normalized text), so re-ingesting the same source reinforces instead of duplicating.",
                "type": "string"
              },
              "invalid_at": {
                "description": "Set when the memory stopped being true (superseded or deleted). The record stays on disk and remains queryable with `include_superseded: true`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "pinned": {
                "default": false,
                "description": "Pinned memories are never touched by any automatic path (consolidation, decay); only an explicit `memory::pin`/`memory::update` changes them.",
                "type": "boolean"
              },
              "revision": {
                "default": 0,
                "description": "Bumped on every appended revision of this id; replay keeps the highest.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "source": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Provenance"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "stated_at": {
                "description": "When the fact was last STATED (said, re-observed, text edited): an extracted memory takes its message's time, not the pass's. Unlike `updated_at`, pin/tag/entity edits never bump it, so recency, the shown date and \"which statement is current\" go by it. Legacy records load as None.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "superseded_by": {
                "description": "Memory id that replaced this one, when superseded by content.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "tags": {
                "default": [],
                "description": "Topical labels for filtering WITHIN a bank (\"iii\", \"workers\", \"billing\") — organization, not ranking. Normalized lowercase, capped like entities. Old records without the field load as untagged.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "text": {
                "type": "string"
              },
              "updated_at": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "confidence",
              "created_at",
              "id",
              "text",
              "updated_at"
            ],
            "type": "object"
          },
          "Provenance": {
            "description": "Where a memory came from. Every extracted memory points back into session-manager; nothing in memory duplicates the transcript store.",
            "properties": {
              "agent": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "correction_reason": {
                "description": "Set on a record written by `memory::correct`: why the old text was replaced, quoting the source conversation.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "entry_id": {
                "description": "The last entry of the run the memory was extracted from.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "first_entry_id": {
                "description": "The first entry of that run: with `entry_id` it bounds the span of transcript the memory came from. Absent on records written before spans were kept.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "turn_id": {
                "description": "The turn an explicit save was called from (`memory::save` inside a turn).",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "description": "Shared response for update/delete/pin.",
        "properties": {
          "memory": {
            "$ref": "#/definitions/Memory"
          }
        },
        "required": [
          "memory"
        ],
        "title": "MemoryResponse",
        "type": "object"
      }
    },
    {
      "description": "Preview the memory injection for a hypothetical chat message: the exact system-prompt memory section a new session gets (rules, budgets, truncation markers; running sessions receive changes as an appended update), the memories the turn would be handed (past the relevance cut and token budget), and the appended message verbatim. Runs the pre-generate hook's own code.",
      "metadata": {},
      "name": "memory::preview",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bank": {
            "default": null,
            "description": "Bank to preview; a directory's bank (`<name>-<6 hex>`) reads `default_bank` under it, as its turns do. Omitted: the calling session's bank with its layers (its agent profile's bank too), else the configured default.",
            "type": [
              "string",
              "null"
            ]
          },
          "query": {
            "description": "The hypothetical user message (what someone would type in chat).",
            "type": "string"
          }
        },
        "required": [
          "query"
        ],
        "title": "PreviewRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Confidence": {
            "description": "How a memory entered the store.",
            "oneOf": [
              {
                "description": "Stated directly in the source conversation.",
                "enum": [
                  "extracted"
                ],
                "type": "string"
              },
              {
                "description": "Derived by the extraction model rather than stated verbatim.",
                "enum": [
                  "inferred"
                ],
                "type": "string"
              },
              {
                "description": "Saved explicitly through `memory::save`: by a human (console, REST, CLI), or by an agent from a turn: then `source.turn_id` is set and it is that agent's note, not a fact the user stated.",
                "enum": [
                  "stated"
                ],
                "type": "string"
              }
            ]
          },
          "Memory": {
            "description": "One memory item. Serialized whole as a `memories.jsonl` line; replay is last-wins by `id`, so an update appends a full record with a bumped `revision` and a delete appends a tombstoned record (`invalid_at` set) — history is never destroyed, only superseded.",
            "properties": {
              "confidence": {
                "$ref": "#/definitions/Confidence"
              },
              "corroboration": {
                "default": 0,
                "description": "Times this memory was independently re-observed. Boosts recall rank.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at": {
                "description": "Milliseconds since epoch.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "entities": {
                "default": [],
                "description": "Entity handles used as an exact-match retrieval signal.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "Content fingerprint (`fp` + FNV-1a of the normalized text), so re-ingesting the same source reinforces instead of duplicating.",
                "type": "string"
              },
              "invalid_at": {
                "description": "Set when the memory stopped being true (superseded or deleted). The record stays on disk and remains queryable with `include_superseded: true`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "pinned": {
                "default": false,
                "description": "Pinned memories are never touched by any automatic path (consolidation, decay); only an explicit `memory::pin`/`memory::update` changes them.",
                "type": "boolean"
              },
              "revision": {
                "default": 0,
                "description": "Bumped on every appended revision of this id; replay keeps the highest.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "source": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Provenance"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "stated_at": {
                "description": "When the fact was last STATED (said, re-observed, text edited): an extracted memory takes its message's time, not the pass's. Unlike `updated_at`, pin/tag/entity edits never bump it, so recency, the shown date and \"which statement is current\" go by it. Legacy records load as None.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "superseded_by": {
                "description": "Memory id that replaced this one, when superseded by content.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "tags": {
                "default": [],
                "description": "Topical labels for filtering WITHIN a bank (\"iii\", \"workers\", \"billing\") — organization, not ranking. Normalized lowercase, capped like entities. Old records without the field load as untagged.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "text": {
                "type": "string"
              },
              "updated_at": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "confidence",
              "created_at",
              "id",
              "text",
              "updated_at"
            ],
            "type": "object"
          },
          "PreviewMemory": {
            "properties": {
              "bank": {
                "description": "The bank holding it, when not `bank`: the default bank, read under a bank the session's directory chose, or its agent profile's bank.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "memory": {
                "$ref": "#/definitions/Memory"
              },
              "score": {
                "description": "Recall score; 0 for a pinned line, shown whatever the message asks.",
                "format": "float",
                "type": "number"
              }
            },
            "required": [
              "memory",
              "score"
            ],
            "type": "object"
          },
          "Provenance": {
            "description": "Where a memory came from. Every extracted memory points back into session-manager; nothing in memory duplicates the transcript store.",
            "properties": {
              "agent": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "correction_reason": {
                "description": "Set on a record written by `memory::correct`: why the old text was replaced, quoting the source conversation.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "entry_id": {
                "description": "The last entry of the run the memory was extracted from.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "first_entry_id": {
                "description": "The first entry of that run: with `entry_id` it bounds the span of transcript the memory came from. Absent on records written before spans were kept.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "turn_id": {
                "description": "The turn an explicit save was called from (`memory::save` inside a turn).",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "properties": {
          "bank": {
            "type": "string"
          },
          "memories": {
            "description": "Memories the turn would be handed, in injection order: the pinned ones first (`pinned_limit`, `pinned_max_chars`), then the recalled ones past the relevance cut and token budget.",
            "items": {
              "$ref": "#/definitions/PreviewMemory"
            },
            "type": "array"
          },
          "message": {
            "description": "The appended `<memory>` message body, verbatim. With rules it can hold only the rules reminder while `memories` is empty; absent when neither a memory fits the budget nor a reminder applies.",
            "type": [
              "string",
              "null"
            ]
          },
          "pinned_skipped": {
            "description": "Pinned memories past the cap, by id: the least recently updated.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "retrieval": {
            "description": "Retrieval mode that ran (`bm25-entity` or `bm25-entity-semantic`; `none` when memories are not injected).",
            "type": "string"
          },
          "rules": {
            "description": "Rules included, and whether any were cut by `max_rule_chars`.",
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "rules_truncated": {
            "type": "boolean"
          },
          "system_prompt_section": {
            "description": "The memory section appended to the system prompt (ambient header + rules) as the user's own session gets it, truncation markers included; a sub-agent's or automation session's header says nothing is captured.",
            "type": "string"
          }
        },
        "required": [
          "bank",
          "memories",
          "pinned_skipped",
          "retrieval",
          "rules",
          "rules_truncated",
          "system_prompt_section"
        ],
        "title": "PreviewResponse",
        "type": "object"
      }
    },
    {
      "description": "Search a bank's memories relevant to a query (BM25 + entities + corroboration + recency; no LLM). The same scorer the pre-generate hook uses; the hook injects only the hits with evidence, one line per fact and the newer of a stated change, never an unpinned work-item or transient line stated over 7 days ago, and memory::preview shows exactly what it injects. mode lexical/semantic returns one raw arm (plain BM25, or cosine).",
      "metadata": {},
      "name": "memory::recall",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "RecallMode": {
            "enum": [
              "hybrid",
              "lexical",
              "semantic"
            ],
            "type": "string"
          }
        },
        "properties": {
          "bank": {
            "default": null,
            "description": "Bank to search; omitted: the calling session's bank (with the default bank's memories about the user under one its directory chose, and its agent profile's bank, as the hook reads), else the configured default.",
            "type": [
              "string",
              "null"
            ]
          },
          "include_superseded": {
            "default": null,
            "description": "Also rank superseded/tombstoned records (the history view).",
            "type": [
              "boolean",
              "null"
            ]
          },
          "limit": {
            "default": null,
            "description": "Max memories returned (default: the configured recall_limit).",
            "format": "uint",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "mode": {
            "allOf": [
              {
                "$ref": "#/definitions/RecallMode"
              }
            ],
            "description": "`hybrid` (default) is the fused scorer the hook uses. `lexical` and `semantic` return ONE raw arm (plain BM25, or cosine as the score) for callers that fuse arms themselves — consolidation interleaves both so a near-duplicate is never buried by the fused rank."
          },
          "query": {
            "type": "string"
          },
          "tag": {
            "default": null,
            "description": "Only rank memories carrying this tag.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "query"
        ],
        "title": "RecallRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Confidence": {
            "description": "How a memory entered the store.",
            "oneOf": [
              {
                "description": "Stated directly in the source conversation.",
                "enum": [
                  "extracted"
                ],
                "type": "string"
              },
              {
                "description": "Derived by the extraction model rather than stated verbatim.",
                "enum": [
                  "inferred"
                ],
                "type": "string"
              },
              {
                "description": "Saved explicitly through `memory::save`: by a human (console, REST, CLI), or by an agent from a turn: then `source.turn_id` is set and it is that agent's note, not a fact the user stated.",
                "enum": [
                  "stated"
                ],
                "type": "string"
              }
            ]
          },
          "Memory": {
            "description": "One memory item. Serialized whole as a `memories.jsonl` line; replay is last-wins by `id`, so an update appends a full record with a bumped `revision` and a delete appends a tombstoned record (`invalid_at` set) — history is never destroyed, only superseded.",
            "properties": {
              "confidence": {
                "$ref": "#/definitions/Confidence"
              },
              "corroboration": {
                "default": 0,
                "description": "Times this memory was independently re-observed. Boosts recall rank.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at": {
                "description": "Milliseconds since epoch.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "entities": {
                "default": [],
                "description": "Entity handles used as an exact-match retrieval signal.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "Content fingerprint (`fp` + FNV-1a of the normalized text), so re-ingesting the same source reinforces instead of duplicating.",
                "type": "string"
              },
              "invalid_at": {
                "description": "Set when the memory stopped being true (superseded or deleted). The record stays on disk and remains queryable with `include_superseded: true`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "pinned": {
                "default": false,
                "description": "Pinned memories are never touched by any automatic path (consolidation, decay); only an explicit `memory::pin`/`memory::update` changes them.",
                "type": "boolean"
              },
              "revision": {
                "default": 0,
                "description": "Bumped on every appended revision of this id; replay keeps the highest.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "source": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Provenance"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "stated_at": {
                "description": "When the fact was last STATED (said, re-observed, text edited): an extracted memory takes its message's time, not the pass's. Unlike `updated_at`, pin/tag/entity edits never bump it, so recency, the shown date and \"which statement is current\" go by it. Legacy records load as None.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "superseded_by": {
                "description": "Memory id that replaced this one, when superseded by content.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "tags": {
                "default": [],
                "description": "Topical labels for filtering WITHIN a bank (\"iii\", \"workers\", \"billing\") — organization, not ranking. Normalized lowercase, capped like entities. Old records without the field load as untagged.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "text": {
                "type": "string"
              },
              "updated_at": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "confidence",
              "created_at",
              "id",
              "text",
              "updated_at"
            ],
            "type": "object"
          },
          "Provenance": {
            "description": "Where a memory came from. Every extracted memory points back into session-manager; nothing in memory duplicates the transcript store.",
            "properties": {
              "agent": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "correction_reason": {
                "description": "Set on a record written by `memory::correct`: why the old text was replaced, quoting the source conversation.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "entry_id": {
                "description": "The last entry of the run the memory was extracted from.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "first_entry_id": {
                "description": "The first entry of that run: with `entry_id` it bounds the span of transcript the memory came from. Absent on records written before spans were kept.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "turn_id": {
                "description": "The turn an explicit save was called from (`memory::save` inside a turn).",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "ScoredMemory": {
            "properties": {
              "bank": {
                "description": "The bank holding it, when not `bank`: the default bank, read under a bank the session's directory chose, or its agent profile's bank.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "memory": {
                "$ref": "#/definitions/Memory"
              },
              "score": {
                "format": "float",
                "type": "number"
              }
            },
            "required": [
              "memory",
              "score"
            ],
            "type": "object"
          },
          "VectorCoverage": {
            "description": "Live memories of the response's `bank` with a vector comparable with the query's, of all its live memories. Layers read under it are not counted.",
            "properties": {
              "covered": {
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "live": {
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "covered",
              "live"
            ],
            "type": "object"
          }
        },
        "properties": {
          "bank": {
            "type": "string"
          },
          "memories": {
            "items": {
              "$ref": "#/definitions/ScoredMemory"
            },
            "type": "array"
          },
          "retrieval": {
            "description": "Retrieval mode actually used — degradation is explicit, never silent. `hybrid`: `bm25-entity`, or `bm25-entity-semantic` when the query was embedded through `router::embed`. `lexical`: `lexical`. `semantic`: `semantic`, or `semantic-unavailable` (empty result — NOT \"no matches\") when the query could not be embedded. A label with semantic does not say every memory has a vector: see `vector_coverage`.",
            "type": "string"
          },
          "vector_coverage": {
            "anyOf": [
              {
                "$ref": "#/definitions/VectorCoverage"
              },
              {
                "type": "null"
              }
            ],
            "description": "How much of `bank` the semantic signal could reach. Present when the query was embedded and `bank` exists, so never in `lexical` mode. `covered < live` means some live memories have no vector in the query's model yet (backfill or a re-embed is still running), and the semantic arm cannot find them; `retrieval` does not change."
          }
        },
        "required": [
          "bank",
          "memories",
          "retrieval"
        ],
        "title": "RecallResponse",
        "type": "object"
      }
    },
    {
      "description": "Drop all in-RAM state and reload every bank from disk — the recovery hatch after editing bank files by hand.",
      "metadata": {},
      "name": "memory::reload",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "ReloadRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "banks": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "ok": {
            "type": "boolean"
          }
        },
        "required": [
          "banks",
          "ok"
        ],
        "title": "ReloadResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal: target of the memory REST routes, the http::on-request observers with args { method: POST, path: /memory/... }. Receives the HttpRequest, runs the memory::* function the route's path names with the request's JSON body, and returns the HttpResponse { status_code, body }: 200 with the function's result, or 400/403/404/500/503 with { error: { code, message } }.",
      "metadata": {
        "internal": true
      },
      "name": "memory::rest",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "The `HttpRequest` fields the adapter reads. The http worker sends more (`method`, `query_params`, `path_params`, `headers` and the stream channels); they are ignored.",
        "properties": {
          "body": {
            "default": null,
            "description": "The request body parsed as JSON; `null` when it is empty or not JSON."
          },
          "path": {
            "description": "The matched route's path: `/memory/...`, the function id with `::` as `/`.",
            "type": "string"
          }
        },
        "required": [
          "path"
        ],
        "title": "RestRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "The `HttpResponse` the http worker answers with.",
        "properties": {
          "body": true,
          "status_code": {
            "format": "uint16",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "body",
          "status_code"
        ],
        "title": "RestResponse",
        "type": "object"
      }
    },
    {
      "description": "List a bank's rules (markdown, injected whole into the system prompt on every turn). Stored as plain files under the bank's rules/ folder; editing them by hand is equivalent. Content is returned redacted, as it is injected.",
      "metadata": {},
      "name": "memory::rule::list",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bank": {
            "default": null,
            "description": "Bank whose rules to list; omitted: the calling session's bank, else the configured default.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "RuleListRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Rule": {
            "description": "One markdown rule: always injected whole into the system prompt for sessions using its bank. Stored as `rules/<name>.md` — open it in any editor.",
            "properties": {
              "content": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "updated_at": {
                "description": "Milliseconds since epoch (file mtime).",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "content",
              "name",
              "updated_at"
            ],
            "type": "object"
          }
        },
        "properties": {
          "bank": {
            "type": "string"
          },
          "rules": {
            "items": {
              "$ref": "#/definitions/Rule"
            },
            "type": "array"
          }
        },
        "required": [
          "bank",
          "rules"
        ],
        "title": "RuleListResponse",
        "type": "object"
      }
    },
    {
      "description": "Create or replace one rule (atomic write; empty content removes it). With `expected`, the write is refused as `rule_changed` when the rule no longer holds that content. Rules are plain markdown files under the bank's rules/ folder.",
      "metadata": {},
      "name": "memory::rule::set",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bank": {
            "default": null,
            "description": "Bank to write into; omitted: the calling session's bank, else the configured default. Created on first use.",
            "type": [
              "string",
              "null"
            ]
          },
          "content": {
            "description": "Markdown content. Empty removes the rule.",
            "type": "string"
          },
          "expected": {
            "default": null,
            "description": "The rule's content as the caller last read it (`memory::rule::list`). The write is refused with `rule_changed` when the rule holds anything else by then. Empty: the rule must not exist yet. Omitted: replace without checking.",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "description": "Rule name, `[a-z0-9][a-z0-9_-]{0,63}` (it becomes `<name>.md`).",
            "type": "string"
          }
        },
        "required": [
          "content",
          "name"
        ],
        "title": "RuleSetRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "exists": {
            "description": "False when the empty content removed the rule.",
            "type": "boolean"
          },
          "ok": {
            "type": "boolean"
          }
        },
        "required": [
          "exists",
          "ok"
        ],
        "title": "RuleSetResponse",
        "type": "object"
      }
    },
    {
      "description": "Save one memory explicitly. Content-fingerprinted: re-saving the same text reinforces the existing memory instead of duplicating it. A text a newer memory superseded is refused with `memory_retired`, naming that memory. Called from a turn it is the agent's note: 3 to 500 characters, in the turn's own bank, at most `max_memories_per_turn` new notes per turn, with that session and turn as its source; a pin, another bank, the `user` entity and the `demoted-rule` tag are refused there, and so is a save from an automation or test session. From a turn a repeat adds no corroboration: it restates the turn's own note and leaves any other memory as it is. Needed where the `# Memory` header asks for it (a sub-agent, extraction off): save what a later session would need.",
      "metadata": {},
      "name": "memory::save",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bank": {
            "default": null,
            "description": "Target bank; omitted: the calling session's bank, else the configured default. From a turn only the turn's own bank.",
            "type": [
              "string",
              "null"
            ]
          },
          "entities": {
            "default": [],
            "description": "Entity handles (people/projects/tools) used as a retrieval signal. None into the default bank from outside a turn (the memory page, the CLI): `user`, read under every repository's bank. From a turn `user` is refused.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "pinned": {
            "default": false,
            "description": "Refused from a turn.",
            "type": "boolean"
          },
          "session_id": {
            "default": null,
            "description": "Provenance session for a save made outside a turn on behalf of a conversation. A save from a turn records that turn's session and turn id instead.",
            "type": [
              "string",
              "null"
            ]
          },
          "tags": {
            "default": [],
            "description": "Topical labels for filtering within the bank (organization, not ranking).",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "text": {
            "description": "The memory, one self-contained sentence.",
            "type": "string"
          }
        },
        "required": [
          "text"
        ],
        "title": "SaveRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Confidence": {
            "description": "How a memory entered the store.",
            "oneOf": [
              {
                "description": "Stated directly in the source conversation.",
                "enum": [
                  "extracted"
                ],
                "type": "string"
              },
              {
                "description": "Derived by the extraction model rather than stated verbatim.",
                "enum": [
                  "inferred"
                ],
                "type": "string"
              },
              {
                "description": "Saved explicitly through `memory::save`: by a human (console, REST, CLI), or by an agent from a turn: then `source.turn_id` is set and it is that agent's note, not a fact the user stated.",
                "enum": [
                  "stated"
                ],
                "type": "string"
              }
            ]
          },
          "Memory": {
            "description": "One memory item. Serialized whole as a `memories.jsonl` line; replay is last-wins by `id`, so an update appends a full record with a bumped `revision` and a delete appends a tombstoned record (`invalid_at` set) — history is never destroyed, only superseded.",
            "properties": {
              "confidence": {
                "$ref": "#/definitions/Confidence"
              },
              "corroboration": {
                "default": 0,
                "description": "Times this memory was independently re-observed. Boosts recall rank.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at": {
                "description": "Milliseconds since epoch.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "entities": {
                "default": [],
                "description": "Entity handles used as an exact-match retrieval signal.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "Content fingerprint (`fp` + FNV-1a of the normalized text), so re-ingesting the same source reinforces instead of duplicating.",
                "type": "string"
              },
              "invalid_at": {
                "description": "Set when the memory stopped being true (superseded or deleted). The record stays on disk and remains queryable with `include_superseded: true`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "pinned": {
                "default": false,
                "description": "Pinned memories are never touched by any automatic path (consolidation, decay); only an explicit `memory::pin`/`memory::update` changes them.",
                "type": "boolean"
              },
              "revision": {
                "default": 0,
                "description": "Bumped on every appended revision of this id; replay keeps the highest.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "source": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Provenance"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "stated_at": {
                "description": "When the fact was last STATED (said, re-observed, text edited): an extracted memory takes its message's time, not the pass's. Unlike `updated_at`, pin/tag/entity edits never bump it, so recency, the shown date and \"which statement is current\" go by it. Legacy records load as None.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "superseded_by": {
                "description": "Memory id that replaced this one, when superseded by content.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "tags": {
                "default": [],
                "description": "Topical labels for filtering WITHIN a bank (\"iii\", \"workers\", \"billing\") — organization, not ranking. Normalized lowercase, capped like entities. Old records without the field load as untagged.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "text": {
                "type": "string"
              },
              "updated_at": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "confidence",
              "created_at",
              "id",
              "text",
              "updated_at"
            ],
            "type": "object"
          },
          "Provenance": {
            "description": "Where a memory came from. Every extracted memory points back into session-manager; nothing in memory duplicates the transcript store.",
            "properties": {
              "agent": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "correction_reason": {
                "description": "Set on a record written by `memory::correct`: why the old text was replaced, quoting the source conversation.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "entry_id": {
                "description": "The last entry of the run the memory was extracted from.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "first_entry_id": {
                "description": "The first entry of that run: with `entry_id` it bounds the span of transcript the memory came from. Absent on records written before spans were kept.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "turn_id": {
                "description": "The turn an explicit save was called from (`memory::save` inside a turn).",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "properties": {
          "created": {
            "description": "False when the text fingerprint matched an existing memory (it was reinforced instead, or, from a turn, left as it was).",
            "type": "boolean"
          },
          "memory": {
            "$ref": "#/definitions/Memory"
          }
        },
        "required": [
          "created",
          "memory"
        ],
        "title": "SaveResponse",
        "type": "object"
      }
    },
    {
      "description": "Retire one memory in favor of another: tombstone with a superseded_by pointer, never a plain delete. The consolidation seam; pinned memories cannot be superseded. reinforce makes it a merge (the non-pinned survivor absorbs the retired record's observations); reason is carried on the memory::on-item-changed events.",
      "metadata": {},
      "name": "memory::supersede",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bank": {
            "default": null,
            "description": "Bank; omitted: the calling session's bank, else the configured default.",
            "type": [
              "string",
              "null"
            ]
          },
          "expected_memory": {
            "default": null,
            "description": "Optional proof-bound snapshot of the loser; compared under the same storage lock as the winner snapshot and both writes."
          },
          "expected_superseded_by": {
            "default": null,
            "description": "Optional proof-bound snapshot of the winner. Legacy callers may omit both."
          },
          "id": {
            "description": "Memory to retire.",
            "type": "string"
          },
          "reason": {
            "default": null,
            "description": "Why — carried on the `memory::on-item-changed` events this call emits (not persisted on the record). Trimmed, capped at 500 chars.",
            "type": [
              "string",
              "null"
            ]
          },
          "reinforce": {
            "default": false,
            "description": "Merge semantics: the survivor absorbs the retired record's observations (corroboration += retired + 1) in the same call. A pinned survivor is never written. Default false (a state change: the new record replaces the old, nothing to absorb).",
            "type": "boolean"
          },
          "superseded_by": {
            "description": "Live memory that replaces it.",
            "type": "string"
          }
        },
        "required": [
          "id",
          "superseded_by"
        ],
        "title": "SupersedeRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Confidence": {
            "description": "How a memory entered the store.",
            "oneOf": [
              {
                "description": "Stated directly in the source conversation.",
                "enum": [
                  "extracted"
                ],
                "type": "string"
              },
              {
                "description": "Derived by the extraction model rather than stated verbatim.",
                "enum": [
                  "inferred"
                ],
                "type": "string"
              },
              {
                "description": "Saved explicitly through `memory::save`: by a human (console, REST, CLI), or by an agent from a turn: then `source.turn_id` is set and it is that agent's note, not a fact the user stated.",
                "enum": [
                  "stated"
                ],
                "type": "string"
              }
            ]
          },
          "Memory": {
            "description": "One memory item. Serialized whole as a `memories.jsonl` line; replay is last-wins by `id`, so an update appends a full record with a bumped `revision` and a delete appends a tombstoned record (`invalid_at` set) — history is never destroyed, only superseded.",
            "properties": {
              "confidence": {
                "$ref": "#/definitions/Confidence"
              },
              "corroboration": {
                "default": 0,
                "description": "Times this memory was independently re-observed. Boosts recall rank.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at": {
                "description": "Milliseconds since epoch.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "entities": {
                "default": [],
                "description": "Entity handles used as an exact-match retrieval signal.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "Content fingerprint (`fp` + FNV-1a of the normalized text), so re-ingesting the same source reinforces instead of duplicating.",
                "type": "string"
              },
              "invalid_at": {
                "description": "Set when the memory stopped being true (superseded or deleted). The record stays on disk and remains queryable with `include_superseded: true`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "pinned": {
                "default": false,
                "description": "Pinned memories are never touched by any automatic path (consolidation, decay); only an explicit `memory::pin`/`memory::update` changes them.",
                "type": "boolean"
              },
              "revision": {
                "default": 0,
                "description": "Bumped on every appended revision of this id; replay keeps the highest.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "source": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Provenance"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "stated_at": {
                "description": "When the fact was last STATED (said, re-observed, text edited): an extracted memory takes its message's time, not the pass's. Unlike `updated_at`, pin/tag/entity edits never bump it, so recency, the shown date and \"which statement is current\" go by it. Legacy records load as None.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "superseded_by": {
                "description": "Memory id that replaced this one, when superseded by content.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "tags": {
                "default": [],
                "description": "Topical labels for filtering WITHIN a bank (\"iii\", \"workers\", \"billing\") — organization, not ranking. Normalized lowercase, capped like entities. Old records without the field load as untagged.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "text": {
                "type": "string"
              },
              "updated_at": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "confidence",
              "created_at",
              "id",
              "text",
              "updated_at"
            ],
            "type": "object"
          },
          "Provenance": {
            "description": "Where a memory came from. Every extracted memory points back into session-manager; nothing in memory duplicates the transcript store.",
            "properties": {
              "agent": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "correction_reason": {
                "description": "Set on a record written by `memory::correct`: why the old text was replaced, quoting the source conversation.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "entry_id": {
                "description": "The last entry of the run the memory was extracted from.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "first_entry_id": {
                "description": "The first entry of that run: with `entry_id` it bounds the span of transcript the memory came from. Absent on records written before spans were kept.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "turn_id": {
                "description": "The turn an explicit save was called from (`memory::save` inside a turn).",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "properties": {
          "memory": {
            "allOf": [
              {
                "$ref": "#/definitions/Memory"
              }
            ],
            "description": "The retired record."
          },
          "reinforced": {
            "description": "True when the survivor was reinforced (`reinforce` asked and the survivor is not pinned).",
            "type": "boolean"
          },
          "survivor": {
            "anyOf": [
              {
                "$ref": "#/definitions/Memory"
              },
              {
                "type": "null"
              }
            ],
            "description": "Post-commit survivor snapshot for a subsequent proof-bound absorption."
          }
        },
        "required": [
          "memory",
          "reinforced"
        ],
        "title": "SupersedeResponse",
        "type": "object"
      }
    },
    {
      "description": "List the tags across a bank's live memories with usage counts, most used first — the filter source for tag-scoped list/recall.",
      "metadata": {},
      "name": "memory::tags",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bank": {
            "default": null,
            "description": "Bank; omitted: the calling session's bank, else the configured default.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "TagsRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "TagCount": {
            "properties": {
              "count": {
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "tag": {
                "type": "string"
              }
            },
            "required": [
              "count",
              "tag"
            ],
            "type": "object"
          }
        },
        "properties": {
          "bank": {
            "type": "string"
          },
          "tags": {
            "items": {
              "$ref": "#/definitions/TagCount"
            },
            "type": "array"
          }
        },
        "required": [
          "bank",
          "tags"
        ],
        "title": "TagsResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal: the source transcript of one live memory, as redacted lines, a long line as its head and tail (its recorded span, or the turn it was saved from). `missing` says why there is none.",
      "metadata": {
        "internal": true,
        "trace_hidden": true
      },
      "name": "memory::transcript",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bank": {
            "default": null,
            "description": "Bank; omitted: the calling session's bank, else the configured default.",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "title": "TranscriptRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Line": {
            "description": "One transcript line as the verify judge reads it.",
            "properties": {
              "date": {
                "description": "The day the line was sent, `YYYY-MM-DD Weekday` in local time.",
                "type": "string"
              },
              "role": {
                "description": "`user`, `assistant`, or `notice` (written by the harness or a bot).",
                "type": "string"
              },
              "text": {
                "type": "string"
              }
            },
            "required": [
              "date",
              "role",
              "text"
            ],
            "type": "object"
          }
        },
        "properties": {
          "lines": {
            "items": {
              "$ref": "#/definitions/Line"
            },
            "type": "array"
          },
          "missing": {
            "description": "Why there are no lines: `not_found`, `edited`, `no_span`, `session_not_found`, `entry_not_found`, `off_path`, `turn_not_found`, `too_long`, `unreadable` or `empty`.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "lines"
        ],
        "title": "TranscriptResponse",
        "type": "object"
      }
    },
    {
      "description": "Serve the memory worker's injected console UI assets (the target of its ade::ui::asset observers; the console calls it through each asset's observer with {path}).",
      "metadata": {
        "internal": true
      },
      "name": "memory::ui-content",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Input of the content function: the console asks for one asset by path.",
        "properties": {
          "path": {
            "description": "The asset path from the observer's args (e.g. `state/page.js`).",
            "type": "string"
          }
        },
        "required": [
          "path"
        ],
        "title": "UiContentInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Output of the content function.",
        "properties": {
          "content": {
            "description": "The asset source, verbatim.",
            "type": "string"
          },
          "content_type": {
            "description": "MIME type the console should serve the asset with.",
            "type": "string"
          }
        },
        "required": [
          "content",
          "content_type"
        ],
        "title": "UiContentResult",
        "type": "object"
      }
    },
    {
      "description": "Revise a memory's text, entities, or pin flag in place (same id, bumped revision; the prior revision stays in the on-disk log). A retired memory is refused with `memory_retired`, naming the memory that replaced it. From a turn: only a note saved from a turn, in the turn's own bank, never a pinned one, never the pin flag.",
      "metadata": {},
      "name": "memory::update",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bank": {
            "default": null,
            "description": "Bank; omitted: the calling session's bank, else the configured default.",
            "type": [
              "string",
              "null"
            ]
          },
          "entities": {
            "default": null,
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "expected_memory": {
            "default": null,
            "description": "Optional snapshot of the memory as the caller read it (a full record or a revision-bound projection): the write is refused when the memory changed since."
          },
          "id": {
            "type": "string"
          },
          "pinned": {
            "default": null,
            "type": [
              "boolean",
              "null"
            ]
          },
          "reason": {
            "default": null,
            "description": "Why, carried on the `memory::on-item-changed` event this call emits (not persisted on the record). Secrets redacted, trimmed, capped at 500 chars.",
            "type": [
              "string",
              "null"
            ]
          },
          "tags": {
            "default": null,
            "description": "Replace the tag set (empty list clears).",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "text": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id"
        ],
        "title": "UpdateRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Confidence": {
            "description": "How a memory entered the store.",
            "oneOf": [
              {
                "description": "Stated directly in the source conversation.",
                "enum": [
                  "extracted"
                ],
                "type": "string"
              },
              {
                "description": "Derived by the extraction model rather than stated verbatim.",
                "enum": [
                  "inferred"
                ],
                "type": "string"
              },
              {
                "description": "Saved explicitly through `memory::save`: by a human (console, REST, CLI), or by an agent from a turn: then `source.turn_id` is set and it is that agent's note, not a fact the user stated.",
                "enum": [
                  "stated"
                ],
                "type": "string"
              }
            ]
          },
          "Memory": {
            "description": "One memory item. Serialized whole as a `memories.jsonl` line; replay is last-wins by `id`, so an update appends a full record with a bumped `revision` and a delete appends a tombstoned record (`invalid_at` set) — history is never destroyed, only superseded.",
            "properties": {
              "confidence": {
                "$ref": "#/definitions/Confidence"
              },
              "corroboration": {
                "default": 0,
                "description": "Times this memory was independently re-observed. Boosts recall rank.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at": {
                "description": "Milliseconds since epoch.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "entities": {
                "default": [],
                "description": "Entity handles used as an exact-match retrieval signal.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "id": {
                "description": "Content fingerprint (`fp` + FNV-1a of the normalized text), so re-ingesting the same source reinforces instead of duplicating.",
                "type": "string"
              },
              "invalid_at": {
                "description": "Set when the memory stopped being true (superseded or deleted). The record stays on disk and remains queryable with `include_superseded: true`.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "pinned": {
                "default": false,
                "description": "Pinned memories are never touched by any automatic path (consolidation, decay); only an explicit `memory::pin`/`memory::update` changes them.",
                "type": "boolean"
              },
              "revision": {
                "default": 0,
                "description": "Bumped on every appended revision of this id; replay keeps the highest.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "source": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Provenance"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "stated_at": {
                "description": "When the fact was last STATED (said, re-observed, text edited): an extracted memory takes its message's time, not the pass's. Unlike `updated_at`, pin/tag/entity edits never bump it, so recency, the shown date and \"which statement is current\" go by it. Legacy records load as None.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "superseded_by": {
                "description": "Memory id that replaced this one, when superseded by content.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "tags": {
                "default": [],
                "description": "Topical labels for filtering WITHIN a bank (\"iii\", \"workers\", \"billing\") — organization, not ranking. Normalized lowercase, capped like entities. Old records without the field load as untagged.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "text": {
                "type": "string"
              },
              "updated_at": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "confidence",
              "created_at",
              "id",
              "text",
              "updated_at"
            ],
            "type": "object"
          },
          "Provenance": {
            "description": "Where a memory came from. Every extracted memory points back into session-manager; nothing in memory duplicates the transcript store.",
            "properties": {
              "agent": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "correction_reason": {
                "description": "Set on a record written by `memory::correct`: why the old text was replaced, quoting the source conversation.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "entry_id": {
                "description": "The last entry of the run the memory was extracted from.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "first_entry_id": {
                "description": "The first entry of that run: with `entry_id` it bounds the span of transcript the memory came from. Absent on records written before spans were kept.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "turn_id": {
                "description": "The turn an explicit save was called from (`memory::save` inside a turn).",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "description": "Shared response for update/delete/pin.",
        "properties": {
          "memory": {
            "$ref": "#/definitions/Memory"
          }
        },
        "required": [
          "memory"
        ],
        "title": "MemoryResponse",
        "type": "object"
      }
    }
  ]
}

Search the registry

Find workers, kits and executables, or jump to a page.