Skip to content

fix(memory): rebuild never finishes on large indexes after updating - #196378

Merged
obviyus merged 5 commits into
openclaw:mainfrom
garrytan:fix/memory-rebuild-worker-oom
Nov 12, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
garrytan:fix/memory-rebuild-worker-oom

Conversation

@garrytan

@garrytan garrytan commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Related: #195414, #192762

What Problem This Solves

A full memory rebuild runs out of worker memory and starts over on every attempt when the index holds tens of thousands of embedded chunks. One trigger is the chunking-format upgrade after updating. Vector search never comes back, and search keeps serving the old keyword index.

Why This Change Was Made

A rebuild reuses each chunk's published vector, and two steps of that path held a whole pass inside one 512 MiB worker:

  1. Vector reuse. collectCachedEmbeddings sent every candidate of a pass in one cache.read: up to 50,000 chunks. The read worker decodes each stored vector into a JavaScript number array, so a full pass at 1536 dimensions is about 600 MB. cache.read now runs in pages of whole hashes, each sized to 8 MiB of decoded vectors, and the host merges the pages. All chunks that share a hash stay in one page, so the published-row check sees the same rows as before.
  2. Publication staging. The SQLite publication worker kept every staged fragment of a source as JSON text until source.replace, about 20 characters per vector dimension. stage.append now parses each sealed row as it arrives and keeps its vector as a Float64Array, the same binary64 values the index stores, so 8 bytes per dimension outside the JS heap. source.replace reads the rows back in order and turns one vector at a time back into a number array.

Nothing else changes: no table, schema, SQL, config, heap limit or retention change, the same single atomic source.replace, and the PostgreSQL path is untouched. Stored vectors are byte-identical.

An earlier revision staged large sources in a connection-local TEMP table. This revision drops that table, its dialect-ratchet classification, the storage-changes doc line, the test-line allocation and the new tests.

Evidence

End to end through the built CLI in Docker (node 24.22.1, no secrets), with a local stand-in OpenAI embeddings endpoint (deterministic 1536-dim vectors). The fixture was built on main through the real path: 12 session transcripts (93,612 events) imported with openclaw doctor --session-sqlite import plus 200 notes, then openclaw memory index, giving 213 files and 94,919 chunks. Each run restores that state, then triggers the rebuild. The worker heap peaks come from an observation-only worker.getHeapStatistics() sampler.

run rebuild time after peak read worker heap peak publication worker heap
main bd63497, format upgrade ERR_WORKER_OUT_OF_MEMORY [task=memorySearch.task] 33 s identity mismatched, dirty 490 MiB (OOM) 54 MiB
main bd63497, --force same OOM 20 s old index kept 482 MiB (OOM) 58 MiB
this PR, format upgrade "213 files indexed" 415 s identity valid, not dirty, 94,919 chunks, vector index complete 101 MiB 107 MiB (+101 MiB packed vectors)
this PR, --force "213 files indexed" 320 s identity valid, not dirty 99 MiB 108 MiB (+111 MiB packed vectors)

Restart loop on main, in a running Gateway (openclaw gateway run, format upgrade pending, one memory.search call opens the index): sync failed (search-identity-repair): ERR_WORKER_OUT_OF_MEMORY [task=memorySearch.task] at 04:04:43, then the retries fail the same way at 04:09:39 and 04:10:46, while search answers "format upgrade rebuild is pending; serving the existing keyword index".

On both candidate runs, no embedding request was made during the rebuild, the digest of every (hash, vector) pair is identical before and after, and openclaw memory search returns hybrid hits with vector scores.

Controls:

  • Small index (634 chunks), format upgrade: main and this PR both finish in about 9 s with identical vectors and the same search hits.
  • Index already rebuilt by this PR, indexed again: no-op in 15 s, vectors unchanged.
  • Memory-file index (213 files, 94,152 chunks, ~7,800 chunks per file): main finishes but its publication worker peaks at 403 of 512 MiB; this PR peaks at 110 MiB.

Focused tests in the container: manager-publication-transfer, manager-publication-print-once and manager-publication-settlement pass (29 tests), including oversized rows that span fragments and staged cache vectors of 4,194,305 coordinates.

