Repository navigation
Fix #2063: algorithm.lightweightMemory.enabled: true does not actually skip evolution pipel - #2074
Conversation
…eightMemory is enabled (MemTensor#2063) `buildPipelineSubscribers` used to attach reward / L2 / L3 / skill / feedback subscribers unconditionally, so `algorithm.lightweightMemory.enabled: true` only affected `flush()` — every `episode.finalized` still cascaded through the LLM-heavy evolution chain. Startup + periodic recovery compounded the bug: `recoverOpenEpisodesAsSessionEnd` and `recoverDirtyClosedEpisodes` re-emitted `episode.finalized` for legacy episodes that lack `meta.lightweightMemory === true`, producing a large backlog of `skill_generate` / `world_model_generate` / `policy_evolve` calls after every bridge restart. - Gate subscriber attachment in `buildPipelineSubscribers` and return no-op stubs for the runner/handle shape callers depend on. - Treat every orphan / stale / dirty-closed episode as lightweight in the recovery paths of `memory-core.init`, `autoFinalizeStaleTasks`, and `autoRescoreDirtyClosedEpisodes` when the flag is on. - Regression coverage in `tests/unit/pipeline/lightweight-mode.test.ts`.
🤖 Open Code ReviewTarget: PR #2074 🔍 OpenCodeReview found 5 issue(s) in this PR. 1.
|
…ight mode - deps.ts: return throwLightweight(...) in rewardSubscription.runManually and l2.runOnce so control-flow analysis marks subsequent statements unreachable, matching the pattern used by every other throwing stub in the file. - memory-core.ts (autoFinalizeStaleTasks lightweight path): write the lightweight meta BEFORE close() so a failing close() cannot leave an episode without meta.lightweightMemory=true (which would let the periodic non-lightweight rescan pick it up). Also rename the meta fields to closeReason="lightweight_stale" + closedAtMs so observability tooling does not mistake a periodic close for startup recovery. - memory-core.ts (init lightweight orphan close): replace the nested ternary for recoveryReason with an explicit if/else.
🤖 Open Code ReviewTarget: PR #2074 🔍 OpenCodeReview found 3 issue(s) in this PR. 1.
|
…htweight close Three issues in the init() lightweight-orphan-close loop: 1. Ordering: close() was called BEFORE updateMeta(). If close() succeeded but updateMeta() threw, the episode ended up closed without meta.lightweightMemory=true, so autoRescoreDirtyClosedEpisodes would later pick it up and feed it into the reward/L2/L3 pipeline. Now the meta write happens first — matching the periodic stale-topic path. 2. Error isolation: the loop had no per-episode try/catch, so a single DB lock / constraint violation would abort the whole loop and be swallowed by the outer scan-level try/catch. Now each episode has its own try/catch that emits init.lightweight_close_error at debug. 3. Backfill semantics: legacy rows being backfilled were tagged closeReason="finalized" even though they were never actually finalized. They now get closeReason="lightweight_backfill", matching the existing recoveryReason="lightweight_startup_close_backfill" distinction so downstream analytics can tell the two apart.
🤖 Open Code ReviewTarget: PR #2074 🔍 OpenCodeReview found 3 issue(s) in this PR. 1.
|
|
✅ Automated Test Results: PASSEDAll tests passed (36/36 executed). memos_local_plugin/unit: 36/36. Duration: 11s [advisory, non-gating] AI-generated tests on branch test/auto-gen-00ce0051970d8558-20260708232552: 76/83 passed, 7 failed — these do NOT affect the PR verdict; review the branch manually. Branch: |
…t actually skip evolution pipel (MemTensor#2074) * fix(memos-local-plugin): actually skip evolution pipeline when lightweightMemory is enabled (MemTensor#2063) `buildPipelineSubscribers` used to attach reward / L2 / L3 / skill / feedback subscribers unconditionally, so `algorithm.lightweightMemory.enabled: true` only affected `flush()` — every `episode.finalized` still cascaded through the LLM-heavy evolution chain. Startup + periodic recovery compounded the bug: `recoverOpenEpisodesAsSessionEnd` and `recoverDirtyClosedEpisodes` re-emitted `episode.finalized` for legacy episodes that lack `meta.lightweightMemory === true`, producing a large backlog of `skill_generate` / `world_model_generate` / `policy_evolve` calls after every bridge restart. - Gate subscriber attachment in `buildPipelineSubscribers` and return no-op stubs for the runner/handle shape callers depend on. - Treat every orphan / stale / dirty-closed episode as lightweight in the recovery paths of `memory-core.init`, `autoFinalizeStaleTasks`, and `autoRescoreDirtyClosedEpisodes` when the flag is on. - Regression coverage in `tests/unit/pipeline/lightweight-mode.test.ts`. * fix(memos-local-plugin): address open code review findings on lightweight mode - deps.ts: return throwLightweight(...) in rewardSubscription.runManually and l2.runOnce so control-flow analysis marks subsequent statements unreachable, matching the pattern used by every other throwing stub in the file. - memory-core.ts (autoFinalizeStaleTasks lightweight path): write the lightweight meta BEFORE close() so a failing close() cannot leave an episode without meta.lightweightMemory=true (which would let the periodic non-lightweight rescan pick it up). Also rename the meta fields to closeReason="lightweight_stale" + closedAtMs so observability tooling does not mistake a periodic close for startup recovery. - memory-core.ts (init lightweight orphan close): replace the nested ternary for recoveryReason with an explicit if/else. * fix(memos-local-plugin): address round-2 open code review on init lightweight close Three issues in the init() lightweight-orphan-close loop: 1. Ordering: close() was called BEFORE updateMeta(). If close() succeeded but updateMeta() threw, the episode ended up closed without meta.lightweightMemory=true, so autoRescoreDirtyClosedEpisodes would later pick it up and feed it into the reward/L2/L3 pipeline. Now the meta write happens first — matching the periodic stale-topic path. 2. Error isolation: the loop had no per-episode try/catch, so a single DB lock / constraint violation would abort the whole loop and be swallowed by the outer scan-level try/catch. Now each episode has its own try/catch that emits init.lightweight_close_error at debug. 3. Backfill semantics: legacy rows being backfilled were tagged closeReason="finalized" even though they were never actually finalized. They now get closeReason="lightweight_backfill", matching the existing recoveryReason="lightweight_startup_close_backfill" distinction so downstream analytics can tell the two apart. --------- Co-authored-by: autodev <autodev@memtensor.local>
Description
Fixed issue #2063 —
algorithm.lightweightMemory.enabled: truenow actually skips the evolution pipeline in @memtensor/memos-local-plugin. Two independent root causes were addressed. First,buildPipelineSubscribersinapps/memos-local-plugin/core/pipeline/deps.tsused to attach reward / L2 / L3 / skill / feedback subscribers unconditionally, so everyepisode.finalizedevent still cascaded through the LLM-heavy chain — the fix short-circuits the subscriber wiring and returns no-op stubs whosedrain/stop/detach/disposeare safe to call fromflush()/shutdown(), and whose runner methods throw with a "lightweight mode" message if reached (every real caller is already gated on the flag). Second,memory-core.tsstartup + periodic recovery paths (init,autoFinalizeStaleTasks,autoRescoreDirtyClosedEpisodes) used to re-emitepisode.finalizedfor legacy episodes lackingmeta.lightweightMemory === true, producing the >19kskill_generate/ >4.7kworld_model_generate/ >2.1kpolicy_evolvebacklog reported in the issue — those paths now close orphan / stale / dirty-closed episodes silently when the flag is on and tag their meta so subsequent restarts stay quiet. Regression coverage added attests/unit/pipeline/lightweight-mode.test.ts: three tests exercising normal-mode listener presence, lightweight-mode listener absence on capture / reward / L2 buses, and a syntheticepisode.finalizedrecovery emission that must produce zero reward / L2 / L3 / skill events. All 50 existing pipeline unit tests + the openclaw full-chain integration test still pass; TypeScript strict typecheck (tsc --noEmit) is clean. Three pre-existing test failures (startup-recovery,storage/migrator,v7-full-chain e2e) reproduce on the pristine base branch and are out of scope.Related Issue (Required): Fixes #2063
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Automated tests are pending.
Checklist
@hijzy please review this PR.
Reviewer Checklist