Skip to content

fix(memory): keep gateway RPCs responsive during startup - #119676

Merged
vincentkoc merged 2 commits into
mainfrom
fix/memory-core-startup
Aug 5, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix/memory-core-startup

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

Gateway startup with the default memory-core plugin could leave immediate health and config.get RPCs stalled or timed out while the memory manager performed its lazy import and initialization.

Why This Change Was Made

The manager warmup ran directly from the post-ready gateway_start hook. Although it was fire-and-forget, its module loading and initialization still contended with the first operator RPC burst.

registerMemoryManagerWarmup now owns a bounded five-second startup idle window plus lifecycle cancellation. Stop and restart invalidate pending or in-flight generations, so stale gateways cannot synchronize a manager after their lifecycle has ended. The existing Dreaming startup path is unchanged; isolation runs showed it was not causal.

Repair summary:

  • root cause: eager post-ready memory-manager initialization
  • architectural owner: registerMemoryManagerWarmup
  • canonical fix: defer the warmup and cancel stale lifecycle generations
  • removed paths: none; temporary diagnostic instrumentation was removed
  • production delta: +33 lines, justified by the lifecycle ownership and cancellation boundary
  • sibling coverage: Dreaming isolated independently and remained responsive

User Impact

Startup health and configuration RPCs remain responsive while long-lived gateways still receive automatic memory warmup. Gateways stopped or restarted during the idle window do not run stale synchronization work.

Evidence

@vincentkoc vincentkoc self-assigned this Aug 5, 2026
@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: M maintainer Maintainer-authored PR labels Aug 5, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 5, 2026 16:06
@vincentkoc
vincentkoc force-pushed the fix/memory-core-startup branch from 8144e5d to 626f53f Compare August 5, 2026 16:15
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 12:42 PM ET / 16:42 UTC.

ClawSweeper review

What this changes

The PR defers memory-core manager warmup for five seconds after gateway readiness and cancels pending or stale warmup generations on stop or restart.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This active maintainer PR remains necessary: current main still triggers memory-manager loading directly during gateway startup, while the PR moves the delay and cancellation to the plugin-owned warmup lifecycle. No blocking defect was found; wait for the in-progress exact-head checks before landing.

Priority: P1
Reviewed head: c6c256c48b5bbe6c97ea1b0ed02afb96cd647801

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-local reliability repair with direct lifecycle coverage and no actionable review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is not subject to the external-contributor proof gate; its body nevertheless documents a packaged after-fix RPC probe.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is not subject to the external-contributor proof gate; its body nevertheless documents a packaged after-fix RPC probe.
Evidence reviewed 6 items Current-main failure path: Current main invokes memory-manager loading directly from the memory-core gateway-start hook, before this PR's deferred lifecycle boundary.
Owner-boundary repair: The PR keeps the remedy inside memory-core: one unref'd delay, generation invalidation, and stale-result guards prevent a stopped or restarted gateway from later syncing its manager.
Gateway lifecycle contract: Gateway startup dispatches post-ready hooks as independently admitted work, and shutdown invokes registered stop hooks before close; this makes the plugin lifecycle hook the appropriate repair boundary.
Findings None None.
Security None None.

How this fits together

The memory-core plugin warms each configured memory index after the Gateway becomes ready. Health and configuration RPCs arrive during that same startup period, so scheduling the warmup determines whether those operator calls stay responsive.

flowchart LR
  A[Gateway becomes ready] --> B[Post-ready lifecycle hook]
  B --> C[Memory-core warmup owner]
  C --> D[Five-second idle window]
  D --> E[Memory manager initialization]
  A --> F[Health and config RPCs]
  F --> G[Responsive Gateway]
  H[Gateway stop or restart] --> C
Loading

Before merge

  • Resolve merge risk (P1) - Required exact-head CI is still in progress; do not land until it completes green and GitHub retains a clean merge result.
  • Complete next step (P2) - No mechanical repair remains; the protected maintainer label and pending exact-head checks require normal human merge handling.
Agent review details

Security

None.

PR surface

Source +33, Tests +129. Total +162 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 55 22 +33
Tests 2 131 2 +129
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 186 24 +162

Review metrics

Metric Value Why it matters
Production versus test LOC production +55/-22 (net +33); tests +131/-2 (net +129) The production increase is justified by the new lifecycle cancellation boundary; the test growth covers delay, stop, restart, and hook-registration behavior.

Stored data model

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

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the owner-local deferred warmup and lifecycle generation guard, then land the exact reviewed head after required checks complete successfully.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the owner-local deferred warmup and lifecycle generation guard, then land the exact reviewed head after required checks complete successfully.

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

Yes, at source level: current main eagerly starts manager loading from the admitted gateway-start hook, and the PR supplies a packaged before/after harness path. This read-only review did not execute that harness.

