Skip to content

agents.ambassador

agents.ambassador

The Ambassador — the conversational front door (Track B / the Voice).

A reasoning agent that is computationally light: it reasons about intent, answers from already-grounded material on the pinned tier, reads its own operational state, says which exchanges the inbox keeps (the inbox's capture lands them as dialogue), and delegates heavy work to the async scheduler — read + propose, never write + act. See agent.py for the full design.

AMBASSADOR_ROLE = "You are the Ambassador of the owner's sealed personal mind-palace — the voice they talk to. You are a mirror onto their own mind, not an oracle (Constitution §III.2): reflect what they actually wrote, hold interpretive claims loosely, and let them draw the conclusions — the judgment is theirs.\n\nGround every substantive claim in the retrieved notes below and cite them by title in double brackets, e.g. [[note title]]. Never invent notes, quotes, facts, or citations. When their notes don't cover something, say so plainly instead of guessing.\n\nBe concise and warm; surface options and tradeoffs, not directives. On health, financial, or legal matters be substantive and honest about uncertainty, but defer the final decision to the owner and a qualified professional (Constitution §III.3)." module-attribute

AMBASSADOR_TEMPLATE = RoleTemplate(name='ambassador', prompt_fragment=AMBASSADOR_ROLE, default_tier='router', scope=frozenset()) module-attribute

Ambassador dataclass

server instance-attribute

librarian instance-attribute

ops_view instance-attribute

budgeter instance-attribute

dreams_view = None class-attribute instance-attribute

tier = 'router' class-attribute instance-attribute

attestor = None class-attribute instance-attribute

delegate = None class-attribute instance-attribute

pending_results = None class-attribute instance-attribute

verdict_transport = None class-attribute instance-attribute

interruption = field(default_factory=InterruptionPolicy) class-attribute instance-attribute

role_prompt = AMBASSADOR_ROLE class-attribute instance-attribute

history_max_turns = 6 class-attribute instance-attribute

respond(text, *, conversation='default')

answer(message)

The CoreInbox responder: a request read whole -> the reply, and whether the exchange is the owner's to keep. The capture loop closes there (note §4): the inbox keeps a kept exchange in its record, and its capture lands the owner's words as authored-dialogue.

handler(text)

A text -> its reply (single default conversation); nothing is kept.

transport_verdict(signed)

Carry a signed owner verdict inbound to the verify+apply seam — TRANSPORT ONLY.

The Ambassador holds no verdict authority: it never signs, verifies, or applies a verdict (each is outside its read+propose scope). It only forwards the signed artifact to the injected receiver, which verifies against the owner PUBLIC key and applies it. A compromised Ambassador can thus drop/reorder but never forge a verdict (verdict-authority.md §4). Raises if no transport is wired — the Ambassador cannot manufacture verdict authority it lacks.

DeliveredResult dataclass

A completed delegated task's result, ready to surface as an EXPECTED update.

ref instance-attribute

topic instance-attribute

text instance-attribute

Turn dataclass

reply instance-attribute

intent instance-attribute

sources = () class-attribute instance-attribute

check = None class-attribute instance-attribute

Intent

Bases: StrEnum

RETRIEVE = 'retrieve' class-attribute instance-attribute

EXPLAIN = 'explain' class-attribute instance-attribute

STATUS = 'status' class-attribute instance-attribute

DREAMS = 'dreams' class-attribute instance-attribute

TASK = 'task' class-attribute instance-attribute

CAPTURE = 'capture' class-attribute instance-attribute

InterruptionPolicy dataclass

Whether the Ambassador may speak UNPROMPTED. The "would the owner want this raised?" judgment is the model-advised part; this policy is the code that acts on it, and the owner-tunable default is EARNED_ONLY (note §3 — "not a silent oracle, not a nag").

A single dial (off / earned-only / verbose) is shipped; per-category sensitivity is left a documented future extension (note §7 leaves it genuinely open — avoid the premature- abstraction trap on an axis nothing uses yet). Expected updates (a result the owner asked for) are NOT governed by this — those are always delivered; this gates only the unprompted.

sensitivity = Sensitivity.EARNED_ONLY class-attribute instance-attribute

admits(worth_raising)

Sensitivity

Bases: StrEnum

OFF = 'off' class-attribute instance-attribute

EARNED_ONLY = 'earned_only' class-attribute instance-attribute

VERBOSE = 'verbose' class-attribute instance-attribute

classify(text, *, chat=None)

Floor first; earn the model only for the ambiguous rest (note §5).

classify_floor(text)

The deterministic floor: an Intent for an obvious message, else None (escalate).

narrate_effort(topic='')

Plain-language "I need to go work on this" — the RIGHT register (note §4): honest about the wait + the rough plan, never the plumbing. A pure function from "what was delegated" to one plain sentence (unit-tested to leak no internal noun).

build_ambassador(config=None, *, delegate=None, pending_results=None, server=None, embedder=None, store=None, drift=None, derived=None)

Wire an Ambassador against the real configured stores + models.

Delegation (the gate→queue seam + completed-result surfacing) is INJECTED by the scheduler-layer wiring (scheduler/interface.py), which owns the queue — the Ambassador never imports the scheduler, so this base build leaves delegate/pending_results as passed (None → TASK still attests + narrates effort, just enqueues nothing).

server/embedder/store are injectable so the offline CLI + tests can swap the two model-backed pieces for deterministic stand-ins without touching the real machinery. The Ambassador writes nothing: the exchanges it keeps go to the inbox's record, and the inbox's capture lands them through the one writer (dn-ingress-language §E13). drift is an optional bound DriftReport reading for the ops-view (None per-chat — drift is measured by a separate job, not on every turn).

agent

The Ambassador — the conversational front door (Track B; ambassador-as-reasoning-agent.md).

A reasoning agent that is computationally light (note §0): it genuinely reasons about each message (the intent step), but holds no heavy work inline — it answers from already-grounded material on the always-warm pinned tier, and delegates anything expensive to the async scheduler. "Wide window, narrow hands": it can read the authored mirror, the curated self-knowledge graph, and the operational state, but its authority is read + propose, never write + act (nervous-system-and-ambassador.md §4). Every step is attested.

The five paths (ambassador-interpretation-and-flow.md §3, split by which graph retrieval reads): RETRIEVE → the authored mirror → grounded answer (inline). [B2, B5] EXPLAIN → the CURATED self-knowledge graph → grounded answer (inline). [B2, B4] STATUS → the read-only ops-view, narrated in plain language (inline). [B2, B3] TASK → compose a scoped task → gate → queue; narrate the effort. [B2] CAPTURE → acknowledge; the inbox keeps the exchange, its capture lands it. [B1, B2]

Which exchanges are the owner's to keep is the Ambassador's call, by intent (answer): a recall, a task and a capture are kept, a status, an explanation and the dreams are not. What is in one is not: the inbox records the owner's text as the request held it and the reply as it was sent, and the palace's table labels the text authored and the reply observed (dn-ingress-language §E13), so nothing the model writes can become the owner's words.

Context for the inline answers is assembled through the §13 budgeter (B5): the Ambassador chooses what to put in ContextParts (which chunks, how much history); the budgeter is the one thing that enforces the window — "agent-judged retrieval within the budgeter ceiling".

AMBASSADOR_ROLE = "You are the Ambassador of the owner's sealed personal mind-palace — the voice they talk to. You are a mirror onto their own mind, not an oracle (Constitution §III.2): reflect what they actually wrote, hold interpretive claims loosely, and let them draw the conclusions — the judgment is theirs.\n\nGround every substantive claim in the retrieved notes below and cite them by title in double brackets, e.g. [[note title]]. Never invent notes, quotes, facts, or citations. When their notes don't cover something, say so plainly instead of guessing.\n\nBe concise and warm; surface options and tradeoffs, not directives. On health, financial, or legal matters be substantive and honest about uncertainty, but defer the final decision to the owner and a qualified professional (Constitution §III.3)." module-attribute

AMBASSADOR_TEMPLATE = RoleTemplate(name='ambassador', prompt_fragment=AMBASSADOR_ROLE, default_tier='router', scope=frozenset()) module-attribute

DeliveredResult dataclass

A completed delegated task's result, ready to surface as an EXPECTED update.

ref instance-attribute
topic instance-attribute
text instance-attribute

Turn dataclass

reply instance-attribute
intent instance-attribute
sources = () class-attribute instance-attribute
check = None class-attribute instance-attribute

ChatServer

Bases: Protocol

The Ambassador's real dependency on ModelServer (core/models/server.py): "chat at a tier, get text back." A Protocol rather than the concrete class so test fakes (bare .chat(tier, messages, ...) -> str stand-ins) satisfy the type structurally, without inheriting from or importing the real ModelServer.

chat(tier, messages, **kwargs)

Ambassador dataclass

server instance-attribute
librarian instance-attribute
ops_view instance-attribute
budgeter instance-attribute
dreams_view = None class-attribute instance-attribute
tier = 'router' class-attribute instance-attribute
attestor = None class-attribute instance-attribute
delegate = None class-attribute instance-attribute
pending_results = None class-attribute instance-attribute
verdict_transport = None class-attribute instance-attribute
interruption = field(default_factory=InterruptionPolicy) class-attribute instance-attribute
role_prompt = AMBASSADOR_ROLE class-attribute instance-attribute
history_max_turns = 6 class-attribute instance-attribute
respond(text, *, conversation='default')
answer(message)

The CoreInbox responder: a request read whole -> the reply, and whether the exchange is the owner's to keep. The capture loop closes there (note §4): the inbox keeps a kept exchange in its record, and its capture lands the owner's words as authored-dialogue.

handler(text)

A text -> its reply (single default conversation); nothing is kept.

transport_verdict(signed)

Carry a signed owner verdict inbound to the verify+apply seam — TRANSPORT ONLY.

The Ambassador holds no verdict authority: it never signs, verifies, or applies a verdict (each is outside its read+propose scope). It only forwards the signed artifact to the injected receiver, which verifies against the owner PUBLIC key and applies it. A compromised Ambassador can thus drop/reorder but never forge a verdict (verdict-authority.md §4). Raises if no transport is wired — the Ambassador cannot manufacture verdict authority it lacks.

handoff

The Ambassador's tools over the filesystem handoff — the core side of the Open WebUI bridge.

uv run python scripts/palace_mcp_handoff.py     # sealed; started on demand by edge/mcp_http.py

Open WebUI (in lmtune's podman stack) reaches the palace only through edge/mcp_http.py, a Zone-B HTTP server that holds no store handle. Each tools/call it receives becomes a request file; this responder — sealed, like every core process (Invariant 1) — answers it with the SAME dispatch the stdio server uses (agents.ambassador.mcp.Server) and writes a response file. The coupling is these JSON files alone (Invariant 2), mirrored, not imported, by the edge — the core.interface.CoreInbox pattern with a structured payload:

requests/<id>.json   = {"id", "name", "arguments", "ts"}
responses/<id>.json  = {"id", "text", "is_error", "ts"}

The web client gets a narrower tool set than OpenCode's: every read, plus capture and the two syncs — never dream/relate (long synthesis-model jobs) or link (interpreted edges) from a chat window. WEB_TOOLS is enforced HERE; the edge's advertised list is a copy for the client, not the gate. query reads, and since the ingress (dn-ingress) it can also speak a command (do …): from the web client it may speak only the commands its tools already allow (web_admits), so the narrowing holds whatever tool carries the sentence. One responder runs at a time (responder.lock, which is also how the edge sees it is up); it exits after idle_exit_s with no calls, and the edge starts it again on the next one.

WEB_TOOLS = frozenset({'query', 'overview', 'capture', 'sync_dialogue', 'sync_notes', 'status', 'task_list', 'task_add', 'task_update', 'remind'}) module-attribute

WEB_SCRIPTS = frozenset({'capture', 'sync_dialogue', 'sync_vault'}) module-attribute

Call = Callable[[str, dict[str, Any]], tuple[str, bool]] module-attribute

ToolInbox dataclass

handoff instance-attribute
call instance-attribute
process_once()

Answer every pending request; return how many. A failed call is an error RESPONSE — one bad request never takes the responder down.

run(*, idle_exit_s, poll_interval=0.1, clock=time.monotonic, sleep=time.sleep)

Serve until idle_exit_s passes with no request: models and stores are not held for a chat window that has gone quiet.

web_admits(sentence)

None when the web client may send sentence through query, else why not. A read is admitted; a request only when it parses as a call of one of WEB_SCRIPTS. What is a request is decided by the parser's own rule (grammar.is_request), and a request that does not parse is refused here: a filter that passed what it could not read would pass a script inline.

web_manifest()

What the edge serves for initialize/tools/list — edge/palace_tools.json must equal this (a test pins it), so the client never sees a tool the responder would refuse. Regenerate the file with mind-palace mcp --manifest > edge/palace_tools.json when the table changes.

server_call(server=None)

A tool call through the stdio server's own dispatch — same results, same error shape — behind the web allowlist.

serve_handoff(handoff, *, idle_exit_s, call=None)

Run the responder unless one already holds the lock (then return at once: it is serving).

intent

Intent reasoning for the Ambassador (Track B / B2).

The authoritative note (§5) is explicit: the intent step is a reasoning step, not a bucket classifier — but a deterministic floor handles the cheap, obvious cases (a clear retrieval, a clear status query) before the model is earned for the ambiguous/compound rest. "Floor for the obvious; mind for the rest."

So this module is two separately-testable units
  • classify_floor — pure, deterministic; returns an Intent for an unambiguous message, else None ("not obvious — earn the model").
  • classify_model — the model-earned fallback; asks the pinned model to reason about intent, parses forgivingly, and degrades to a safe heuristic if the model is unavailable/unparseable.

The five intents map to the conversation loop's paths (ambassador-interpretation-and-flow.md §3), with retrieval split by which graph it reads — the mirror (authored) vs. the curated self-knowledge graph — so the firewall (curated ∉ mirror) is honored at the intent boundary.

CLASSIFIER_ROLE = "Classify the owner's message into exactly ONE intent and reply with only that single word.\n- retrieve: they want to recall or find something from their OWN notes/journals.\n- explain: they're asking how YOU (the system) work — your design or guarantees.\n- status: they're asking what you've been doing, or whether you are healthy.\n- dreams: they're asking what PATTERNS, themes, or insights you've noticed across their notes.\n- task: they're asking you to go look into / research / investigate something.\n- capture: they're telling you something (a thought, a journal entry) rather than asking.\nReply with one word: retrieve, explain, status, dreams, task, or capture." module-attribute

Intent

Bases: StrEnum

RETRIEVE = 'retrieve' class-attribute instance-attribute
EXPLAIN = 'explain' class-attribute instance-attribute
STATUS = 'status' class-attribute instance-attribute
DREAMS = 'dreams' class-attribute instance-attribute
TASK = 'task' class-attribute instance-attribute
CAPTURE = 'capture' class-attribute instance-attribute

classify_floor(text)

The deterministic floor: an Intent for an obvious message, else None (escalate).

heuristic_fallback(text)

Model-free default for ambiguous messages: a question is a retrieval (blast radius = a wrong query, which is read-only and recoverable — note §1b); a statement is a capture.

classify_model(text, chat)

The model-earned step. chat(text) -> reply asks the pinned model to name the intent; parse the first intent word it returns. Forgiving: any unparseable/empty reply degrades to the deterministic heuristic, so a missing model never breaks the conversation.

classify(text, *, chat=None)

Floor first; earn the model only for the ambiguous rest (note §5).

mcp

The Ambassador's MCP surface — the palace as a tool server for the local model.

uv run --project ~/mind-palace python scripts/palace_mcp.py      # MCP over stdio

A harness (OpenCode, or anything that speaks MCP over stdio) spawns this process; it has no listener and no socket of its own, and it seals itself (Invariant 1) before it opens a store. It is the Ambassador's client of the core: every read is ONE command, query — a sentence of the query algebra (core.sentence, dn-query-sentence-algebra) compiled under the Ambassador's grant, widened by the hypothetical overlay the owner granted on 2026-11-04 — so an ill-scoped read is refused in code, not by the prompt, and the plan rides with every answer; writes are only the ones the grant's W_Σ allows — dialogue capture (provenance fixed by role, never by the text) and interpreted relation edges. Long operations (dream, relate, sync) wake models and run on demand.

--role guest serves an external agent instead (dn-guest-principal): query under the read-only GUEST grant, over the dialogue, the repo's code and docs, the papers and the observed records, never the notes or their interpretations, and overview; no write tool, no request, no status.

Protocol: JSON-RPC 2.0, one message per line (MCP stdio transport). initialize, ping, tools/list, tools/call; a line that is no request is answered with JSON-RPC's error for it, a request whose reply cannot be written with an internal error, and the server reads on (_answer, serve). Stdout carries protocol messages only. The launcher writes the replies to a copy of file descriptor 1 and points the descriptor itself at stderr (protocol_stream), and a tool runs with sys.stdout pointed at stderr (Server.handle), so what an operation, a library under it or a child process writes joins the diagnostics on stderr. The client that spawned the process holds both streams.

PROTOCOL_VERSION = '2025-06-18' module-attribute

SERVER_INFO = {'name': 'mind-palace', 'version': '0.1.0'} module-attribute

INSTRUCTIONS = Path(__file__).with_name('brief.md').read_text(encoding='utf-8').strip() module-attribute

GUEST_INSTRUCTIONS = 'A read-only view of a mind-palace instance. Ask with query: a sentence of the query algebra, not keywords, over the strata this grant reads: the dialogue (chat turns, transcripts and the documents written in them), reference (the repository\'s code and docs), curated (papers) and observed. Name them with over, as in near "<text>" over dialogue reference curated observed: near, diffuse S and a causal walk\'s endpoints read the owner\'s notes unless over names other strata, and over is a mask, so a walk from a turn to the files it wrote needs over reference. A clause over the notes or the interpretations derived from them is refused. So are assume, the version chains (trace, reach D) and every do request. Verbs: near, diffuse S from, reach F|C from, walk from <ref> via <regex over S, F, C>, witness, read "<ref>" (a repo path, code/<name>/<path> for a file of a repository the instance lands, transcript/<session>/<turn>, a dialogue ref, reference:<paper>). overview counts what this grant reads, shows the grant, and says when the instance embeds nothing: near then ranks by the lexical index, and S has no edges.' module-attribute

EMBEDDING_OFF = 'off: this instance embeds nothing; near ranks by the lexical index' module-attribute

GUEST_SCOPE_HINT = '; the guest grant reads dialogue, reference, curated and observed (name them with `over dialogue reference curated observed`, or some of them), never the mirror or the interpreted stratum, and has no overlay for `assume`, no version plane for `trace` or `reach D`, and no write bit for `do`' module-attribute

GUEST_RAN = {'lookup': 'a name in the sentence was not found in the strata this grant reads, or what it names cannot be read as text: spell a ref as an answer\'s `ref` is spelled (a repo path from the repository\'s root such as `core/query.py`, `code/<name>/<path>` for a file of a repository the instance lands, `transcript/<session>/<turn>`, a dialogue ref, `reference:<paper>`), name with `over` the strata a title is to be found in, and ask `near "<text>" over dialogue reference curated observed` for refs to start from', 'ambiguous': 'a name in the sentence fits more than one node of the strata this grant reads, or more than one commit; write the ref in full in place of a title, and more of the sha after `as of`', 'unsupported': 'the sentence compiles and the stores cannot answer it as written: `as of` takes a commit the citation graph holds a cut at, and a verb walks only the relations recorded for the nodes it names; drop `as of` or change the relation', 'scope': "a ref in the sentence names something outside the strata its clauses read: a transcript turn is read by walking C or under `over dialogue_transcript`, and `read` returns a record only of the stratum its ref's spelling names", 'sort': "the sentence's sorts did not compose when it ran; give each connective the sorts its grammar takes", 'parse': 'the sentence could not be read when it ran; write one sentence of the query algebra', 'busy': 'the instance is busy and took no request; ask again later', 'error': "the sentence failed while it ran, for a reason this surface does not show; the instance's query log keeps it for the owner"} module-attribute

GUEST_OVERVIEW_FAILED = 'the overview could not be counted on this instance, for a reason this surface does not show; `query` may still answer' module-attribute

TOOLS = [('query', 'The one read: a sentence of the query algebra, not keywords. Verbs: near "text" | diffuse S from <note> [beta b] | reach F from <note> [depth n] [back|forward] | relate <note> | trace <note> | walk from <note> [to <note>] via <regex over S,F,D,C> | witness "<edge id>" | read "<ref>" [chunk n] (the full text; read before quoting). Connectives and, or, minus, then; adjectives within <region>, over <strata>; top k, atleast t, far, not; assume <rel> <a> <b> [+w] in <sentence> (a hypothetical: the answer is a Hyp, never a fact). A <note> is a quoted path or title. Papers: over curated. Example: top 5 (near "sleep" and diffuse S from "health.md"), the five best of the product; top k takes its field with the field\'s adjectives, so top 5 near "x" within <region> ranks within it. The plan rides with the answer; a refusal names the word that would fix it; trace: true shows the work: the parse, every rewrite with its law, the support\'s census, each clause\'s arithmetic, the ranking.', _schema({'sentence': _S, 'trace': {'type': 'boolean', 'description': "show the work: the parse, the rewrites and their laws, the census, each clause's arithmetic, the ranking"}}, ['sentence']), 'query'), ('overview', 'Counts per stratum and relation type; your grant.', _schema({}, []), 'overview'), ('sync_dialogue', 'Sync new Open WebUI and OpenCode chats into the palace now.', _schema({}, []), 'sync_dialogue'), ('sync_notes', "Re-ingest the owner's changed notes (a `do sync vault` request the daemon lands).", _schema({}, []), 'sync_notes'), ('capture', "Remember text you relay, stored as observed, never as the owner's words (a `do capture` request the daemon lands).", _schema({'text': _S, 'conversation': _S}, ['text']), 'capture'), ('status', 'Palace processes and jobs (ingestion, imports) with progress, models, services, store sizes, open and due items.', _schema({}, []), 'status'), ('task_list', "The owner's open tasks and reminders, and running jobs.", _schema({'include_done': {'type': 'boolean'}}, []), 'task_list'), ('task_add', 'Track a task for the owner; due is optional.', _schema({'title': _S, 'detail': _S, 'due': _WHEN}, ['title']), 'task_add'), ('task_update', 'Change a task or reminder: status open/waiting/done/dropped, a note, or a new due.', _schema({'id': _I | {'maximum': 10 ** 9}, 'status': {'enum': ['open', 'waiting', 'done', 'dropped']}, 'note': _S, 'due': _WHEN}, ['id']), 'task_update'), ('remind', 'Remind the owner at a time.', _schema({'text': _S, 'at': _WHEN}, ['text', 'at']), 'remind'), ('link', 'Propose a relation between two notes, stored as interpreted (a `do link` request the daemon lands).', _schema({'note_a': _S, 'note_b': _S, 'relation': {'enum': ['supports', 'contradicts', 'contextualizes']}}, ['note_a', 'note_b', 'relation']), 'link'), ('dream', 'Request one dreaming pass (a `do dream` request; minutes, in a trough, wakes the large model).', _schema({}, []), 'dream'), ('relate', 'Request a relation pass among similar notes (a `do relate` request; minutes, wakes the large model).', _schema({'max_pairs': _I}, []), 'relate')] module-attribute

GUEST_TOOLS = [('query', 'The one read, under a read-only grant over dialogue, reference (the repository\'s code and docs), curated (papers) and observed: a sentence of the query algebra, not keywords. Verbs: near "text" | diffuse S from <ref> [beta b] | reach F|C from <ref> [depth n] [back|forward] | walk from <ref> [to <ref>] via <regex over S,F,C> | witness "<edge id>" | read "<ref>" [chunk n]. Connectives and, or, minus, then; adjectives within <region>, over <strata>; top k, atleast t, far, not. Name the strata with over, separated by spaces: near "x" over dialogue reference curated observed. A refusal names what the grant reads; trace: true shows the work.', TOOLS[0][2], 'query'), ('overview', 'Counts over the strata this grant reads; your grant.', _schema({}, []), 'overview')] module-attribute

ROLES = ('ambassador', 'guest') module-attribute

Ambassador

Tool implementations. Stores and the launcher open lazily, once per process.

engine = QueryEngine() instance-attribute
launcher property
query(sentence, trace=False)

A sentence of the query algebra (dn-query-sentence-algebra) under sentence_grant() — the Ambassador's grant with the overlay the owner granted: the plan rides with the answer, a refusal names the word that would fix it, a hypothetical answers as a Hyp beside the actual answer, and trace shows the work. Logged as mcp/ambassador (the query log, the sensor).

overview()
sync_dialogue()
sync_notes()
dream()
relate(max_pairs=12)
capture(text, conversation='captures')

Remember text the MODEL relays (a summary, a decision it was asked to remember) as an observed dialogue turn, by the ingress, under dialogue/ingress/ambassador/<conversation>/. Never authored: only the owner's own turns, synced from their chat app, carry authored provenance. A conversation is a name, not a path.

Propose a signed relation between two notes, stored as interpreted, by the ingress.

status()

The ecosystem at a glance, read-only and local: jobs (ledger and live processes), models, services, store sizes, and what is open or due.

task_add(title, detail='', due='')

Track a task for the owner, with an optional deadline.

remind(text, at)

Bring something up at a moment: it appears among the due items from then on.

task_list(include_done=False)

Open tasks and reminders, running jobs; recently finished ones on request.

task_update(id, status='', note='', due='')

Change an item's status, add a note, or move its deadline.

GuestRefusal

Bases: PermissionError

A refusal as the guest reads it: its class, then what the surface says of it, one of two texts (_refused chooses). A sentence the compiler refuses is told the compiler's reason with every quoted run replaced by its length (redact_reason): compiling reads the sentence and the grant and no store, so that reason holds the asker's own words and nothing a store holds. A sentence refused while it ran against the stores is told one fixed sentence for its class (GUEST_RAN), never the reason, which may quote what a store holds and which the redaction, pairing quotes by position, does not reliably hide. A scope refusal of either kind adds what the grant reads.

Guest

The guest's tools (dn-guest-principal): the one read under GUEST, and counts over the strata it reads. No write tool, no request, and no status, which lists the owner's tasks. A tool's body raises GuestRefusal and nothing else, whatever fails in it: the engine is built on first use, inside the body, so a configuration or a store that cannot be opened is a refusal too.

engine property writable
query(sentence, trace=False)

A sentence under GUEST, logged as mcp/guest. The universe withholds what the stores say of the notes (hide_mirror); a refusal is a GuestRefusal, its text chosen by _refused.

overview()

The catalog's active entries of the classes the grant's strata hold, the curated store's chunks, and the grant; then what the Ambassador's overview says of the lite profile (dn-palace-lite), over the same classes: that the instance embeds nothing, when it is so; the lexical index's current units of those classes; and each repository of a lexical code source, with the commit it last landed and how far its ref has moved since. Nothing of the mirror or the interpreted stratum is counted, not even in a total. A failure is a GuestRefusal of one fixed sentence.

Server

The protocol, for one principal: the Ambassador's surface by default, or the guest's (role="guest": GUEST_TOOLS, GUEST_INSTRUCTIONS, the Guest tools).

role = role instance-attribute
tools = GUEST_TOOLS if role == 'guest' else TOOLS instance-attribute
instructions = GUEST_INSTRUCTIONS if role == 'guest' else INSTRUCTIONS instance-attribute
amb property
handle(msg)

The reply to one message, None for a notification. A message that is not a request object (an array, which this protocol version has no batch for, a number, a string, null), an id that is no string or number, and params that are not an object are each refused with JSON-RPC's invalid request, the id null when the request's cannot be used. initialize answers with the protocol version the client asks for when it is a string and with the server's own otherwise, as MCP answers a version a server does not support: a value of another type is not repeated, so no nesting a client sends there makes a reply that json.dumps cannot write.

code_sources(cfg)

Each repository of the lexical code source (dn-palace-lite): the commit whose files it last landed whole, when, and how many commits its ref has moved past that since, so a reader knows how current the code stratum is before trusting an answer from it.

protocol_stream()

The process's stdout, kept for the protocol alone. File descriptor 1 is copied to a descriptor of its own for the replies, one a child process does not inherit, and then pointed at stderr's file, or at the null device when the process has no stderr. Whatever writes to descriptor 1 from then on, C code, a child process that inherits it or sys.__stdout__, lands with the diagnostics and never in the stream the client reads; Server.handle points sys.stdout at stderr as well, for a stream that is not descriptor 1. The launcher (scripts/palace_mcp.py) serves on it.

serve(stdin=None, stdout=None, server=None)

Speak MCP on stdio for server, the Ambassador's surface when none is given.

policy

The two cross-cutting build deltas (authoritative note §5): effort narration + the earned-interruption policy.

Both follow "model advises, code acts": the judgment ("is this worth raising?", "what to say") may be model-advised, but the policy (whether to deliver an unprompted message at all, the default-off knob) and the register (plain language, never internals) are plain, testable code.

LEAKY_NOUNS = ('synthesis', 'tier', 'queue', 'job', 'token', 'accessor', 'signature', 'sqlite', 'lancedb', 'embedding', 'vector', 'attestation', 'ledger', 'podman', 'ollama', 'qwen') module-attribute

TASK_PREFIXES = ('look into whether', 'look into', 'dig into', 'dig through', 'investigate', 'find out whether', 'find out', 'figure out', 'research whether', 'do some research on', 'do some research', 'can you research', 'go research', 'explore whether', 'look at whether', 'cross-check') module-attribute

RESEARCH_CUES = ('research on', 'research about', 'research into', 'the research on', 'recent research', 'papers', 'literature', 'studies on', 'the studies', 'publications', 'scientific', 'clinical trial', 'clinical trials', 'meta-analysis', 'meta analysis', 'systematic review', 'peer-reviewed', 'peer reviewed', 'academic', 'the evidence on', 'what does the science', 'what does the research') module-attribute

Sensitivity

Bases: StrEnum

OFF = 'off' class-attribute instance-attribute
EARNED_ONLY = 'earned_only' class-attribute instance-attribute
VERBOSE = 'verbose' class-attribute instance-attribute

InterruptionPolicy dataclass

Whether the Ambassador may speak UNPROMPTED. The "would the owner want this raised?" judgment is the model-advised part; this policy is the code that acts on it, and the owner-tunable default is EARNED_ONLY (note §3 — "not a silent oracle, not a nag").

A single dial (off / earned-only / verbose) is shipped; per-category sensitivity is left a documented future extension (note §7 leaves it genuinely open — avoid the premature- abstraction trap on an axis nothing uses yet). Expected updates (a result the owner asked for) are NOT governed by this — those are always delivered; this gates only the unprompted.

sensitivity = Sensitivity.EARNED_ONLY class-attribute instance-attribute
admits(worth_raising)

topic_of(text)

A short topic for a delegated request — strip the delegation verb, cap the length. Shared by the effort narration and the delegated-result surfacing so they read consistently.

is_research_request(text)

True when a TASK message asks for EXTERNAL literature grounding (the airlock), not a dig through the owner's own notes. Conservative: an explicit literature cue is required, else the request stays on the mirror path (the safe default — external-grounding.md §2.5).

narrate_effort(topic='')

Plain-language "I need to go work on this" — the RIGHT register (note §4): honest about the wait + the rough plan, never the plumbing. A pure function from "what was delegated" to one plain sentence (unit-tested to leak no internal noun).

parse_sensitivity(value)

Tolerant config parse — an unknown value degrades to the safe default (earned-only).