Skip to content

fix(memory-core): recover dreaming cron after startup list failure - #115174

Merged
steipete merged 2 commits into
openclaw:mainfrom
IWhatsskill:agent/fix-memory-dreaming-startup-reconcile-recovery
Jul 28, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
IWhatsskill:agent/fix-memory-dreaming-startup-reconcile-recovery

Conversation

@IWhatsskill

@IWhatsskill IWhatsskill commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

[AI-assisted]

What Problem This Solves

When memory-core's first managed dreaming Cron list operation rejects, the gateway logs the startup error but never starts the periodic reconciliation owner. That transient failure can therefore leave the managed dreaming job absent or stale until an unrelated runtime trigger or another gateway restart.

Failure mode

A Cron service can be present while its first list operation fails transiently. The startup catch logs that failure, but the old success-only timer setup leaves no periodic owner to retry the reconciliation.

Why This Change Was Made

The gateway-start hook now arms its existing recovery owners in a finally path after the initial reconciliation settles. Runtime timer creation also checks the plugin's disposed state so a concurrent gateway stop cannot resurrect recovery after shutdown.

Root Cause

Both startRuntimeCronReconcileTimer() and scheduleStartupCronRetry() were called inside the successful side of the startup try. Any thrown reconciliation skipped both calls.

Lifecycle boundary

Moving timer setup to finally restores recovery after thrown startup work. The added disposed-state guard preserves the opposite transition: if gateway_stop wins while startup reconciliation is pending, the completing startup hook cannot install a new interval.

User Impact

Managed memory dreaming now self-heals after a transient startup Cron list failure on the existing 60-second cadence. Successful startup behavior, Cron-unavailable retries, managed job shape, runtime throttling, persistence, and gateway-stop cleanup remain unchanged.

Evidence

Exact-head proof is bound to ff4b779b5b53261a2694bdd53fe3e1ffca51266c; expand the ledger for direct behavior, commands, preserved boundaries, gaps, and artifacts.

Inspect exact-head proof ledger

Provenance

  • Base: 4f6fc38a22042ba3b08f04b9388864b3e4d4b149
  • Proof head: ff4b779b5b53261a2694bdd53fe3e1ffca51266c
  • Revalidated: after merging current upstream main

Direct behavior

  • Real CronService lifecycle recovery (PRODUCTION_RUNTIME; boundary: production lifecycle callbacks, real timer, real CronService, and real SQLite; only plugin registration and lifecycle context are harnessed) — Observed: The production registerShortTermPromotionDreaming lifecycle hook received a real started CronService. Only its first real list call was fault-injected. Startup observed one failed list and zero managed jobs. At the observation made 61,258 ms after startup, the second list had run, the real service had created exactly one managed job, and the independently opened read-only SQLite snapshot passed integrity_check with exactly one matching cron_jobs row. The production gateway_stop hook then completed. Result: PASS on exact merge head ff4b779b5b53261a2694bdd53fe3e1ffca51266c with no CronService, timer, or persistence double. Proves a transient first Cron list rejection no longer disables the periodic owner, and recovery reaches the real persistent managed-job boundary. Preserves the existing 60-second cadence, configured schedule, isolated target, agentTurn payload, no-delivery mode, SQLite schema, and gateway-stop lifecycle.

Exact-head real CronService lifecycle proof

REAL_CRONSERVICE_LIFECYCLE_PROOF PASS
exactHead=ff4b779b5b53261a2694bdd53fe3e1ffca51266c
failure.cronClass=CronService
failure.listCallsAfterStartup=1
failure.managedJobsAfterFailure=0
recovery.elapsedMs=61258
recovery.listCalls=2
recovery.managedJobs=1
recovery.sqliteRows=1
persistence.snapshotPages=376
shutdown.gatewayStopHookInvoked=true
runtime.mockedAffectedOwners=none

Independent SQLite inspection: DatabaseSync readOnly=true; integrity_check=ok; cron_jobs rows=1; schedule=17 4 * * * UTC; sessionTarget=isolated; wakeMode=now; payloadKind=agentTurn; lightContext=1; deliveryMode=none.

Automated verification

Focused lifecycle behavior

node scripts/run-vitest.mjs extensions/memory-core/src/dreaming.test.ts
  • node scripts/run-vitest.mjs extensions/memory-core/src/dreaming.test.ts — 34/34 tests passed with 0 failures and 0 skips on exact merge head. Proves startup failure recovery, one runtime interval owner, the Cron-unavailable retry path, and gateway_stop preventing post-disposal timer creation. Preserves existing startup success, retry, throttle, idempotence, disabled-mode cleanup, and managed-job behavior.

Static verification

./node_modules/.bin/oxfmt --check extensions/memory-core/src/dreaming.ts extensions/memory-core/src/dreaming.test.ts
  • ./node_modules/.bin/oxfmt --check extensions/memory-core/src/dreaming.ts extensions/memory-core/src/dreaming.test.ts — both exact-head files matched the required format. Proves the merged two-file patch follows repository formatting. Preserves the bounded source and regression-test scope.
./node_modules/.bin/oxlint extensions/memory-core/src/dreaming.ts extensions/memory-core/src/dreaming.test.ts
  • ./node_modules/.bin/oxlint extensions/memory-core/src/dreaming.ts extensions/memory-core/src/dreaming.test.ts — 0 warnings and 0 errors across 212 rules on exact merge head. Proves the changed TypeScript satisfies the focused lint rules after the upstream merge. Preserves the existing plugin API and test contracts.
git diff --check 4f6fc38a22042ba3b08f04b9388864b3e4d4b149...ff4b779b5b53261a2694bdd53fe3e1ffca51266c
  • git diff --check 4f6fc38a22042ba3b08f04b9388864b3e4d4b149...ff4b779b5b53261a2694bdd53fe3e1ffca51266c — exit 0 with no whitespace errors. Proves the exact current-main-to-merge-head patch is whitespace-clean. Preserves the bounded two-file manifest.

Preserved boundaries

  • The five-second Cron-unavailable startup retry path and its attempt limit are unchanged and remain covered by the focused suite.
  • The runtime reconciliation interval, throttle, and managed Cron job schema are unchanged.
  • gateway_stop still clears both timer owners, including when it wins an in-flight startup race.
  • The real-service proof persisted the existing schedule, isolated target, agentTurn payload, light-context flag, and no-delivery mode without schema changes.
  • An already-running Cron API operation is not cancelled by this change; only recovery-owner reinstallation after disposal is prevented.
  • No configuration, network, authentication, authorization, or user-data contract changes.

Proof gap

The scoped behavior is proved with the production memory-core lifecycle callbacks, a real 60-second timer, real CronService, and real SQLite persistence. The harness supplies only the plugin API registration/context and injects one first-list rejection; it does not bind a network listener or install a long-lived service because this patch changes neither surface. Separate add/update rejection scenarios and cancellation of a Cron operation already running at gateway_stop are not claimed.

Artifacts

  • Retained exact-head runtime evidence: REAL_CRONSERVICE_LIFECYCLE_PROOF PASS; exactHead=ff4b779b5b53261a2694bdd53fe3e1ffca51266c; startup list calls 1; managed jobs after failure 0; recovery observed by the 61,258 ms check; recovery list calls 2; managed jobs 1; SQLite rows 1; snapshot pages 376; gateway-stop hook invoked; mocked affected owners none. Separate read-only inspection returned integrity_check=ok and the expected row.
  • Runtime artifact digests: harness 55ab6cc022806d1b5318b064e5ce2ac6a1d3f83acda236bf797d2478f566ff01; full terminal 56fb57ebd974a250ad73d15b29aafac4eb8a4393033001e8a147a72644a52498; summary cfbfa38fc10d90166e90332369f00a6e175afc48ff4dc50fe798cb64f41fa707; self-contained SQLite bb6d9764e9f14e570c5680c3cb864201bdc2405c71c1164762659e0f8f946ab5; inspector 9d9d61c8372caed3289aad4902b5560ca1901fe89587862a2fed4e203350cf8e; inspection output 764b48c77a5022aa12a84408af6dd2161c025b718d0fbcd1e394b1eecb1f9673.
  • Retained exact-head focused-suite transcript: node scripts/run-vitest.mjs extensions/memory-core/src/dreaming.test.ts; Test Files 1 passed (1); Tests 34 passed (34); [test] passed 1 Vitest shard in 16.33s. Terminal SHA-256 b83eba0df0066347d5ddd2188834822dbc74a43e6b7fed55f4a02fe70c293c2b.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 28, 2026, 11:19 AM ET / 15:19 UTC.

ClawSweeper review

What this changes

This PR moves memory-core’s dreaming-Cron recovery-owner setup into the gateway-start completion path and prevents the periodic reconciliation timer from being created after disposal.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

The proposed lifecycle fix is narrowly scoped and its supplied exact-head evidence is strong: an initial managed-Cron list failure now reaches the existing recovery cadence without recreating recovery after shutdown. The PR is currently behind main, however, so the real CronService lifecycle proof should be refreshed against the current merge result before maintainers merge it.

Priority: P2
Reviewed head: ff4b779b5b53261a2694bdd53fe3e1ffca51266c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused reliability fix with strong direct behavior evidence; the remaining merge gate is refreshing that evidence on the current merge result.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body supplies exact-head, after-fix real CronService and SQLite evidence showing recovery after the injected first-list failure, plus the persisted managed job and gateway-stop completion; refresh it after rebasing onto current main.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies exact-head, after-fix real CronService and SQLite evidence showing recovery after the injected first-list failure, plus the persisted managed job and gateway-stop completion; refresh it after rebasing onto current main.
Evidence reviewed 4 items Proposed lifecycle repair: The PR changes the gateway-start handler so both recovery owners run from finally after startup reconciliation settles; the periodic owner additionally refuses creation after disposal.
Focused regression coverage: The supplied PR diff adds coverage for a first Cron list rejection recovering on the runtime interval and for gateway stop winning the in-flight startup race.
Real behavior proof: The PR body reports exact-head real-CronService evidence: after one injected initial list failure, the next reconciliation created one managed job and a read-only SQLite inspection found one matching row; gateway stop then completed.
Findings None None.
Security None None.

How this fits together

Memory Core’s dreaming feature creates and reconciles a managed Cron job when the gateway starts, then periodically rechecks it. Gateway lifecycle events supply the Cron service and configuration; successful reconciliation produces a persisted managed job, while gateway stop clears its retry and interval owners.

flowchart LR
  A[Gateway start event] --> B[Memory Core dreaming handler]
  B --> C[Initial managed Cron reconciliation]
  C --> D[Recovery-owner setup]
  D --> E[Periodic reconciliation]
  E --> F[Managed dreaming Cron job]
  G[Gateway stop event] --> H[Dispose retry and interval owners]
  H --> D
Loading

Before merge

  • Resolve merge risk (P1) - The current PR head is behind main; its direct real-service proof is tied to ff4b779b5b53261a2694bdd53fe3e1ffca51266c, so merging should wait for a rebase and refreshed lifecycle evidence on the current merge result.
Agent review details

Security

None.

PR surface

Source +1, Tests +125. Total +126 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 3 +1
Tests 1 125 0 +125
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 129 3 +126

Review metrics

Metric Value Why it matters
Recovery owners 2 existing owners moved to the startup completion path Both the periodic reconciler and the Cron-unavailable retry remain armed after a thrown initial reconciliation instead of only after the success path.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/memory-core/src/dreaming.test.ts, vector/embedding metadata: extensions/memory-core/src/dreaming.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Refresh proof on current main (recommended)
    Rebase onto current main and rerun the focused dreaming lifecycle test plus the real CronService recovery scenario against the resulting merge head.
  2. Accept the stale-base evidence
    A maintainer may merge the clean result without refreshed proof if they judge intervening main changes cannot affect this lifecycle boundary.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Rebase onto current main, then attach exact-head focused lifecycle and real CronService recovery proof showing both startup-failure recovery and gateway-stop disposal behavior.

Technical review

Best possible solution:

Rebase the focused two-file fix onto current main, retain the disposed-state lifecycle guard, and publish refreshed focused and real CronService recovery evidence for the resulting head before merge.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: the supplied regression setup makes the first Cron list reject during gateway startup and then advances the existing reconciliation interval. The PR also supplies a real-CronService run that observes recovery into persisted managed-job state.

Is this the best way to solve the issue?

Yes, subject to current-base refresh: using the existing timer owners in the startup completion path addresses the skipped-success-path failure without adding configuration, schema, or a parallel recovery mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 35f035806baf.

Labels

Label justifications:

  • P2: This is a bounded reliability repair for an optional managed background Cron job whose transient startup failure can leave reconciliation absent until a later trigger.
  • merge-risk: 🚨 availability: The patch changes gateway lifecycle timer ownership, which determines whether managed Cron reconciliation resumes after startup failure and remains stopped after disposal.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies exact-head, after-fix real CronService and SQLite evidence showing recovery after the injected first-list failure, plus the persisted managed job and gateway-stop completion; refresh it after rebasing onto current main.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head, after-fix real CronService and SQLite evidence showing recovery after the injected first-list failure, plus the persisted managed job and gateway-stop completion; refresh it after rebasing onto current main.

Evidence

What I checked:

Likely related people:

  • unknown: The supplied PR context identifies only the proposed-branch author and does not provide prior current-main attribution for the affected memory-core lifecycle code; the author is therefore not treated as a current-main owner. (role: area-history attribution unavailable; confidence: low; files: extensions/memory-core/src/dreaming.ts, extensions/memory-core/src/dreaming.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase the branch onto current main and rerun the supplied focused lifecycle and real CronService recovery proof on the resulting head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-07-28T12:08:05.941Z sha 3fea8d2 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-28T12:24:27.328Z sha 3fea8d2 :: needs maintainer review before merge. :: none

@IWhatsskill
IWhatsskill marked this pull request as ready for review July 28, 2026 12:20
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 28, 2026
@steipete
steipete merged commit bb06e0f into openclaw:main Jul 28, 2026
90 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 28, 2026
…etwork-none

* origin/main: (24 commits)
  refactor(sessions): isolate legacy transcript fixtures (#115231)
  fix(discord): clear pending launch watchdog (#115100)
  fix(agents): stop quadratic subagent prompt rendering (#115263)
  fix(memory-core): recover dreaming cron reconciliation (#115174)
  fix(qa-lab): filter incompatible channel scenarios (#115087)
  fix(android): respect locale in compact labels
  test(i18n): prove iOS discovery catalog ownership
  chore(i18n): refresh gateway discovery catalogs
  fix(i18n): include shared discovery copy in macOS catalog
  fix(apple): localize gateway discovery status
  chore(i18n): drop release-owned changelog entry
  fix(macos): localize privacy permission prompts
  fix(voice-call): bracket IPv6 webhook hosts (#115135)
  test(ci): split control UI scope coverage
  fix(ui): detect composed accessibility copy
  fix(ci): run localization checks for UI changes
  test(ui): catch untranslated accessibility labels
  fix(ui): localize chat action labels
  fix(ui): localize chat status indicators
  fix(ui): sync document locale metadata
  ...
vincentkoc added a commit that referenced this pull request Jul 28, 2026
…-20260728

* origin/main: (21 commits)
  refactor(sessions): isolate legacy transcript fixtures (#115231)
  fix(discord): clear pending launch watchdog (#115100)
  fix(agents): stop quadratic subagent prompt rendering (#115263)
  fix(memory-core): recover dreaming cron reconciliation (#115174)
  fix(qa-lab): filter incompatible channel scenarios (#115087)
  fix(android): respect locale in compact labels
  test(i18n): prove iOS discovery catalog ownership
  chore(i18n): refresh gateway discovery catalogs
  fix(i18n): include shared discovery copy in macOS catalog
  fix(apple): localize gateway discovery status
  chore(i18n): drop release-owned changelog entry
  fix(macos): localize privacy permission prompts
  fix(voice-call): bracket IPv6 webhook hosts (#115135)
  test(ci): split control UI scope coverage
  fix(ui): detect composed accessibility copy
  fix(ci): run localization checks for UI changes
  test(ui): catch untranslated accessibility labels
  fix(ui): localize chat action labels
  fix(ui): localize chat status indicators
  fix(ui): sync document locale metadata
  ...
vincentkoc added a commit to LZY3538/openclaw that referenced this pull request Jul 28, 2026
* origin/main: (199 commits)
  refactor(workboard): tidy Control UI card execution helpers (openclaw#115195)
  perf(agents): amortize history-limit eviction with hysteresis (openclaw#115273) (openclaw#115281)
  fix: schema-version refusal blames a downgrade that never happened and cannot identify the stale install (openclaw#115232)
  fix: restore Fish completion after global CLI options (openclaw#115222)
  refactor(agents): collapse the client-tool catalog branch (openclaw#115212)
  fix(macos): signed rebuild no longer stalls on app shutdown (openclaw#103957)
  fix(agents): prevent repeated Code Mode output across waits (openclaw#115213)
  refactor(ui): split Profile (identity) from Usage (statistics) (openclaw#115245)
  fix(channels): report a channel that cannot receive as unhealthy instead of connected (openclaw#115229)
  fix(cli): reject malformed infer model refs (openclaw#115225)
  feat(ui): finish the Lobsterdex at 42 with wild variants, squish fix, and blink variance (openclaw#115264)
  test(migrations): avoid mtime precision in checkpoint fixture (openclaw#115269)
  test(signal): verify archive limits without malformed tar (openclaw#115270)
  refactor(sessions): isolate legacy transcript fixtures (openclaw#115231)
  fix(discord): clear pending launch watchdog (openclaw#115100)
  fix(agents): stop quadratic subagent prompt rendering (openclaw#115263)
  fix(memory-core): recover dreaming cron reconciliation (openclaw#115174)
  fix(qa-lab): filter incompatible channel scenarios (openclaw#115087)
  fix(android): respect locale in compact labels
  test(i18n): prove iOS discovery catalog ownership
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: memory-core Extension: memory-core merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants