Skip to content

feat: dreaming engine with scope isolation and embedded reflections#799

Open
jlin53882 wants to merge 4 commits into
CortexReach:masterfrom
jlin53882:pr-752-rebuild
Open

feat: dreaming engine with scope isolation and embedded reflections#799
jlin53882 wants to merge 4 commits into
CortexReach:masterfrom
jlin53882:pr-752-rebuild

Conversation

@jlin53882
Copy link
Copy Markdown
Contributor

Summary

Rebuild of PR #752 with targeted openclaw.plugin.json changes — no more block-replace noise.

What changed

File Change
openclaw.plugin.json Only +5 semantic additions (dreaming block + existing fields preserved)
src/dreaming-engine.ts +488 — dreaming engine core
test/dreaming-engine.test.ts +566 — unit tests
index.ts +173 — wired dreaming into start()
scripts/ci-test-manifest.mjs +2 — test registration

Previous issue (fixed here)

Commit 3212c3a in the original PR replaced the entire openclaw.plugin.json block, accidentally removing:

  • memoryReflection.excludeAgents
  • memoryReflection.serialCooldownMs
  • autoRecallBadRecallDecayMs
  • autoRecallSuppressionDurationMs

This rebuild uses targeted diff instead, preserving all existing fields.

Test coverage

  • MR1 — scope isolation (each phase filters store.list() by scope)
  • MR2 — REM reflection loop prevention (metadata.source = 'dreaming-engine' exclusion)
  • F2 — embedded reflections via embedder.embed()
  • F3 — DEFAULT_DREAMING_CONFIG + mergeDreamingConfig() null-safe deep merge
  • All 3 phases (Light / Deep / REM)
  • Error resilience

Breaking change note

index.ts:2034 calls api.registerMemoryCapability(...) unconditionally. Requires OpenClaw host that provides this API. Will crash on older hosts.

TurboTheTurtle and others added 4 commits May 12, 2026 18:58
Co-authored-by: Andy Ye <andy@Andys-MacBook-Pro-2.local>
… tests

Clean implementation addressing all reviewer feedback from PR CortexReach#592:

MR1 — Scope isolation: Each phase filters store.list() by scope.
Dreaming runs per-scope using scopeManager.getAllScopes().

MR2 — REM reflection loop prevention: Reflections tagged with
metadata.source = 'dreaming-engine' and excluded from all phase inputs.

F2 — REM reflections now embedded via embedder.embed() instead of
vector: []. Falls back to zero-vector on embedding failure.

F3 — DEFAULT_DREAMING_CONFIG + mergeDreamingConfig() provides
null-safe deep merge. Minimal config { enabled: true } works.

F6 — Removed unimplemented fields (storageMode, separateReports,
timezone) from schema. Only runtime-active fields exposed.

Also includes:
- 8 unit tests covering MR1, MR2, F2, F3, all 3 phases, error resilience
- Dreaming wired inside async start() callback (fixes ParseError)
- Cron scheduler with per-scope execution
- DREAMS.md report generation per scope

# Conflicts:
#	openclaw.plugin.json
Copy link
Copy Markdown

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

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: 86e5ddb48a

ℹ️ 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".

{ group: "cli-smoke", runner: "node", file: "test/functional-e2e.mjs" },
{ group: "storage-and-schema", runner: "node", file: "test/per-agent-auto-recall.test.mjs", args: ["--test"] },
{ group: "core-regression", runner: "node", file: "test/retriever-rerank-regression.mjs" },
{ group: "core-regression", runner: "node", file: "test/upgrader-compactor-rerank-fixes.test.mjs" },
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Point the CI manifest at an existing test

This new manifest entry references test/upgrader-compactor-rerank-fixes.test.mjs, but that file is not present (I checked the repo with find test scripts src ...), so node scripts/verify-ci-test-manifest.mjs now fails with missing test file on disk, and scripts/run-ci-tests.mjs --group core-regression will also fail when it tries to spawn this path. This blocks the packaging/workflow test path instead of registering the new dreaming test.

Useful? React with 👍 / 👎.

Comment thread index.ts
}
// Flush and destroy AccessTracker on plugin stop
try {
if (accessTracker) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the access tracker reachable for shutdown

When the service stop hook runs, accessTracker is not in this scope because it was declared locally inside _initPluginState() and is not returned in the singleton state. In the transpiled runtime this if (accessTracker) throws a ReferenceError that is caught here, so destroy() never runs and any debounced access-count flush/timer can be left behind after plugin shutdown.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants