From d73923caf3801bcf3157b6507038d0ca58822b74 Mon Sep 17 00:00:00 2001 From: Eureka Date: Sun, 1 Nov 2026 08:41:43 +0000 Subject: [PATCH 001/354] =?UTF-8?q?docs:=20chat=20retrieval=20authority=20?= =?UTF-8?q?map=20and=20cut=20(extends=20prose-knowledge-target=20=C2=A74)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- docs/chat-retrieval-map.md | 112 +++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 docs/chat-retrieval-map.md diff --git a/docs/chat-retrieval-map.md b/docs/chat-retrieval-map.md new file mode 100644 index 0000000..9daa5a4 --- /dev/null +++ b/docs/chat-retrieval-map.md @@ -0,0 +1,112 @@ +# Chat retrieval: authority map and cut + +Serves `gamecult-chat:follow_up:chat-s732-733` (Meta, #swarm, 2026-11-01). +Extends `prose-knowledge-target.md` §4. Written by Imagination (Self, run +`mind-20261101T073859496Z`) against Huginn `55484c0`. Nothing here is built. + +## What changed since §4 + +§4 rejected "a second prose index in Huginn" because VoidBot owned prose +retrieval. Ruling `eureka-body:ruling:huginn-owns-prose-retrieval` moved it, and +Huginn now has the index: `huginn-daemon/src/sources` (collection +`huginn_sources`, one writer `refresh` run by the `huginn-sources` oneshot, the +daemon only reads through `sources::search`). The rejection stands in a new +form: **chat joins that organ; there is no second collection, embedder, writer +or search path.** + +## Current mechanism (read, not guessed) + +- `sources::search` (sources/mod.rs:433) embeds ONE text, `Instruct:`-prefixed, + and asks `SourceIndex::search_sources` for the nearest chunks. `SourceQuery` + (huginn-mind wire.rs:103) is `{text: Line, top_k, repo}`; `Line` is 1,000 + bytes, so a long brief cannot even be sent whole, and a clipped brief is one + vector that averages its topics. That is the "long briefs retrieve poorly". +- `Embedder::embed(&[String])` already takes a batch (index/mod.rs:208). +- `SourcesMeta.corpus` is the constant `forge:GameCult`; cursors are + `BTreeMap` written whole by the job alone, advanced only after + acknowledged upserts, dropped before a repo's first delete (sources/mod.rs:9-18). +- A Persona turn's recall (`mind-body/src/recall.rs`) reads only her own mind + and "reads no chat"; ruling `persona-memory-written-not-transcript` says what + she must keep is written as memory, not recovered from a transcript. The + Persona call is tool-less (persona.rs:13), so retrieval has to arrive in her + input; she has no shell. +- Matrix: Synapse is the truth of events. Only the Bifrost mouth holds Matrix + tokens; no Persona unit holds a credential. Rooms are plain (F2 recommends + encrypted DMs only), DMs exist, and the Discord bridge is a later campaign. + Rulings `no-discord-ingestion` and `discord-taints-training` are in force. + +## Authority map + +| Decision | Owner | Forbidden writers | +| --- | --- | --- | +| Which events exist, who sent them, redactions | Synapse | Huginn, Bifrost mouth | +| Which rooms are in the corpus | Huginn `sources` config: an **allowlist** of public community room ids | any Persona, any query | +| Chunks, vectors, cursors for rooms | `sources::refresh`, the one writer | the daemon's `search`, Persona units | +| Query embedding and rank fusion | `sources::search` | the caller (Persona, CLI) | +| What a turn shows from chat | Persona `recall` lane, within a byte budget | the model, the retrieval hit text itself | +| Discord exclusion | the allowlist plus an ingest refusal (below), both in `refresh` | nothing downstream may be relied on to filter | + +One cursor map, keyed by source id (`repo name` or `room id`); a room cursor is +the last event the collection holds, advanced only after acknowledged upserts, +exactly as a repo's commit is. Payload gains `corpus` (`forge` or `chat`) so a +query can filter; `SourcesMeta.corpus` becomes the set both write under, which +is a collection rebuild once (the meta already forces rebuild on mismatch). + +## Citations + +A chat chunk is a window of consecutive messages in one room (bounded by bytes +and a time gap), so a hit cites: room id and alias, the first and last event id +in the window, each message's sender mxid and timestamp inside the chunk text. +A hit renders as quoted data with the organ's own provenance tag; the organ, +never the text, decides what looks like a framed message (the existing +`message_line` rule in persona.rs). Edits replace by event id; a redaction +deletes the chunk window's points and re-chunks the window without it. + +## Cuts, smallest first + +1. **multi-text-query** (no chat needed). `SourceQuery` gains `texts` (1..8 + Lines) beside, then replacing, `text`; `search` embeds all in one + `embed` batch, asks `search_sources` per vector, fuses by reciprocal rank + `score = Σ 1/(k + rank_i)`, k=60 (Cormack, Clarke, Büttcher, SIGIR 2009; k=60 + is their value, and the one place to calibrate), de-duplicates by chunk id, + returns `top_k`. Negative checks: one text gives exactly today's order and + hits; a chunk first in two lists outranks one first in a single list; + duplicated text does not double-count; more than 8 texts or an empty one is + refused naming the field. +2. **chat-ingest**. Port `RoomHistory` (rooms, events after a token); chunker + for message windows; room cursors; redaction; allowlist. Negative checks, + each a test that fails when the rule breaks: a room not on the allowlist is + never read; a room carrying a bridge state event (`m.bridge` / + `uk.half-shot.bridge`) or a sender in a bridge's puppet namespace is refused + whole and named in the journal; an encrypted event is skipped, never stored + as ciphertext; a DM room is refused even if listed; a redacted event's text + is absent from every point after the next refresh; a failed upsert leaves + the cursor where it was. A grep over the collection payload for the Discord + puppet pattern returns nothing. +3. **persona-chat-recall**. A recall lane built from the batch's messages as + the `texts` of cut 1, `corpus=chat`, own byte budget, not shown for text + already in the batch, shown as conversation (not memory). Negative checks: a + hit from a room the sender could not read is never shown (DM rule, persona.rs + `next_batch`); a hit whose text imitates a `message` line or `role=operator` + is rendered quoted and carries no role; the lane failing leaves the turn + going without it (as `Search::Unavailable`). + +Cut 1 ships alone and improves every `huginn sources` caller. Cut 2 waits on +questions 1 and 2. Cut 3 waits on 2 and 3. + +## Questions (put to the operator; admitted as questions) + +1. Credential: who reads Synapse? Recommend a read-only service user, joined + only to allowlisted public rooms, its token a systemd credential on the + refresh job only. Alternatives: Bifrost exports history over typed CultNet + (one more server in the path), or Synapse admin API (broader than needed). +2. Scope: public community rooms only (recommended) or also Persona-visible + private rooms. DMs stay out either way. +3. Recall tension: does transcript search in a Persona turn contradict + `persona-memory-written-not-transcript`? Recommend no: it is lookup, labelled + conversation, not memory; what she must keep is still written. + +Confidence: cut 1 and the owner decision, high. The window chunker size and +k=60 are calibration, not design; RRF over a handful of lists is the +established baseline and I did not survey learned fusion (it needs training +data we lack). From 8d7e8ccffbbb96b9cd625164dcb629dc58e806b4 Mon Sep 17 00:00:00 2001 From: Eureka Date: Thu, 5 Nov 2026 10:58:43 +0000 Subject: [PATCH 002/354] chat-retrieval-map: correct anchors, record answered questions and the stale Persona premise Co-Authored-By: Claude Sonnet 5.5 --- docs/chat-retrieval-map.md | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/docs/chat-retrieval-map.md b/docs/chat-retrieval-map.md index 9daa5a4..799f3a1 100644 --- a/docs/chat-retrieval-map.md +++ b/docs/chat-retrieval-map.md @@ -2,7 +2,7 @@ Serves `gamecult-chat:follow_up:chat-s732-733` (Meta, #swarm, 2026-11-01). Extends `prose-knowledge-target.md` §4. Written by Imagination (Self, run -`mind-20261101T073859496Z`) against Huginn `55484c0`. Nothing here is built. +`mind-20261101T073859496Z`) against Huginn `55484c0`. Nothing here is built. See Status for what changed after writing. ## What changed since §4 @@ -16,20 +16,20 @@ or search path.** ## Current mechanism (read, not guessed) -- `sources::search` (sources/mod.rs:433) embeds ONE text, `Instruct:`-prefixed, +- `sources::search` (sources/mod.rs:439) embeds ONE text, `Instruct:`-prefixed, and asks `SourceIndex::search_sources` for the nearest chunks. `SourceQuery` - (huginn-mind wire.rs:103) is `{text: Line, top_k, repo}`; `Line` is 1,000 + (huginn-mind wire.rs:187) is `{text: Line, top_k, repo}`; `Line` is 1,000 bytes, so a long brief cannot even be sent whole, and a clipped brief is one vector that averages its topics. That is the "long briefs retrieve poorly". -- `Embedder::embed(&[String])` already takes a batch (index/mod.rs:208). +- `Embedder::embed(&[String])` already takes a batch (index/mod.rs:209). - `SourcesMeta.corpus` is the constant `forge:GameCult`; cursors are `BTreeMap` written whole by the job alone, advanced only after acknowledged upserts, dropped before a repo's first delete (sources/mod.rs:9-18). - A Persona turn's recall (`mind-body/src/recall.rs`) reads only her own mind and "reads no chat"; ruling `persona-memory-written-not-transcript` says what she must keep is written as memory, not recovered from a transcript. The - Persona call is tool-less (persona.rs:13), so retrieval has to arrive in her - input; she has no shell. + Persona call was tool-less when this was written and retrieval had to arrive + in her input; that premise no longer holds, see Status below. - Matrix: Synapse is the truth of events. Only the Bifrost mouth holds Matrix tokens; no Persona unit holds a credential. Rooms are plain (F2 recommends encrypted DMs only), DMs exist, and the Discord bridge is a later campaign. @@ -110,3 +110,21 @@ Confidence: cut 1 and the owner decision, high. The window chunker size and k=60 are calibration, not design; RRF over a handful of lists is the established baseline and I did not survey learned fusion (it needs training data we lack). + +## Status (head-maintainer pass, 2026-11-05, Huginn `25199c9`) + +Checked against main on merge. Nothing in this map is built: no `texts` on +`SourceQuery`, no chat code under `sources/`. The anchors above were corrected. +What changed since the map was written: + +- Questions 1 and 2 are answered with the recommendations + (`gamecult-chat:ruling:chat-index-synapse-credential`, operator 2026-11-03, + "I take both recs."; `gamecult-chat:ruling:chat-index-room-scope`, + public-only). Question 3 (`chat-recall-vs-memory-ruling`) is still open. +- **Cut 3's premise is stale.** A Persona now carries a live session under + bubblewrap with a shell and the web (`mind-body/src/persona.rs:53`, `--tools`; + rulings `persona-session-full-sandbox`, `live-mind-sessions`). She can run + `huginn sources` herself, so a pushed recall lane is no longer the only path. + Re-map cut 3 on that before it is specced: whether to push chat hits into her + input at all, and under which budget, is open again. Cuts 1 and 2 are + unaffected. From 3ef5da5e0dd76d503cbdb86df5fcafa2880febca Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 6 Nov 2026 20:17:45 +0000 Subject: [PATCH 003/354] reply kind: one result of her Self session, as its actuator heard it (eureka-pipeline, huginn-mind, schemas, golden) Co-Authored-By: Claude Sonnet 5.5 --- crates/eureka-pipeline/golden/envelopes.txt | 1 + crates/eureka-pipeline/src/lib.rs | 55 ++++++++++- crates/eureka-state/src/bin/huginn/schema.rs | 2 +- crates/huginn-mind/src/admission.rs | 24 ++++- crates/huginn-mind/src/docs.rs | 11 ++- crates/huginn-mind/src/index.rs | 2 +- crates/huginn-mind/src/query.rs | 9 +- crates/huginn-mind/src/rows.rs | 16 +-- .../epiphany.pipeline.finding.v2.schema.json | 3 +- ...epiphany.pipeline.follow_up.v2.schema.json | 3 +- .../epiphany.pipeline.idea.v2.schema.json | 3 +- .../epiphany.pipeline.memory.v2.schema.json | 3 +- .../epiphany.pipeline.question.v2.schema.json | 3 +- .../epiphany.pipeline.reply.v2.schema.json | 97 +++++++++++++++++++ .../epiphany.pipeline.research.v2.schema.json | 3 +- ...piphany.pipeline.resolution.v2.schema.json | 3 +- .../epiphany.pipeline.ruling.v2.schema.json | 3 +- .../epiphany.pipeline.run.v2.schema.json | 3 +- .../huginn.mind_request.v1.schema.json | 51 +++++++++- .../huginn.mind_response.v1.schema.json | 89 ++++++++++++++++- schemas/cultnet/index.json | 11 +++ 21 files changed, 368 insertions(+), 27 deletions(-) create mode 100644 schemas/cultnet/epiphany.pipeline.reply.v2.schema.json diff --git a/crates/eureka-pipeline/golden/envelopes.txt b/crates/eureka-pipeline/golden/envelopes.txt index 596a7cf..c4a9797 100644 --- a/crates/eureka-pipeline/golden/envelopes.txt +++ b/crates/eureka-pipeline/golden/envelopes.txt @@ -29,6 +29,7 @@ sample.pulse yggdrasil:pulse:2026-10-31t041200-t0 epiphany.pipeline.pulse.v2 Epi sample.memory yggdrasil:memory:2026-10-31t041200-t0-m0 epiphany.pipeline.memory.v2 EpiphanyPipelineMemoryDocument 9189a8696e7374616e6365a979676764726173696ca56c6162656cb7323032362d31302d3331743034313230302d74302d6d30a4736f7274a9436f6d6d6974746564a474657874d936492074616b6520746865206261636b67726f756e6420736861646572733b204c6962627920686f6c64732074686520736f756e64732ea561626f757491ab406c696262793a63686174a66f726967696e81a4526f6f6d82a5726f6f6d73a5737761726daa68656172645f66726f6d91ab406c696262793a63686174a7736f757263657391a3246531b173616c69656e63655f7065726d696c6c65cd02bcac636f6e736f6c69646174657390 sample.research eureka-state:research:p1.scope epiphany.pipeline.research.v2 EpiphanyPipelineResearchDocument 9189a863616d706169676eac657572656b612d7374617465a470617373a27031a56c6162656ca573636f7065a5636c61696dd93654686520656d626564206c696d6974206973203430393620746f6b656e7320776974682073696c656e74207472756e636174696f6e2ea664657461696cd934526561642066726f6d20746865206461656d6f6e277320696e646578206d6f64756c6520616e642070726f626564206c6976652ea8696e666572726564c2a7736f75726365739481a45265706f82a47265706fb147616d6543756c742f4570697068616e79a2617484a470617468d9256372617465732f687567696e6e2d6461656d6f6e2f7372632f696e6465782f6d6f642e7273aa73746172745f6c696e6532a8656e645f6c696e6538a6636f6d6d6974a8356639383232386481a357656283a375726cd92268747470733a2f2f7a657474656c6b617374656e2e64652f61746f6d69636974792fa4776f726bb65a657474656c6b617374656e2061746f6d6963697479ac7265747269657665645f6f6eaa323032362d30392d313581a84f6273657276656481a865766964656e636583a46b696e64a454657374a76c6f6361746f72aa636172676f2074657374a6726573756c74a26f6b81a8446f63756d656e7481a97265666572656e636582a46b696e64a652756c696e67a26964b6657572656b612d73746174653a72756c696e673a5238a67365727665739182a46b696e64a85175657374696f6ea26964b8657572656b612d73746174653a7175657374696f6e3a5131ab6f627365727665645f6f6eaa323032362d30392d3135 sample.idea eureka-state:idea:p1.i1 epiphany.pipeline.idea.v2 EpiphanyPipelineIdeaDocument 9189a863616d706169676eac657572656b612d7374617465a470617373a27031a56c6162656ca26931a57469746c65b24f6e65206e6f74652070657220636c61696da469646561d9204b65657020612070617373206173206d616e7920736d616c6c206e6f7465732ea974726164656f666673b74d6f726520646f63756d656e747320746f206c6973742ea872657374735f6f6e9182a46b696e64a85265736561726368a26964be657572656b612d73746174653a72657365617263683a70312e73636f7065a6746f776172649182a46b696e64a85175657374696f6ea26964b8657572656b612d73746174653a7175657374696f6e3a5131ab70726f706f7365645f6f6eaa323032362d30392d3135 +sample.reply yggdrasil:reply:mind-2026-10-09-1-r1 epiphany.pipeline.reply.v2 EpiphanyPipelineReplyDocument 9185a8696e7374616e6365a979676764726173696ca56c6162656cb46d696e642d323032362d31302d30392d312d7231a372756e82a46b696e64a352756ea26964bf79676764726173696c3a72756e3a6d696e642d323032362d31302d30392d31a7616e73776572739182a46b696e64a8466f6c6c6f775570a26964d923657572656b612d73746174653a666f6c6c6f775f75703a61736b2d7468652d73656c66a474657874d93054686520736861646572207061737320697320646f6e653b2074686520736f756e647320617265204c6962627927732e resolution.superseded eureka-state:resolution:question.Q1.n1 epiphany.pipeline.resolution.v2 EpiphanyPipelineResolutionDocument 9185a77375626a65637482a46b696e64a85175657374696f6ea26964b8657572656b612d73746174653a7175657374696f6e3a5131a873657175656e636501a76f7574636f6d6581aa5375706572736564656481a262799282a46b696e64a652756c696e67a26964b6657572656b612d73746174653a72756c696e673a523882a46b696e64a85175657374696f6ea26964b8657572656b612d73746174653a7175657374696f6e3a5131a9726174696f6e616c65a852756c656420412eab7265736f6c7665645f6f6eaa323032362d30392d3135 resolution.fixed-by-none eureka-state:resolution:question.Q1.n1 epiphany.pipeline.resolution.v2 EpiphanyPipelineResolutionDocument 9185a77375626a65637482a46b696e64a85175657374696f6ea26964b8657572656b612d73746174653a7175657374696f6e3a5131a873657175656e636501a76f7574636f6d6581a5466978656482a6636f6d6d6974a83566393832323864a26279c0a9726174696f6e616c65a852756c656420412eab7265736f6c7665645f6f6eaa323032362d30392d3135 resolution.fixed-by-some eureka-state:resolution:question.Q1.n1 epiphany.pipeline.resolution.v2 EpiphanyPipelineResolutionDocument 9185a77375626a65637482a46b696e64a85175657374696f6ea26964b8657572656b612d73746174653a7175657374696f6e3a5131a873657175656e636501a76f7574636f6d6581a5466978656482a6636f6d6d6974a83566393832323864a2627982a46b696e64a94375745265706f7274a26964d921657572656b612d73746174653a6375745f7265706f72743a6375742d33612e6831a9726174696f6e616c65a852756c656420412eab7265736f6c7665645f6f6eaa323032362d30392d3135 diff --git a/crates/eureka-pipeline/src/lib.rs b/crates/eureka-pipeline/src/lib.rs index eab3ca8..e787545 100644 --- a/crates/eureka-pipeline/src/lib.rs +++ b/crates/eureka-pipeline/src/lib.rs @@ -606,6 +606,22 @@ fn pulse_is_well_formed(pulse: &PipelinePulse, at: &str) -> Result<(), PipelineR Ok(()) } +/// A reply says something and answers only follow-ups, from a run. +fn reply_is_well_formed(reply: &PipelineReply, at: &str) -> Result<(), PipelineRefusal> { + if reply.text.0.trim().is_empty() { + return Err(format_error(&format!("{at}.text"), "a reply with no words")); + } + if reply.run.kind != PipelineKind::Run { + return Err(format_error(&format!("{at}.run.kind"), reply.run.kind.name())); + } + for (index, answer) in reply.answers.iter().enumerate() { + if answer.kind != PipelineKind::FollowUp { + return Err(format_error(&format!("{at}.answers[{index}].kind"), answer.kind.name())); + } + } + Ok(()) +} + /// The most thousandths a memory's salience may carry. pub const SALIENCE_MAX_PERMILLE: u16 = 1000; @@ -820,6 +836,11 @@ value_types! { pub struct PipelinePulse { instance: Slug, label: Label, tempo_vote_beat_s: Option, tempo_vote_withdrawn: bool = absent, urgency_permille: Option, note: Line, } => pulse_is_well_formed + /// One result of her Self session, as its actuator heard it: the words her + /// Self ended a turn with, and the follow-ups (briefs) the turn answers. + /// Instance-rooted: the key is `:reply: