AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).
fix(memory): let a name reach a lesson and keep the grader's proof to the person's words (#551)
Rufus528e546db923
diff --git a/packages/core/openexecutive/architecture/architecture-facts.yaml b/packages/core/openexecutive/architecture/architecture-facts.yamlindex c2873352..8e8e1767 100644--- a/packages/core/openexecutive/architecture/architecture-facts.yaml+++ b/packages/core/openexecutive/architecture/architecture-facts.yaml@@ -5141,7 +5141,9 @@ chat:requirement, re-checked on every render. Stored in chat_review_lessons(shared = learned in a channel or group thread that never read mail); chat_review_lesson_usesrecords which turn id, and whose, saw which lesson. Reaches a turn by keyword match (two shared content words- between lesson+quote and the message; no vector index): the Executive's+ between lesson+quote and the message, or the name the lesson defines, like+ "Atlas means ..." or "your name is R2", written mid-sentence in the message;+ no vector index): the Executive'sturn as a <lessons> user-turn block (build_lessons_block, counted asshown against the active turn id), each specialist call under its<failure_cases> block (router._lessons_for_call). A lesson reaches itsdiff --git a/packages/core/openexecutive/architecture/prebuilt/memory.json b/packages/core/openexecutive/architecture/prebuilt/memory.jsonindex 76dd5bf6..d907cc0e 100644--- a/packages/core/openexecutive/architecture/prebuilt/memory.json+++ b/packages/core/openexecutive/architecture/prebuilt/memory.json@@ -1,7 +1,7 @@{"section_id": "memory","title": "Memory System",- "markdown": "The Executive's durable memory is an episodic SQLite store at `./episodic_memory.db`, managed by `openexecutive.memory.episodic`. It holds four tables:\n\n- `decisions` — choices made, with `domain`, `summary`, `rationale`, `outcome`, and `tags`. `outcome` is filled in when the principal says how a decision turned out — the `record_decision_outcome` chat tool (principal on a verified surface only) or the Memories page. The weekly review reads this table twice: the week's decisions (`decisions_since`) and up to three older than 30 days with no outcome yet (`decisions_awaiting_outcome`), which it asks about.\n- `initiatives` — tracked efforts with a `status` and `summary` (idempotent upserts).\n- `advice_given` — query/advice pairs per domain.\n- `scheduled_actions` — a dispatch queue, treated separately from recall memory. `cancel_scheduled_action` guards its UPDATE on `status = 'pending'`, so a cancel never overwrites a row the scheduler claimed a moment earlier.\n\n### What gets extracted, and when\n\n`episodic.extract_and_store` runs after a turn and asks a utility-fast model for decisions, initiatives and advice. Every candidate must carry a `user_commitment_quote` that appears verbatim in the principal's own message (`_is_valid_user_commitment`) — the turn's speaker text (`memory_text` when the entry point supplies one, else the prompt), so a quoted Executive email or a briefing card's body inside the prompt cannot satisfy it — the model has repeatedly tried to log the Executive's *recommendations* as the user's commitments, and that quote is the hard gate against it.\n\nA turn reaches the extractor if `should_extract(speaker_text, session=...)` is true, which means only that the principal said something on a surface that proved it was them — there is deliberately **no length floor**. There used to be one, on the combined user+assistant length, and on a live tenant it selected almost exactly the wrong turns: 9 of 16 exchanges were blocked, and the 9 held every instruction the principal gave, while the 7 admitted were long analytical exchanges with no commitment in them. The extractor ran 13 times and stored nothing.\n\nMoving that floor to the user's side would relocate the bug, not fix it. The canonical executive decision is a long analysis answered with \"Approve option B.\" (17 chars) or \"Do B.\" (5), and any floor high enough to skip \"Done\" (4) also skips those — \"Do B.\" and \"Done\" differ by one character and mean opposite things. Length cannot separate a decision from an acknowledgement; the verbatim-quote check can, so `_is_valid_user_commitment` is the gate that decides. The price is one utility-fast call on turns that propose nothing.\n\nThat quote check is only meaningful when `user_message` holds the **principal's** words, and on a chat channel it does not — `Executive.chat()` is reached from Slack, Discord, Telegram, Google Chat and the email poller. A teammate's line would be written to `decisions` with no speaker attached, indistinguishable from the principal's own; an inbound email body is text the sender chose, so a self-quote is free. Removing the length floor is what makes this bite — short channel traffic used to fall under it incidentally — so `should_extract` asks the untrusted-content policy (`orchestrator.content_trust.principal_speaking`) whether the principal is speaking. It names the principal's surfaces rather than inferring them: the web chat (signed in as the principal — or, on an install with no principal on the People page yet, a request that carried no sign-in; a signed-in email on nobody's entry, such as an archived teammate still allowed to sign in, is not the principal), the CLI (`Session.from_cli`), the principal's own Slack or Discord or a private Telegram chat with a valid webhook secret (`people_tools.is_principal_on_verified_surface`), and email from the principal's primary address that Gmail's own `Authentication-Results` marks `dmarc=pass` (`Session.email_authenticated`). Everything else fails closed: a teammate (on the web too), an unrostered sender, the principal's address on mail Gmail did not authenticate, Google Chat, the MCP server (its caller names themselves), unattended runs, and an unreadable roster. The rule used to be \"no `origin_channel` means the principal's own surface\", and the email poller left `origin_channel` empty, so every stranger's email ran through the extractor with its body — headers, quoted chain and all — as the principal's words, and whatever it stored rendered on every later turn. The poller now tags its sessions `origin_channel=\"email\"`, and the gate no longer reads an empty channel as trust.\n\nThe extractor also reads only the words **outside** every `<untrusted_content>` block (`schedule_extraction` runs `content_trust.strip_untrusted` first): an attached document's text is inlined in that block, so a sentence the principal did not type can never be quoted back as their commitment, and a turn that is nothing but an attachment is not extracted at all.\n\nEach pass writes a `memory_extraction` audit row — in a `finally`, so a pass that crashed is recorded too, with the exception type as its `failure` reason: how many items the model proposed, how many were stored, a `malformed` count so a pass where the model returned only garbage does not read as one that found nothing, and a `{kind, reason}` record per drop — `bad_quote` and `missing_field` for an item the model proposed, `not_a_list`, `item_not_a_dict` and `payload_not_a_dict` for a shape that was never a usable item. Every proposed item is either stored or dropped, so `proposed == stored + item drops` is the arithmetic that says whether anything was lost silently. The tool payload is not schema-checked anywhere, so a malformed shape is counted as a drop rather than raised — it used to abort the whole pass, discarding the other two kinds with it and suppressing the row, which read exactly like \"extraction never ran\". Without it, \"the model found nothing\" and \"the model found things and every one was rejected\" are indistinguishable from outside the database — which is why the failure above survived undetected and took a SQLite session on the tenant to find. A `proposed>0, stored=0` streak is the signal to watch.\n\nThe validator rejects a paraphrase, and the model paraphrases: on one install two of three real commitments were lost that way, the quote beginning \"SVN's engagement covers only …\" where the person had typed something else. So a `bad_quote` drop earns exactly one corrective call. The model is shown the rejected items and the quotes it gave, told to copy the span character-for-character (typos and casing included) or return empty arrays, and the tool is forced where the provider supports tool choice. Every retry item is validated first; a still-invalid one adds no second drop and is counted `still_invalid`. A valid item is then classified in order: its label matches a pending drop record → a recovery, stored and the record released; else its quote (terminal punctuation ignored) already supports a stored item of that kind → a re-send, ignored and counted `repeated`, so a model that re-sends everything cannot double-count `stored`; else a new proposal, stored and counted — a reworded label cannot be told from a different item, and crediting it would erase the very `bad_quote` census the row exists to show, so its original drop stands. Recovery is checked before re-send because two commitments can rest on one sentence. Malformed shapes at any level — a kind that is not a list, an item or payload that is not a dict, a response with no tool call — are counted `malformed`, so a retry that returned garbage does not read like one that obediently returned nothing. The row's `retry` block (`rejected`, `recovered`, `repeated`, `still_invalid`, `malformed`, `failure`) is always present, zeros when nothing was rejected; `rejected` is set from the complete drop list when the row is written, so neither a store failure before the retry nor a cancellation during it can zero it. The arithmetic above still holds after the retry. An exception on the retry is recorded as the retry's own `failure` and leaves the first pass's results untouched; the cost is one utility-model call, only on turns that dropped something. `memory_extraction` is a declared event type, so the audit page's filter can select it.\n\n### Standing facts (corrections that persist everywhere)\n\nA fifth table, `facts` (`openexecutive.memory.facts`, created on first write), holds facts and corrections the principal stated and asked to keep — \"Maple House is 48 units, not 52\". Before it, a chat correction's only durable home was Honcho peer memory: optional, best-effort (its prefetch times out or errors under load), re-injected only into that person's later chat turns, and never read by the briefs, the scheduled runs or the alert review. The episodic extractor cannot hold one either: it stores only decisions backed by a commitment quote, and a fact is not a commitment.\n\n- **Written from chat, by the principal or an attributed teammate.** `remember_fact` stores one (subject, statement, optional wrong value) and `forget_fact` retires one. The principal on a verified surface may do both. A teammate on the People list (a `team` row, not archived, not a contact) on a verified surface (the web app signed in, their own Slack or Discord; `fact_tools._teammate_speaker`) may call `remember_fact` only; email, Google Chat and unrostered senders are refused. Both tools are withheld from every unattended run and every turn private to the principal. Every call, `forget_fact` included (retiring a fact changes what later prompts treat as true just as writing one does), also needs `source_quote`: at least two words and eight characters, found in what the speaker typed this turn (`delegation.settings.own_words` over the pinned `TurnDelegation.speaker_text`). The `<outbound_reply_context>` backstory a Slack or Discord reply is hydrated with is stripped first, and a message with an attachment is refused outright. The quote alone only proves the principal asked, so everything `remember_fact` stores and renders (the statement, the subject shown as `[fact N] subject:`, and a previous value shown as `(corrects: …)`) is tied to their words too. An omitted previous value falls back to the replaced fact's own statement. Every figure must be a number they wrote, compared at its magnitude: `$180k` matches `180,000`, but `180m` never lets `$180k` through. Every name must also appear in what they typed: a capitalised word, or any word holding a non-ASCII letter, other than the statement's very first word (a statement is one fact, so splitting a document's names into one-word sentences exempts nothing). So must every month, weekday or quarter. A name the model writes in lower case is not caught: the gate narrows what a real quote can carry in; it does not prove a paraphrase. A real quote therefore cannot carry a document's figure, name or date in with it (\"Cedar Court's lease expires in March\" after \"remember what the lease doc says\"), while a paraphrase of what they said still passes. So the model cannot store its own inference, a document's figure or text quoted back at the principal as something they said. Every audit row the tools write, and the chat loop's `skill:` dispatch row for them (whose input quotes the principal verbatim), is private to the principal (`executive._private_tool_row`). Those rows tie a fact to the principal's session and turn, which `GET /memories/facts` hides from teammates, and a teammate can read any non-private audit row. The handlers run in a worker thread (`asyncio.to_thread`, which carries the turn's context), and the chat and committee paths, the alert review, the morning brief's synthesis and the end-of-day, weekly-review and reflection workflows read the block the same way, so SQLite, the profile file and its lock never block the event loop the SSE streams share. The principal's own email may ask too: the change is checked the same way, then held until they confirm it by replying to a one-time token sent to their own address (see Integrations → Standing facts by email).\n- **Provenance and attribution.** Each row keeps the quote, the channel (`web` or the adapter), `session_id`, `turn_id`, the recording person and the time, plus `recorded_by_role` (`principal` or `teammate`) and, for a teammate, `recorded_by_name` as the People list had it. Rows written before these columns existed read as the principal's (`_migrate` adds the columns on the first write; the read-only render tolerates a DB that has none).\n- **One active fact per subject.** A new row supersedes any active row with the same folded subject key, or the id named in `replaces_fact_id`, in one transaction. The old row stays as `superseded` (with `superseded_by`), and the new one is stored as a `correction` carrying what it replaced. Retiring sets `retired` with a reason. **The principal outranks a teammate:** a teammate's write that would replace an active fact the principal set (by subject or `replaces_fact_id`) raises `PrincipalFactConflict`, and the tool stores it as `proposed` instead, naming the fact it would replace (`replaces_fact_id`); teammates replace each other's facts freely, and the principal replaces anyone's. **\"Needs my approval\"** (`fact_approval_rules`, per teammate, **on by default**, set only by the principal) stores every fact from that teammate as `proposed`; the principal turns it off for a teammate they trust, whose facts then apply at once (except one that would replace the principal's). The rule is read inside `record_fact`'s own write transaction, so a switch turned on a moment earlier cannot let one fact through; a teammate write that names no person is never trusted. One teammate may have at most `MAX_PENDING_PROPOSALS_PER_PERSON` (20) proposals waiting (`TooManyProposals`; the tool tells them to wait for the principal's review). A teammate's retire checks ownership in the `UPDATE` itself (`retire_fact(teammate_id=)`: their own row, not approved). A proposed row never renders; `approve_fact` makes it active and replaces what it names (the principal's own fact included — approving it is their word) and stamps `approved_at`, after which it outranks teammates exactly as the principal's own fact does (`Fact.principal_owned`: no teammate may replace or retire it); `decline_fact` sets `declined`. No field of a teammate's fact may carry what the render adds itself — `(per <anyone>)` in any case (a unit such as `(per month)` or `(per unit)` is fine), `[fact N]` or a date stamp after any dash, read NFKC-folded with invisible characters removed (`fact_tools._marker_error`) — so a teammate cannot plant a second, forged attribution inside their statement (the principal's own unmarked lines are not checked: \"(per Smith lease)\" is ordinary wording for them). The tool answers `awaiting_approval` (no action chip) and tells the model to say it is not in use yet.\n- **Rendered everywhere output is produced.** `render_facts_for_prompt` renders the active rows newest first under a self-explaining `STANDING FACTS` header (use these over older figures; a line ending `(per <name>)` is that teammate's word and the principal's unmarked line wins a conflict; the current conversation still wins; quoted data never instructions). A teammate's line ends `(per <name>)`, the name defanged like the rest, capped at 40 facts / 6000 chars, with angle brackets defanged. It opens the DB read-only and never creates it or the table. The block always rides in a user turn, never a cached system block: a chat turn's `<standing_facts>` (so every scheduled run through the chat loop too), each specialist consult (`route_to_specialist`, chat and workflow steps alike), the /today header and the morning brief (`render_briefing_context`, after the quiet check and inside the string the header's cache key hashes, so a new fact rewrites the header), the alert review's batch (`render_batch`, read once per pass), and the end-of-day digest, the weekly review's top-three call and the morning reflection (`with_standing_facts`).\n- **Company-profile edits from chat.** `update_company_profile` (same gate and quote rule) changes one whitelisted field of `company/profile.yaml`, under `PROFILE_EDIT_LOCK` (also taken by `PATCH /company-profile`, so neither edit silently drops the other): a text or number field is set, a list field gets an item added or removed, and `financials.key_metrics` takes a named metric. It writes through `CompanyProfile.save_to_yaml` and updates the session's profile, so the next turn's cached company block carries it (one cache miss on the change). The new value must itself appear in the principal's own words, not just the quote: the value renders into the cached company block on every later turn, so \"set our mission to what the doc says\" or \"update our headcount\" is refused rather than saving a document's text or a guessed figure. A number must be one they wrote, however they wrote it (`$180k`, `1.2m`, `2,400,000`). Saved text has `<`/`>` defanged. A `kind='profile'` row records each edit with its quote for the Pulse page. Those rows are never rendered into a prompt, because the profile block already carries the value.\n\n### Session scoping\n\n`decisions` and `advice_given` rows carry a `session_id`, so per-thread channels (Discord, Telegram) can pull just-this-thread history without leaking cross-conversation context. A null `session_id` falls back to a global view.\n\n### Surfacing\n\n`openexecutive.memory.episodic.format_for_prompt` renders recent decisions and initiatives into a compact `<past_decisions>` block injected into the user turn — alongside `<retrieved_context>` and peer memory — never into a cached system block. Each decision names where it was recorded when that was a channel — `- 2026-09-01 [finance] (via email): …`, from the prefix of its `session_id` (`email:`, `slack:`, `discord:`, `telegram:`, `google_chat:`); a web or CLI decision has no tag. Rows extracted from mail before the untrusted-content policy, when any sender's body could be stored, therefore read as mail rather than as the principal's own word.\n\nScoped to a session, decisions and advice cover every conversation of a chat app's stream (`memory.conversation_ids.family_clause`): a Telegram chat or a DM is cut into conversations after two quiet hours or a /new (`memory.conversations`), and what an earlier conversation decided still renders in the next.\n\nThe chat route also injects a `<briefing>` block into the same user turn: a compact digest of the current open (unread) alerts, built by `openexecutive.briefing.context.format_open_alerts_for_prompt` (company-wide, `status=\"unread\"`, mirroring `/today`). This is what lets the Executive discuss a briefing item the principal clicked or named on `/today` (e.g. \"Gulf Coast Port Cyberattack\"). It is resolved in parallel with the other context fetches, omitted when there are no open alerts, and never placed in a cached system block.\n\nOn the Pulse page the Memory section shows the three lists as Decisions, Initiatives and Advice tabs, then a **Corrections** tab (`GET /memories/facts`: active standing facts and profile edits with their quote, channel and — for a teammate's — their name; proposals first under \"Waiting for your approval\" with **Approve** / **Decline** for the principal; the replaced, retired and declined history folded away; **Retire** on any fact for the principal and on their own not-yet-approved one for a teammate; and, for the principal, a per-teammate \"needs my approval\" switch), and a **History** tab for the person's own Always in the loop notes (see below). The header's Memories tile counts the three lists. What peer memory has learned about the signed-in person is theirs alone, so it is not on Pulse: it is on **Settings → About you** (see the peer memory section).\n\nThe same user turn carries a `<drive_memory>` block when the conversation has touched Google Drive (`openexecutive.memory.drive_reads`). Drive is reached only as live Google Workspace calls inside a turn and history keeps only prose, so without it a file found one turn was gone the next. `MCPGateway.call_tool` hands each `search_drive_files` and `get_drive_file_content` result to `record_drive_result`, which keeps, per session, every file found or opened (file id, name, type, link, and for an opened file its first 600 characters) and every search that matched nothing, with its query. `format_drive_memory` lists the 20 most recent files, so \"the file you found earlier\" resolves to a file id the Executive reopens rather than searching again, and the queries that found nothing (dropped once the same query later finds something). Rows are keyed on the session *and* the speaker, and shown only to that speaker in that session, because one session can span several people (an email thread, a Slack or Discord thread). Nothing is recorded or shown without a bound `current_session` and a rostered speaker, on a turn private to the principal, or on one that touched the speaker's own mailbox (Act as me). workspace-mcp writes file names into its output unescaped, so a name containing a newline can forge a result line. Only a Drive-shaped file id, type and `docs`/`drive.google.com` link are therefore kept; any other line is dropped, and the name is always quoted as the file's own content, not instructions. Each speaker keeps at most 100 files and 100 searches per session, older rows are pruned on write, and `session_store.delete_session` drops them all.\n\nThe scheduler reads one more thing from the transcript: when a follow-up back to the person who set it fires, `session_store.own_messages_since` gives it that person's own messages since it was set (their words only, across their conversations, capped), so a follow-up whose reason was already settled in chat stands down instead of sending (see the scheduler section).\n\nA conversation can also become its owner's alone. When Act as me first reads the speaker's own mailbox in it, `session_store.mark_mail_private` sets `sessions.mail_private` (creating the row with its owner when a channel adapter hasn't written it yet), and from then on only the session's owner may open, continue or delete it — the principal included, when it is a team member's (`chat._session_access`). It is never cleared. Beside it `sessions.mail_read_at` keeps how many history messages the conversation held before the last turn that read the mail (`session_store.mail_read_at`; NULL on rows marked before the column): Act as me's hold on links and scripts in later turns lasts only while that turn is still in the history window (see Act as me). \n\nThe chat list has owner controls on the same row: `sessions.pinned_at` (pinned chats list first) and `sessions.title_locked` (set by `rename_session`, after which `update_session_title`, the automatic title, leaves the name alone). Chats are also grouped by topic for their owner (`memory/chat_topics.py`): a `chat_topics(id, owner_person_id, name, kept, pinned_at, created_at)` row per topic, unique per owner and name (any case), and `sessions.topic_id` with `sessions.topic_source` (NULL = not looked at, `auto` = chosen by the model, `owner` = filed by the owner and never refiled). The one utility-fast call that titles a new chat (`utils/chat_topics.name_chat`, from the web chat and the chat-app conversations) also picks its topic, reusing one of the owner's 60 most recent topic names or making a new one. Only when the owner alone has written in the chat: a channel or group conversation, a shared chat, or one where someone else wrote first is titled without the owner's topic names in the prompt (another writer could steer the title into repeating them) and is filed later by the backfill, whose answer only the owner sees. Each call is bounded by the utility-fast timeout (60 s for a backfill batch). Only a turn that makes a new topic costs a second short call, over the topic names alone, which merges it into an existing topic that means the same unless the owner has `kept` it (renamed, pinned, merged into or filed a chat under it). Chats from before, or whose naming failed, are filed from their titles in batches of 80 the first time the owner opens the Topic view (`backfill`; a failure waits 10 minutes). Topics left with no chat are dropped when listed. Related topics share an `area` (`chat_topics.area`, `area_kept`): one property, deal or client, shown as one heading over them. The same second call that checks a new topic also names the area it shares with related ones, and after the backfill one call over the names gives areas to topics not yet looked at (once the owner has three); an area counts only when two topics share it. An area the owner renamed or ungrouped is left as they made it. A `session_shares(session_id, person_id, shared_by_person_id, created_at)` row adds one team member to someone's chat (`list_shared_with_person`, `set_shares`, `leave_share`): they read and write in it with its owner, each of their messages saved with their own `sender_person_id`; a `mail_private` chat is never shared or opened that way, and deleting the chat drops its shares. `last_turn_sender` says who wrote the last turn, which is how redo stays with the person who asked. The chat list's preview puts `You:` only before the caller's own words. `rewind_last_turn` deletes a web chat's last turn (the last reply and the user messages after the reply before it) so it can be asked again; the next turn's history is re-read from these rows, so nothing else needs clearing. A search that matched nothing also gains a note in its tool result: say the exact query and that it found nothing, never that the file does not exist. This is a first step: Drive is still not indexed into the company collection.\n\n### System of record\n\nSQL is the system of record; the peer-memory service is a recall layer mirrored from it, not a replacement. When `store_decision` / `store_initiative` / `store_advice` insert a row whose `department` is non-empty and not `\"general\"`, the row is mirrored as a kind-tagged note into that department's peer via `append_department_note`. The mirror fires only after a successful INSERT, is fire-and-forget, and never rolls back the SQL row on peer-memory failure. `scheduled_actions` is never mirrored — it is a queue, not memory.\n\nThe episodic extractor still learns only from the principal's own words. Commitments and asks from everyone else on the roster are tracked as **open loops** (see Attunement) — `scheduled_actions` rows with `kind='open_loop'`, opened and closed by a separate quote-gated pass after each attributed turn. That pass depends on `chat_messages.sender_person_id`, which records who actually wrote each persisted user message. An open loop counts toward `list_awaiting_replies_by_person` only once it is due, and `list_scheduled_actions(exclude_internal=True)` filters `__internal__` rows in SQL so readers that want real sends are not starved by them. `mark_outbound_context_consumed` also resolves the Attunement outcome row for that DM as `replied` — a matched reply is the clearest sign proactive outreach landed — and a real change to an existing initiative (`store_initiative` / `update_initiative`, new status or summary) marks the updater's own check-in nudges `acted` — an update with no known updater, such as `PATCH /memories/initiatives/{id}`, credits nobody.\n\n### Workspace settings\n\nThe same database holds one row of settings that are not memory: `workspace_settings` (`openexecutive.memory.workspace_settings`) — the install's mode (`team` by default, or `solo` for one person using Open Executive just for themselves), the user's IANA time zone, the principal's role (`PrincipalRole`: `role_kind`, `role_title`, `reports_to`, `remit`, `measured_on`, all nullable; only solo mode reads it), and the company's own email domains (`company_domains`, a JSON list, or NULL to derive them from the principal's primary address — `people.identity` matches a teammate by local part on them; `validate_company_domains` lowercases, dedupes and sorts, allows at most 10 plain DNS names and refuses a free-mail provider's, and a stored value that no longer validates reads as NULL). It is a table of its own rather than a company-profile field because onboarding rebuilds the profile from scratch. Every read is fresh and read-only (a missing file or table reads as the defaults; a table from before the role or `company_domains` columns reads them as unset and is migrated additively by the next init or write). A read error (a locked database, say) also reads as the defaults, so `get_workspace` then says team; `read_stored_mode` is the strict read of the mode alone — None when the row cannot be read or holds no valid mode — for the scheduler's weekly-review check, which must not take a failed read for team. A session may carry an explicit `workspace_mode` override; otherwise the mode is read fresh at the start of each turn and pinned on the session for that turn only (`Session.turn_workspace_mode`, via `pin_turn_workspace_mode`), so every tool handler in the turn sees the mode its persona and tools were built in. `effective_workspace_mode` reads override, then the pin, then the setting; `effective_principal_role` reads a session's `principal_role` override, then the role pinned for the turn (`Session.turn_principal_role`, via `pin_turn_principal_role`), then the stored role. See Org for what solo changes and Scheduler for the time zone.\n\n### Act as me\n\n`initialize_db` also creates Act as me's per-person tables (`delegation.schema.ensure_schema`): `delegation_settings`, `delegation_voice` and `delegation_voice_history`. They hold a setting and a writing profile rather than memory, and nothing in them is mirrored to peer memory. A turn that touched the speaker's own mailbox teaches no memory: the episodic, open-loop and working-style passes are skipped along with the Honcho peer and department syncs, since its reply quotes a draft built from other people's mail. See **Act as Me (Delegation)**.\n\n### Always in the loop (notes of what you said)\n\nA person can keep private, dated notes of what they said, in chat with the Executive and in email replies it drafted for them: what they promised, agreed, declined, answered, asked for or shared. The switch is per person (\"Keep track of what happens\", `history_person_settings.reply_notes`, off by default, one switch for every channel). Any team member on the People list may turn it on (`history.can_keep_notes`: kind `team`, not archived, the principal included); Act as me isn't needed, though notes from email replies only come through it.\n\n- **Where notes come from: chat.** After each chat turn, on both the single-voice and the committee path, the Executive's post-turn block calls `memory.history_chat.schedule_chat_notes` next to the open-loop and style passes, except on a turn that touched the speaker's mailbox. It reads only what the speaker typed this turn (`delegation.settings.own_words`: no backstory an adapter added, nothing when a file came with it), never the reply and never anyone else's message: every channel calls the Executive with the one speaker's message, and what other people say to each other is never read. It runs only for a speaker the turn verified (`history_chat.verified_speaker`): the turn's `caller_person_id` is them, nobody started it by email or runs it unattended or for them, and the surface proved who they are (the web chat signed in or a local install, the principal or a team member on their own Slack or Discord, a private Telegram chat behind a valid webhook secret, or a channel whose adapter verified the sender itself and set `Session.speaker_verified`). A shared Slack or Discord thread counts: the notes stay private and are read back only where nobody else can see them. A message under 40 characters is skipped, and each person gets at most 40 passes a day, counted in `history_chat_passes` so the cap holds across workers and restarts. The pass uses a constant `CHAT_PROMPT` (requests to the assistant, questions and small talk are not notes), the same `record_notes` tool and the same `check_note` gate with the message as both body and allowed words; the note's channel is the inbound channel or `web`, its conversation the session id, and it names no counterpart.\n- **Where notes come from: email.** After `delegation.reply_send` sends a reply, it starts `memory.history_notes.note_sent_reply` in the background. The note-taker reads only the words the person sent (`email_poller.sender_new_text` strips quoted mail) and the recipients' names, cut to four words of name characters (`history_notes.short_name`): never the mail being answered, nor the subject, which others in the thread write too, so nothing another person wrote can become a note. One forced `record_notes` call with a constant prompt and no other tools returns at most three notes. Code then drops any note that says more than they did: the `quote` must appear word for word in what they sent, every figure in the summary must be in the quote, every name or date word must be in what they sent or the recipients' names, at least half its other content words must be theirs, the summary carries no link or address, and a `due_date` is kept only for something promised or agreed. Notes record events, never instructions, and carry `trust = high` because they rest on the person's own words.\n- **Whose they are.** Every note is private to its person (`visibility = private`). Nobody else reads it, the principal included; there is no shared note.\n- **How long they last.** The company default is 90 days (`history_settings.retention_days`, the principal's choice of 30, 90, 365 or until forgotten). A person may only choose a shorter time; shortening the company time clamps everyone's choice and re-dates live notes. A pinned note never expires; unpinning restarts its clock, and a later retention change counts from there. Reads skip expired notes and the scheduler's alert sweep deletes them (`history.sweep_expired`).\n- **What a person controls.** Through `/memories/history` they read, search, pin, correct and forget their own notes. On the Pulse page this is the **History** tab, last in the Memory section and shown only to someone with notes to see (signed in and on the People list): each note shows its kind, who it was with, the date, the person's own words, any due date and when it will be forgotten, and its menu holds **Correct** (a side panel; \"Use the original\" clears a correction), **Pin**, **Don't remember this** and **Forget**. \"Don't remember this\" forgets every note from that conversation and adds it to `history_excluded`, so it is never noted again. Settings → **Memory** holds the switch (\"Keep track of what happens\") and a shorter time for their own notes, and the company time, which the principal changes and everyone else reads. A chat note shows the channel alone (\"Slack\", \"Web chat\").\n- **Recall.** `recall_history` (`orchestrator.history_tools`) is offered only on a turn where the speaker may read their notes: verified as above, a team member who may keep notes, in a conversation private to them (`history_chat.private_chat`: the web chat, a Slack or Discord DM, a Telegram chat, or one its adapter marked `Session.private_chat`), with their switch on. Before any note is read the turn is set `touched_mail`, for the principal too, so its rows are private to the speaker, it teaches no memory and the mail lockdown holds from that round on. The conversation is also marked theirs alone (`session_store.mark_mail_private`), so every later turn in it is private the same way (the lockdown is that turn's alone) and, for a team member, the principal can't open it; recall refuses if that can't be stored. Notes come back in a `<history_notes>` block as history to cite: the date, the person's own words first, then how they were noted. With `due: true` it lists only notes with a due date, from a week overdue to two weeks ahead, soonest first (\"what's due today?\").\n- **In the owner's briefs.** The morning brief adds a FROM YOUR NOTES — DUE SOON block (`memory.history_brief.due_soon_block`: what the owner promised, agreed or asked of someone, from a week overdue to a week ahead, in the workspace's local dates) and the end-of-day digest a FROM YOUR NOTES — TODAY block (`noted_today_block`: what they promised, agreed, asked or declined since the last digest, then what is due tomorrow). Both only on the scheduler's delivery to the owner alone (`morning_brief.PRINCIPAL_DELIVERY`), never a run started from chat, whose tool result lands in the turn's shared audit row and peer memory; only when the owner may keep notes and has the switch on (`history_brief.owner_keeping_notes`), and only the owner's own notes. A run that used any is marked `private_to_principal`, so the shared run history keeps `PRIVATE_RUN_ARTIFACT` instead of its text, and the note ids with their state (overdue, today, soon) enter the brief's fingerprint, so one falling due un-suppresses an unchanged brief. Teammates get no brief, so their notes reach them only through recall and reminders.\n- **In Act as me drafts.** The ghostwriter gets a `<writer_noted>` block (`memory.history_drafts.notes_for_draft`): the writer's own notes from earlier Act as me replies that every recipient of the new draft was on, with their switch on. It keeps the draft consistent with them and turns a contradiction into an open question on the card; it never adds anything from them (see Act as me).\n- **Due-today reminders.** `memory.history_reminders.maybe_remind`, called from the scheduler tick every 15 minutes between 09:00 and 18:00 local time, sends each person with the switch on one message on a day something they promised or agreed to by email (`source = approved_reply`) falls due. Chat promises are left to open loops, which the nudge engine already chases. The message says only how many things are due, never what or to whom, and the channel senders' audit rows for it are private to the person (`audit.context.rows_for_person`; the owner's `private_rows`), which also keeps the send off the shared activity rail (`_record_send_to_activity` skips a send whose rows are private). The person asks \"what's due today?\" in a private conversation and `recall_history` answers. It goes to their own Slack or Discord DM, a private Telegram chat (`delivery_order` skips a negative group id, for the owner's briefs too) or their own email (`scheduler.runner.deliver_to_person`), never a shared channel. `history_reminders` holds one row per person per day, claimed before sending and never released, so two workers never both send and a half-failed send is never repeated; a failed one waits for the next due day.\n- **Not peer memory.** Notes never reach Honcho, episodic extraction, standing facts or another person's turn. The tables (`history_notes`, `history_settings`, `history_person_settings`, `history_excluded`, `history_chat_passes`, `history_reminders`, created by `history_schema.ensure_schema` from `initialize_db`) swap with a client slot and are cleared by a factory reset.\n\n### Conversation review (fixing what replies left undone)\n\n`memory.chat_review` looks back over a chat once it has been quiet `CHAT_REVIEW_QUIET_MINUTES` (30) and fixes what the replies left undone: \"I sent it\" answered with \"noted\" and the draft still waiting, \"drop that reminder\" answered with \"sure\" and the reminder still set. The claim check (`orchestrator.claim_check`, see Lifecycle) catches a false claim in the same turn; this catches the rest.\n\n- **Never from another AI app.** `history_chat.verified_speaker` refuses every turn from Open Executive's MCP server (`Session.from_mcp_client`), even one allowed to act that counts as a verified surface for its tools, so neither History notes nor the conversation review take that app's text as the person's own words.\n- **What is recorded.** On both the single-voice and the committee path the post-turn block calls `record_turn` with the speaker's own words (`delegation.settings.own_words`), the reply and the tools the turn ran (`_stream_agent_loop(calls_out=)`). Only a verified speaker's turn is kept: the principal on a surface `people_tools` verifies, or a rostered teammate on their own signed-in web chat, Slack or Discord. A channel whose adapter set `Session.speaker_verified` counts as a verified surface here too; an email, an unattended run, a turn private to the principal and a message with an attachment are never kept. A turn that touched the speaker's mailbox, and every turn of a conversation that once did (`sessions.mail_private`), is kept for their own review only: its tools are kept by name with only a failure marker, never their output (other people's mail), its fix loop is not offered `remember_fact`, a lesson from it is never shared, the Reflection screen shows it to its owner alone (`chat._session_access`), and every audit row the review and the nightly replay write about it is that person's own (`chat_review_turns.mail`, `mail_private_turns`, `audit.context.rows_for_person`), since a judge's notes quote the chat. Rows live in `chat_review_turns` for 7 days, a turn graded a miss (below) for `MISS_KEEP_DAYS` (90); each row also keeps the audit `turn_id` of the turn, so the claim check's row can be joined back to it.\n- **When.** Each kept turn makes sure one `chat_review` `__internal__` action is waiting for the conversation (`channel_ref` = session id), due 30 minutes on. The runner marks it done and calls `run_scheduled`, which schedules a fresh one if a newer turn arrived meanwhile, else reviews the oldest unreviewed turns (at most 20, the rest in a review right after) and marks exactly those reviewed, so a chat is read in parts and never twice. `CHAT_REVIEW_MAX_PER_DAY` (10) caps each person's passes a day (`chat_review_days`), so one person's chats can't use up another's.\n- **The pass.** One small tool loop per person on `CHAT_REVIEW_MODEL` (default `ROUTING_MODEL`), at most 5 rounds and 8 changes, in its own task with a session rebuilt from the recorded surface and caller and a delegation pin holding their words, so each tool runs through the chat tool's own handler and checks: `list_open_loops` / `close_open_loop`, `remember_fact`, `list_followups` / `cancel_followup` / `move_followup`, `leave_out_of_brief`, plus `learn_reply_style` (a working-style rule), `learn_writing_style` (a habit or avoid line in their Act as me voice profile, only for someone who may use it) and `raise_in_brief` (one line for the next brief). Every change carries `source_quote` of at least four of the person's own words (`fact_tools._quote_error`), and the thing it changes (the loop's or follow-up's text, the fact, the brief item or line) must share two words with what they wrote (its only one, for a one-word target) A chat draft's state is left to the brief's own check of the mailbox's Drafts. The replies are shown as `<untrusted_content>` (they quote mail and documents) and tool results not at all, only the tools' names. `leave_out_of_brief` and `raise_in_brief` are the principal's only; dropping a fact and changing a goal are left to chat. It never sends, books, deletes or grants permission to act, and nothing it does is said in chat. One `chat_review` audit row per pass lists the changes.\n- **Grading (looking back at how it went).** Before the fix loop, the same pass grades each turn it reads with one forced-tool call (`grade_turns`) on the review model. The grader sees what the fix loop sees plus one SIGNALS line per turn, joined from where the product already records them (`turn_signals`): a 👍/👎 and its note on the saved reply (`chat_messages`, matched to the recorded reply by its first 120 characters, which also gives the Reflection screen the reply's `message_id`), or a thumbs up or down typed or said as the whole next message (a chat app has no buttons), a reply the person stopped (`stopped`), a turn they took back to ask again (a `session_rewound` audit row after a turn whose reply is no longer in the chat), a claim the reply made that no tool backed (a `claim_check` audit row with the turn's `turn_id`), and a tool whose recorded result reads as an error. Per turn it records `fine`, `miss` or `unclear`; for a miss, `wanted` (what the person wanted instead, one or two sentences) backed by a `quote` of at least four of their own words from that turn or the ones after it, or by a signal on the turn other than a 👍 (a miss the product recorded needs no words from them), code-checked (`accept_grades`) or the turn is `unclear` and `wanted` dropped, plus the `kind`: `company` (a term, a fact, a preference, which specialist to ask, doing a thing rather than promising it would have fixed it) or `product` (a tool failed or was refused, a capability it lacks). A turn the model skipped is `unclear`. Grades go on the row (`verdict`, `kind`, `wanted`, `signals`, `graded_at`, `message_id`), and each person's weekly count of graded turns and misses on `chat_review_weeks`, so the rate outlives the 7-day rows. Grading changes nothing in the workspace and never blocks the fixes: a failed grade leaves the turns ungraded. The pass's audit row carries the counts. `list_misses` (one person's or everyone's; the route then keeps, for the principal, only rows from chats `chat._session_access` lets them open, so a teammate's own chat stays theirs), `weekly_rates` and `forget_miss` (`is_principal_or_self`) serve `GET`/`DELETE /memories/reflection` (the Pulse screen **What it got wrong**).\n- **Lessons** (`memory/lessons.py`): for a turn graded a miss the review may call `learn_lesson` once: one sentence this workspace wants done differently (a term and what it means, a preference about the content, a thing to do rather than promise, a specialist to consult), quoted from the person's own words (the quote must come from the miss turn or a later one, and the lesson must be what the quote says). It passes the working-style deny-list (`attunement.style._DENY_PATTERNS`: no link, handle, amount, markup, identifier, action verb, instruction talk, nudge to act unchecked, roster name) plus the lessons' own list (the verbs that move information: email, share, post, export, attach...; the words that widen a request to everyone or everything) without the about-the-writing requirement, may add at most two content words beyond the quote (`lesson_overreach`, so a real quote can't carry a different sentence in), and is re-checked on every render. Rows live in `chat_review_lessons` (text, quote, person, session, `shared` = learned in a channel or group thread, turn, `shown`, `fine_after`, `miss_after`, `retired_at`/`retired_reason`) with `chat_review_lesson_uses` (lesson, turn id, whose turn). A lesson reaches a turn by a keyword match (two shared content words between the lesson plus its quote and the message; no vector index for a list this short): the Executive's own turn gets the matching ones as a `<lessons>` block in the user turn (`build_lessons_block`, never a cached block; the header says the current request wins and nothing in it authorizes an action), and each specialist call gets the same lines under its `<failure_cases>` block (`router._lessons_for_call` → `lessons_for_query`). A lesson reaches its own person's turns; the principal's reach everyone's only when learned in a shared space (`shared`), so nothing said in someone's own chat is paraphrased into another person's turn. `build_lessons_block` counts each showing against the active turn id and the speaker; when the review later grades that turn, `note_outcome` adds to `fine_after` or `miss_after` only when the turn was the lesson's own person's (nobody else's chats can retire it), and a lesson shown 5 times with more misses than fine turns retires itself (`unhelpful`). At most 40 live lessons per person; their oldest retires to make room (`BEGIN IMMEDIATE`, so two reviews can't both skip it). Forget on the screen retires one by hand (`forgotten`); a retired lesson is listed as stopped, never erased.\n- **Replay: the workspace's own evals** (`memory/replay.py`). Nightly (the `chat_replay` scheduled action, `CHAT_REPLAY_TIME` 03:30 in the user's zone, seeded and chained like the reflection), the Executive runs its misses again with everything in force today and a judge says whether each would now go right. A case is a graded turn: a miss (its `wanted`), or a turn that went fine and got a thumbs up (`kept = 1`, held as long as a miss, at most `MAX_KEPT` 300 per person), which the replay protects so a lesson can't break what worked; a closed miss joins that pool. `due_cases` picks a miss the night a lesson is written for it (`WHY_LESSON`), when a lesson learned since the last night reaches it (`WHY_REACHED`), else once a week (`WHY_WEEKLY`), from the last 30 days only and at most `CHAT_REPLAY_MAX_CASES` (30) a night within `CHAT_REPLAY_MINUTES` (20); 20 protected cases (`WHY_PROTECT`, rotated by last replay) run only on a night a new lesson landed. `replay_case` runs `Executive.chat` on a session rebuilt from the recorded surface and speaker (`chat_review._rebuild_session`) with the saved conversation up to that turn (`chat_messages` before the reply's `message_id`), flagged `Session.replay`: reads run for real through every gate, and every tool a read-only turn is denied (`MCP_CLIENT_WITHHELD_TOOLS`, and gateway calls outside `MCP_CLIENT_MCP_TOOLS`) returns \"done\" and lands in `Session.replay_calls` instead (`faked_handlers` / `faked_call_tool`, wrapped outermost in the agent loop); scripts, Python jobs, `load_mcp_server`, Act as me's tools, `recall_history` and extension tools are not offered at all; nothing a replay does is kept (no extraction, open loops, style, notes, review or Honcho mirror, and `build_lessons_block(count=False)` counts no showing). The judge (`CHAT_REPLAY_JUDGE_MODEL`, else `EVAL_JUDGE_MODEL`, else Sonnet; `evals.judges.judge_message`) reads the original date, the person's words and the conversation before, what they wanted (or the reply they liked), today's reply and the recorded actions, and answers `{passed, time_bound, notes}`, intent and action rather than figures; an unreadable answer is a fail. The gate (`_settle`): a miss that passes is `closed` with `closed_at`; a time-bound one becomes `evidence` and is not replayed again; a lesson for a miss that still fails on `LESSON_FAILS` (2) judged replays after it was learned retires (`replay`); a protected case that fails reopens a closed miss and counts a strike against each new lesson of the same person that reached it (a teammate's turn never retires the principal's shared lessons), which retires at `PROTECT_FAILS` (2) such strikes, so one judged turn, or one message written to fail the judge, is not enough. A case that didn't run (an error, the `CASE_SECONDS` timeout) is recorded with `ran = 0` and settles nothing. The judge's input is scrubbed like outside content (`content_trust._scrub`) with the prompt's own tag names renamed inside it. Every replay is a `chat_review_replays` row (the reply and recorded calls; dropped with its turn when a miss or chat is forgotten or purged, `chat_review._prune_replays`) and a `chat_review` audit row (actor `chat_replay`); each night a `chat_review_replay_runs` row, written before the first case (so a second runner sees nothing new) and filled in after, which is also what \"new since the last night\" means. The nightly Executive carries the scheduler's MCP gateway, so the reads a miss needs run as they did. The Reflection screen's number, \"of the N things that went wrong in the last 30 days, M would go right today\" (`summary_for`, over the misses the caller sees), and each miss's last replay come from these columns on `chat_review_turns` (`replay_state`, `replayed_at`, `closed_at`, `replay_count`, `replay_notes`). Off with `CHAT_REPLAY_ENABLED=false` or when the review itself is off.\n\n## Decision ledger\n\n`openexecutive.memory.decision_ledger` keeps one `decision_instances` row per gated action — a meeting the Executive proposes to book, an Act as me reply card — with how it was resolved, so each class has a reliability record. Every status change is a compare-and-set. A tap with an outside effect (sending an email) claims the row first (`claim_for_execution`, proposed → executing), so of two taps only one acts, and finishes it as `approved_unchanged`, `approved_with_edit` or `failed`, or hands it back (`release_claim`). A row whose class acted on its own with nobody tapping — `gate_mode` `auto_execute`, as Act as me's **Handle it for me** replies are — finishes as `executed` instead, with no resolver, so a reliability read never counts it as an approval. A send whose result is unclear stays `executing` for a reconciler and is never retried. A row still waiting can have its payload changed only by compare-and-set (`update_open_payload`, on `proposed` and, when given, on the payload as it was read): that is how an Act as me reply card takes the person's edit, or records the draft made for it at Send.",+ "markdown": "The Executive's durable memory is an episodic SQLite store at `./episodic_memory.db`, managed by `openexecutive.memory.episodic`. It holds four tables:\n\n- `decisions` — choices made, with `domain`, `summary`, `rationale`, `outcome`, and `tags`. `outcome` is filled in when the principal says how a decision turned out — the `record_decision_outcome` chat tool (principal on a verified surface only) or the Memories page. The weekly review reads this table twice: the week's decisions (`decisions_since`) and up to three older than 30 days with no outcome yet (`decisions_awaiting_outcome`), which it asks about.\n- `initiatives` — tracked efforts with a `status` and `summary` (idempotent upserts).\n- `advice_given` — query/advice pairs per domain.\n- `scheduled_actions` — a dispatch queue, treated separately from recall memory. `cancel_scheduled_action` guards its UPDATE on `status = 'pending'`, so a cancel never overwrites a row the scheduler claimed a moment earlier.\n\n### What gets extracted, and when\n\n`episodic.extract_and_store` runs after a turn and asks a utility-fast model for decisions, initiatives and advice. Every candidate must carry a `user_commitment_quote` that appears verbatim in the principal's own message (`_is_valid_user_commitment`) — the turn's speaker text (`memory_text` when the entry point supplies one, else the prompt), so a quoted Executive email or a briefing card's body inside the prompt cannot satisfy it — the model has repeatedly tried to log the Executive's *recommendations* as the user's commitments, and that quote is the hard gate against it.\n\nA turn reaches the extractor if `should_extract(speaker_text, session=...)` is true, which means only that the principal said something on a surface that proved it was them — there is deliberately **no length floor**. There used to be one, on the combined user+assistant length, and on a live tenant it selected almost exactly the wrong turns: 9 of 16 exchanges were blocked, and the 9 held every instruction the principal gave, while the 7 admitted were long analytical exchanges with no commitment in them. The extractor ran 13 times and stored nothing.\n\nMoving that floor to the user's side would relocate the bug, not fix it. The canonical executive decision is a long analysis answered with \"Approve option B.\" (17 chars) or \"Do B.\" (5), and any floor high enough to skip \"Done\" (4) also skips those — \"Do B.\" and \"Done\" differ by one character and mean opposite things. Length cannot separate a decision from an acknowledgement; the verbatim-quote check can, so `_is_valid_user_commitment` is the gate that decides. The price is one utility-fast call on turns that propose nothing.\n\nThat quote check is only meaningful when `user_message` holds the **principal's** words, and on a chat channel it does not — `Executive.chat()` is reached from Slack, Discord, Telegram, Google Chat and the email poller. A teammate's line would be written to `decisions` with no speaker attached, indistinguishable from the principal's own; an inbound email body is text the sender chose, so a self-quote is free. Removing the length floor is what makes this bite — short channel traffic used to fall under it incidentally — so `should_extract` asks the untrusted-content policy (`orchestrator.content_trust.principal_speaking`) whether the principal is speaking. It names the principal's surfaces rather than inferring them: the web chat (signed in as the principal — or, on an install with no principal on the People page yet, a request that carried no sign-in; a signed-in email on nobody's entry, such as an archived teammate still allowed to sign in, is not the principal), the CLI (`Session.from_cli`), the principal's own Slack or Discord or a private Telegram chat with a valid webhook secret (`people_tools.is_principal_on_verified_surface`), and email from the principal's primary address that Gmail's own `Authentication-Results` marks `dmarc=pass` (`Session.email_authenticated`). Everything else fails closed: a teammate (on the web too), an unrostered sender, the principal's address on mail Gmail did not authenticate, Google Chat, the MCP server (its caller names themselves), unattended runs, and an unreadable roster. The rule used to be \"no `origin_channel` means the principal's own surface\", and the email poller left `origin_channel` empty, so every stranger's email ran through the extractor with its body — headers, quoted chain and all — as the principal's words, and whatever it stored rendered on every later turn. The poller now tags its sessions `origin_channel=\"email\"`, and the gate no longer reads an empty channel as trust.\n\nThe extractor also reads only the words **outside** every `<untrusted_content>` block (`schedule_extraction` runs `content_trust.strip_untrusted` first): an attached document's text is inlined in that block, so a sentence the principal did not type can never be quoted back as their commitment, and a turn that is nothing but an attachment is not extracted at all.\n\nEach pass writes a `memory_extraction` audit row — in a `finally`, so a pass that crashed is recorded too, with the exception type as its `failure` reason: how many items the model proposed, how many were stored, a `malformed` count so a pass where the model returned only garbage does not read as one that found nothing, and a `{kind, reason}` record per drop — `bad_quote` and `missing_field` for an item the model proposed, `not_a_list`, `item_not_a_dict` and `payload_not_a_dict` for a shape that was never a usable item. Every proposed item is either stored or dropped, so `proposed == stored + item drops` is the arithmetic that says whether anything was lost silently. The tool payload is not schema-checked anywhere, so a malformed shape is counted as a drop rather than raised — it used to abort the whole pass, discarding the other two kinds with it and suppressing the row, which read exactly like \"extraction never ran\". Without it, \"the model found nothing\" and \"the model found things and every one was rejected\" are indistinguishable from outside the database — which is why the failure above survived undetected and took a SQLite session on the tenant to find. A `proposed>0, stored=0` streak is the signal to watch.\n\nThe validator rejects a paraphrase, and the model paraphrases: on one install two of three real commitments were lost that way, the quote beginning \"SVN's engagement covers only …\" where the person had typed something else. So a `bad_quote` drop earns exactly one corrective call. The model is shown the rejected items and the quotes it gave, told to copy the span character-for-character (typos and casing included) or return empty arrays, and the tool is forced where the provider supports tool choice. Every retry item is validated first; a still-invalid one adds no second drop and is counted `still_invalid`. A valid item is then classified in order: its label matches a pending drop record → a recovery, stored and the record released; else its quote (terminal punctuation ignored) already supports a stored item of that kind → a re-send, ignored and counted `repeated`, so a model that re-sends everything cannot double-count `stored`; else a new proposal, stored and counted — a reworded label cannot be told from a different item, and crediting it would erase the very `bad_quote` census the row exists to show, so its original drop stands. Recovery is checked before re-send because two commitments can rest on one sentence. Malformed shapes at any level — a kind that is not a list, an item or payload that is not a dict, a response with no tool call — are counted `malformed`, so a retry that returned garbage does not read like one that obediently returned nothing. The row's `retry` block (`rejected`, `recovered`, `repeated`, `still_invalid`, `malformed`, `failure`) is always present, zeros when nothing was rejected; `rejected` is set from the complete drop list when the row is written, so neither a store failure before the retry nor a cancellation during it can zero it. The arithmetic above still holds after the retry. An exception on the retry is recorded as the retry's own `failure` and leaves the first pass's results untouched; the cost is one utility-model call, only on turns that dropped something. `memory_extraction` is a declared event type, so the audit page's filter can select it.\n\n### Standing facts (corrections that persist everywhere)\n\nA fifth table, `facts` (`openexecutive.memory.facts`, created on first write), holds facts and corrections the principal stated and asked to keep — \"Maple House is 48 units, not 52\". Before it, a chat correction's only durable home was Honcho peer memory: optional, best-effort (its prefetch times out or errors under load), re-injected only into that person's later chat turns, and never read by the briefs, the scheduled runs or the alert review. The episodic extractor cannot hold one either: it stores only decisions backed by a commitment quote, and a fact is not a commitment.\n\n- **Written from chat, by the principal or an attributed teammate.** `remember_fact` stores one (subject, statement, optional wrong value) and `forget_fact` retires one. The principal on a verified surface may do both. A teammate on the People list (a `team` row, not archived, not a contact) on a verified surface (the web app signed in, their own Slack or Discord; `fact_tools._teammate_speaker`) may call `remember_fact` only; email, Google Chat and unrostered senders are refused. Both tools are withheld from every unattended run and every turn private to the principal. Every call, `forget_fact` included (retiring a fact changes what later prompts treat as true just as writing one does), also needs `source_quote`: at least two words and eight characters, found in what the speaker typed this turn (`delegation.settings.own_words` over the pinned `TurnDelegation.speaker_text`). The `<outbound_reply_context>` backstory a Slack or Discord reply is hydrated with is stripped first, and a message with an attachment is refused outright. The quote alone only proves the principal asked, so everything `remember_fact` stores and renders (the statement, the subject shown as `[fact N] subject:`, and a previous value shown as `(corrects: …)`) is tied to their words too. An omitted previous value falls back to the replaced fact's own statement. Every figure must be a number they wrote, compared at its magnitude: `$180k` matches `180,000`, but `180m` never lets `$180k` through. Every name must also appear in what they typed: a capitalised word, or any word holding a non-ASCII letter, other than the statement's very first word (a statement is one fact, so splitting a document's names into one-word sentences exempts nothing). So must every month, weekday or quarter. A name the model writes in lower case is not caught: the gate narrows what a real quote can carry in; it does not prove a paraphrase. A real quote therefore cannot carry a document's figure, name or date in with it (\"Cedar Court's lease expires in March\" after \"remember what the lease doc says\"), while a paraphrase of what they said still passes. So the model cannot store its own inference, a document's figure or text quoted back at the principal as something they said. Every audit row the tools write, and the chat loop's `skill:` dispatch row for them (whose input quotes the principal verbatim), is private to the principal (`executive._private_tool_row`). Those rows tie a fact to the principal's session and turn, which `GET /memories/facts` hides from teammates, and a teammate can read any non-private audit row. The handlers run in a worker thread (`asyncio.to_thread`, which carries the turn's context), and the chat and committee paths, the alert review, the morning brief's synthesis and the end-of-day, weekly-review and reflection workflows read the block the same way, so SQLite, the profile file and its lock never block the event loop the SSE streams share. The principal's own email may ask too: the change is checked the same way, then held until they confirm it by replying to a one-time token sent to their own address (see Integrations → Standing facts by email).\n- **Provenance and attribution.** Each row keeps the quote, the channel (`web` or the adapter), `session_id`, `turn_id`, the recording person and the time, plus `recorded_by_role` (`principal` or `teammate`) and, for a teammate, `recorded_by_name` as the People list had it. Rows written before these columns existed read as the principal's (`_migrate` adds the columns on the first write; the read-only render tolerates a DB that has none).\n- **One active fact per subject.** A new row supersedes any active row with the same folded subject key, or the id named in `replaces_fact_id`, in one transaction. The old row stays as `superseded` (with `superseded_by`), and the new one is stored as a `correction` carrying what it replaced. Retiring sets `retired` with a reason. **The principal outranks a teammate:** a teammate's write that would replace an active fact the principal set (by subject or `replaces_fact_id`) raises `PrincipalFactConflict`, and the tool stores it as `proposed` instead, naming the fact it would replace (`replaces_fact_id`); teammates replace each other's facts freely, and the principal replaces anyone's. **\"Needs my approval\"** (`fact_approval_rules`, per teammate, **on by default**, set only by the principal) stores every fact from that teammate as `proposed`; the principal turns it off for a teammate they trust, whose facts then apply at once (except one that would replace the principal's). The rule is read inside `record_fact`'s own write transaction, so a switch turned on a moment earlier cannot let one fact through; a teammate write that names no person is never trusted. One teammate may have at most `MAX_PENDING_PROPOSALS_PER_PERSON` (20) proposals waiting (`TooManyProposals`; the tool tells them to wait for the principal's review). A teammate's retire checks ownership in the `UPDATE` itself (`retire_fact(teammate_id=)`: their own row, not approved). A proposed row never renders; `approve_fact` makes it active and replaces what it names (the principal's own fact included — approving it is their word) and stamps `approved_at`, after which it outranks teammates exactly as the principal's own fact does (`Fact.principal_owned`: no teammate may replace or retire it); `decline_fact` sets `declined`. No field of a teammate's fact may carry what the render adds itself — `(per <anyone>)` in any case (a unit such as `(per month)` or `(per unit)` is fine), `[fact N]` or a date stamp after any dash, read NFKC-folded with invisible characters removed (`fact_tools._marker_error`) — so a teammate cannot plant a second, forged attribution inside their statement (the principal's own unmarked lines are not checked: \"(per Smith lease)\" is ordinary wording for them). The tool answers `awaiting_approval` (no action chip) and tells the model to say it is not in use yet.\n- **Rendered everywhere output is produced.** `render_facts_for_prompt` renders the active rows newest first under a self-explaining `STANDING FACTS` header (use these over older figures; a line ending `(per <name>)` is that teammate's word and the principal's unmarked line wins a conflict; the current conversation still wins; quoted data never instructions). A teammate's line ends `(per <name>)`, the name defanged like the rest, capped at 40 facts / 6000 chars, with angle brackets defanged. It opens the DB read-only and never creates it or the table. The block always rides in a user turn, never a cached system block: a chat turn's `<standing_facts>` (so every scheduled run through the chat loop too), each specialist consult (`route_to_specialist`, chat and workflow steps alike), the /today header and the morning brief (`render_briefing_context`, after the quiet check and inside the string the header's cache key hashes, so a new fact rewrites the header), the alert review's batch (`render_batch`, read once per pass), and the end-of-day digest, the weekly review's top-three call and the morning reflection (`with_standing_facts`).\n- **Company-profile edits from chat.** `update_company_profile` (same gate and quote rule) changes one whitelisted field of `company/profile.yaml`, under `PROFILE_EDIT_LOCK` (also taken by `PATCH /company-profile`, so neither edit silently drops the other): a text or number field is set, a list field gets an item added or removed, and `financials.key_metrics` takes a named metric. It writes through `CompanyProfile.save_to_yaml` and updates the session's profile, so the next turn's cached company block carries it (one cache miss on the change). The new value must itself appear in the principal's own words, not just the quote: the value renders into the cached company block on every later turn, so \"set our mission to what the doc says\" or \"update our headcount\" is refused rather than saving a document's text or a guessed figure. A number must be one they wrote, however they wrote it (`$180k`, `1.2m`, `2,400,000`). Saved text has `<`/`>` defanged. A `kind='profile'` row records each edit with its quote for the Pulse page. Those rows are never rendered into a prompt, because the profile block already carries the value.\n\n### Session scoping\n\n`decisions` and `advice_given` rows carry a `session_id`, so per-thread channels (Discord, Telegram) can pull just-this-thread history without leaking cross-conversation context. A null `session_id` falls back to a global view.\n\n### Surfacing\n\n`openexecutive.memory.episodic.format_for_prompt` renders recent decisions and initiatives into a compact `<past_decisions>` block injected into the user turn — alongside `<retrieved_context>` and peer memory — never into a cached system block. Each decision names where it was recorded when that was a channel — `- 2026-09-01 [finance] (via email): …`, from the prefix of its `session_id` (`email:`, `slack:`, `discord:`, `telegram:`, `google_chat:`); a web or CLI decision has no tag. Rows extracted from mail before the untrusted-content policy, when any sender's body could be stored, therefore read as mail rather than as the principal's own word.\n\nScoped to a session, decisions and advice cover every conversation of a chat app's stream (`memory.conversation_ids.family_clause`): a Telegram chat or a DM is cut into conversations after two quiet hours or a /new (`memory.conversations`), and what an earlier conversation decided still renders in the next.\n\nThe chat route also injects a `<briefing>` block into the same user turn: a compact digest of the current open (unread) alerts, built by `openexecutive.briefing.context.format_open_alerts_for_prompt` (company-wide, `status=\"unread\"`, mirroring `/today`). This is what lets the Executive discuss a briefing item the principal clicked or named on `/today` (e.g. \"Gulf Coast Port Cyberattack\"). It is resolved in parallel with the other context fetches, omitted when there are no open alerts, and never placed in a cached system block.\n\nOn the Pulse page the Memory section shows the three lists as Decisions, Initiatives and Advice tabs, then a **Corrections** tab (`GET /memories/facts`: active standing facts and profile edits with their quote, channel and — for a teammate's — their name; proposals first under \"Waiting for your approval\" with **Approve** / **Decline** for the principal; the replaced, retired and declined history folded away; **Retire** on any fact for the principal and on their own not-yet-approved one for a teammate; and, for the principal, a per-teammate \"needs my approval\" switch), and a **History** tab for the person's own Always in the loop notes (see below). The header's Memories tile counts the three lists. What peer memory has learned about the signed-in person is theirs alone, so it is not on Pulse: it is on **Settings → About you** (see the peer memory section).\n\nThe same user turn carries a `<drive_memory>` block when the conversation has touched Google Drive (`openexecutive.memory.drive_reads`). Drive is reached only as live Google Workspace calls inside a turn and history keeps only prose, so without it a file found one turn was gone the next. `MCPGateway.call_tool` hands each `search_drive_files` and `get_drive_file_content` result to `record_drive_result`, which keeps, per session, every file found or opened (file id, name, type, link, and for an opened file its first 600 characters) and every search that matched nothing, with its query. `format_drive_memory` lists the 20 most recent files, so \"the file you found earlier\" resolves to a file id the Executive reopens rather than searching again, and the queries that found nothing (dropped once the same query later finds something). Rows are keyed on the session *and* the speaker, and shown only to that speaker in that session, because one session can span several people (an email thread, a Slack or Discord thread). Nothing is recorded or shown without a bound `current_session` and a rostered speaker, on a turn private to the principal, or on one that touched the speaker's own mailbox (Act as me). workspace-mcp writes file names into its output unescaped, so a name containing a newline can forge a result line. Only a Drive-shaped file id, type and `docs`/`drive.google.com` link are therefore kept; any other line is dropped, and the name is always quoted as the file's own content, not instructions. Each speaker keeps at most 100 files and 100 searches per session, older rows are pruned on write, and `session_store.delete_session` drops them all.\n\nThe scheduler reads one more thing from the transcript: when a follow-up back to the person who set it fires, `session_store.own_messages_since` gives it that person's own messages since it was set (their words only, across their conversations, capped), so a follow-up whose reason was already settled in chat stands down instead of sending (see the scheduler section).\n\nA conversation can also become its owner's alone. When Act as me first reads the speaker's own mailbox in it, `session_store.mark_mail_private` sets `sessions.mail_private` (creating the row with its owner when a channel adapter hasn't written it yet), and from then on only the session's owner may open, continue or delete it — the principal included, when it is a team member's (`chat._session_access`). It is never cleared. Beside it `sessions.mail_read_at` keeps how many history messages the conversation held before the last turn that read the mail (`session_store.mail_read_at`; NULL on rows marked before the column): Act as me's hold on links and scripts in later turns lasts only while that turn is still in the history window (see Act as me). \n\nThe chat list has owner controls on the same row: `sessions.pinned_at` (pinned chats list first) and `sessions.title_locked` (set by `rename_session`, after which `update_session_title`, the automatic title, leaves the name alone). Chats are also grouped by topic for their owner (`memory/chat_topics.py`): a `chat_topics(id, owner_person_id, name, kept, pinned_at, created_at)` row per topic, unique per owner and name (any case), and `sessions.topic_id` with `sessions.topic_source` (NULL = not looked at, `auto` = chosen by the model, `owner` = filed by the owner and never refiled). The one utility-fast call that titles a new chat (`utils/chat_topics.name_chat`, from the web chat and the chat-app conversations) also picks its topic, reusing one of the owner's 60 most recent topic names or making a new one. Only when the owner alone has written in the chat: a channel or group conversation, a shared chat, or one where someone else wrote first is titled without the owner's topic names in the prompt (another writer could steer the title into repeating them) and is filed later by the backfill, whose answer only the owner sees. Each call is bounded by the utility-fast timeout (60 s for a backfill batch). Only a turn that makes a new topic costs a second short call, over the topic names alone, which merges it into an existing topic that means the same unless the owner has `kept` it (renamed, pinned, merged into or filed a chat under it). Chats from before, or whose naming failed, are filed from their titles in batches of 80 the first time the owner opens the Topic view (`backfill`; a failure waits 10 minutes). Topics left with no chat are dropped when listed. Related topics share an `area` (`chat_topics.area`, `area_kept`): one property, deal or client, shown as one heading over them. The same second call that checks a new topic also names the area it shares with related ones, and after the backfill one call over the names gives areas to topics not yet looked at (once the owner has three); an area counts only when two topics share it. An area the owner renamed or ungrouped is left as they made it. A `session_shares(session_id, person_id, shared_by_person_id, created_at)` row adds one team member to someone's chat (`list_shared_with_person`, `set_shares`, `leave_share`): they read and write in it with its owner, each of their messages saved with their own `sender_person_id`; a `mail_private` chat is never shared or opened that way, and deleting the chat drops its shares. `last_turn_sender` says who wrote the last turn, which is how redo stays with the person who asked. The chat list's preview puts `You:` only before the caller's own words. `rewind_last_turn` deletes a web chat's last turn (the last reply and the user messages after the reply before it) so it can be asked again; the next turn's history is re-read from these rows, so nothing else needs clearing. A search that matched nothing also gains a note in its tool result: say the exact query and that it found nothing, never that the file does not exist. This is a first step: Drive is still not indexed into the company collection.\n\n### System of record\n\nSQL is the system of record; the peer-memory service is a recall layer mirrored from it, not a replacement. When `store_decision` / `store_initiative` / `store_advice` insert a row whose `department` is non-empty and not `\"general\"`, the row is mirrored as a kind-tagged note into that department's peer via `append_department_note`. The mirror fires only after a successful INSERT, is fire-and-forget, and never rolls back the SQL row on peer-memory failure. `scheduled_actions` is never mirrored — it is a queue, not memory.\n\nThe episodic extractor still learns only from the principal's own words. Commitments and asks from everyone else on the roster are tracked as **open loops** (see Attunement) — `scheduled_actions` rows with `kind='open_loop'`, opened and closed by a separate quote-gated pass after each attributed turn. That pass depends on `chat_messages.sender_person_id`, which records who actually wrote each persisted user message. An open loop counts toward `list_awaiting_replies_by_person` only once it is due, and `list_scheduled_actions(exclude_internal=True)` filters `__internal__` rows in SQL so readers that want real sends are not starved by them. `mark_outbound_context_consumed` also resolves the Attunement outcome row for that DM as `replied` — a matched reply is the clearest sign proactive outreach landed — and a real change to an existing initiative (`store_initiative` / `update_initiative`, new status or summary) marks the updater's own check-in nudges `acted` — an update with no known updater, such as `PATCH /memories/initiatives/{id}`, credits nobody.\n\n### Workspace settings\n\nThe same database holds one row of settings that are not memory: `workspace_settings` (`openexecutive.memory.workspace_settings`) — the install's mode (`team` by default, or `solo` for one person using Open Executive just for themselves), the user's IANA time zone, the principal's role (`PrincipalRole`: `role_kind`, `role_title`, `reports_to`, `remit`, `measured_on`, all nullable; only solo mode reads it), and the company's own email domains (`company_domains`, a JSON list, or NULL to derive them from the principal's primary address — `people.identity` matches a teammate by local part on them; `validate_company_domains` lowercases, dedupes and sorts, allows at most 10 plain DNS names and refuses a free-mail provider's, and a stored value that no longer validates reads as NULL). It is a table of its own rather than a company-profile field because onboarding rebuilds the profile from scratch. Every read is fresh and read-only (a missing file or table reads as the defaults; a table from before the role or `company_domains` columns reads them as unset and is migrated additively by the next init or write). A read error (a locked database, say) also reads as the defaults, so `get_workspace` then says team; `read_stored_mode` is the strict read of the mode alone — None when the row cannot be read or holds no valid mode — for the scheduler's weekly-review check, which must not take a failed read for team. A session may carry an explicit `workspace_mode` override; otherwise the mode is read fresh at the start of each turn and pinned on the session for that turn only (`Session.turn_workspace_mode`, via `pin_turn_workspace_mode`), so every tool handler in the turn sees the mode its persona and tools were built in. `effective_workspace_mode` reads override, then the pin, then the setting; `effective_principal_role` reads a session's `principal_role` override, then the role pinned for the turn (`Session.turn_principal_role`, via `pin_turn_principal_role`), then the stored role. See Org for what solo changes and Scheduler for the time zone.\n\n### Act as me\n\n`initialize_db` also creates Act as me's per-person tables (`delegation.schema.ensure_schema`): `delegation_settings`, `delegation_voice` and `delegation_voice_history`. They hold a setting and a writing profile rather than memory, and nothing in them is mirrored to peer memory. A turn that touched the speaker's own mailbox teaches no memory: the episodic, open-loop and working-style passes are skipped along with the Honcho peer and department syncs, since its reply quotes a draft built from other people's mail. See **Act as Me (Delegation)**.\n\n### Always in the loop (notes of what you said)\n\nA person can keep private, dated notes of what they said, in chat with the Executive and in email replies it drafted for them: what they promised, agreed, declined, answered, asked for or shared. The switch is per person (\"Keep track of what happens\", `history_person_settings.reply_notes`, off by default, one switch for every channel). Any team member on the People list may turn it on (`history.can_keep_notes`: kind `team`, not archived, the principal included); Act as me isn't needed, though notes from email replies only come through it.\n\n- **Where notes come from: chat.** After each chat turn, on both the single-voice and the committee path, the Executive's post-turn block calls `memory.history_chat.schedule_chat_notes` next to the open-loop and style passes, except on a turn that touched the speaker's mailbox. It reads only what the speaker typed this turn (`delegation.settings.own_words`: no backstory an adapter added, nothing when a file came with it), never the reply and never anyone else's message: every channel calls the Executive with the one speaker's message, and what other people say to each other is never read. It runs only for a speaker the turn verified (`history_chat.verified_speaker`): the turn's `caller_person_id` is them, nobody started it by email or runs it unattended or for them, and the surface proved who they are (the web chat signed in or a local install, the principal or a team member on their own Slack or Discord, a private Telegram chat behind a valid webhook secret, or a channel whose adapter verified the sender itself and set `Session.speaker_verified`). A shared Slack or Discord thread counts: the notes stay private and are read back only where nobody else can see them. A message under 40 characters is skipped, and each person gets at most 40 passes a day, counted in `history_chat_passes` so the cap holds across workers and restarts. The pass uses a constant `CHAT_PROMPT` (requests to the assistant, questions and small talk are not notes), the same `record_notes` tool and the same `check_note` gate with the message as both body and allowed words; the note's channel is the inbound channel or `web`, its conversation the session id, and it names no counterpart.\n- **Where notes come from: email.** After `delegation.reply_send` sends a reply, it starts `memory.history_notes.note_sent_reply` in the background. The note-taker reads only the words the person sent (`email_poller.sender_new_text` strips quoted mail) and the recipients' names, cut to four words of name characters (`history_notes.short_name`): never the mail being answered, nor the subject, which others in the thread write too, so nothing another person wrote can become a note. One forced `record_notes` call with a constant prompt and no other tools returns at most three notes. Code then drops any note that says more than they did: the `quote` must appear word for word in what they sent, every figure in the summary must be in the quote, every name or date word must be in what they sent or the recipients' names, at least half its other content words must be theirs, the summary carries no link or address, and a `due_date` is kept only for something promised or agreed. Notes record events, never instructions, and carry `trust = high` because they rest on the person's own words.\n- **Whose they are.** Every note is private to its person (`visibility = private`). Nobody else reads it, the principal included; there is no shared note.\n- **How long they last.** The company default is 90 days (`history_settings.retention_days`, the principal's choice of 30, 90, 365 or until forgotten). A person may only choose a shorter time; shortening the company time clamps everyone's choice and re-dates live notes. A pinned note never expires; unpinning restarts its clock, and a later retention change counts from there. Reads skip expired notes and the scheduler's alert sweep deletes them (`history.sweep_expired`).\n- **What a person controls.** Through `/memories/history` they read, search, pin, correct and forget their own notes. On the Pulse page this is the **History** tab, last in the Memory section and shown only to someone with notes to see (signed in and on the People list): each note shows its kind, who it was with, the date, the person's own words, any due date and when it will be forgotten, and its menu holds **Correct** (a side panel; \"Use the original\" clears a correction), **Pin**, **Don't remember this** and **Forget**. \"Don't remember this\" forgets every note from that conversation and adds it to `history_excluded`, so it is never noted again. Settings → **Memory** holds the switch (\"Keep track of what happens\") and a shorter time for their own notes, and the company time, which the principal changes and everyone else reads. A chat note shows the channel alone (\"Slack\", \"Web chat\").\n- **Recall.** `recall_history` (`orchestrator.history_tools`) is offered only on a turn where the speaker may read their notes: verified as above, a team member who may keep notes, in a conversation private to them (`history_chat.private_chat`: the web chat, a Slack or Discord DM, a Telegram chat, or one its adapter marked `Session.private_chat`), with their switch on. Before any note is read the turn is set `touched_mail`, for the principal too, so its rows are private to the speaker, it teaches no memory and the mail lockdown holds from that round on. The conversation is also marked theirs alone (`session_store.mark_mail_private`), so every later turn in it is private the same way (the lockdown is that turn's alone) and, for a team member, the principal can't open it; recall refuses if that can't be stored. Notes come back in a `<history_notes>` block as history to cite: the date, the person's own words first, then how they were noted. With `due: true` it lists only notes with a due date, from a week overdue to two weeks ahead, soonest first (\"what's due today?\").\n- **In the owner's briefs.** The morning brief adds a FROM YOUR NOTES — DUE SOON block (`memory.history_brief.due_soon_block`: what the owner promised, agreed or asked of someone, from a week overdue to a week ahead, in the workspace's local dates) and the end-of-day digest a FROM YOUR NOTES — TODAY block (`noted_today_block`: what they promised, agreed, asked or declined since the last digest, then what is due tomorrow). Both only on the scheduler's delivery to the owner alone (`morning_brief.PRINCIPAL_DELIVERY`), never a run started from chat, whose tool result lands in the turn's shared audit row and peer memory; only when the owner may keep notes and has the switch on (`history_brief.owner_keeping_notes`), and only the owner's own notes. A run that used any is marked `private_to_principal`, so the shared run history keeps `PRIVATE_RUN_ARTIFACT` instead of its text, and the note ids with their state (overdue, today, soon) enter the brief's fingerprint, so one falling due un-suppresses an unchanged brief. Teammates get no brief, so their notes reach them only through recall and reminders.\n- **In Act as me drafts.** The ghostwriter gets a `<writer_noted>` block (`memory.history_drafts.notes_for_draft`): the writer's own notes from earlier Act as me replies that every recipient of the new draft was on, with their switch on. It keeps the draft consistent with them and turns a contradiction into an open question on the card; it never adds anything from them (see Act as me).\n- **Due-today reminders.** `memory.history_reminders.maybe_remind`, called from the scheduler tick every 15 minutes between 09:00 and 18:00 local time, sends each person with the switch on one message on a day something they promised or agreed to by email (`source = approved_reply`) falls due. Chat promises are left to open loops, which the nudge engine already chases. The message says only how many things are due, never what or to whom, and the channel senders' audit rows for it are private to the person (`audit.context.rows_for_person`; the owner's `private_rows`), which also keeps the send off the shared activity rail (`_record_send_to_activity` skips a send whose rows are private). The person asks \"what's due today?\" in a private conversation and `recall_history` answers. It goes to their own Slack or Discord DM, a private Telegram chat (`delivery_order` skips a negative group id, for the owner's briefs too) or their own email (`scheduler.runner.deliver_to_person`), never a shared channel. `history_reminders` holds one row per person per day, claimed before sending and never released, so two workers never both send and a half-failed send is never repeated; a failed one waits for the next due day.\n- **Not peer memory.** Notes never reach Honcho, episodic extraction, standing facts or another person's turn. The tables (`history_notes`, `history_settings`, `history_person_settings`, `history_excluded`, `history_chat_passes`, `history_reminders`, created by `history_schema.ensure_schema` from `initialize_db`) swap with a client slot and are cleared by a factory reset.\n\n### Conversation review (fixing what replies left undone)\n\n`memory.chat_review` looks back over a chat once it has been quiet `CHAT_REVIEW_QUIET_MINUTES` (30) and fixes what the replies left undone: \"I sent it\" answered with \"noted\" and the draft still waiting, \"drop that reminder\" answered with \"sure\" and the reminder still set. The claim check (`orchestrator.claim_check`, see Lifecycle) catches a false claim in the same turn; this catches the rest.\n\n- **Never from another AI app.** `history_chat.verified_speaker` refuses every turn from Open Executive's MCP server (`Session.from_mcp_client`), even one allowed to act that counts as a verified surface for its tools, so neither History notes nor the conversation review take that app's text as the person's own words.\n- **What is recorded.** On both the single-voice and the committee path the post-turn block calls `record_turn` with the speaker's own words (`delegation.settings.own_words`), the reply and the tools the turn ran (`_stream_agent_loop(calls_out=)`). Only a verified speaker's turn is kept: the principal on a surface `people_tools` verifies, or a rostered teammate on their own signed-in web chat, Slack or Discord. A channel whose adapter set `Session.speaker_verified` counts as a verified surface here too; an email, an unattended run, a turn private to the principal and a message with an attachment are never kept. A turn that touched the speaker's mailbox, and every turn of a conversation that once did (`sessions.mail_private`), is kept for their own review only: its tools are kept by name with only a failure marker, never their output (other people's mail), its fix loop is not offered `remember_fact`, a lesson from it is never shared, the Reflection screen shows it to its owner alone (`chat._session_access`), and every audit row the review and the nightly replay write about it is that person's own (`chat_review_turns.mail`, `mail_private_turns`, `audit.context.rows_for_person`), since a judge's notes quote the chat. Rows live in `chat_review_turns` for 7 days, a turn graded a miss (below) for `MISS_KEEP_DAYS` (90); each row also keeps the audit `turn_id` of the turn, so the claim check's row can be joined back to it.\n- **When.** Each kept turn makes sure one `chat_review` `__internal__` action is waiting for the conversation (`channel_ref` = session id), due 30 minutes on. The runner marks it done and calls `run_scheduled`, which schedules a fresh one if a newer turn arrived meanwhile, else reviews the oldest unreviewed turns (at most 20, the rest in a review right after) and marks exactly those reviewed, so a chat is read in parts and never twice. `CHAT_REVIEW_MAX_PER_DAY` (10) caps each person's passes a day (`chat_review_days`), so one person's chats can't use up another's.\n- **The pass.** One small tool loop per person on `CHAT_REVIEW_MODEL` (default `ROUTING_MODEL`), at most 5 rounds and 8 changes, in its own task with a session rebuilt from the recorded surface and caller and a delegation pin holding their words, so each tool runs through the chat tool's own handler and checks: `list_open_loops` / `close_open_loop`, `remember_fact`, `list_followups` / `cancel_followup` / `move_followup`, `leave_out_of_brief`, plus `learn_reply_style` (a working-style rule), `learn_writing_style` (a habit or avoid line in their Act as me voice profile, only for someone who may use it) and `raise_in_brief` (one line for the next brief). Every change carries `source_quote` of at least four of the person's own words (`fact_tools._quote_error`), and the thing it changes (the loop's or follow-up's text, the fact, the brief item or line) must share two words with what they wrote (its only one, for a one-word target) A chat draft's state is left to the brief's own check of the mailbox's Drafts. The replies are shown as `<untrusted_content>` (they quote mail and documents) and tool results not at all, only the tools' names. `leave_out_of_brief` and `raise_in_brief` are the principal's only; dropping a fact and changing a goal are left to chat. It never sends, books, deletes or grants permission to act, and nothing it does is said in chat. One `chat_review` audit row per pass lists the changes.\n- **Grading (looking back at how it went).** Before the fix loop, the same pass grades each turn it reads with one forced-tool call (`grade_turns`) on the review model. The grader sees what the fix loop sees plus one SIGNALS line per turn, joined from where the product already records them (`turn_signals`): a 👍/👎 and its note on the saved reply (`chat_messages`, matched to the recorded reply by its first 120 characters, which also gives the Reflection screen the reply's `message_id`), or a thumbs up or down typed or said as the whole next message (a chat app has no buttons), a reply the person stopped (`stopped`), a turn they took back to ask again (a `session_rewound` audit row after a turn whose reply is no longer in the chat), a claim the reply made that no tool backed (a `claim_check` audit row with the turn's `turn_id`), and a tool whose recorded result reads as an error. Per turn it records `fine`, `miss` or `unclear`; for a miss, `wanted` (what the person wanted instead, one or two sentences) backed by a `quote` of at least four of their own words from that turn or the ones after it, or by a signal on the turn other than a 👍 (a miss the product recorded needs no words from them), code-checked (`accept_grades`) or the turn is `unclear` and `wanted` dropped, plus the `kind`: `company` (a term, a fact, a preference, which specialist to ask, doing a thing rather than promising it would have fixed it) or `product` (a tool failed or was refused, a capability it lacks). A turn the model skipped is `unclear`. Grades go on the row (`verdict`, `kind`, `wanted`, `signals`, `graded_at`, `message_id`), and each person's weekly count of graded turns and misses on `chat_review_weeks`, so the rate outlives the 7-day rows. Grading changes nothing in the workspace and never blocks the fixes: a failed grade leaves the turns ungraded. The pass's audit row carries the counts. `list_misses` (one person's or everyone's; the route then keeps, for the principal, only rows from chats `chat._session_access` lets them open, so a teammate's own chat stays theirs), `weekly_rates` and `forget_miss` (`is_principal_or_self`) serve `GET`/`DELETE /memories/reflection` (the Pulse screen **What it got wrong**).\n- **Lessons** (`memory/lessons.py`): for a turn graded a miss the review may call `learn_lesson` once: one sentence this workspace wants done differently (a term and what it means, a preference about the content, a thing to do rather than promise, a specialist to consult), quoted from the person's own words (the quote must come from the miss turn or a later one, and the lesson must be what the quote says). It passes the working-style deny-list (`attunement.style._DENY_PATTERNS`: no link, handle, amount, markup, identifier, action verb, instruction talk, nudge to act unchecked, roster name) plus the lessons' own list (the verbs that move information: email, share, post, export, attach...; the words that widen a request to everyone or everything) without the about-the-writing requirement, may add at most two content words beyond the quote (`lesson_overreach`, so a real quote can't carry a different sentence in), and is re-checked on every render. Rows live in `chat_review_lessons` (text, quote, person, session, `shared` = learned in a channel or group thread, turn, `shown`, `fine_after`, `miss_after`, `retired_at`/`retired_reason`) with `chat_review_lesson_uses` (lesson, turn id, whose turn). A lesson reaches a turn by a keyword match (two shared content words between the lesson plus its quote and the message, or the name the lesson defines (\"Atlas means ...\", \"your name is R2\") written as a name mid-sentence in the message; no vector index for a list this short): the Executive's own turn gets the matching ones as a `<lessons>` block in the user turn (`build_lessons_block`, never a cached block; the header says the current request wins and nothing in it authorizes an action), and each specialist call gets the same lines under its `<failure_cases>` block (`router._lessons_for_call` → `lessons_for_query`). A lesson reaches its own person's turns; the principal's reach everyone's only when learned in a shared space (`shared`), so nothing said in someone's own chat is paraphrased into another person's turn. `build_lessons_block` counts each showing against the active turn id and the speaker; when the review later grades that turn, `note_outcome` adds to `fine_after` or `miss_after` only when the turn was the lesson's own person's (nobody else's chats can retire it), and a lesson shown 5 times with more misses than fine turns retires itself (`unhelpful`). At most 40 live lessons per person; their oldest retires to make room (`BEGIN IMMEDIATE`, so two reviews can't both skip it). Forget on the screen retires one by hand (`forgotten`); a retired lesson is listed as stopped, never erased.\n- **Replay: the workspace's own evals** (`memory/replay.py`). Nightly (the `chat_replay` scheduled action, `CHAT_REPLAY_TIME` 03:30 in the user's zone, seeded and chained like the reflection), the Executive runs its misses again with everything in force today and a judge says whether each would now go right. A case is a graded turn: a miss (its `wanted`), or a turn that went fine and got a thumbs up (`kept = 1`, held as long as a miss, at most `MAX_KEPT` 300 per person), which the replay protects so a lesson can't break what worked; a closed miss joins that pool. `due_cases` picks a miss the night a lesson is written for it (`WHY_LESSON`), when a lesson learned since the last night reaches it (`WHY_REACHED`), else once a week (`WHY_WEEKLY`), from the last 30 days only and at most `CHAT_REPLAY_MAX_CASES` (30) a night within `CHAT_REPLAY_MINUTES` (20); 20 protected cases (`WHY_PROTECT`, rotated by last replay) run only on a night a new lesson landed. `replay_case` runs `Executive.chat` on a session rebuilt from the recorded surface and speaker (`chat_review._rebuild_session`) with the saved conversation up to that turn (`chat_messages` before the reply's `message_id`), flagged `Session.replay`: reads run for real through every gate, and every tool a read-only turn is denied (`MCP_CLIENT_WITHHELD_TOOLS`, and gateway calls outside `MCP_CLIENT_MCP_TOOLS`) returns \"done\" and lands in `Session.replay_calls` instead (`faked_handlers` / `faked_call_tool`, wrapped outermost in the agent loop); scripts, Python jobs, `load_mcp_server`, Act as me's tools, `recall_history` and extension tools are not offered at all; nothing a replay does is kept (no extraction, open loops, style, notes, review or Honcho mirror, and `build_lessons_block(count=False)` counts no showing). The judge (`CHAT_REPLAY_JUDGE_MODEL`, else `EVAL_JUDGE_MODEL`, else Sonnet; `evals.judges.judge_message`) reads the original date, the person's words and the conversation before, what they wanted (or the reply they liked), today's reply and the recorded actions, and answers `{passed, time_bound, notes}`, intent and action rather than figures; an unreadable answer is a fail. The gate (`_settle`): a miss that passes is `closed` with `closed_at`; a time-bound one becomes `evidence` and is not replayed again; a lesson for a miss that still fails on `LESSON_FAILS` (2) judged replays after it was learned retires (`replay`); a protected case that fails reopens a closed miss and counts a strike against each new lesson of the same person that reached it (a teammate's turn never retires the principal's shared lessons), which retires at `PROTECT_FAILS` (2) such strikes, so one judged turn, or one message written to fail the judge, is not enough. A case that didn't run (an error, the `CASE_SECONDS` timeout) is recorded with `ran = 0` and settles nothing. The judge's input is scrubbed like outside content (`content_trust._scrub`) with the prompt's own tag names renamed inside it. Every replay is a `chat_review_replays` row (the reply and recorded calls; dropped with its turn when a miss or chat is forgotten or purged, `chat_review._prune_replays`) and a `chat_review` audit row (actor `chat_replay`); each night a `chat_review_replay_runs` row, written before the first case (so a second runner sees nothing new) and filled in after, which is also what \"new since the last night\" means. The nightly Executive carries the scheduler's MCP gateway, so the reads a miss needs run as they did. The Reflection screen's number, \"of the N things that went wrong in the last 30 days, M would go right today\" (`summary_for`, over the misses the caller sees), and each miss's last replay come from these columns on `chat_review_turns` (`replay_state`, `replayed_at`, `closed_at`, `replay_count`, `replay_notes`). Off with `CHAT_REPLAY_ENABLED=false` or when the review itself is off.\n\n## Decision ledger\n\n`openexecutive.memory.decision_ledger` keeps one `decision_instances` row per gated action — a meeting the Executive proposes to book, an Act as me reply card — with how it was resolved, so each class has a reliability record. Every status change is a compare-and-set. A tap with an outside effect (sending an email) claims the row first (`claim_for_execution`, proposed → executing), so of two taps only one acts, and finishes it as `approved_unchanged`, `approved_with_edit` or `failed`, or hands it back (`release_claim`). A row whose class acted on its own with nobody tapping — `gate_mode` `auto_execute`, as Act as me's **Handle it for me** replies are — finishes as `executed` instead, with no resolver, so a reliability read never counts it as an approval. A send whose result is unclear stays `executing` for a reconciler and is never retried. A row still waiting can have its payload changed only by compare-and-set (`update_open_payload`, on `proposed` and, when given, on the payload as it was read): that is how an Act as me reply card takes the person's edit, or records the draft made for it at Send.","mermaid": "flowchart TD\n Store[\"store_decision / store_initiative / store_advice\"]\n DB[\"episodic_memory.db<br/>decisions / initiatives<br/>advice_given / scheduled_actions\"]\n Fmt[\"format_for_prompt\"]\n Turn[\"User turn<br/>past_decisions block\"]\n Mirror[\"append_department_note\"]\n Peer[\"Department peer<br/>(Honcho)\"]\n Store --> DB\n DB --> Fmt\n Fmt --> Turn\n Store -->|\"dept set & not general\"| Mirror\n Mirror -->|\"fire-and-forget\"| Peer\n Tool[\"remember_fact / update_company_profile<br/>(principal, verified, quoted)\"]\n Facts[\"facts table<br/>active / superseded / retired\"]\n Every[\"STANDING FACTS block<br/>chat, specialists, briefs,<br/>alert review, workflows\"]\n Tool --> Facts\n Facts -->|\"render_facts_for_prompt\"| Every\n class Store entry\n class DB storage\n class Fmt compute\n class Turn hot\n class Peer external\n\n class Tool entry\n class Facts storage\n class Every hot",- "generated_at": "2026-10-19T09:30:00Z"+ "generated_at": "2026-10-19T11:20:00Z"}diff --git a/packages/core/openexecutive/memory/chat_review.py b/packages/core/openexecutive/memory/chat_review.pyindex 50576339..b5632418 100644--- a/packages/core/openexecutive/memory/chat_review.py+++ b/packages/core/openexecutive/memory/chat_review.py@@ -825,7 +825,8 @@ was asked.For a miss, say what the person wanted instead in one or two sentences \(wanted), and copy as quote at least four of their exact words, from the THEM \-lines of that turn or the next ones, that show it (a miss a SIGNAL shows needs \+lines of that turn or the next ones, that show it (their correction or their \+ask again, never your own reply) (a miss a SIGNAL shows needs \no quote when they said nothing about it). Then the kind: company when \something only this workspace knows would have fixed it (a term they use, a \fact, a preference, which specialist to ask, doing a thing rather than \@@ -852,7 +853,7 @@ GRADE_TOOL: dict[str, Any] = {"wanted": {"type": "string","description": "For a miss: what the person wanted instead."},"quote": {"type": "string",- "description": "For a miss: at least four of their exact words that show it."},+ "description": "For a miss: at least four of their exact words (a THEM line, never your reply) that show it."},},"required": ["turn", "verdict"],},@@ -1339,6 +1340,9 @@ async def _run_loop(messages: list[dict[str, Any]] = [{"role": "user", "content": content}]done: list[str] = []changes = 0+ # One fact per subject a pass: the model tends to save a correction again+ # in other words, and each save replaces the last.+ facts_saved: set[str] = set()for iteration in range(MAX_ITERATIONS):response = await get_provider(model).messages_create(model=model, max_tokens=_MAX_TOKENS, system=_SYSTEM, tools=tools, messages=messages,@@ -1355,6 +1359,8 @@ async def _run_loop(out = json.dumps({"error": f"no tool {name!r} here"})elif name in _READ_TOOLS:out = await handlers[name](tool_input)+ elif name == "remember_fact" and _fact_key(tool_input) and _fact_key(tool_input) in facts_saved:+ out = json.dumps({"status": "noop", "detail": "a fact under this subject was already saved in this review; a different fact needs its own subject"})elif changes >= MAX_CHANGES:out = json.dumps({"status": "refused", "detail": "change limit for this review reached"})else:@@ -1371,12 +1377,18 @@ async def _run_loop(turns=turns, db_path=db_path)if _went_through(out):done.append(name)+ if name == "remember_fact":+ facts_saved.add(_fact_key(tool_input))results.append({"type": "tool_result", "tool_use_id": block.id, "content": str(out)[:2000]})messages.append({"role": "assistant", "content": response.content})messages.append({"role": "user", "content": results})return done+def _fact_key(tool_input: dict[str, Any]) -> str:+ return " ".join(str(tool_input.get("subject") or "").casefold().split())++def _content_words(text: str) -> set[str]:return {w for w in re.findall(r"[a-z0-9']+", text.casefold())if len(w) >= 4 and w not in _STOPWORDS}diff --git a/packages/core/openexecutive/memory/lessons.py b/packages/core/openexecutive/memory/lessons.pyindex b54ec211..f6234d92 100644--- a/packages/core/openexecutive/memory/lessons.py+++ b/packages/core/openexecutive/memory/lessons.py@@ -14,7 +14,10 @@ The Executive's own turn gets the matching lessons as a ``<lessons>`` block(``build_lessons_block``); each specialist call gets them under the``<failure_cases>`` block it already reads (``lessons_for_query``). A lessonmatches a message when they share two content words (the lesson's text and-the quote it came from, against the message); a short list of short lines+the quote it came from, against the message), or the name the lesson+defines ("Atlas means ...", "your name is R2") written as a name+mid-sentence in the message, since a lesson about what a name means shares+only that word with the question it answers. A short list of short linesneeds no vector index, and the match is what makes the counters below meansomething. The block says the current request wins and nothing in itauthorizes an action, as the style block does.@@ -72,8 +75,8 @@ MAX_ACTIVE = 40MAX_PER_TURN = 6MAX_NEW_WORDS = 2RETIRE_AFTER_SHOWN = 5-# Two shared content words, always: one common word ("report") matches too-# much, so a lesson with a single content word reaches nothing.+# Two shared content words: one common word ("report") matches too much.+# The name a lesson defines is enough (``_defined_names``)._MATCH_WORDS = 2# Beyond the style rules' deny-list (which has the acting verbs and the@@ -395,9 +398,55 @@ def _content_words(text: str) -> set[str]:return {w for w in re.findall(r"[a-z0-9']+", text.casefold()) if len(w) >= 4 and w not in _STOPWORDS}-def _matches(lesson: dict[str, Any], message_words: set[str]) -> bool:+_TOKEN_RE = re.compile(r"[A-Za-z0-9][A-Za-z0-9']*")+# A lesson that says what a name means: "Atlas means ...", "R2 is ...",+# "... is called Atlas", "your name is R2".+_NAME = r"([A-Z][A-Za-z0-9']*|[A-Za-z]*\d[A-Za-z0-9']*)"+_DEFINED_RES = (+ re.compile(_NAME + r"\s+(?:is|means|stands for|refers to)\b"),+ re.compile(r"\b(?:called|call it|named|name is|known as)\s+" + _NAME),+)+++def _names(text: str, *, sentence_starts: bool = True) -> set[str]:+ """The name-like words in ``text``, casefolded: written with a capital+ or a digit ("Atlas", "R2"), not a stopword or a bare number.+ ``sentence_starts=False`` skips a word that opens a sentence, where a+ capital says nothing."""+ out: set[str] = set()+ for m in _TOKEN_RE.finditer(text):+ word = m.group()+ if not any(c.isupper() or c.isdigit() for c in word) or word.isdigit():+ continue+ if not sentence_starts and re.search(r"(^|[.!?:]\s+)$", text[: m.start()]):+ continue+ folded = word.casefold()+ if len(folded) >= 2 and folded not in _STOPWORDS:+ out.add(folded)+ return out+++def _defined_names(text: str) -> set[str]:+ """The names ``text`` says the meaning of: a lesson about what a name+ means ("Atlas means the Dallas warehouse move") shares only that word+ with the question it answers. A name it merely mentions ("Pipeline+ reports go to Sam") is not one."""+ found: set[str] = set()+ for pattern in _DEFINED_RES:+ for m in pattern.finditer(text):+ found |= _names(m.group(1))+ return found+++def _matches(lesson: dict[str, Any], message: str) -> bool:+ """Whether ``lesson`` reaches a turn about ``message``: two shared+ content words, or the name the lesson defines, written as a name+ mid-sentence in the message."""own = _content_words(lesson["text"]) | _content_words(lesson["quote"])- return len(own & message_words) >= _MATCH_WORDS+ if len(own & _content_words(message)) >= _MATCH_WORDS:+ return True+ names = _defined_names(lesson["text"]) | _defined_names(lesson["quote"])+ return bool(names & _names(message, sentence_starts=False))def lessons_for(@@ -411,8 +460,7 @@ def lessons_for(try:from openexecutive.people.store import find_principal_person- words = _content_words(message)- if not words:+ if not _content_words(message) and not _names(message, sentence_starts=False):return []principal = find_principal_person()principal_id = int(principal.id) if principal is not None and principal.id is not None else -1@@ -425,7 +473,7 @@ def lessons_for().fetchall()finally:conn.close()- return [lesson for lesson in map(_out, rows) if _matches(lesson, words)][:MAX_PER_TURN]+ return [lesson for lesson in map(_out, rows) if _matches(lesson, message)][:MAX_PER_TURN]except Exception:logger.debug("lessons: lookup failed", exc_info=True)return []diff --git a/packages/core/openexecutive/memory/replay.py b/packages/core/openexecutive/memory/replay.pyindex a2e51551..c3327937 100644--- a/packages/core/openexecutive/memory/replay.py+++ b/packages/core/openexecutive/memory/replay.py@@ -182,7 +182,7 @@ def _reaches(lesson: dict[str, Any], row: sqlite3.Row) -> bool:mine = int(lesson["person_id"]) == int(row["person_id"])if not mine and not lesson["shared"]:return False- return lessons._matches(lesson, lessons._content_words(str(row["message"])))+ return lessons._matches(lesson, str(row["message"]))def due_cases(diff --git a/packages/core/tests/unit/test_chat_review.py b/packages/core/tests/unit/test_chat_review.pyindex 561a4397..810b943d 100644--- a/packages/core/tests/unit/test_chat_review.py+++ b/packages/core/tests/unit/test_chat_review.py@@ -252,6 +252,17 @@ def test_it_closes_a_loop_the_person_said_is_done(db: Path, roster: SimpleNamespassert _tool_results(provider)[0]["status"] == "closed"+def test_a_fact_is_saved_once_a_review(db: Path, roster: SimpleNamespace, provider: _Provider) -> None:+ _record(roster.principal)+ fact = {"subject": "Vendor email", "statement": "The vendor email was sent already.",+ "source_quote": "I sent the vendor email already"}+ provider.script = [[("remember_fact", fact), ("remember_fact", {**fact, "subject": " vendor EMAIL"})]]+ _review(db)+ first, second = _tool_results(provider)+ assert first["status"] == "ok"+ assert second["status"] == "noop" and "already saved" in second["detail"]++def test_a_change_without_their_words_is_refused(db: Path, roster: SimpleNamespace,provider: _Provider) -> None:loop_id = open_loop(owner_person_id=roster.principal.id, description="Send the vendor email",diff --git a/packages/core/tests/unit/test_lessons.py b/packages/core/tests/unit/test_lessons.pyindex 43db18af..7b989655 100644--- a/packages/core/tests/unit/test_lessons.py+++ b/packages/core/tests/unit/test_lessons.py@@ -124,6 +124,21 @@ def test_a_lesson_reaches_the_turns_it_matches(roster: SimpleNamespace) -> None:assert "Pipeline" not in lessons.build_lessons_block(roster.principal.id, "how is the pipeline looking")+def test_one_shared_name_is_enough(roster: SimpleNamespace) -> None:+ _add(roster.principal.id, "Atlas means the Dallas warehouse move.",+ quote="Atlas always means the Dallas warehouse move")+ _add(roster.principal.id, "Your name is R2.", quote="your name is R2 from now on")+ block = lessons.build_lessons_block(roster.principal.id, "Give me a two-line update on Atlas for the board.")+ assert "Atlas means the Dallas warehouse move." in block and "R2" not in block+ assert "Your name is R2." in lessons.build_lessons_block(roster.principal.id, "Hey, are you R2?")+ # A capital that only opens a sentence, or a bare number, is no name.+ assert lessons.build_lessons_block(roster.principal.id, "Atlas? never mind, book lunch.") == ""+ assert lessons._names("Book 2026 travel. Then Q4", sentence_starts=False) == {"q4"}+ # A name the lesson only mentions is not enough on its own.+ _add(roster.principal.id, "Pipeline reports go to Sam on Fridays.", quote="pipeline reports go to Sam on Fridays")+ assert "Pipeline reports" not in lessons.build_lessons_block(roster.principal.id, "Can you check the Pipeline view?")++def test_a_lesson_from_someones_own_chat_stays_with_them(roster: SimpleNamespace) -> None:"""A principal's lesson reaches everyone only when it was learned in ashared space (a channel or group thread); one from their own chat, like