A full memory rebuild, such as the format upgrade after updating from
2026.10.9, reuses each chunk's published vector instead of embedding it
again. Two steps of that path held a whole pass in one bounded worker:

- Vector reuse asked the read worker for every candidate's vector in one
  cache.read, up to 50,000 chunks per pass, and the worker decodes each
  vector into a JavaScript number array, 8 bytes per dimension, inside
  its 512 MiB heap.
- Publication staged every fragment of a source in the SQLite store
  worker's memory until the source was replaced. A source's fragments
  carry its vectors as JSON, about 30 KB per 1536-dimension chunk.

On an index of 95,884 chunks with 1536-dimension vectors the rebuild
failed at the first step with ERR_WORKER_OUT_OF_MEMORY
[task=memorySearch.task], and with that step fixed it failed at the
second in the SQLite store worker. Each failure starts the rebuild over,
so vector search never comes back.

The host now reads cached and published vectors in pages of whole
hashes, sized to 8 MiB of decoded vectors (682 hashes at 1536
dimensions), and merges the pages. All chunks that share a hash stay in
one page, so the published-row agreement check sees the same rows as
before. Staged fragments stay in worker memory up to 32 MiB; past that a
source's fragments spill to a private temporary file, are read back in
order when the source is replaced, and the file is removed when the
stage settles. Published rows and vectors are unchanged.
@clawsweeper

clawsweeper Bot commented Nov 10, 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR pages stored-vector reads and packs staged publication vectors into binary64 arrays to reduce worker heap usage.

Example: Rebuild an existing index containing 94,919 chunks with 1,536-dimensional vectors.

  • Before: The read worker exhausts its heap, leaving the format upgrade pending and search using the prior keyword index.
  • After: The rebuild completes, preserves the vector digest, and restores hybrid search with vector scores.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong shipped-path before/after proof supports a focused repair with no identified correctness defect; dedicated committed coverage for the memory-growth regression remains limited.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): At reviewed head 5d285b2, the built CLI in secretless Docker exercises format-upgrade and forced rebuilds over an existing 94,919-chunk index using a deterministic local embeddings endpoint; rebuilds complete with identical vector digests, valid identity, clean status, and hybrid search results, with small-index and repeat-index controls.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Large memory indexes cannot finish rebuilding after a format upgrade, so vector search stays unavailable.
Reason: The supplied reproduction demonstrates a real failure, and the repair preserves the existing product contract without adding settings or changing retention.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a demonstrated large-index rebuild failure still present on current main. No introduced correctness defect was found; the remaining CI failures have documented reproductions without this diff.

Priority: P2
Reviewed head: 5d285b2afa6e3e8490a839de588a5e9248749b9f

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Shipped CLI proof is supplied, but the current diff adds no committed regression specifically detecting whole-pass cache-read or staging heap growth.
Agent review details

How this fits together

Memory Core prepares indexed chunks, retrieves reusable vectors through a read worker, and transfers source rows to the existing SQLite publication worker for atomic replacement.

flowchart TD
  A[Memory index request] --> B[Prepared chunks]
  B --> C[Paged vector reads]
  C --> D[Publication fragments]
  D --> E[Packed worker staging]
  E --> F[Atomic source replacement]
  F --> G[Hybrid memory search]
Loading

Technical review

Best possible solution:

Retain the existing read and publication owners while paging vector retrieval and storing staged vectors compactly without changing atomic replacement or stored bytes.

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

The source exposes both whole-pass memory accumulations, and exact-head Docker CLI traces demonstrate base OOM followed by successful candidate rebuilds; this read-only review ran no target code.

Is this the best way to solve the issue?

