Skip to content

fix(memory): harden dreaming diary pipeline#70332

Closed
vivito wants to merge 2 commits into
openclaw:mainfrom
vivito:fix/dreaming-diary-regressions
Closed

fix(memory): harden dreaming diary pipeline#70332
vivito wants to merge 2 commits into
openclaw:mainfrom
vivito:fix/dreaming-diary-regressions

Conversation

@vivito

@vivito vivito commented Apr 22, 2026

Copy link
Copy Markdown

Summary

  • strip managed dream blocks even when they contain nested subheadings or legacy heading-only sections
  • turn request-scoped dream fallbacks back into diary-style prose instead of raw Reflections: fragments
  • dedupe diary entries by body so identical dream text does not repeat across days, and skip duplicate appends
  • add regression coverage for the strip, fallback, and dedupe paths

Validation

  • node scripts/test-projects.mjs extensions/memory-core/src/dreaming-phases.test.ts extensions/memory-core/src/dreaming-narrative.test.ts extensions/memory-core/src/short-term-promotion.test.ts
  • pnpm build

@greptile-apps

greptile-apps Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR hardens three aspects of the dreaming diary pipeline: managed dream blocks are now stripped correctly even when they contain nested subheadings (the boundary check is now heading-level-aware); request-scoped fallback fragments are converted into poetic diary prose instead of being written as raw Reflections: / Possible Lasting Truths: lines; and diary entries are deduplicated by body text alone (timestamps are excluded from the fingerprint), preventing identical narratives from accumulating across days. All three changes are covered by new regression tests.

Confidence Score: 5/5

Safe to merge; all changes are well-tested and the single finding is a minor variable-shadow style issue with no runtime impact.

Three targeted bug fixes each covered by a dedicated regression test. The only finding (variable shadowing of endIdx/startIdx in the updater closure) does not affect correctness because the early-return exits before the shadowing declarations are reached.

No files require special attention.

Comments Outside Diff (1)

  1. extensions/memory-core/src/dreaming-narrative.ts, line 671-692 (link)

    P2 Variable shadowing for endIdx / startIdx

    The new outer const endIdx (from ensured.indexOf(...)) and, in the else if branch, the pre-existing inner const startIdx and const endIdx shadow each other inside the same closure. No runtime bug occurs because the early-return exits before the shadowing declarations are reached, but TypeScript's no-shadow lint rule (if enabled) will flag these. Consider renaming the outer variables to ensuredStartIdx / ensuredEndIdx to make the intent explicit and remove the shadow.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: extensions/memory-core/src/dreaming-narrative.ts
    Line: 671-692
    
    Comment:
    **Variable shadowing for `endIdx` / `startIdx`**
    
    The new outer `const endIdx` (from `ensured.indexOf(...)`) and, in the `else if` branch, the pre-existing inner `const startIdx` and `const endIdx` shadow each other inside the same closure. No runtime bug occurs because the early-return exits before the shadowing declarations are reached, but TypeScript's `no-shadow` lint rule (if enabled) will flag these. Consider renaming the outer variables to `ensuredStartIdx` / `ensuredEndIdx` to make the intent explicit and remove the shadow.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/memory-core/src/dreaming-narrative.ts
Line: 671-692

Comment:
**Variable shadowing for `endIdx` / `startIdx`**