Is this the best way to solve the issue?

Yes. Deferring at the existing memory-core warmup owner avoids adding core policy or a competing flow, and the generation guard follows the established Dreaming lifecycle pattern.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The default memory-core startup path can stall immediate Gateway health and configuration RPCs for real operators.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is not subject to the external-contributor proof gate; its body nevertheless documents a packaged after-fix RPC probe.

Evidence

What I checked:

  • Current-main failure path: Current main invokes memory-manager loading directly from the memory-core gateway-start hook, before this PR's deferred lifecycle boundary. (extensions/memory-core/index.ts:282, b0d8dd3866d0)
  • Owner-boundary repair: The PR keeps the remedy inside memory-core: one unref'd delay, generation invalidation, and stale-result guards prevent a stopped or restarted gateway from later syncing its manager. (extensions/memory-core/index.ts:284, c6c256c48b5b)
  • Gateway lifecycle contract: Gateway startup dispatches post-ready hooks as independently admitted work, and shutdown invokes registered stop hooks before close; this makes the plugin lifecycle hook the appropriate repair boundary. (src/gateway/server-startup-post-attach.ts:1404, b0d8dd3866d0)
  • Sibling and regression coverage: Dreaming uses the same timer-and-generation lifecycle pattern, while the PR tests delayed initialization, stop-before-timer cancellation, stale resolution after restart, and typed hook registration. (extensions/memory-core/index.test.ts:249, c6c256c48b5b)
  • Feature-history provenance: Blame and symbol history associate the current eager warmup implementation with Peter Steinberger's current-main commit; the PR is therefore addressing a current-main-only regression rather than a shipped release behavior. (extensions/memory-core/index.ts:282, 4c94d9fb937a)
  • Scoped size: The patch is production +55/-22 (net +33) and tests +131/-2; the production growth is the explicit lifecycle ownership and cancellation boundary. (extensions/memory-core/index.ts:280, c6c256c48b5b)

Likely related people:

  • steipete: Blame and symbol history tie the eager current-main warmup path to this commit. (role: current implementation introducer; confidence: high; commits: 4c94d9fb937a; files: extensions/memory-core/index.ts)
  • vincentkoc: Prior merged memory-core refactors and fixes establish direct familiarity with the affected plugin beyond this PR. (role: recent area contributor; confidence: high; commits: eae846e3e550, 64a76d18eee5; files: extensions/memory-core/index.ts)

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-08-05T16:24:58.170Z sha 626f53f5453ce244af836c5cbc1501817d0732b7 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T16:32:11.756Z sha 626f53f5453ce244af836c5cbc1501817d0732b7 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc force-pushed the fix/memory-core-startup branch from 626f53f to c6c256c Compare August 5, 2026 16:36
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc
vincentkoc merged commit 824d170 into main Aug 5, 2026
117 checks passed
@vincentkoc
vincentkoc deleted the fix/memory-core-startup branch August 5, 2026 18:08
vincentkoc added a commit to VACInc/openclaw that referenced this pull request Aug 5, 2026
…cope

* origin/main: (70 commits)
  fix(clickclack): preserve MIME extension for unnamed uploads (openclaw#119646)
  fix(memory): keep post-ready RPCs responsive (openclaw#119710)
  fix(browser): preserve locale, timezone, and device overrides (openclaw#119695)
  fix(agents): stop messaging dedupe from dropping final replies that quote a short tool send (openclaw#118178)
  test(agents): batch code mode budget proof (openclaw#119699)
  fix(memory): keep gateway RPCs responsive during startup (openclaw#119676)
  improve(ui): trail transient session status beside row actions (openclaw#119560)
  refactor(msteams): consolidate channel action target resolution (openclaw#119632)
  fix: tail context answers the current user message (openclaw#117364)
  fix(whatsapp): exercise descriptor-safe credential persistence (openclaw#119621)
  fix(diagnostics-otel): route OTLP endpoints by signal (openclaw#101655)
  refactor(skills): consolidate workshop transcript and record normalization (openclaw#119643)
  fix(video): harden DashScope task and media lifecycle (openclaw#117303)
  refactor(transcripts): consolidate persistence and export ownership (openclaw#119634)
  fix: preserve ClickClack discussion state contracts (openclaw#118851)
  fix(matrix): retire shared E2EE clients safely (openclaw#119570)
  refactor(cron): unify catch-up persistence and payload encoding (openclaw#119636)
  refactor(ui): centralize composer attachment and capability controls (openclaw#119650)
  refactor(daemon): consolidate managed service lifecycle ownership (openclaw#119647)
  fix(browser): honor explicit navigation timeouts across browser drivers (openclaw#119654)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
…9676)

* fix(memory): defer startup manager warmup

* test(plugins): register memory stop hook contract
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 maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

1 participant