The change addresses both demonstrated allocations at their existing owners, keeps same-hash candidates together for ambiguity checks, preserves fragmented-row ordering, and retains transaction admission and session tombstones.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Published-vector cache reads keeps the original intent (198b761: Reuse compatible published vectors for ordinary edits while preserving cache precedence, scoped ambiguity rejection, provider identity, and dimensions.)
  • Worker-memory publication staging keeps the original intent (04647ea: Avoid TEMP-table and per-fragment SQL overhead while retaining bounded transfers and one atomic publication; source-sized buffering was an explicit accepted tradeoff.)
  • Publication row decoding changes intended behavior with a stated reason (a1f9ced: Keep publication off the Gateway thread while preserving native transaction settlement and admission; subsequent refactors consolidated fragment parsing in the worker.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +72. Total +72 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 129 57 +72
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 129 57 +72

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦐 gold shrimp.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: Large existing indexes can repeatedly fail rebuilding and lose vector-search availability, while the prior keyword index remains usable.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rank-up moves

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

  • Add a focused production-boundary regression that detects whole-pass vector accumulation on the base and passes with paging and packed staging.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (5 earlier review cycles)
  • reviewed 2026-11-10T01:58:33.468Z sha 179721c :: needs changes before merge. :: [P2] Keep overflow staging in the SQLite publication owner | [P2] Use OpenClaw's temp-root owner for any retained file staging
  • reviewed 2026-11-10T06:00:59.519Z sha 19cfc48 :: needs changes before merge. :: [P2] Classify SQLite overflow staging in the dialect ratchet
  • reviewed 2026-11-10T22:33:53.515Z sha 36f62ec :: needs maintainer review before merge. :: none
  • reviewed 2026-11-11T23:40:11.841Z sha b86bd71 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-12T04:20:36.022Z sha 5d285b2 :: needs maintainer review before merge. :: none

Reviewed November 12, 2026, 12:03 AM ET / 05:03 UTC (Revision 6).

Publication staging keeps up to 32 MiB of fragments in worker memory as
before. A larger source now overflows into a connection-local TEMP table on
the publication worker's own SQLite connection instead of a private file
under os.tmpdir(), which root AGENTS.md (no sidecar stores) and
lint:tmp:no-random-messaging both reject. The table is read back in
ordinal pages and dropped when the publication settles or is discarded.
@garrytan

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Both findings are fixed in 19cfc48:

  • Keep overflow staging in the SQLite publication owner (P2): the file spill is gone. Staging stays in worker memory up to 32 MiB, as in the first revision. A larger source now overflows into a connection-local TEMP table on the publication worker's own connection. The table is read back in order, in pages, and dropped when the stage settles or is discarded.
  • Use OpenClaw's temp-root owner (P2): no file staging is left, so there is no os.tmpdir() call. lint:tmp:no-random-messaging now passes locally, along with the other lint:tmp:* checks.

I reran the proof on the new head. The capped-heap test is red on main and on each half alone, and green with both. The 95,884-chunk CLI rebuild fails on main after 27 s and finishes in 294 s with this change, with identity valid and no worker OOMs. The description has the updated evidence.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 10, 2026
…ct ratchet

The SQLite dialect ratchet counted the new overflow stage's CREATE TEMP
TABLE as temp-schema design debt. Only the SQLite publication backend
builds that stage; PostgreSQL publication spools through
manager-publication-postgres.ts. Classify temp-schema in
manager-publication-stage.ts as engine maintenance, next to the existing
Knowledge and PostgreSQL-spool owners, and keep every other construct in
that file and the same TEMP table anywhere else counted.
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts labels Nov 10, 2026
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 10, 2026
@garrytan

Copy link
Copy Markdown
Contributor Author

The remaining finding is fixed in 36f62ec:

  • Classify SQLite overflow staging in the dialect ratchet (P2): scripts/database-dialect-inventory.mts now classifies temp-schema in manager-publication-stage.ts as engine maintenance, the same way it already handles the Knowledge index and the PostgreSQL publication spool. No baseline changed. A new case in check-database-dialect-ratchet.test.ts checks that a rowid in the same file, and the same TEMP table in any other file, still count. The storage-changes reference lists the new owner.

pnpm check:database-dialect-ratchet reports no growth against bd63497, and the other baseline ratchets pass locally.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 11, 2026
…table

Staged rows are parsed as they arrive and keep their vectors in the stored
binary64 encoding, so a large source no longer holds about 20 JSON characters
per dimension in the publication worker heap. The single atomic source.replace
is unchanged and no table is added.
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed docs Improvements or additions to documentation scripts Repository scripts size: M labels Nov 12, 2026
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Proof at 5d285b2 (built CLI in Docker, node 24.22.1, no secrets, local stand-in embeddings endpoint). Fixture built on main through the real path: 12 imported session transcripts plus 200 notes, 213 files, 94,919 chunks at 1536 dims.

## base-s1
exit=1 seconds=33  Memory index failed (main): Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit: JS heap out of memory [task=memorySearch.task admittedInputBytes=21946914 exchanges=0 stage=running] | ERR_WORKER_OUT_OF_MEMORY
chunks before=94919 after=94919; (hash, vector) digest identical 975ca083be43790d
embedding requests during index: (not recorded)
status: chunks=94919 dirty=true identity=mismatched vector=complete
search: 6 hits, top vectorScore=undefined path=sessions/main/proof-12.jsonl
peak memory-search worker: 490 MiB heap / 515 MiB external (ERR_WORKER_OUT_OF_MEMORY)
peak sqlite-store worker: 54 MiB heap / 5 MiB external

## base-s2
exit=1 seconds=20  Memory index failed (main): Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit: JS heap out of memory [task=memorySearch.task admittedInputBytes=21946914 exchanges=0 stage=running] | ERR_WORKER_OUT_OF_MEMORY
chunks before=94919 after=94919; (hash, vector) digest identical 975ca083be43790d
embedding requests during index: 0
status: chunks=94919 dirty=false identity=valid vector=complete
search: 6 hits, top vectorScore=0.0648 path=sessions/main/proof-10.jsonl
peak memory-search worker: 482 MiB heap / 515 MiB external (ERR_WORKER_OUT_OF_MEMORY)
peak sqlite-store worker: 58 MiB heap / 6 MiB external

## cand-s1
exit=0 seconds=415  Memory index updated (main): 213 files indexed.
chunks before=94919 after=94919; (hash, vector) digest identical 975ca083be43790d
embedding requests during index: (not recorded)
status: chunks=94919 dirty=false identity=valid vector=complete
search: 6 hits, top vectorScore=0.0648 path=sessions/main/proof-10.jsonl
peak memory-search worker: 101 MiB heap / 19 MiB external
peak sqlite-store worker: 107 MiB heap / 101 MiB external

## cand-s2
exit=0 seconds=320  Memory index updated (main): 213 files indexed.
chunks before=94919 after=94919; (hash, vector) digest identical 975ca083be43790d
embedding requests during index: 0
status: chunks=94919 dirty=false identity=valid vector=complete
search: 6 hits, top vectorScore=0.0648 path=sessions/main/proof-10.jsonl
peak memory-search worker: 99 MiB heap / 17 MiB external
peak sqlite-store worker: 108 MiB heap / 111 MiB external

## cand-sagain
exit=0 seconds=15  Memory index updated (main): 213 files indexed.
chunks before=94919 after=94919; (hash, vector) digest identical 975ca083be43790d
embedding requests during index: (not recorded)
status: chunks=94919 dirty=false identity=valid vector=complete
search: 6 hits, top vectorScore=0.0648 path=sessions/main/proof-10.jsonl
peak memory-search worker: 50 MiB heap / 7 MiB external
peak sqlite-store worker: 59 MiB heap / 6 MiB external

## base-ssmall
exit=0 seconds=9  Memory index updated (main): 8 files indexed.
chunks before=634 after=634; (hash, vector) digest identical a0ff83a5e0a4db3a
embedding requests during index: 0
status: chunks=634 dirty=false identity=valid vector=complete
search: 6 hits, top vectorScore=0.0519 path=memory/notes/note-3.md
peak memory-search worker: 41 MiB heap / 5 MiB external
peak sqlite-store worker: 61 MiB heap / 11 MiB external

## cand-ssmall
exit=0 seconds=8  Memory index updated (main): 8 files indexed.
chunks before=634 after=634; (hash, vector) digest identical a0ff83a5e0a4db3a
embedding requests during index: 0
status: chunks=634 dirty=false identity=valid vector=complete
search: 6 hits, top vectorScore=0.0519 path=memory/notes/note-3.md
peak memory-search worker: 41 MiB heap / 5 MiB external
peak sqlite-store worker: 58 MiB heap / 6 MiB external

## base Gateway restart loop (format upgrade pending)
2026-11-12T04:04:43.550+00:00 [memory] sync failed (search-identity-repair): Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit: JS heap out of memory
2026-11-12T04:04:43.550+00:00 [memory] sync failed (watch): WorkerTaskError: Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit: JS heap out of memory
2026-11-12T04:04:43.651+00:00 [memory] search: format upgrade rebuild is pending; serving the existing keyword index
2026-11-12T04:04:44.131+00:00 [memory] search: format upgrade rebuild is pending; serving the existing keyword index
2026-11-12T04:09:39.570+00:00 [memory] session update failed: Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit: JS heap out of memory
2026-11-12T04:10:46.697+00:00 [memory] session update failed: Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit: JS heap out of memory

@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 12, 2026
@obviyus

obviyus commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Maintainer override: the two red changed-extensions bundles in CI run 43152375306 were already red on main. This PR's diff does not cause them.

Red jobs:

  • checks-node-changed-extensions-bundle-1: cli.test.ts › fails index --force when the memory index has orphaned provenance (expected +0 to be 1), and manager-publication-admission.test.ts › retains reindexed memory admission with a invalid seal without skipping required integrity (sqlite.full-verification admission is undefined)
  • checks-node-changed-extensions-bundle-2: manager.borrowed-connection.test.ts › rejects shared integrity failure before exposing a manager (expected [Function] to throw an error)
  • openclaw/ci-gate is red only because of these two jobs. Every other job in the run passed.

The same three tests fail without this PR. I ran them in a secretless Docker container (node:24.22.1) with pnpm test extensions/memory-core/src/memory/manager.borrowed-connection.test.ts extensions/memory-core/src/cli.test.ts extensions/memory-core/src/memory/manager-publication-admission.test.ts:

Tree Result
0daf4f7b9284 (main, the base CI merged into) 3 failed, 84 passed
CI's merge of 5d285b2a into 0daf4f7b the same 3 failed, 84 passed
082ed658f463 (current main) the same 3 failed, 84 passed

Bisect on main, running the borrowed-connection and publication-admission files:

The first bad commit is 0e966cc6e092; its parent dcd8640cb1ae passes. That commit changed SQLite startup-integrity admission, which is what these three tests check. This PR only touches memory publication staging and cache-read paging, not integrity or admission code.

@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 12, 2026
@obviyus
obviyus merged commit 3e7fb1b into openclaw:main Nov 12, 2026
121 of 128 checks passed
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Landed in 3e7fb1b. Thanks @garrytan.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…penclaw#196378)

fix(memory): let large memory rebuilds finish without running out of worker memory

A full memory rebuild ran out of its 512 MiB worker and restarted on every attempt when the index held tens of thousands of embedded chunks, for example after the chunking-format upgrade from 2026.10.9, so vector search never came back and search kept serving the old keyword index. Two steps held a whole pass in one worker. Vector reuse now reads cached embeddings in pages of whole hashes sized to 8 MiB of decoded vectors. The SQLite publication worker now parses each staged row as it arrives and keeps its vector as a Float64Array instead of JSON, turning one row at a time back into a number array at source.replace, which stays one atomic replace. Stored bytes, schema and retention are unchanged, no table is added, and the PostgreSQL path is untouched.

Evidence: a 94,919-chunk index at 1536 dimensions built through the real import and memory index paths in a secretless node:24.22.1 container with a stand-in embeddings server. On the PR base and current main, the format-upgrade rebuild and memory index --force ran out of memory after 19-33 s with the read worker near 490 MiB, and a running Gateway retried and failed again while search served the keyword index. With this change both rebuilds finish in 320-415 s with peak worker heaps near 100-110 MiB, no embedding calls, byte-identical stored vectors and vector search hits. A 634-chunk index and an already-rebuilt index behave the same on both. The red changed-extensions bundles are three memory-core integrity tests that fail on main since openclaw#194484: openclaw#196378 (comment). Net 0 test lines. Details: openclaw#196378 (comment).

Thanks @garrytan.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 14, 2026
…196378)

