Repository navigation
fix(database): rebuild memory indexes before agent ports return - #182008
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesPreserve embedding caches across agent database ports and rebuild memory indexes before the command returns. Example: Port an agent with 4,857 cached chunks from SQLite to PostgreSQL.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses a demonstrated post-port recall delay through existing owners, and I found no actionable introduced defect. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe offline database-port command publishes converted stores, releases port custody, then invokes the selected memory plugin under fresh configured ownership and returns per-agent results. flowchart TD
A[Database port CLI] --> B[Convert and publish stores]
B --> C[Release port custody]
C --> D[Acquire configured memory owner]
D --> E[Selected memory plugin rebuilds]
E --> F[Per-agent results and retry guidance]
Technical reviewBest possible solution: Preserve cached embeddings and complete the deferred offline rebuild through the selected memory owner, with nonfatal per-agent recovery guidance. Do we have a high-confidence way to reproduce the issue? Current-main projection policy establishes cache omission and empty indexes; the reporter and PR provide real CLI observations, while this read-only review ran no target code. Is this the best way to solve the issue? The change completes the documented pending hook using existing publication, custody, credential, and plugin owners without introducing a competing indexing implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 335c0ccf04e6. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +194, Tests +300, Docs +9. Total +503 across 8 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 23, 2026, 7:36 PM ET / 23:36 UTC. |
|
Merged via squash.
|
) Preserve reusable embedding-cache rows across engine ports and run the selected memory owner after port custody releases. Keep published ports successful when rebuilding fails, with per-agent retry guidance. Fixes openclaw#181859. Thanks to @etzelm for the report.
What Problem This Solves
Fixes #181859. Porting an agent store discarded its embedding cache and left the memory index empty, so the first search rebuilt the corpus and repeated embedding calls. Thanks @etzelm for the report.
User Impact
Agent-family ports preserve cached embeddings and rebuild memory before returning, while the Gateway remains stopped. Text output and
--jsonreport each agent's result. A failed rebuild warns withopenclaw memory index --agent <id>and leaves the published port successful. Unchanged cached chunks need no embedding calls; new or uncached content retains normal indexing behavior.Why This Change Was Made
The existing docs explicitly reserved this post-port hook. The port now retains the cache's provider/model/provider_key/hash identities and binary payload, then releases port custody before acquiring a fresh configured
memory.cliowner. The selected memory plugin owns indexing. Fresh config loading avoids the pre-port runtime snapshot, and per-agent secret resolution prevents an unavailable peer credential from blocking healthy agents. Retained stores outside active configuration receive recovery guidance rather than opening a different store.No new CLI options, configuration, SDK contract, schema, or Gateway-startup rebuild is introduced. Both pending-hook documentation passages are updated.
Evidence
Baseline pin:
ddbf65c9215087e7e1d10164021d8bcad7514cad, including #181860 and #181957. The local deterministic provider uses no paid API. The fixture contains 4,857 chunks (1,000 memory / 3,857 sessions), 60 sources and a full 1,536-dimensional embedding cache.On main, the first PostgreSQL search took 23.778s and embedded 4,857 corpus chunks plus its query; the next search took 3.634s and embedded only its query. Both port directions dropped the cache; rebuilding reproduced identical cache identities and bytes. A cached full PostgreSQL rebuild still took 20.158s with zero embedding calls and 4,001 top-level statements / 12.984s server execution. This does not reproduce or partition the reporter's historical 1,376.9s latency.
The cache round-trip regression is red under main's omission policy and green with this fix. All 15 focused command tests, source and touched-test TSRS checks, lint, the native line-cap guard, docs sanity, and independent P0–P3 review pass. Tests cover fresh post-port ownership/configuration, custody through close, isolated rebuild/close/dirty-state failures, retained-path selection and per-agent SecretRefs.
Clean-tree real CLI replay passes the pre-registered acceptance rule on
cf88eb38a3637f2af4198ae8d1c52ddb96ec6d7c:Searches additionally embed one query. The candidate port reports a 17.171s automatic rebuild, 60 files / 4,857 chunks, and preserves the exact cache digest. PostgreSQL → SQLite also rebuilds before returning (18.908s, zero embedding calls); its first search is 4.496s versus 4.067s warm, with no corpus embeddings. Unchanged manual indexing makes zero provider calls on both engines. SQLite → SQLite remains a no-op. The longer port deliberately pays rebuild cost while offline instead of delaying first recall.
All three PostgreSQL conformance shards actually ran and passed on
cf88eb38a3637f2af4198ae8d1c52ddb96ec6d7c: 1,143 tests passed, 37 existing skips, with 163 files passed and 3 skipped. Exact-head CI is green; no CI exception or rerun was needed. Both GitHub Codex review and ClawSweeper found no actionable defects. The requested Testbox allocation queued and was stopped under the campaign policy (allocation); no remote timing result is claimed.The frozen general warm-turn controls were attempted unchanged (63/63 hashes verified), but both baselines failed before any turns: SQLite rejected the retired heartbeat fixture setting; PostgreSQL rejected main-thread connection admission. No R/T/S or C64 numbers are claimed from failed setup.