Skip to content

fix(memory-core): ignore managed dreaming blocks during daily ingestion - #61720

Merged
vincentkoc merged 7 commits into
openclaw:mainfrom
MonkeyLeeT:codex/fix-dreaming-daily-ingestion-loop
Apr 6, 2026
Merged

vincentkoc merged 7 commits into
openclaw:mainfrom
MonkeyLeeT:codex/fix-dreaming-daily-ingestion-loop

Conversation

@MonkeyLeeT

Copy link
Copy Markdown
Contributor

Summary

  • prevent daily dreaming ingestion from re-reading managed ## Light Sleep and ## REM Sleep blocks out of memory/YYYY-MM-DD.md
  • preserve line numbers while stripping those managed blocks so later evidence coordinates stay stable
  • add a regression test that repeats Light Dreaming three times and locks in a flat candidate set instead of recursive growth

Why

Light/REM phase output can be written inline into the same dated daily note that ingestDailyMemorySignals() re-scans on the next run. That let Dreaming ingest its own generated Candidate: / status: lines and recursively bloat both the recall candidates and the managed block itself.

Root Cause

collectDailyIngestionBatches() chunked raw daily note contents without excluding managed Dreaming sections, while writeDailyDreamingPhaseBlock() writes those sections back into memory/YYYY-MM-DD.md in inline mode.

Fix

Before chunking a dated daily note for ingestion, blank out the managed Light/REM Dreaming blocks identified by their heading + marker pairs. The replacement preserves newline structure so subsequent line references in the same note do not drift.

Validation

  • pnpm test extensions/memory-core/src/dreaming-phases.test.ts
  • pnpm test extensions/memory-core/src/dreaming-markdown.test.ts
  • pnpm exec oxlint extensions/memory-core/src/dreaming-phases.ts extensions/memory-core/src/dreaming-phases.test.ts

Notes

  • I first tried the repo commit hook, but pnpm check currently fails on untouched origin/main TypeScript errors under src/auto-reply/reply/*, so I used the repo's fast-commit path after running the focused Dreaming checks above.

@MonkeyLeeT MonkeyLeeT changed the title [codex] memory-core: ignore managed dreaming blocks during daily ingestion memory-core: ignore managed dreaming blocks during daily ingestion Apr 6, 2026
@MonkeyLeeT MonkeyLeeT changed the title memory-core: ignore managed dreaming blocks during daily ingestion fix(memory-core): ignore managed dreaming blocks during daily ingestion Apr 6, 2026
@MonkeyLeeT
MonkeyLeeT marked this pull request as ready for review April 6, 2026 06:33

@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: 18f13a9141

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@greptile-apps

greptile-apps Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR prevents recursive dreaming bloat by stripping managed ## Light Sleep and ## REM Sleep blocks from daily notes before daily ingestion chunking. It uses blankNonNewlineCharacters to zero out content while preserving newline structure, keeping downstream evidence line coordinates stable.

Confidence Score: 5/5

Safe to merge; fix is correct and well-targeted.

No P0/P1 findings. The strip regex matches the exact block format emitted by replaceManagedMarkdownBlock, newline-preservation is correct, and the regression test covers the key invariant. One P2 concern about a time-sensitive test date does not block merge.

extensions/memory-core/src/dreaming-phases.test.ts — the new regression test uses real Date.now() with a hardcoded lookback window that will expire 2026-04-07.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/memory-core/src/dreaming-phases.test.ts
Line: 94-113

Comment:
**Time-sensitive lookback window**

The `beforeAgentReply` handler calls `runLightDreaming` without an explicit `nowMs`, so it uses real `Date.now()`. Combined with `lookbackDays: 2` and a hardcoded `memory/2026-04-05.md` file, the 2-day lookback window will exclude this file after 2026-04-07 — at which point the loop produces `[0, 0, 0]` instead of `[1, 1, 1]` and the test fails silently. Consider freezing time with `vi.setSystemTime` or wiring a fixed `nowMs` through `runPhaseIfTriggered` so the test stays green regardless of when CI runs it.

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

Reviews (1): Last reviewed commit: "memory-core: harden dreaming block strip..." | 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: a25f91aed8

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@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: 20ffcd2bf9

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@vincentkoc vincentkoc self-assigned this Apr 6, 2026
@vincentkoc
vincentkoc force-pushed the codex/fix-dreaming-daily-ingestion-loop branch from e7acabc to b19958f Compare April 6, 2026 12:22
@vincentkoc
vincentkoc merged commit 2373022 into openclaw:main Apr 6, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Landed via temp rebase onto latest main and squash merge.

Scoped verification:

  • pnpm test extensions/memory-core/src/dreaming-phases.test.ts

Repo-wide note:

  • pnpm check is currently blocked on unrelated latest-main drift in apps/macos/Sources/OpenClaw/HostEnvSecurityPolicy.generated.swift.

  • latest-main pnpm build is also currently red on unrelated TypeScript failures in src/auto-reply/reply/commands-subagents.ts, src/auto-reply/reply/commands-subagents/shared.ts, and extensions/discord/src/proxy-request-client.ts.

  • Land branch head: MonkeyLeeT@b19958f

  • Merge commit: 2373022

Thanks @MonkeyLeeT!

@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: b19958f9f3

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
@MonkeyLeeT
MonkeyLeeT deleted the codex/fix-dreaming-daily-ingestion-loop branch June 4, 2026 06:19
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants