Skip to content

fix: exclude recordTurn audit records from wake recall - #3

Merged
apresmoi merged 3 commits into
mainfrom
fix/exclude-turn-audit-from-recall
Oct 3, 2026
Merged

apresmoi merged 3 commits into
mainfrom
fix/exclude-turn-audit-from-recall

Conversation

@apresmoi

@apresmoi apresmoi commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Production (2026-10-02): about half of every Daimon `## Memory context` block was old turn records — raw wake envelopes (`Wake request … Carry out this delivery. <delivery …>`), empty `Agent output:` stubs, echoed packet sections (each turn re-wrote every recalled item, so recall fed on itself), and `Observed N tool event(s)` summaries. Stale room messages and superseded verdicts were steering agents.

Root cause: `JsonlMemoryRuntime.recordTurn` → `buildDecisionEvents` / `selectToolSummary` (src/runtime/support.ts) writes these as ordinary claimed/observed/summarized events, and `recallableEvents` returned them as candidates. Daimon only calls `recordTurn`; capture and recall selection are both Mneme's.

Change

  • Every event `recordTurn` writes is tagged `turn-audit`. They stay in the ledger (audit + `memory.written` causal facts unchanged).
  • `recallableEvents` (wake recall) skips `isTurnAuditEvent` events.
  • Legacy ledgers: untagged records are recognised by their exact `recordTurn` shape (type + tags + fixed text template) and only when they carry no kernel `origin` — every memory-tool write is origin-stamped, so agent notes can't match. Old ledgers stop polluting recall without rotation.
  • Not changed: `memory_search` tool filtering (agent-initiated; separate decision).

Tests

  • `src/runtime/turnAudit.test.ts`: tag, legacy shapes, kernel-origin/ordinary notes never match.
  • `src/runtime/turnAuditRecall.test.ts`: a recorded wake keeps its envelope in the audit ledger but never as a recall candidate; recall ignores raw-envelope turn records already present in a pre-existing ledger.
  • Three existing tests seeded recall through `recordTurn` (the removed behavior); they now seed via `kernel.register`.
  • Mutation-checked: removing the recall filter turns both runtime tests red; removing legacy matching turns the legacy-ledger test red.

Daimon follow-up: bump `@noopolis/mneme` once released.

@apresmoi
apresmoi merged commit 920726f into main Oct 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant