Repository navigation
fix(memory): remove interrupted Dreaming sessions after Gateway restart - #117885
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 4:10 AM ET / 08:10 UTC. ClawSweeper reviewWhat this changesThe PR makes the Memory Core plugin reconcile stale Dreaming child sessions at Gateway startup and extends shared SQLite lifecycle cleanup with agent and plugin-owner filtering. Merge readinessKeep this PR open for the requested maintainer decision. Current main only runs Dreaming artifact cleanup from the narrative path and its Gateway-start hook reconciles cron state, so it does not address interrupted child sessions left after a restart; the proposed owner-boundary repair is plausible and has strong reported Gateway-restart proof, but it intentionally reclaims aged ownerless legacy session rows and changes the shared plugin cleanup contract. Priority: P2 Review scores
Verification
How this fits togetherMemory Core schedules and runs Dreaming work through Gateway lifecycle hooks, while session entries and transcripts persist in each agent’s SQLite state. The cleanup path determines which stale Dreaming records disappear from session listings and which active, foreign-plugin, or other-agent records remain. flowchart LR
A[Gateway restart] --> B[Memory Core startup hook]
B --> C[Configured Dreaming agents]
C --> D[SQLite session lifecycle cleanup]
D --> E{Age, agent, and owner filters}
E -->|stale Dreaming child| F[Remove session and transcript artifacts]
E -->|active or foreign state| G[Preserve stored session]
F --> H[Gateway session listings]
G --> H[Gateway session listings]
Decision needed
Why: This is a durable-session cleanup policy with intentional upgrade effects; source and tests can establish mechanics, but they cannot decide whether ownerless historical rows should remain eligible for automatic deletion. Before merge
Agent review detailsSecurityNone. PR surfaceSource +148, Tests +871. Total +1019 across 13 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the Memory Core plugin as the lifecycle owner, land the bounded startup and deferred reconciliation only after explicitly accepting the documented policy for aged ownerless legacy Dreaming rows, and retain the agent/plugin/freshness protections as the canonical shared cleanup contract. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main runs cleanup from the Dreaming narrative path, while the Gateway-start path only reconciles cron state. Restarting after an interrupted child run can therefore retain the persisted child session until another narrative cleanup happens. Is this the best way to solve the issue? Yes, with a maintainer-owned policy confirmation: the plugin owns Dreaming lifecycle timing, while core receives a generic agent/plugin ownership filter instead of Dreaming-specific logic. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 86a95b459c94. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
8be9c5f to
ee288a9
Compare
|
Merged via squash.
|
…r-117788-empty-startup-race * commit '9517b10778ba69b94471cb1f122a5f1e19aa22a4': fix(hooks): show eventless status consistently (openclaw#116127) refactor(cli): consolidate security-sensitive regression fixtures (openclaw#114411) perf(plugins): list from installed metadata (openclaw#117900) fix(memory): remove interrupted Dreaming sessions after Gateway restart (openclaw#117885) test(gateway): reuse startup plugin metadata snapshot (openclaw#117897)
…rt (openclaw#117885) * fix(memory): clean interrupted Dreaming sessions after Gateway restart * test(sessions): preserve historical timestamps in lifecycle fixtures * test(plugins): remove duplicate registry handle mock from main * style(sessions): format lifecycle conformance assertion
Fixes #78458.
What Problem This Solves
Fixes an issue where restarting Gateway during a Dreaming cycle left completed or interrupted Dreaming child sessions visible permanently in the Control UI and session listings.
Why This Change Was Made
Give the memory plugin ownership of bounded Dreaming-session reconciliation during Gateway startup and one deferred age-safe follow-up. Freeze both evaluation clocks at Gateway startup so slow initialization, delayed callbacks, and same-millisecond admissions can never delete sessions created after startup. Use canonical SQLite session/node/window metadata to preserve active or freshly updated sessions, explicitly foreign plugin owners, unrelated users, and other logical agents sharing the same physical store; retain compatibility with previously shipped ownerless Dreaming rows. Existing normal narrative cleanup now uses the same agent-scoped owner instead of scanning every state directory. Missing agent databases are never created by cleanup, and lifecycle timers are cancelled safely on shutdown or a newer Gateway start.
User Impact
Interrupted Dreaming light, REM, deep, and consolidation child sessions disappear automatically after a Gateway restart or after their existing safe age window. Real user sessions, active Dreaming work, other plugins, and other agents remain untouched. No operator action, new configuration, schema migration, file store, or cron scheduling is required.
Evidence
3384a0967ad5cdf4d978276cb769d5713c1e467d, rebased onto the latest main without changing reviewed Dreaming behavior; the final follow-up only applies canonical formatting to an existing conformance assertion.sessions.list, terminates and restarts the process against the same state, and proves old Dreaming children are removed while active, foreign-owned, and unrelated user sessions survive. Dreaming and cron scheduling are disabled during the scenario; no fake startup hook or direct cleanup call is used.loadPluginRegistryHandlekeys insrc/plugins/cli.test.ts, simultaneously breaking required lint and test TypeScript gates. This PR removes only the obsolete first mock, preserving the existing last-definition behavior and the correctactivate: falseloader contract. Exact rebased hosted proof https://github.com/openclaw/openclaw/actions/runs/30738360646 passed targeted core lint, plugin CLI/loader owners, 219 session/config scenarios, 159 memory scenarios, real authenticated Gateway restart, and the complete officialpnpm check:test-typescore/extension/root lanes; command exit 0 and Testbox stopped.gpt-5.6-solxhigh autoreview with--max-priority P2: no actionable P0/P1/P2 findings; final conformance-fix correctness confidence 0.99.