fix(memory): let large memory rebuilds finish without running out of worker memory

A full memory rebuild ran out of its 512 MiB worker and restarted on every attempt when the index held tens of thousands of embedded chunks, for example after the chunking-format upgrade from 2026.10.9, so vector search never came back and search kept serving the old keyword index. Two steps held a whole pass in one worker. Vector reuse now reads cached embeddings in pages of whole hashes sized to 8 MiB of decoded vectors. The SQLite publication worker now parses each staged row as it arrives and keeps its vector as a Float64Array instead of JSON, turning one row at a time back into a number array at source.replace, which stays one atomic replace. Stored bytes, schema and retention are unchanged, no table is added, and the PostgreSQL path is untouched.

Evidence: a 94,919-chunk index at 1536 dimensions built through the real import and memory index paths in a secretless node:24.22.1 container with a stand-in embeddings server. On the PR base and current main, the format-upgrade rebuild and memory index --force ran out of memory after 19-33 s with the read worker near 490 MiB, and a running Gateway retried and failed again while search served the keyword index. With this change both rebuilds finish in 320-415 s with peak worker heaps near 100-110 MiB, no embedding calls, byte-identical stored vectors and vector search hits. A 634-chunk index and an already-rebuilt index behave the same on both. The red changed-extensions bundles are three memory-core integrity tests that fail on main since #194484: #196378 (comment). Net 0 test lines. Details: #196378 (comment).

