Repository navigation
Conversation
… finishing An agent with a large pre-existing memory index could see `openclaw memory index` appear to hang and vector search never reach ready after upgrading to the canonicalized memory schema. The one-time legacy->canonical migration runs in a single transaction on every store open and verifies the copy with a full-tuple anti-join that byte-compares the text/embedding columns it just copied. On a large store that verification dominates migration time and grows super-linearly, so any interruption rolls the transaction back, leaving the legacy tables in place to restart from scratch on the next open. When the canonical table was empty before the copy, INSERT OR IGNORE from a single legacy source cannot collide, so the anti-join can only ever return zero. Verify that case with a row-count match instead, and keep the full anti-join only when the canonical table already held rows (the real conflict case). What gets migrated and conflict handling are unchanged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Codex review: needs changes before merge. Reviewed June 27, 2026, 11:12 PM ET / 03:12 UTC. Summary PR surface: Source +54, Tests +45. Total +99 across 2 files. Reproducibility: no. not with a high-confidence live current-main large-store run in this read-only review. Source inspection shows current main still performs full tuple anti-joins over legacy memory rows, and the PR body provides file-backed benchmark evidence for the bottleneck. Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Refresh the PR against current main and apply the empty-canonical verifier optimization to the current same-database and Memory Core doctor sidecar import helpers, with conflict-preservation tests for both paths. Do we have a high-confidence way to reproduce the issue? No, not with a high-confidence live current-main large-store run in this read-only review. Source inspection shows current main still performs full tuple anti-joins over legacy memory rows, and the PR body provides file-backed benchmark evidence for the bottleneck. Is this the best way to solve the issue? No for the branch as-is: the row-count shortcut is a good narrow fix, but the branch must be refreshed after #95631 and ported to the current sidecar import path before it is the best solution. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d1b917120a47. Label changesLabel justifications:
Evidence reviewedPR surface: Source +54, Tests +45. Total +99 across 2 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
AI-assisted PR (Claude Code). I understand the change and have validated the touched surface; details below.
What Problem This Solves
Fixes an issue where an agent with a large pre-existing memory index (tens of thousands of chunks / embedding-cache rows) sees
openclaw memory indexappear to hang and vector search never reachreadyafter upgrading to the canonicalized memory schema. The one-time legacy→canonical migration runs inside a single transaction on every memory-store open; on a large store it runs long enough that any interruption (gateway restart, redeploy) rolls it back, leaving the legacy tables in place — so it restarts from scratch on the next open and never finishes.Why This Change Was Made
The migration verifies the copy by re-scanning every legacy row with a full-tuple anti-join that byte-compares the large
text/embeddingcolumns it just copied. When the canonical table was empty before the copy, anINSERT OR IGNOREfrom a single legacy source cannot collide, so that check can only ever return zero — it is provably unnecessary work, and it dominates (and outgrows) migration time as the store grows.This change verifies the empty-canonical case with a row-count match, and keeps the full anti-join only when the canonical table already held rows (the real conflict case that the existing "keeps legacy tables when canonical rows conflict" test guards). What gets migrated, and conflict handling, are unchanged. Scope is intentionally limited to the verification step; relocating the migration out of the hot store-open path entirely is a larger, separate change.
User Impact
Agents with large legacy memory stores complete the one-time migration far faster and reliably reach
Vector search: readyafter upgrade, instead of looping. No configuration or user action is required, and there is no behavior change for normal-size stores.Evidence
Touched surface is
packages/memory-host-sdk/src/host/memory-schema.ts(+ its test).Unit tests —
packages/memory-host-sdk/src/host/memory-schema.test.tspasses 7/7. The existing migrate + conflict-keep tests are unchanged; added one test asserting the new empty-canonical path still fails closed (keeps the legacy tables) when a copy would lose rows.Typecheck / lint / format —
tsgo:test:packagesclean (0 errors); prod typecheck reports nothing inmemory-host-sdk;oxlintandoxfmtclean on the changed files.Benchmark — file-backed SQLite, canonical rows are exact copies of legacy rows (the migration's real worst case, where every blob comparison must read the full value):
INSERT OR IGNORE)The old verification grows super-linearly (≈24× slower for ≈2.7× the rows) and reaches 37% of migration time at 40k rows and climbing; on a ~6 GB / 90k-chunk store it is tens of seconds to minutes, which is what exceeds the interrupt window and drives the restart loop. The new row-count check is constant-time.
codex review(local,--base upstream/main) — no actionable findings.Full
pnpm build && pnpm check && pnpm testis left to CI on this PR; local validation focused on the touched memory-host-sdk surface above.