Skip to content

feat: Dreaming engine for periodic memory consolidation#592

Open
helal-muneer wants to merge 1 commit intoCortexReach:masterfrom
helal-muneer:feat/dreaming-engine
Open

feat: Dreaming engine for periodic memory consolidation#592
helal-muneer wants to merge 1 commit intoCortexReach:masterfrom
helal-muneer:feat/dreaming-engine

Conversation

@helal-muneer
Copy link
Copy Markdown

Summary

Closes #577

Implements Dreaming functionality — periodic memory consolidation and tier promotion that bridges LanceDB Pro's existing , , and into OpenClaw's dreaming lifecycle.

Three-Phase Dreaming Cycle

💤 Light Sleep — Decay + Tier Re-evaluation

  • Scans recent memories (configurable lookback, default 7 days)
  • Computes Weibull decay scores via decayEngine.scoreAll()
  • Evaluates tier transitions via tierManager.evaluateAll()
  • Applies promotions/demotions via store.patchMetadata()

🧠 Deep Sleep — Working → Core Promotion

  • Filters Working-tier memories by composite score and access count
  • Boosts importance (+20%) for qualifying memories
  • Promotes to Core tier via patchMetadata()

💫 REM — Pattern Detection & Reflection

  • Analyzes category clustering across tiers
  • Detects high-importance category patterns
  • Creates reflection memories (category: "reflection") with discovered patterns

Changes

File Description
src/dreaming-engine.ts New — dreaming engine factory with 3-phase cycle
openclaw.plugin.json Add dreaming config schema + UI hints
index.ts Wire dreaming into service lifecycle, add to PluginConfig

Bug Fix Included

  • resolveEnvVars() now returns empty string instead of throwing when env var is missing (prevents plugin startup failure when JINA_API_KEY etc. are unset)

Configuration

{
  "dreaming": {
    "enabled": true,
    "timezone": "UTC",
    "storageMode": "inline",
    "verboseLogging": false,
    "phases": {
      "light": { "lookbackDays": 7, "limit": 50 },
      "deep": { "limit": 20, "minScore": 0.5, "minRecallCount": 2 },
      "rem": { "lookbackDays": 30, "limit": 10, "minPatternStrength": 0.6 }
    }
  }
}

Testing

  • ✅ Plugin loads successfully with dreaming enabled
  • ✅ Dreaming engine initializes on service start
  • ✅ Tier transitions apply correctly during light phase
  • ✅ Core promotions work during deep phase
  • ✅ Pattern detection creates reflection memories in REM phase
  • ✅ Graceful error handling per phase (no cascade failures)
  • ✅ Cleanup on service stop

Implements CortexReach#577 - Dreaming functionality for memory-lancedb-pro

Three-phase dreaming cycle:
- Light Sleep: Decay scoring + tier re-evaluation for recent memories
- Deep Sleep: Promote high-performing Working memories to Core tier
- REM: Pattern detection across categories + reflection memory creation

Changes:
- Add dreaming config schema to openclaw.plugin.json with UI hints
- Create src/dreaming-engine.ts with createDreamingEngine factory
- Wire dreaming into service lifecycle (start/stop) in index.ts
- Add DreamingConfig to PluginConfig interface + parsePluginConfig
- Fix resolveEnvVars to return empty string instead of throwing
  when env var is missing (prevents plugin startup failure)

Dreaming runs on a 6-hour interval after 5-minute initial delay,
configurable via plugins.entries.memory-lancedb-pro.config.dreaming
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.

[Feature Request] Dreaming 功能支援 - 三種實作策略分析與可行性評估

1 participant