Thanks @garrytan.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 3e7fb1b)

Release adaptation: page the release branch's existing cache-only reads; do
not import newer published-vector fallback, PostgreSQL, or retirement owners.
Retain provider identity order, disabled-cache behavior and SQLite publication
contracts. Packed staging is unchanged from the source fix.

Companion review: 3ea0883 (#195369) is a separate cache-retention change,
not required for bounded reads or packed staging; intentionally excluded.
No later PR-number follow-ups. Existing transfer/settlement fixtures retain
the same protocol. No storage format, schema or retention change.

Proof: Node syntax checks and exact production staging-helper value/order,
replay and fragmented-tail checks pass. Full owner tests/typecheck remain
unrun: isolated worktree has no dependencies; no install authorized.
Independent review remains with the parent (worker cannot spawn children).

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
(cherry picked from commit 8d8df0799fba9770b913bdc9be546915c8351a8c)
RomneyDa pushed a commit that referenced this pull request Nov 15, 2026
…196378)

fix(memory): let large memory rebuilds finish without running out of worker memory

A full memory rebuild ran out of its 512 MiB worker and restarted on every attempt when the index held tens of thousands of embedded chunks, for example after the chunking-format upgrade from 2026.10.9, so vector search never came back and search kept serving the old keyword index. Two steps held a whole pass in one worker. Vector reuse now reads cached embeddings in pages of whole hashes sized to 8 MiB of decoded vectors. The SQLite publication worker now parses each staged row as it arrives and keeps its vector as a Float64Array instead of JSON, turning one row at a time back into a number array at source.replace, which stays one atomic replace. Stored bytes, schema and retention are unchanged, no table is added, and the PostgreSQL path is untouched.

Evidence: a 94,919-chunk index at 1536 dimensions built through the real import and memory index paths in a secretless node:24.22.1 container with a stand-in embeddings server. On the PR base and current main, the format-upgrade rebuild and memory index --force ran out of memory after 19-33 s with the read worker near 490 MiB, and a running Gateway retried and failed again while search served the keyword index. With this change both rebuilds finish in 320-415 s with peak worker heaps near 100-110 MiB, no embedding calls, byte-identical stored vectors and vector search hits. A 634-chunk index and an already-rebuilt index behave the same on both. The red changed-extensions bundles are three memory-core integrity tests that fail on main since #194484: #196378 (comment). Net 0 test lines. Details: #196378 (comment).

Thanks @garrytan.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 3e7fb1b)
Co-authored-by: RomneyDa <[email protected]>

(cherry picked from commit 512b5d231bff565381824a8796ccb9417f118ef6)

Co-authored-by: vincentkoc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. extensions: memory-core Extension: memory-core P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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