Plan + ADR for channel-memory capability and digest-backed channel-awareness (issue #232 Phase 2) - #262
Plan + ADR for channel-memory capability and digest-backed channel-awareness (issue #232 Phase 2)#262mostlydev wants to merge 3 commits into
Conversation
deee3d2 to
c0b159d
Compare
Purpose and scope (for implementers)This is design-only. Before anyone writes code against it, here is the intent and the boundaries so the implementation lands correctly. Why this existsThis came out of a live incident on a downstream real-money trading desk. Agents there wake cold every turn and share a Discord trading floor as their only common reality. The provider-visible prompt began hitting the ~120s request envelope and timing out. Investigation showed the size driver was the raw 24h The critical finding: the bytes were mostly substantive agent decision content, not telemetry noise. So this is not fixable by truncation or by stripping status lines alone. We need to keep recent floor reality at high resolution while compacting older material, and never drop the exact messages where trading decisions were made. Product goal: retention and recall as first-classThe target model is "high-resolution recent, compact older, exact-source retrievable." Retention (a durable source-of-truth for channel messages) and recall (compact, decision-relevant, provenance-backed) are the actual goals — not byte reduction for its own sake. A 90% smaller feed that drops a fill report, a stop change, or a routing decision is a failure, not a success. The load-bearing invariantSparse/digest blocks are derived artifacts over retained source messages, never a parallel primary history that can diverge. This mirrors ADR-018 (raw ledger stays authoritative) and #164 salience-memory (raw session ledger stays authoritative outside the adapter). If you find yourself building a sparse/digest table that becomes the source of truth for older content, stop — that divergence is exactly what this design exists to prevent. Source messages are authoritative; digest rows point back to them with many-to-many provenance and are recomputed/tombstoned when sources change. In scope (this PR)
Out of scope (do not start here)
Hard prerequisiteDigest provenance cannot round-trip without stable Discord message IDs (or an equivalent stable source handle) in What "done" looks like for a first cut
The downstream desk will supply sanitized real busy-window captures as acceptance evidence once an implementation exists. Two small clarifications worth folding into the plan
|
|
Folded the two provenance clarifications into the plan/ADR in f01155c: current non-deleted source version selection after edits, and explicit sparse=true/false content-fidelity semantics.\n\nI also opened the prerequisite implementation issue (#263) and draft PR #264 for stable channel source handles. #264 intentionally stays below the channel-memory adapter boundary: it only makes current claw-wall awareness/retrieval source-backed enough for the digest work to build on. |
|
Execution follow-up status:
Leaving this as the design/ADR PR; the implementation work is now tracked in the follow-up issues above. |
When a pod declares x-claw.channel-memory.service, claw up flips the generated channel-awareness feed to context_kind=raw_window+digest. claw-wall fetches deterministic digest blocks from channel-memory, renders a compact [digest] section with source_channel + source_messages provenance ahead of a bounded [raw recent] tail, and emits digest status, raw/digest bytes, digest block count, coverage gaps, and deterministic_only in the feed header. Digest lookup is LLM-free and fail-open: on digest error the feed degrades to the full raw window. cllama parses the new header tokens into channel_context_op telemetry (raw-only/digest/stale/unavailable/coverage-gap states) and splits raw vs digest bytes in feed-budget accounting; header parsing stays first-line only so the [digest] body is never mis-parsed. Submodule moves to the released cllama v0.6.8 commit. DefaultCllamaTag stays v0.6.7 and bumps with the next clawdapus release, at which point the telemetry goes live; digest injection itself already works on v0.6.7. Closes #267 Refs #262 #263
…#271) When a pod declares x-claw.channel-memory.service, claw up flips the generated channel-awareness feed to context_kind=raw_window+digest. claw-wall fetches deterministic digest blocks from channel-memory, renders a compact [digest] section with source_channel + source_messages provenance ahead of a bounded [raw recent] tail, and emits digest status, raw/digest bytes, digest block count, coverage gaps, and deterministic_only in the feed header. Digest lookup is LLM-free and fail-open: on digest error the feed degrades to the full raw window. cllama parses the new header tokens into channel_context_op telemetry (raw-only/digest/stale/unavailable/coverage-gap states) and splits raw vs digest bytes in feed-budget accounting; header parsing stays first-line only so the [digest] body is never mis-parsed. Submodule moves to the released cllama v0.6.8 commit. DefaultCllamaTag stays v0.6.7 and bumps with the next clawdapus release, at which point the telemetry goes live; digest injection itself already works on v0.6.7. Closes #267 Refs #262 #263
Summary
This PR fills in the design surface for issue #232 Phase 2 without starting implementation.
It adds:
channel-awarenesschannel-memorycapability boundary andraw_window+digestawareness modelDesign Shape
The plan keeps the existing #232 surfaces rather than creating a new feed:
channel-awarenessremains the provider-visible awareness feedraw_window+digestbecomes the Phase 2 context kindclaw-wallowns Discord ingest, message identity, ACL checks, and feed servingchannel-memoryowns durable channel-message retention, deterministic processing, async LLM digest generation, tombstones, and provenancecllamaowns provider-visible injection, feed budgets, retrieval mediation, andchannel_context_optelemetryStorage And Recall
The plan now requires an indexed durable store for v1, with SQLite as the recommended embedded database. Raw source messages and sparse summaries are not parallel histories: sparse recall blocks are derived rows over retained source-message ranges, with many-to-many provenance back to exact messages.
That allows recent recall to stay detailed while older channel exchanges can compact into sparse
topic_rolluporsequence_rollupblocks.Prerequisite
Digest-backed awareness depends on a tight #232 Phase 1 follow-up:
channel-awarenessand the retrieval tools must expose stable Discord message IDs, or equivalent stable source handles, so digest provenance can round-trip to exact source messages.Validation
Docs-only change. Validated with:
git diff --checkRefs #232.