Skip to content

fix(dreaming): default storage.mode to "separate" so phase blocks stop polluting daily memory files#66412

Merged
jalehman merged 2 commits into
openclaw:mainfrom
mjamiv:fix/dreaming-storage-default-separate
Apr 15, 2026
Merged

fix(dreaming): default storage.mode to "separate" so phase blocks stop polluting daily memory files#66412
jalehman merged 2 commits into
openclaw:mainfrom
mjamiv:fix/dreaming-storage-default-separate

Conversation

@mjamiv

@mjamiv mjamiv commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #66328.

The dreaming pipeline writes Light Sleep and REM Sleep phase blocks to the location selected by dreaming.storage.mode. The mode was already wired up to support "inline" | "separate" | "both" in writeDailyDreamingPhaseBlock, but the unset-default fallback in src/memory-host-sdk/dreaming.ts was hardcoded to "inline". As a result, every installation that didn't explicitly set plugins.entries.memory-core.config.dreaming.storage.mode silently got dream phase blocks injected straight into memory/YYYY-MM-DD.md.

This PR flips the unset-default to "separate". Phase blocks now land in memory/dreaming/{phase}/YYYY-MM-DD.md by default, leaving the daily memory file alone.

Why this matters (#66328)

The reporter measured 340 lines of Light Sleep narrative being injected into a single daily file. A second host on a v2026.4.12 install observed 475 inline lines from the Light phase plus 14 from REM in a single sweep, leaving the daily file unusable as a "what happened today" record - the same dreaming output that gets dumped into DREAMS.md (working correctly) was also being dumped inline.

The reporter also surfaced the symptom side: when an agent reads memory/YYYY-MM-DD.md to answer "what did I do yesterday?" it ends up reading hundreds of lines of dreaming narrative instead of actual event records.

stripManagedDailyDreamingLines already protects the daily-ingestion scanner from re-ingesting dream marker blocks as recall candidates, so the recall side is unaffected by either mode. Flipping the default just stops the daily file from being written to in the first place.

Backward compatibility

Operators who actually want inline behavior can opt in explicitly:

"plugins": {
  "entries": {
    "memory-core": {
      "config": {
        "dreaming": {
          "storage": { "mode": "inline" }
        }
      }
    }
  }
}

normalizeStorageMode continues to accept all three documented modes (inline | separate | both); only the unset-default fallback changes. The MemoryDreamingStorageMode type is unchanged.

Test changes

  • src/memory-host-sdk/dreaming.test.ts adds two new assertions: one pinning the new default shape, and one confirming explicit "inline" still round-trips for opt-in callers.
  • extensions/memory-core/src/dreaming.test.ts updates four default-output assertions in resolveShortTermPromotionDreamingConfig from mode: "inline" to mode: "separate".
  • extensions/memory-core/src/dreaming-phases.test.ts pins LIGHT_DREAMING_TEST_CONFIG and the inline-mode harness in checkpoints daily ingestion and skips unchanged daily files to storage.mode: "inline" with an inline comment, since those tests rely on inline-mode side effects on memory/<day>.md and now need to opt in explicitly. The substantive coverage they provide is unchanged.

The schema accept-test in extensions/memory-core/src/config.test.ts and the inline-mode write-path tests in extensions/memory-core/src/dreaming-markdown.test.ts intentionally keep asserting mode: "inline" because they cover input handling and the inline write path itself, both of which still need to work.

Validation

  • Targeted suite (the 9 test files touching this code): 125/125 pass
    • pnpm vitest run extensions/memory-core/src/dreaming-phases.test.ts extensions/memory-core/src/dreaming.test.ts extensions/memory-core/src/dreaming-markdown.test.ts extensions/memory-core/src/dreaming-narrative.test.ts extensions/memory-core/src/dreaming-command.test.ts extensions/memory-core/src/dreaming-repair.test.ts extensions/memory-core/src/memory-events.test.ts extensions/memory-core/src/config.test.ts src/memory-host-sdk/dreaming.test.ts
  • Pre-commit checks (pnpm check): madge import cycles, tsgo, oxlint, host-env-policy:swift, webhook auth body order, pairing-store-group, pairing-account-scope - all clean.

@greptile-apps

greptile-apps Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Flips DEFAULT_MEMORY_DREAMING_STORAGE_MODE from "inline" to "separate" in src/memory-host-sdk/dreaming.ts, stopping Light Sleep and REM Sleep phase blocks from being injected into daily memory files by default. Tests that relied on inline side-effects are pinned to storage.mode: "inline" with explanatory comments, and new assertions cover both the new default and the explicit opt-in path.

  • One stale defensive fallback in extensions/memory-core/src/dreaming.ts:618 still hardcodes { mode: "inline" } — TypeScript typing prevents it from firing, but it should be updated for consistency.

Confidence Score: 5/5

  • Safe to merge; the one-line default change is correct and well-tested, with only a minor stale fallback comment remaining.
  • All remaining findings are P2: a stale defensive ?? fallback that can't fire in practice due to TypeScript's required-field guarantee. No correctness, data-integrity, or behavior issues remain.
  • extensions/memory-core/src/dreaming.ts line 618 — stale inline fallback, low urgency.

Comments Outside Diff (1)

  1. extensions/memory-core/src/dreaming.ts, line 618 (link)

    P2 Stale inline-mode fallback not updated

    This defensive ?? fallback still hardcodes "inline" after the default flipped to "separate". Because params.config.storage is typed as a required field (MemoryDreamingStorageConfig), this branch should never execute in well-typed flows — but if it did fire at runtime (e.g. via a loosely-constructed config in a test or migration path), deep dreaming reports would silently use the old default instead of the new one.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: extensions/memory-core/src/dreaming.ts
    Line: 618
    
    Comment:
    **Stale inline-mode fallback not updated**
    
    This defensive `??` fallback still hardcodes `"inline"` after the default flipped to `"separate"`. Because `params.config.storage` is typed as a required field (`MemoryDreamingStorageConfig`), this branch should never execute in well-typed flows — but if it did fire at runtime (e.g. via a loosely-constructed config in a test or migration path), deep dreaming reports would silently use the old default instead of the new one.
    
    
    
    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.ts
Line: 618

Comment:
**Stale inline-mode fallback not updated**

This defensive `??` fallback still hardcodes `"inline"` after the default flipped to `"separate"`. Because `params.config.storage` is typed as a required field (`MemoryDreamingStorageConfig`), this branch should never execute in well-typed flows — but if it did fire at runtime (e.g. via a loosely-constructed config in a test or migration path), deep dreaming reports would silently use the old default instead of the new one.

```suggestion
        storage: params.config.storage ?? { mode: "separate", separateReports: false },
```

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

Reviews (1): Last reviewed commit: "fix(dreaming): default storage.mode to "..." | Re-trigger Greptile

@jalehman jalehman self-assigned this Apr 15, 2026
mjamiv added 2 commits April 15, 2026 13:23
…p polluting daily memory files

Closes openclaw#66328.

Before this change, every dreaming installation that did not explicitly
set `plugins.entries.memory-core.config.dreaming.storage.mode` accepted
the silent default of `"inline"`, which routes Light Sleep and REM Sleep
phase blocks (the structured staged-candidate lists with their
`<!-- openclaw:dreaming:{phase}:start -->` markers) into
`memory/YYYY-MM-DD.md`. On heavy days the inline blocks dominate the
daily memory file - the reporter measured 340 lines for the Light phase
alone, and a second cross-host check on a v2026.4.12 install observed
475 inline lines from Light plus 14 from REM in a single sweep, leaving
the daily file unusable as a "what happened today" record.

The `"separate"` storage mode that was already wired up in
`writeDailyDreamingPhaseBlock` writes the same content to
`memory/dreaming/{phase}/YYYY-MM-DD.md` instead, leaving the daily file
untouched. `stripManagedDailyDreamingLines` was already in place so the
daily-ingestion scanner does not re-record dream blocks as recall
candidates either way, but flipping the default also avoids the
incidental round-trip where the dreaming pipeline writes inline output
and then reads its own output back as fresh recall material in the next
cycle.

Operators who want the previous behavior can still opt in explicitly:

    plugins.entries.memory-core.config.dreaming.storage.mode: "inline"

The host helper `normalizeStorageMode` continues to accept all three
documented modes (`inline | separate | both`); only the unset-default
fallback changes.

Test changes:
- src/memory-host-sdk/dreaming.test.ts adds two new assertions: one
  pinning the new default shape and one confirming explicit `"inline"`
  still round-trips for opt-in callers.
- extensions/memory-core/src/dreaming.test.ts updates four
  default-output assertions in `resolveShortTermPromotionDreamingConfig`
  to expect `mode: "separate"`.
- extensions/memory-core/src/dreaming-phases.test.ts pins
  `LIGHT_DREAMING_TEST_CONFIG` and the inline-mode harness in
  "checkpoints daily ingestion and skips unchanged daily files" to
  `storage.mode: "inline"` with a comment, since those tests rely on
  inline-mode side effects on `memory/<day>.md` and now need to opt in
  explicitly.

The schema accept-test in extensions/memory-core/src/config.test.ts and
the inline-mode write-path tests in
extensions/memory-core/src/dreaming-markdown.test.ts intentionally keep
asserting `mode: "inline"` because they cover input handling and the
inline write path itself, both of which still need to work.
…w "separate" default

Address review feedback on openclaw#66412.

`writeDeepDreamingReport` is called with a defensive
`params.config.storage ?? { mode: "inline", ... }` fallback for cases
where the config object is loosely constructed (tests, migrations).
After flipping the unset default to `"separate"` in
`src/memory-host-sdk/dreaming.ts`, this hardcoded `"inline"` fallback
would silently re-introduce the old behavior for any caller that
exercises the fallback branch.

Update the fallback to `"separate"` so all default code paths agree.
The `MemoryDreamingStorageMode` type continues to accept all three
documented modes; this is purely a default-value alignment.
@jalehman
jalehman force-pushed the fix/dreaming-storage-default-separate branch from afee0f4 to 4b1c8ac Compare April 15, 2026 20:23
@jalehman
jalehman merged commit 8c392f0 into openclaw:main Apr 15, 2026
43 checks passed
@jalehman

Copy link
Copy Markdown
Contributor

Merged via squash.

Thanks @mjamiv!

xudaiyanzi pushed a commit to xudaiyanzi/openclaw that referenced this pull request Apr 17, 2026
…p polluting daily memory files (openclaw#66412)

Merged via squash.

Prepared head SHA: 4b1c8ac
Co-authored-by: mjamiv <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
kamskans pushed a commit to kamskans/openclaw that referenced this pull request Apr 17, 2026
…p polluting daily memory files (openclaw#66412)

Merged via squash.

Prepared head SHA: 4b1c8ac
Co-authored-by: mjamiv <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
kvnkho pushed a commit to kvnkho/openclaw that referenced this pull request Apr 17, 2026
…p polluting daily memory files (openclaw#66412)

Merged via squash.

Prepared head SHA: 4b1c8ac
Co-authored-by: mjamiv <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
Mquarmoc pushed a commit to Mquarmoc/openclaw that referenced this pull request Apr 20, 2026
…p polluting daily memory files (openclaw#66412)

Merged via squash.

Prepared head SHA: 4b1c8ac
Co-authored-by: mjamiv <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…p polluting daily memory files (openclaw#66412)

Merged via squash.

Prepared head SHA: 4b1c8ac
Co-authored-by: mjamiv <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…p polluting daily memory files (openclaw#66412)

Merged via squash.

Prepared head SHA: 4b1c8ac
Co-authored-by: mjamiv <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…p polluting daily memory files (openclaw#66412)

Merged via squash.

Prepared head SHA: 4b1c8ac
Co-authored-by: mjamiv <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request May 13, 2026
…p polluting daily memory files (openclaw#66412)

Merged via squash.

Prepared head SHA: 4b1c8ac
Co-authored-by: mjamiv <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…p polluting daily memory files (openclaw#66412)

Merged via squash.

Prepared head SHA: 4b1c8ac
Co-authored-by: mjamiv <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
…p polluting daily memory files (openclaw#66412)

Merged via squash.

Prepared head SHA: 4b1c8ac
Co-authored-by: mjamiv <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
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.

[Bug]: Dreaming Dream Diary entries are written to daily memory files instead of only to DREAMS.md

2 participants