Skip to content

fix(memory): keep generated REM reflections out of promotion rankings - #154994

Merged
obviyus merged 7 commits into
openclaw:mainfrom
chelsealong:fix/rem-reflection-contamination-154803
Sep 21, 2026
Merged

obviyus merged 7 commits into
openclaw:mainfrom
chelsealong:fix/rem-reflection-contamination-154803

Conversation

@chelsealong

@chelsealong chelsealong commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #154803

What Problem This Solves

Generated REM reflections in eligible daily memory notes can accumulate ordinary recall signals and appear in promotion rankings after repeated searches.

User Impact

Recognizable REM artifacts no longer compete with ordinary notes for promotion. Ordinary memories, including prose mentioning “Reflections,” remain eligible. Search results themselves remain available; this change filters recall signals and promotion candidates, not retrieval.

Existing managed-block safeguards still independently prevent promoting fenced dreaming output. No configuration, database migration, or user action is required.

Why This Change Was Made

The shared artifact detector now recognizes the actual Markdown ### Reflections heading and note: reflection metadata. It preserves the existing staged-block signature rather than adding a separate filter.

Evidence

Exercised the built, registered memory index, memory search --json, and memory promote --json commands with isolated synthetic daily notes, FTS-only search, and unchanged promotion thresholds. Recall state was populated exclusively by actual searches, never seeded directly.

Default-threshold promotion preview Before (2d71ebc9426e) After
Producer-format REM reflection in an unfenced daily note Ranked, score 0.836 Excluded
Same reflection inside a managed REM block Ranked, score 0.830 Excluded
Two ordinary notes, including prose mentioning Reflections Both eligible Both eligible
Existing staged artifact format Excluded Excluded

Fresh baseline and candidate search results contained the complete reflection heading and metadata. A separate promotion-only check against recall state previously created by the baseline CLI excluded the artifacts while retaining both ordinary notes; search was not rerun in that existing-state check. No promotion was applied, and the existing MEMORY.md sentinel remained unchanged; this does not claim that fenced REM output previously bypassed apply-time safeguards.

The consolidated regression uses the real REM generator and recall-to-ranking path. It failed with the original predicate because the generated reflection remained ranked. On the final revision, the focused promotion suite passed 97/97: 25.73 s wall, 22.64 s Vitest, with the changed regression taking 16 ms. Scoped formatting, assertion safety, and both line-growth ratchets passed without exceptions. The test file shrank instead of adding another fixture-store regression.

chelsealong and others added 2 commits September 21, 2026 15:55
…ming snippets

isContaminatedDreamingSnippet required status: staged AND recalls: N
alongside the narrative lead/confidence/evidence signals. Generated
REM ### Reflections blocks (buildRemReflections in dreaming-phases.ts)
carry note: reflection instead, so they satisfied only three of the
five AND'd conditions and slipped through into promotion scoring.

Accept a reflection-note marker as an alternate to the staged
status/recalls pair, closing the leak (openclaw#154803).
… lead

The prior commit only widened the status/recalls clause to accept
note: reflection, but left hasDreamingNarrativeLead requiring a
colon-suffixed "Reflections:" marker. The real REM generator
(buildRemReflections/previewRemDreaming) emits the block under a
markdown heading, "### Reflections" (no colon), so that clause never
matched real generated content and the fix was unreachable.

Widen hasDreamingNarrativeLead to also match the markdown heading
form, and rewrite the regression test to build its snippet from the
real previewRemDreaming generator output instead of a hand-authored
string that inserted a colon the generator never emits.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 21, 2026, 12:44 PM ET / 16:44 UTC.

ClawSweeper review

What this changes

Memory Core’s promotion filter now recognizes generated REM reflection headings and metadata, with a regression covering generator-produced content.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful, focused fix: current main and the latest release retain the faulty predicate. No introduced correctness defect was found, but real behavior proof is still required before merge.

Priority: P2
Reviewed head: 7d37b397e13b7cc5a314b273b563110fd971b102

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch is focused and source-supported, but test-only evidence leaves the required real-setup proof incomplete.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The supplied generator-to-fixture-store ranking regression supports the predicate repair, but does not show after-fix recall and promotion behavior in a real OpenClaw setup. Add redacted terminal output or logs showing generated REM content excluded while ordinary memory remains eligible; terminal screenshots or recordings also count. Remove private data before posting. Updating the PR body should trigger review automatically; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The supplied generator-to-fixture-store ranking regression supports the predicate repair, but does not show after-fix recall and promotion behavior in a real OpenClaw setup. Add redacted terminal output or logs showing generated REM content excluded while ordinary memory remains eligible; terminal screenshots or recordings also count. Remove private data before posting. Updating the PR body should trigger review automatically; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 9 items Verified introduced change: The pinned merge-base-to-head diff changes only the contamination predicate and its regression. It preserves the staged status/recall signature while adding heading recognition and the reflection-note alternative.
Generator and filter agree after the patch: The REM generator emits a markdown Reflections heading, confidence, memory evidence, and note: reflection; it does not emit the staged status/recall pair. The production REM phase uses this generator when writing its managed block.
Current main still needs the repair: Fetched main still recognizes only colon-suffixed narrative markers and requires both staged status and recalls. It lacks both additions proposed here.
Findings None None.
Security None None.

How this fits together

Memory Core consolidates recalled material into durable memory. Its contamination filter excludes internal dreaming output during recall ingestion, stored-entry loading, candidate ranking, and promotion.

flowchart TD
  A[Recent memory traces] --> B[REM reflection generator]
  B --> C[Daily memory snippets]
  C --> D{Internal dreaming artifact?}
  D -->|Yes| E[Exclude from promotion]
  D -->|No| F[Score memory candidates]
  F --> G[Validated durable memory]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The supplied generator-to-fixture-store ranking regression supports the predicate repair, but does not show after-fix recall and promotion behavior in a real OpenClaw setup. Add redacted terminal output or logs showing generated REM content excluded while ordinary memory remains eligible; terminal screenshots or recordings also count. Remove private data before posting. Updating the PR body should trigger review automatically; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Complete next step (P2) - Supply the real-setup proof described above and add the required focused-test timing to the PR body.
Agent review details

Security

None.

PR surface

Source +12, Tests +72. Total +84 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 14 2 +12
Tests 1 72 0 +72
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 86 2 +84

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #154803
Summary: This PR is the candidate repair for the linked contamination-filter issue; the earlier theme-echo proposal is overlapping historical work, not a viable replacement.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep the repair in the shared contamination predicate so generated REM artifacts are excluded consistently while ordinary memories retain existing eligibility.

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

Yes, source establishes the mismatch: generated REM blocks lack both the colon marker and staged metadata required by current main. The contributor reports a failing regression, but this review did not execute a current-main reproduction.

Is this the best way to solve the issue?

Yes, extending the existing shared predicate is a narrow repair that preserves the prior staged-block check and avoids a competing filter.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against bb3a9b0f40e1.

Labels

Label changes:

  • add P2: This fixes a bounded memory-quality defect where internal REM reflections can enter promotion scoring.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The supplied generator-to-fixture-store ranking regression supports the predicate repair, but does not show after-fix recall and promotion behavior in a real OpenClaw setup. Add redacted terminal output or logs showing generated REM content excluded while ordinary memory remains eligible; terminal screenshots or recordings also count. Remove private data before posting. Updating the PR body should trigger review automatically; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: This fixes a bounded memory-quality defect where internal REM reflections can enter promotion scoring.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The supplied generator-to-fixture-store ranking regression supports the predicate repair, but does not show after-fix recall and promotion behavior in a real OpenClaw setup. Add redacted terminal output or logs showing generated REM content excluded while ordinary memory remains eligible; terminal screenshots or recordings also count. Remove private data before posting. Updating the PR body should trigger review automatically; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • pcpilot-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add after-fix evidence from the real memory recall and promotion flow.
  • Record the focused test’s measured wall time and available CI duration in the PR body.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@obviyus obviyus self-assigned this Sep 21, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling extensions: ollama size: XL and removed size: S labels Sep 21, 2026
@obviyus obviyus changed the title fix(memory-core): classify REM reflection blocks as contaminated dreaming snippets fix(memory): keep generated REM reflections out of promotion rankings Sep 21, 2026
@obviyus
obviyus merged commit 05f3f89 into openclaw:main Sep 21, 2026
110 of 112 checks passed
@obviyus

obviyus commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Merged as 05f3f89.

Generated REM reflections now stay out of recall signals and promotion rankings while ordinary notes remain eligible. Verified through the built memory CLI with fresh and existing recall state, plus 97 passing focused tests. Existing fenced-block safeguards are unchanged.

Thanks @chelsealong for the contribution!

vincentkoc added a commit that referenced this pull request Sep 21, 2026
* commit '8a26ae487b5fb9b72ea2c12bf384e9c776659429': (154 commits)
  fix(ui): preserve skill group expansion when filtering (#150911)
  test(gateway): consolidate server history and lifecycle fixtures (#155063)
  test(codex): select HTTP fallback in native finalizer fixtures (#155008)
  improve: reduce isolated Gateway CI test time (#154366)
  test(gateway): await approval registration acknowledgments
  fix(workboard): explain blocked-card claim recovery (#154990)
  perf(agents): consolidate exec target policy tests (#155060)
  perf(config): consolidate environment test fixtures (#155062)
  fix(ui): keep the chat rail anchored through composer resize
  fix: recovery tests wait for committed outcomes (#154995)
  fix(codex): keep inference bursts from failing turns (#154945)
  fix(memory): keep generated REM reflections out of promotion rankings (#154994)
  fix(sqlite): reclaim scratch files when storage is full (#154937)
  test(cli): spawn the compiled Doctor entry in the output process test (#155055)
  fix(update): distinguish config validation execution failures (#154892)
  test(doctor): await session cleanup before deleting fixture state
  fix(update): report unavailable service inspection accurately (#154896)
  test(gateway): observe plugin approval response completion
  perf(msteams): reduce file-consent test scaffolding (#155050)
  fix(ui): retain saved permissions during delayed startup reads (#154982)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
…openclaw#154994)

Closes openclaw#154803

## What Problem This Solves

Generated REM reflections in eligible daily memory notes can accumulate ordinary recall signals and appear in promotion rankings after repeated searches.

## User Impact

Recognizable REM artifacts no longer compete with ordinary notes for promotion. Ordinary memories, including prose mentioning “Reflections,” remain eligible. Search results themselves remain available; this change filters recall signals and promotion candidates, not retrieval.

Existing managed-block safeguards still independently prevent promoting fenced dreaming output. No configuration, database migration, or user action is required.

## Why This Change Was Made

The shared artifact detector now recognizes the actual Markdown `### Reflections` heading and `note: reflection` metadata. It preserves the existing staged-block signature rather than adding a separate filter.

## Evidence

Exercised the built, registered `memory index`, `memory search --json`, and `memory promote --json` commands with isolated synthetic daily notes, FTS-only search, and unchanged promotion thresholds. Recall state was populated exclusively by actual searches, never seeded directly.

| Default-threshold promotion preview | Before (`6eb97ae49348`) | After |
| --- | --- | --- |
| Producer-format REM reflection in an unfenced daily note | Ranked, score 0.836 | Excluded |
| Same reflection inside a managed REM block | Ranked, score 0.830 | Excluded |
| Two ordinary notes, including prose mentioning Reflections | Both eligible | Both eligible |
| Existing staged artifact format | Excluded | Excluded |

Fresh baseline and candidate search results contained the complete reflection heading and metadata. A separate promotion-only check against recall state previously created by the baseline CLI excluded the artifacts while retaining both ordinary notes; search was not rerun in that existing-state check. No promotion was applied, and the existing `MEMORY.md` sentinel remained unchanged; this does not claim that fenced REM output previously bypassed apply-time safeguards.

The consolidated regression uses the real REM generator and recall-to-ranking path. It failed with the original predicate because the generated reflection remained ranked. On the final revision, the focused promotion suite passed **97/97**: **25.73 s wall**, **22.64 s Vitest**, with the changed regression taking **16 ms**. Scoped formatting, assertion safety, and both line-growth ratchets passed without exceptions. The test file shrank instead of adding another fixture-store regression.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation extensions: memory-core Extension: memory-core extensions: ollama gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: isContaminatedDreamingSnippet's AND-of-five-conditions filter lets REM reflection blocks pass as uncontaminated

2 participants