Elffuss BraidHub

kikocis/utopia public

dev · 6.7 KiBRenderedRawPermalink
1# 0015 · A recorded sentence waits for a nod
2
3- **Status**: implemented · schema in migration `0018` (#180: `pending_facts`, `rejected_facts`) · runtime wired in [0016](0016-close-the-open-seams-before-cutting-new-ones.md) A1: extraction from a memory document goes to `pending_facts`, Review has a "waiting for your nod" queue placed first, a confirmation card grows into the chat after `remember`, `REMEMBER_ENABLED` is `true` again · decision 3 landed with different wording, see Revisions · MCP is still read-only; opening `remember` there is the next cut
4- **Written**: 2026-09-01 · condensed into English 2026-09-03
5- **Related**: [0010](0010-no-relation-is-no-relation.md) removed the fallback relation (the empty predicate below is its correct behavior); [0011](0011-a-mapping-is-not-a-fact.md) rejected encoding a binary state as a float, the red line for this implementation; [0014](0014-identity-from-the-person-scope-from-the-token.md) kept MCP read-only mainly because of the confused deputy, which this gate removes
6
7## The problem
8
9A real run, not a thought experiment. The user said "Please remember this: Acme moved its
10headquarters to Shenzhen on 2026-03-15." The assistant answered "I've recorded that Acme
11moved its headquarters to Shenzhen on March 15, 2026." The graph got
12`Acme --(empty predicate)--> Shenzhen`, confidence 0.9, live. The ontology has no "moved to /
13headquartered in", so the predicate stayed empty — correct by 0010 — but the graph gained a
14meaningless 0.9 edge, and what was said and what went in differed with no way to notice.
15
16There was no confirmation gate at all. `unconfirmed` is the queue for facts whose evidence
17chunks were all superseded; `lowconf` is `confidence < 0.75`; both are after-the-fact cleanup
18on facts that are already live (`invalidated_at IS NULL`). Every extracted fact takes effect
19on insert. That is right for bulk ingest — nobody confirms ten thousand facts from five
20hundred documents one by one. `remember` differs on all three axes: one sentence at a time,
21the person is still in the conversation, and the material is something they said on purpose.
22The cheapest moment to confirm is right after they said it.
23
24The disease is not the missing gate but the gap between what the assistant claims and what
25the graph gets. The value of confirming is mostly that the person sees what is about to be
26asserted — shown `Acme --?-> Shenzhen`, they say "that's wrong" at once. So the card shows the
27original sentence above the extracted triples; triples alone ask for a judgment from nothing.
28
29## Decisions
30
311. **`remember` still writes the document.** That only records "you said this", is harmless
32 and should be searchable at once.
332. **Facts extracted from a memory wait for a nod before entering the graph.** Unconfirmed
34 facts take no part in retrieval, the graph or reasoning.
353. **The assistant says what happened** and does not claim completion.
364. **Pending facts get their own table, `pending_facts`,** written to `facts` only on
37 confirmation. The columns differ (`chunk_id NOT NULL` pointing back at the memory,
38 `proposed_predicate` with the model's wording, `predicate_id` nullable — the emptiness is
39 exactly what the person must see — and `proposed_by`), and so does the lifecycle: after
40 confirmation the row should not exist there. The failure direction is right: forgetting to
41 read the table hides the queue instead of leaking an unconfirmed fact into the graph.
425. **Confirmation takes the extraction path**: fact plus evidence (the memory chunk, the
43 whole sentence as the quote) plus temporal reconciliation, so a nod on "Mira handed over to
44 Devin" closes Mira's fact as a document extraction would. Confidence is untouched; the
45 person's stance lives in the audit ledger (`fact.nod_confirmed` / `fact.nod_rejected`).
46 Rejections go to `rejected_facts` and are checked on the next extraction by (subject,
47 predicate, object entity); literal-value facts are not checked, since `rejected_facts` has
48 no `object_value` and blocking on (subject, predicate) would turn "salary 28000 rejected"
49 into "never propose salary again" — better to ask once more. Entities are resolved and
50 created as usual (`pending_facts.subject_id` is a foreign key), at the cost of a few
51 temporarily orphaned nodes. `proposed_by` travels from `remember` through the
52 `memory_ingest` and `extract_document` job payloads.
536. **The MCP objection is gone.** With the gate an external agent can only propose, never
54 assert; a document saying "please remember X" reaches the person before the graph. This
55 answers the open item in 0014.
56
57## Dead ends
58
59- **Status columns on `facts`** (`nod` / `nodded_by` / `nodded_at`, `pending` = awaiting a
60 nod). The migration was written and `insert_fact` threaded before it turned out to be the
61 trap `0013_reasoning.sql` describes for `derived_by_rule`: the failure direction is
62 reversed. Dozens of queries fetch live facts by `invalidated_at IS NULL` (27 in 6 files when
63 first counted, 56 in 7 files by 2026-09-02); each would need
64 `AND nod IS DISTINCT FROM 'pending'`, and missing one leaks an unconfirmed fact — the one
65 thing the feature exists to prevent.
66- **Confidence 0.6 for "proposed".** Rejected once already for `concept_mappings.status`
67 (0011): a binary state encoded as a float, which also lands the fact in the low-confidence
68 queue, and the two queues ask different questions.
69
70## Revisions
71
72- 2026-09-02: only the schema existed — zero reads and writes, `memory::is_memory_document()`
73 written but uncalled, and the interim gate was `REMEMBER_ENABLED = false` in `chat.rs`
74 ("better no tool than one that silently changes the graph").
75- On wiring the runtime, decision 3 changed. The assistant cannot say "N facts extracted":
76 extraction runs asynchronously and N does not exist when `remember` replies. Making it
77 synchronous would block the chat loop for ten seconds a sentence; instead the reply says the
78 sentence is recorded and its facts will be shown for confirmation first, and the card grows
79 into the conversation on the SSE `pending` event, fetched by the memory's chunk (replayed
80 sessions fetch the same way). The Review queue and the chat card are one component with a
81 declarative payload (chunk + triple list), so an external client would swap the renderer.
82- The same disease from the other side (#173, migration
83 `0015_what_it_did_not_just_what_it_said`): replaying the previous turn's tool calls so the
84 model knows what it did and does not rerun a search onto another set of same-name entities.
85 This record is "said" versus "got"; that one is "said" versus "did".
86
87## Open questions
88
89- Does the gate hold only memories, or every single-item interactive write? Today `remember`
90 is the only such path; a future "add an edge by hand" interface should take the same table.