Skip to content

fix(memory-core): drop dreaming theme echoes from promotion candidates - #75139

Closed
keane-751892 wants to merge 1 commit into
openclaw:mainfrom
keane-751892:fix/dreaming-corpus-contamination-filter
Closed

keane-751892 wants to merge 1 commit into
openclaw:mainfrom
keane-751892:fix/dreaming-corpus-contamination-filter

Conversation

@keane-751892

Copy link
Copy Markdown

Summary

Light Sleep / Deep Sleep phases write
```

  • Theme: `X` kept surfacing across N memories.
    ```
    into daily notes. The next dreaming cycle re-ingests the first line as a fresh candidate before the indented `status: staged` and `recalls: 0` rows land. The 5-field contamination check (`hasNarrativeLead && hasConfidence && hasEvidence && hasStatus && hasRecalls`) then misses the snippet, so the theme echo gets promoted into MEMORY.md and the cycle keeps recursing. Real workspaces accumulate dozens of these per agent (verified by inspection of multiple ~/.openclaw/workspace-*/memory/2026-04-*.md files).

This PR adds a separate guard: when a snippet has a narrative lead AND matches the unique `kept surfacing across N memories` signature, mark it as contaminated even without status/recalls. The original 5-field check stays as additional safety.

Test plan

  • pnpm test extensions/memory-core/src/short-term-promotion.test.ts — 45 tests pass, including the new "treats Light Sleep theme echoes as contaminated even without status/recalls" case
  • pnpm check:changed — typecheck and tests green for extension lanes
  • Existing "does not treat ordinary candidate notes with daily-memory evidence as contaminated" still passes (regular candidates without the theme signature stay through)

🤖 Generated with Claude Code

Light Sleep and Deep Sleep phases write
  - Theme: `X` kept surfacing across N memories.
into daily notes. The next dreaming cycle re-ingests just the first
line as a fresh candidate before its indented status:staged and
recalls fields land. The 5-field contamination check then misses it,
so the theme echo gets promoted into MEMORY.md and the cycle keeps
recursing. Real workspaces accumulate dozens of these per agent.

Match the unique "kept surfacing across N memories" signature when a
narrative lead is present, even without status/recalls. Add a
regression test covering both the line-prefixed and bare-Reflections
variants observed in production daily notes.

Thanks @keane-751892
@clawsweeper

clawsweeper Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and the useful part of this older PR is already implemented there.

Close: current main already blocks the reported managed Dreaming theme-echo promotion path with broader source-aware guards, while this old branch is conflicting and its remaining exact predicate-only change is minor/unproven.

So I’m closing this older PR as already covered on main rather than keeping a mostly-duplicated branch open.

Review details

Best possible solution:

Keep the current source-aware managed-block stripping and rehydration fence guard; if a remaining unfenced theme-only leak is observed, open a fresh narrow PR with current-main reproduction and real workspace proof.

Do we have a high-confidence way to reproduce the issue?

Yes, source-level: current main still emits the reported REM theme line, and the old exact predicate would miss a bare theme-only Candidate/Reflections snippet. The managed-block ingestion strip and rehydration fence guard now block the reported generated daily-note path without a live workspace replay in this read-only review.

Is this the best way to solve the issue?

No for merging this stale branch. The current main solution is broader and more source-aware than the predicate-only branch; any remaining exact-signature gap needs fresh proof that it still escapes outside managed Dreaming fences.

Security review:

Security review cleared: The diff only changes a local memory-core string predicate and colocated test; it adds no dependency, workflow, permission, secret, network, or code-execution surface.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • MonkeyLeeT: Authored the merged daily-ingestion fix that blanks managed Light/REM Dreaming blocks before they are chunked into recall candidates. (role: managed-block stripping contributor; confidence: high; commits: 23730229e151; files: extensions/memory-core/src/dreaming-phases.ts, extensions/memory-core/src/dreaming-phases.test.ts)
  • solomonneas: Authored the merged short-term promotion hardening that added the rehydration-time Dreaming fence guard in the same MEMORY.md promotion path. (role: recent adjacent filter contributor; confidence: high; commits: 314903417fcc; files: extensions/memory-core/src/short-term-promotion.ts, extensions/memory-core/src/short-term-promotion.test.ts)
  • gumadeiras: Authored the merged dreaming self-ingestion hardening that added and refined the shared contamination predicate this PR extends. (role: adjacent contamination guard contributor; confidence: high; commits: 0c4e0d703023; files: extensions/memory-core/src/short-term-promotion.ts, extensions/memory-core/src/short-term-promotion.test.ts, extensions/memory-core/src/dreaming-phases.ts)
  • vincentkoc: History ties this handle to the Dreaming phase artifact work that introduced the current REM reflection output shape and to merging the daily-ingestion guard. (role: Dreaming phase contributor and merger; confidence: high; commits: bb440b328f5a, 23730229e151; files: extensions/memory-core/src/dreaming-phases.ts)
  • vignesh07: Authored and merged the original weighted Dreaming promotion flow that owns the short-term promotion pipeline affected by this PR. (role: original promotion feature contributor; confidence: high; commits: 4c1022c73b39; files: extensions/memory-core/src/short-term-promotion.ts, extensions/memory-core/src/dreaming.ts, extensions/memory-core/src/dreaming-phases.ts)

Codex review notes: model internal, reasoning high; reviewed against 010b61746379; fix evidence: commit 010b61746379, main fix timestamp 2026-07-03T13:23:11-07:00.

@RomneyDa

Copy link
Copy Markdown
Member

Heads up: this PR needs to be updated against current main before the new required Dependency Guard check can pass.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jun 14, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label Jun 14, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Jun 26, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 26, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 1, 2026
@clawsweeper

clawsweeper Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: memory-core Extension: memory-core merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants