fix(memory-core): keep QMD JSON search one-shot#91837
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 10, 2026, 1:21 AM ET / 05:21 UTC. Summary PR surface: Source +8, Tests +49. Total +57 across 2 files. Reproducibility: yes. I did not run the failing current-main command, but the source path is clear: CLI search can schedule QMD sync work and manager close waits for pending update/embed work, matching the linked report and the PR's after-fix terminal proof. Review metrics: none identified. 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 the lifecycle-bound QMD fix after normal maintainer review and CI, keeping explicit memory index commands as the path for blocking QMD refresh work. Do we have a high-confidence way to reproduce the issue? Yes. I did not run the failing current-main command, but the source path is clear: CLI search can schedule QMD sync work and manager close waits for pending update/embed work, matching the linked report and the PR's after-fix terminal proof. Is this the best way to solve the issue? Yes. Fixing the QMD manager's CLI lifecycle is more maintainable than adding process.exit() after JSON output because it prevents the background work that keeps close() alive while preserving normal explicit sync commands. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 54c400a97571. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +8, Tests +49. Total +57 across 2 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
|
11a832b to
28deb04
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. Re-review progress:
|
28deb04 to
4137a2a
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Landed after maintainer verification:
Proof gap: no live Landed commit: 9408380 |
Summary
Fixes #91821.
openclaw memory search <query> --jsoncould print valid JSON with the QMD backend and then stay alive because the one-shot QMD CLI manager could still schedule session-start/search sync work.withManager()closes the manager after JSON output, andclose()waits for pending QMD update/embed work, so a background sync can keep the CLI process alive after the result has already been written.This keeps the repair in the QMD lifecycle boundary: CLI-mode QMD managers still initialize without watchers or boot timers, and now also skip session/search-triggered sync scheduling during one-shot searches. JSON output remains prompt; best-effort recall tracking is not moved into the blocking JSON path.
Verification
node scripts/run-vitest.mjs extensions/memory-core/src/cli.test.ts extensions/memory-core/src/memory/qmd-manager.test.ts— 192 passedpnpm exec oxfmt --check --threads=1 extensions/memory-core/src/cli.runtime.ts extensions/memory-core/src/cli.test.ts extensions/memory-core/src/memory/qmd-manager.ts extensions/memory-core/src/memory/qmd-manager.test.ts— cleangit diff --check— cleangit log --format='%h %an <%ae> %s' upstream/main..HEAD—4137a2ab05 Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com> fix(memory-core): keep qmd json search one-shotReal behavior proof
Behavior addressed: QMD-backed
memory search --jsonexits after printing successful JSON even when sync settings would otherwise trigger session/search update work. The proof uses a stubqmdbinary that returns valid search JSON and intentionally never exits forqmd update/qmd embed; if the CLI schedules the old background update path, the command times out.Real environment tested: macOS source checkout
/Users/andy/openclaw-91821-memory-json-exit, Node 24.15.0, rebuilt localdist/index.js, temporaryOPENCLAW_CONFIG_PATH, temporaryOPENCLAW_STATE_DIR, QMD backend enabled,memorySearch.sync.onSessionStart=true,memorySearch.sync.onSearch=true, fakeqmdcommand on PATH logging every invocation.Exact steps or command run after this patch:
node dist/index.js memory search "QMD proof token" --jsonEvidence after fix:
{ "proof": "PR91837_QMD_JSON_EXIT_STUB", "command": "node dist/index.js memory search \"QMD proof token\" --json", "config": { "backend": "qmd", "sync": { "onSessionStart": true, "onSearch": true }, "qmdUpdateStubWouldHang": true }, "exit": { "code": 0, "signal": null }, "timedOut": false, "durationMs": 4020, "stdout": "{\n \"results\": [\n {\n \"path\": \"memory/proof.md\",\n \"startLine\": 1,\n \"endLine\": 1,\n \"score\": 0.91,\n \"snippet\": \"@@ -1,1\\nQMD proof token from stub\",\n \"source\": \"memory\"\n }\n ]\n}", "stderr": "[memory] qmd manager initialized for agent \"main\" mode=cli collections=1 durationMs=210\n[memory] failed to read qmd index stats: Error: unable to open database file", "qmdCalls": [ ["collection", "list", "--json"], ["collection", "add", "<temp-workspace>", "--name", "workspace-main", "--mask", "**/*.md"], ["search", "QMD proof token", "--json", "-n", "4", "-c", "workspace-main"] ], "backgroundUpdateCallCount": 0 }Observed result after fix: the CLI printed a valid JSON result and exited with status 0 before the 7s proof timeout. The QMD invocation log shows collection setup and search only; no
qmd updateorqmd embedcommand was spawned, so the intentionally hanging update path was not reached.What was not tested: a live installed QMD binary and real QMD index. The proof is a faithful process-lifecycle stub for the reported exit hang: it exercises the OpenClaw CLI, config loading, QMD manager creation, QMD collection/search subprocess calls, JSON output, and process exit behavior.