fix(memory-core): guard searches during safe reindex#90453
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 2, 2026, 12:41 AM ET / 04:41 UTC. Summary PR surface: Source +98, Tests +311. Total +409 across 5 files. Reproducibility: yes. at source level: current main still swaps the live manager to a temp reindex DB before metadata publication, and the tool still fail-closes when status reports missing identity. I did not run a live concurrent gateway reproduction in this read-only review. Review metrics: none identified. Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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:
Next step before merge
Security Review detailsBest possible solution: Land or replace this manager-level read barrier after maintainers accept the latency tradeoff and coordinate adjacent metadata/WAL cleanup work. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main still swaps the live manager to a temp reindex DB before metadata publication, and the tool still fail-closes when status reports missing identity. I did not run a live concurrent gateway reproduction in this read-only review. Is this the best way to solve the issue? Yes as an implementation direction: the manager-level read barrier and stable status snapshot address the lifecycle race more directly than a tool-wrapper workaround. The remaining question is maintainer acceptance of the latency tradeoff and adjacent metadata cleanup ordering. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8c7ac9b9b9df. Label changesLabel justifications:
Evidence reviewedPR surface: Source +98, Tests +311. Total +409 across 5 files. View PR surface stats
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
|
55ddb80 to
1f4817e
Compare
1f4817e to
09c4abb
Compare
09c4abb to
0a9c4d1
Compare
|
CI note for the current head This branch has been rebased onto the current The remaining failing CI checks are outside this PR's touched surface and reproduce locally as standalone failures: node scripts/run-vitest.mjs src/agents/tools/pdf-tool.model-config.test.ts
node scripts/run-vitest.mjs src/agents/workspace-templates.test.ts
node scripts/run-vitest.mjs src/commands/doctor-heartbeat-template-repair.test.tsObserved failures:
These failures look like current-main expectation drift in agent/doctor tests rather than regressions from the memory-core reindex/search-status race fix in this PR. |
0a9c4d1 to
239c193
Compare
|
Thanks for working on this. I hit the same failure mode in an affected install and this PR matches the direction that tested well locally. Additional local evidence from the failure window:
I also tested a minimal current- Given that, I think this PR's broader reindex latch/status-snapshot approach is likely the better upstream shape than a minimal duplicate PR. The main practical blocker I see is that the branch currently appears stale/dirty against current |
239c193 to
26b0b99
Compare
Addresses #21: memory_search returns 'disabled: true, unavailable: true, error: index metadata is missing' when the on-disk index sidecar is missing or was written by a different embedding provider/model. The deploy pipeline was silently green because the existing health check (/healthz + gateway process) does not look at the memory index — the disable message only surfaces when an agent actually calls memory_search. The root-cause upstream race lives in openclaw/openclaw#90361 and PR #90453 is the mergeable closing PR (owned by upstream maintainers — L3b does not duplicate the fix). This commit adds the L3b-side detection + deploy-gate integration that catches regressions of the same shape at the deploy boundary. What ships: 1. scripts/lib-parse-memory-status.py Pure decision logic. Reads JSON from stdin (the output of 'openclaw memory status --json') and emits TSV rows (agent_id<TAB>verdict<TAB>reason). Verdicts: ok identity=ok warn-fresh identity missing/mismatch but no data yet warn-swap provider != requestedProvider warn-unknown unrecognized identity state (forward-compat) fail identity missing/mismatch AND data present 2. scripts/post-deploy-verify-memory-index.sh Bash wrapper that runs the probe, classifies rows, and decides: exit 0 = healthy (or fresh install) exit 1 = degraded index on an agent that has data (deploy gate fails) exit 2 = probe failure (openclaw not on PATH, JSON parse error) Honors SKIP_POST_DEPLOY_MEMORY_CHECK=1 (opt-out) and MEMORY_CHECK_FAIL_ON_FRESH=1 (promote fresh-install WARN to FAIL). 3. scripts/install/deploy.sh Wires the verify script in as section 7 (post-deploy verification, called immediately before 'OpenClaw Gateway installation complete'). Exit 1 fails the deploy gate; exit 2 is soft-warned (don't block deploy on missing CLI). 4. tests/post-deploy-verify-memory-index.bats 19 cases covering: healthy / fresh / regression / mismatch / multi-agent / MEMORY_CHECK_FAIL_ON_FRESH / provider swap / unknown state / skip / openclaw-not-on-PATH / invalid JSON / empty output / no agents / parser existence / parser inline- python-free / parser exit codes / deploy.sh wiring. 5. docs/troubleshooting/memory-index-disabled.md Symptom / diagnose / recover / why / prevention matrix / forward-compat notes. Cross-links to upstream issue #90361 and the mergeable closing PR #90453. Verification: - bats tests/post-deploy-verify-memory-index.bats: 19/19 pass - shellcheck --severity=warning: clean on both new bash scripts - pre-commit run --files <all>: clean - python3 -m py_compile: clean on the parser lib Refs: - #21 - openclaw/openclaw#90361 (root cause) - openclaw/openclaw#90453 (upstream closing PR)
…ills (#35) * feat(gateway): post-deploy memory-index verification gate Addresses #21: memory_search returns 'disabled: true, unavailable: true, error: index metadata is missing' when the on-disk index sidecar is missing or was written by a different embedding provider/model. The deploy pipeline was silently green because the existing health check (/healthz + gateway process) does not look at the memory index — the disable message only surfaces when an agent actually calls memory_search. The root-cause upstream race lives in openclaw/openclaw#90361 and PR #90453 is the mergeable closing PR (owned by upstream maintainers — L3b does not duplicate the fix). This commit adds the L3b-side detection + deploy-gate integration that catches regressions of the same shape at the deploy boundary. What ships: 1. scripts/lib-parse-memory-status.py Pure decision logic. Reads JSON from stdin (the output of 'openclaw memory status --json') and emits TSV rows (agent_id<TAB>verdict<TAB>reason). Verdicts: ok identity=ok warn-fresh identity missing/mismatch but no data yet warn-swap provider != requestedProvider warn-unknown unrecognized identity state (forward-compat) fail identity missing/mismatch AND data present 2. scripts/post-deploy-verify-memory-index.sh Bash wrapper that runs the probe, classifies rows, and decides: exit 0 = healthy (or fresh install) exit 1 = degraded index on an agent that has data (deploy gate fails) exit 2 = probe failure (openclaw not on PATH, JSON parse error) Honors SKIP_POST_DEPLOY_MEMORY_CHECK=1 (opt-out) and MEMORY_CHECK_FAIL_ON_FRESH=1 (promote fresh-install WARN to FAIL). 3. scripts/install/deploy.sh Wires the verify script in as section 7 (post-deploy verification, called immediately before 'OpenClaw Gateway installation complete'). Exit 1 fails the deploy gate; exit 2 is soft-warned (don't block deploy on missing CLI). 4. tests/post-deploy-verify-memory-index.bats 19 cases covering: healthy / fresh / regression / mismatch / multi-agent / MEMORY_CHECK_FAIL_ON_FRESH / provider swap / unknown state / skip / openclaw-not-on-PATH / invalid JSON / empty output / no agents / parser existence / parser inline- python-free / parser exit codes / deploy.sh wiring. 5. docs/troubleshooting/memory-index-disabled.md Symptom / diagnose / recover / why / prevention matrix / forward-compat notes. Cross-links to upstream issue #90361 and the mergeable closing PR #90453. Verification: - bats tests/post-deploy-verify-memory-index.bats: 19/19 pass - shellcheck --severity=warning: clean on both new bash scripts - pre-commit run --files <all>: clean - python3 -m py_compile: clean on the parser lib Refs: - #21 - openclaw/openclaw#90361 (root cause) - openclaw/openclaw#90453 (upstream closing PR) * feat(skills): add memory-status and memory-rebuild slash commands Brings the recovery flow for #21 out of the SSH-only domain and into Discord. Both skills are wired into the existing skill-sync phase of scripts/install/deploy.sh (section 6) — no extra deploy wiring is needed. Two skills: 1. memory-status (/memory-status) Reads 'openclaw memory status --json' and produces a per-agent table with: agent, identity (ok/missing/mismatch), provider, chunks, notes. Surfaces the L3b deploy gate's verdict matrix (warn-fresh / warn-swap / fail) so the user knows whether a rebuild is required, or whether the index is empty and will rebuild on first-use. 2. memory-rebuild (/memory-rebuild) Runs 'openclaw memory index --force' and reports the result. Lists the documented failure modes (auth error, EACCES, model-not-in-catalog) and the recovery steps for each. Warns before rebuilding blindly — does not auto-rebuild on unknown identity states. Both skills reference the troubleshooting doc and the upstream issue (#90361) so a user hitting this in the future has a single documented path to resolution. Verification: - deploy-skills-sync.bats (existing tests cover the new skills): 11/11 pass — they are picked up by the generic skill-sync test - pre-commit run --files <new SKILL.md>: clean - Frontmatter validates as YAML with name + commands (matches the existing model-management skill pattern) Refs: - #21 - openclaw/openclaw#90361 - 78890b8 (Tier 1: deploy-gate wiring) --------- Co-authored-by: Migration Agent <[email protected]>
bc317e2 to
a820c14
Compare
|
@clawsweeper re-review Repair pushed for the current head Addressed finding:
Validation completed after the repair/rebase: pnpm exec oxfmt --check extensions/memory-core/src/memory/manager.ts extensions/memory-core/src/memory/manager.async-search.test.ts
pnpm exec oxlint --tsconfig config/tsconfig/oxlint.extensions.json extensions/memory-core/src/memory/manager.ts extensions/memory-core/src/memory/manager.async-search.test.ts
git diff --check upstream/main...HEAD
.agents/skills/autoreview/scripts/autoreview --mode commit --commit HEAD --prompt-file /tmp/openclaw-90453-autoreview-context.txtResult: formatting, oxlint, diff check, and autoreview are clean. Local Vitest/tsgo attempts on this host did not complete because the local test runner stayed in a no-output build/startup state; I am not counting those as passed. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(memory-core): guard searches during safe reindex This is item 1/1 in the current shard. Shard 2/4. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Closing due to inactivity. |
Summary
What problem does this PR solve?
index metadata is missing.Why does this matter now?
What is the intended outcome?
What is intentionally out of scope?
What does success look like?
index metadata is missing.What should reviewers focus on?
Linked context
Which issue does this close?
Closes #90361
Which issues, PRs, or discussions are related?
Related #90422
Related #90395
Was this requested by a maintainer or owner?
Real behavior proof (required for external PRs)
index metadata is missingafter a safe forced reindex when the durable OpenClaw index is valid.0a9c4d1ef5, Nodev24.15.0, real OpenClaw CLI memory commands, temporaryOPENCLAW_HOME, temporary workspace, FTS-only memory provider (provider: "none",model: "fts-only") to avoid external credentials.Temporary config used for the proof:
{ "agents": { "defaults": { "workspace": "<tmp-workspace>", "memorySearch": { "provider": "none", "model": "fts-only", "cache": { "enabled": false }, "sync": { "watch": false, "onSessionStart": false, "onSearch": false } } }, "list": [{ "id": "main", "default": true }] } }MEMORY.mdresult. Neither status nor search output containedindex metadata is missing.Tests and validation
Which commands did you run?
git diff --check node scripts/run-vitest.mjs extensions/memory-core/src/tools.test.ts extensions/memory-core/src/memory/manager.reindex-read-race.test.ts node scripts/run-vitest.mjs src/scripts/test-projects.test.ts pnpm exec oxlint --tsconfig config/tsconfig/oxlint.extensions.json extensions/memory-core/src/memory/manager.ts extensions/memory-core/src/memory/manager-sync-ops.ts extensions/memory-core/src/memory/manager.reindex-read-race.test.ts .agents/skills/autoreview/scripts/autoreview --mode branch --base upstream/mainReal CLI proof commands are listed in the Real behavior proof section.
What regression coverage was added or updated?
extensions/memory-core/src/memory/manager.reindex-read-race.test.ts.status()during in-flight full safe reindex.search()waiting during the temp-DB window.search()waiting when provider initialization yields and another actor starts a full safe reindex before identity/FTS reads.What failed before this fix, if known?
If no test was added, why not?
Risk checklist
Did user-visible behavior change? (
Yes/No)Yes. Memory search/status now wait through an in-flight full safe reindex instead of reading transient temp-DB state.
Did config, environment, or migration behavior change? (
Yes/No)No.
Did security, auth, secrets, network, or tool execution behavior change? (
Yes/No)No.
What is the highest-risk area?
How is that risk mitigated?
finally.nextMetabuilt and verified during the full reindex.Current review state
What is the next action?
What is still waiting on author, maintainer, CI, or external proof?
Which bot or reviewer comments were addressed?
.agents/skills/autoreview/scripts/autoreview --mode branch --base upstream/mainreportedautoreview clean: no accepted/actionable findings reported.