Skip to content

refactor: move memory event persistence off the Gateway thread - #147948

Merged
steipete merged 2 commits into
mainfrom
codex/memory-host-journal-worker-current
Sep 15, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/memory-host-journal-worker-current

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Related: #144592

What Problem This Solves

Fixes: saving or reading memory event history can pause other Gateway work while SQLite runs.

User Impact

Memory event appends and bounded reads use the shared SQLite worker while preserving existing events, ordering, retention, and reopening behavior. No configuration, schema-version, or stored-data migration is required.

Why This Change Was Made

The plugin-state owner allocates the sequence, writes the cursor and event, and applies retention in one worker transaction. Bounded reads use the existing-only path. This refresh contains only the journal change on current main, preserving the merged worker and maintenance owners and the lazy event imports.

Evidence

Nine selected ordinary journal cases passed on the refreshed composition, covering public append/read, captured inputs, concurrent sequences, retention, and reopening. The two LanceDB artifact-provider cases also pass after moving their existing file to the canonical worker test lane. Routing checks and both P2 reviews are clean.

The normal build and complete changed-file gate passed at 2596b5f8e608. Built public API checks on Node 24.21.0 and Bun 1.4.2 preserved exact event/cursor JSON and sequence 3 after reopening; missing reads created no database. Six calibrated counters (prepare, exec, get, all, run, iterate) stayed at zero during journal operations. Build metadata identifies 2596b5f8e608; the follow-up changes only LanceDB test routing, and production sources and measured runtime artifacts remain byte-identical. The opt-in Codex provider harness and excluded fault/held-lock scenarios were not replayed.

@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 14, 2026 05:35
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Sep 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 14, 2026, 10:47 PM ET / September 15, 2026, 02:47 UTC (Revision 4).

ClawSweeper review

What this changes

Moves memory-event appends and bounded history reads onto the shared SQLite worker while preserving event ordering, retention, and durable completion.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this protected PR still addresses synchronous journal work present on main. No blocking defect was identified, and the previous migration-proof concern does not apply to the preserved storage format and public contracts.

Priority: P2
Reviewed head: 6b389544fc7a4ad1a25b4b37e509930a0886e98f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused conversion with preserved storage contracts, meaningful boundary coverage, and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a maintainer-authored PR, so external-contributor proof is not required. Its body reports built public memory-helper runs covering worker isolation, stored bytes, missing reads, and reopening; the final commit changes only test routing.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a maintainer-authored PR, so external-contributor proof is not required. Its body reports built public memory-helper runs covering worker isolation, stored bytes, missing reads, and reopening; the final commit changes only test routing.
Evidence reviewed 9 items Verified introduction and review continuity: The complete merge-base-to-head diff contains the journal conversion. Comparing the previous reviewed head with the current head shows only the LanceDB test-routing addition; production code is unchanged. The supplied test merge is stale and was not used to infer removal of main-branch behavior.
Main still executes journal persistence inline: At fetched main, registerPluginStateSequencedJournalEntry still calls the synchronous SQLite journal implementation. The merged keyed-store conversion at #146557 supplies the worker infrastructure but does not complete this journal conversion.
Latest release retains synchronous journal internals: The supplied latest release, v2026.9.4, implements registerMemoryHostEvent and listStoredMemoryHostEvents synchronously and calls registerPluginStateSyncSequencedJournalEntry. Its source was retrieved through GitHub after the local historical blob read failed.
Findings None None.
Security None None.

How this fits together

Memory recall and dreaming operations record diagnostic events in OpenClaw’s shared state database. The memory event helpers feed the plugin-state owner, whose results support history readers and exported event logs.

flowchart TD
  A[Memory recall and dreaming] --> B[Validate and capture event]
  B --> C[Shared SQLite worker]
  C --> D[Allocate sequence and commit journal]
  D --> E[Existing state database]
  E --> F[Bounded history read]
  F --> G[History helpers and exports]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +135, Tests +148, Docs +9, Other 0. Total +292 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 9 386 251 +135
Tests 11 188 40 +148
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 22 584 292 +292

Review metrics

Metric Value Why it matters
Production and test growth Production +135 net lines; tests +145 net lines; test routing +3 Production growth implements worker dispatch and serialized journal preparation while replacing the previous inline transaction implementation.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/memory-host-sdk/event-store.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: partial_overlap
Canonical: #144592
Summary: This PR covers the memory-journal slice of the broader asynchronous-storage effort.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep journal persistence with the existing shared worker and transaction owner, preserving the public asynchronous API and existing durable records.

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

Not applicable to this execution-boundary refactor; current-main source confirms inline SQLite work, but this review did not reproduce or measure a Gateway pause.

Is this the best way to solve the issue?

Yes: moving the complete journal operation onto the existing worker preserves one transaction owner and avoids a competing persistence implementation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against dd3383345724.

Labels

Label justifications:

  • P2: This is a bounded Gateway responsiveness improvement within the established asynchronous-storage work.
  • 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: The supplied repository state identifies a maintainer-authored PR, so external-contributor proof is not required. Its body reports built public memory-helper runs covering worker isolation, stored bytes, missing reads, and reopening; the final commit changes only test routing.

Evidence

What I checked:

  • Verified introduction and review continuity: The complete merge-base-to-head diff contains the journal conversion. Comparing the previous reviewed head with the current head shows only the LanceDB test-routing addition; production code is unchanged. The supplied test merge is stale and was not used to infer removal of main-branch behavior. (test/vitest/vitest.extension-database-workers-paths.mjs:44, 6b389544fc7a)
  • Main still executes journal persistence inline: At fetched main, registerPluginStateSequencedJournalEntry still calls the synchronous SQLite journal implementation. The merged keyed-store conversion at feat: offload data-only keyed plugin state operations #146557 supplies the worker infrastructure but does not complete this journal conversion. (src/plugin-state/plugin-state-store.ts:544, dd3383345724)
  • Latest release retains synchronous journal internals: The supplied latest release, v2026.9.4, implements registerMemoryHostEvent and listStoredMemoryHostEvents synchronously and calls registerPluginStateSyncSequencedJournalEntry. Its source was retrieved through GitHub after the local historical blob read failed. (src/memory-host-sdk/event-store.ts:299, 3a9d69db306c)
  • Atomic owner and complete caller cutover: The worker dispatch runs sequence allocation, cursor and journal writes, and retention inside the existing synchronous state transaction. Journal fields are serialized before admission; bounded reads use the existing-only worker path. Repository-wide references show the production memory caller and affected test callers await the converted internal read. (src/plugin-state/plugin-state.worker.ts:132, 6b389544fc7a)
  • Storage and public API compatibility: The extracted journal retains the existing event/cursor JSON fields, sortable keys, namespace budgets, tail recovery, and transaction rollback. Public memory helpers already return Promises; the changed callback and range-reader signatures are internal. No schema, persisted representation, setting, or migration is introduced. (src/plugin-state/plugin-state-store.journal.ts:83, 6b389544fc7a)
  • Prior storage checkpoint reassessed: The storage guide distinguishes material public/persistent-contract changes from internal scheduling and transaction mechanics that preserve those contracts. The previous review had no findings; its generic migration-proof next step is not supported by this introduced diff. Public docs: docs/reference/database-schemas/storage-changes.md. (docs/reference/database-schemas/storage-changes.md:425, 6b389544fc7a)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

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 (3 earlier review cycles)
  • reviewed 2026-09-14T05:46:27.885Z sha d8e0eef :: blocked before merge. :: none
  • reviewed 2026-09-14T23:44:46.641Z sha d8e0eef :: blocked before merge. :: none
  • reviewed 2026-09-15T02:28:25.286Z sha 2596b5f :: blocked before merge. :: none

Base automatically changed from codex/plugin-keyed-store-merged-main-20260912 to main September 14, 2026 23:36
@steipete
steipete requested a review from a team as a code owner September 14, 2026 23:36
@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call app: web-ui App: web-ui extensions: memory-core Extension: memory-core scripts Repository scripts commands Command implementations agents Agent runtime and tooling extensions: device-pair extensions: acpx extensions: codex channel: synology-chat plugin: file-transfer extensions: crabbox extensions: onepassword 1Password plugin labels Sep 14, 2026
Run memory recall and dreaming journal appends and bounded reads through the shared-state worker. Preserve atomic sequence allocation, cursor and event writes, retention, rollback, and stored JSON/key bytes. Retain current maintenance context and lazy event schema ownership. Related: #144592.
@steipete
steipete force-pushed the codex/memory-host-journal-worker-current branch from d8e0eef to 2596b5f Compare September 15, 2026 02:21
The registered public artifact provider now reaches worker-backed journal reads. Use the existing isolated database-worker test lane while preserving every fixture and assertion. Related: #144592.
@steipete
steipete merged commit 51ea3db into main Sep 15, 2026
194 of 196 checks passed
@steipete
steipete deleted the codex/memory-host-journal-worker-current branch September 15, 2026 03:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
…law#147948)

* refactor: move memory journal persistence to SQLite worker

Run memory recall and dreaming journal appends and bounded reads through the shared-state worker. Preserve atomic sequence allocation, cursor and event writes, retention, rollback, and stored JSON/key bytes. Retain current maintenance context and lazy event schema ownership. Related: openclaw#144592.

* test: route LanceDB artifact tests through database workers

The registered public artifact provider now reaches worker-backed journal reads. Use the existing isolated database-worker test lane while preserving every fixture and assertion. Related: openclaw#144592.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: buzz channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: slack Channel integration: slack channel: synology-chat channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call commands Command implementations docs Improvements or additions to documentation extensions: acpx extensions: codex extensions: crabbox extensions: device-pair extensions: memory-core Extension: memory-core extensions: onepassword 1Password plugin gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. plugin: beam Beam session sharing plugin plugin: file-transfer plugin: visitor-access rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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