The new outer `const endIdx` (from `ensured.indexOf(...)`) and, in the `else if` branch, the pre-existing inner `const startIdx` and `const endIdx` shadow each other inside the same closure. No runtime bug occurs because the early-return exits before the shadowing declarations are reached, but TypeScript's `no-shadow` lint rule (if enabled) will flag these. Consider renaming the outer variables to `ensuredStartIdx` / `ensuredEndIdx` to make the intent explicit and remove the shadow.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(memory): harden dreaming diary pipel..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a2e288824

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +390 to 391
if (line.startsWith("*") && line.endsWith("*") && line.length > 2) {
continue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve italic diary lines when fingerprinting duplicates

Skip logic in normalizeDiaryBlockFingerprint now drops every *...* line, not just the timestamp line. When a generated entry contains an italicized standalone sentence, that content is removed from the fingerprint, so distinct diary entries can collapse to the same fingerprint and appendNarrativeEntry/dedupeDreamDiaryEntries may silently skip or delete valid entries.

Useful? React with 👍 / 👎.

@prtags

prtags Bot commented Apr 23, 2026

Copy link
Copy Markdown

Related work from PRtags group safe-marten-ot47

Title: Open PR candidate: Dream Diary duplicate/raw fallback cleanup

Number Title
#65138 Fix dreaming replay, repair polluted artifacts, and gate wiki tabs
#70332* fix(memory): harden dreaming diary pipeline
#70403 fix(memory-core): keep Dream Diary to one entry per sweep
#70523 fix(memory-core): suppress raw dreaming inline dumps on fallback (Fixes #70509)

* This PR

@clawsweeper

clawsweeper Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep open for now: this PR still contains a useful memory-core nested-heading stripping fix, but the branch is not merge-ready because it regresses fallback privacy, changes diary dedupe in a way that can drop valid content, targets a stale memory-host SDK path, and still lacks real behavior proof.

Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

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

Yes for the review blockers: source inspection shows the PR builds fallback prose from staging fragments, drops all italic lines from diary fingerprints, and patches a stale SDK path. I did not run tests or a live dreaming flow because this review is read-only.

Is this the best way to solve the issue?

No. The nested-heading strip direction is useful, but this branch is not the best fix until it preserves fallback secrecy, keeps valid diary body text in fingerprints, targets the active runtime path, and supplies real behavior proof.

Security review:

Security review needs attention: The diff introduces a concrete fallback privacy regression by deriving user-readable DREAMS.md fallback text from raw staging snippets and promotions.

  • [medium] Fallback prose can leak staging fragments — extensions/memory-core/src/dreaming-narrative.ts:146
    The new fallback builder consumes snippets/promotions and persists derived text to DREAMS.md, while current main deliberately writes a generic placeholder to avoid leaking session metadata, conversation summaries, or operational logs.
    Confidence: 0.9

AGENTS.md: found and applied where relevant.

What I checked:

  • stale F-rated PR: PR was opened 2026-04-22T20:23:24Z, is older than 60 days, and the latest review rated it F.
  • proof blocker: real behavior proof is mock_only and proof tier is F, so this branch is not merge-ready without contributor follow-up.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • vincentkoc: Recent history shows multiple memory-core dreaming changes, and current-main blame/review context is relevant to the fallback privacy, fingerprint, and session-ingestion boundaries. (role: recent area contributor and reviewer; confidence: high; commits: 8a4a63ca076e, 077cfca22972, b78713a36391; files: extensions/memory-core/src/dreaming-phases.ts, extensions/memory-core/src/dreaming-narrative.ts, packages/memory-host-sdk/src/host/session-files.ts)
  • Ted Li: Commit 2373022 added stripManagedDailyDreamingLines and daily-ingestion stripping for managed Light/REM blocks, credited in the commit subject to @MonkeyLeeT. (role: introduced managed-block stripping behavior; confidence: high; commits: 23730229e151; files: extensions/memory-core/src/dreaming-phases.ts, extensions/memory-core/src/dreaming-phases.test.ts)
  • Mariano: History search shows request-scoped dreaming fallback hardening and adjacent daily dreaming ingestion/chunking work in the affected memory-core files. (role: fallback and daily-ingestion contributor; confidence: medium; commits: 46f8c4dfd5f9, 4661bf66c4c4, 20cbc11f1a0a; files: extensions/memory-core/src/dreaming-narrative.ts, extensions/memory-core/src/dreaming-phases.ts)
  • Takhoffman: Merged broad dreaming replay, repair, diary cleanup, and session-ingestion work that this PR builds on and partially overlaps. (role: adjacent feature owner; confidence: medium; commits: 847739d82c60; files: extensions/memory-core/src/dreaming-narrative.ts, extensions/memory-core/src/dreaming-phases.ts, packages/memory-host-sdk/src/host/session-files.ts)
  • gumadeiras: The self-ingestion hardening commit added contamination heuristics and tests adjacent to this PR's short-term-promotion changes. (role: adjacent contamination-filter contributor; confidence: medium; 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)

Codex review notes: model internal, reasoning high; reviewed against c21dcfc7c272.

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 14, 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels May 22, 2026
@clawsweeper

clawsweeper Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 7, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Jun 7, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 13, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 Jun 17, 2026
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 Jun 17, 2026
@clawsweeper

clawsweeper Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 21, 2026
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: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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.

1 participant