Skip to content

fix(memory): return JSON when the memory backend is unavailable - #140229

Merged
steipete merged 1 commit into
mainfrom
codex/qa-memory-json-20260906
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-memory-json-20260906

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #140184

Additional instructions

Keep Allow edits from maintainers enabled when applicable.

What Problem This Solves

Fixes an issue where users running memory search --json receive an empty stdout stream and exit code 0 when memory search is disabled. JSON consumers cannot parse that response or distinguish an unavailable backend from a completed search. Five other single-agent JSON commands share the same missing-manager branch.

Why This Change Was Made

The memory plugin's manager-acquisition owner now emits one availability result for search, promote, promote-explain, rem-harness, rem-backfill, and session-backfill when their --json option is selected. The change absorbs a redundant one-caller wrapper and reuses the canonical CLI error formatter through the existing private memory host facade; status retains ownership of its single aggregate array.

User Impact

Disabled commands return {"agentId":"main","status":"disabled"} with the existing successful exit behavior. Acquisition failures return the standard {"ok":false,"error":{"type":"cli_error","message":"..."}} envelope plus agentId, with exit code 1. The memory CLI documentation explains these alternate outcomes before consumers read normal result fields.

Successful result shapes remain intact, including {"results":[]} for an enabled search with no matches. Status still returns its array of available agents, including [] when all are disabled. Existing diagnostics, argument validation, and manager cleanup remain at their current owners; unavailable commands do not run search, promotion, or backfill work or invent completed-work counts. No configuration, database schema, migration, or protocol change is included.

Evidence

Candidate: 90b87fa859f2a85f99de69ea6a4fb1b0761ceed2 on codex/qa-memory-json-20260906.

Proof Observed result
Built CLI before the fix, source c2ffbec6fc9af0da51921acfb5bbb19b66aecd78, Node v24.20.0 Disabled search: exit 0, stdout 0 bytes, stderr Memory search disabled. and newline. Disabled status: []. Enabled positive and no-match searches: valid JSON. The isolated fixture was cleaned up.
Focused source regression before/after All 12 disabled/error cases across the six commands failed before the fix because no JSON result was written. Those cases and four status/empty-search controls passed after the fix.
Full memory CLI and manager-acquisition suites 123 passed, 0 failed, 0 skipped.
Relevant core CLI helper, error and JSON-routing suites 92 passed, 0 failed, 0 skipped. Focused total: 215 passing cases.
Fresh independent review No actionable findings.
Doctor contract checks 6 passed as part of changed-file validation.
Changed-file checks All 36 stages passed, including formatting, lint, typechecks, guards, package exports, and SDK surface checks.
Candidate build One uncached runtime, SDK and UI build passed in 122.04 seconds at 90b87fa859f2a85f99de69ea6a4fb1b0761ceed2; source, dependency and artifact identities verified.
Expanded real CLI before/after 25 commands per build: all six disabled branches and six genuine backend-open failures reproduce empty JSON stdout on baseline and emit exactly one documented JSON object on the candidate. All thirteen human/status/index/enabled/no-match controls pass on both builds. Root independently checked 50 raw streams per build, exit codes, source/build/dependency/mode seals and cleanup.
Published-head CI CI 34043066614 completed successfully on 90b87fa859f2a85f99de69ea6a4fb1b0761ceed2.

The backend-open fixture is an empty directory at the database filename inside fresh isolated state; it exercises real acquisition errors without writing database records. No model or external provider request is involved.

The candidate contains 44 added / 45 removed production lines (net −1), 122 added / 2 removed test lines (net +120), and 14 added documentation lines. No generated files, lockfiles, or snapshots changed.

Review follow-through

The September 6, 15:46 UTC ClawSweeper review of the exact candidate found no correctness or security defects. Its sole before-merge item, “Add data-model compatibility proof,” is not applicable to this patch: the six edits in the search/promotion and REM/backfill callers only pass the JSON writer to the shared acquisition owner. That owner preserves the same configuration, agent, purpose, source-inspection and local-service arguments; missing managers still return before work, and successful managers retain the same cleanup.

Compared with the PR parent, the complete memory storage implementation, state database owners, memory host SDK, configuration, plugin manifest and canonical database schema documentation are unchanged. The patch changes no stored vector/embedding metadata, schema, migration or persisted representation. The existing paired built-CLI proof confirms real backend-open failure handling and unchanged enabled indexing/search/status controls; it is not presented as a migration test. No migration is needed for an output-only availability result.

Report disabled memory and backend acquisition failures through the existing
single-command JSON writers. Reuse the canonical CLI error envelope and
preserve status aggregation, diagnostics, exit codes, and manager cleanup.
Absorb the redundant acquisition wrapper into its command owner.

Closes #140184.
@clawsweeper

clawsweeper Bot commented Sep 6, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-core Extension: memory-core size: M maintainer Maintainer-authored PR labels Sep 6, 2026
@steipete
steipete marked this pull request as ready for review September 6, 2026 15:40
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 6, 2026, 11:46 AM ET / 15:46 UTC.

ClawSweeper review

What this changes

The memory CLI now returns JSON for disabled or unavailable backends across six commands, with regression coverage and documentation for the alternate results.

Merge readiness

⛔ Blocked before merge - 1 item remains

The repair remains necessary: current main and v2026.9.2 retain the empty-output branch. No actionable correctness or security defects were found in the introduced changes.

Priority: P2
Reviewed head: 90b87fa859f2a85f99de69ea6a4fb1b0761ceed2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with useful regression controls, clear output documentation, and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository State identifies a MEMBER-authored PR, so the external-contributor proof gate does not apply. Its pinned body additionally reports real built-CLI disabled and backend-open failure runs through the changed acquisition owner, with one JSON result per candidate invocation and preserved controls.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State identifies a MEMBER-authored PR, so the external-contributor proof gate does not apply. Its pinned body additionally reports real built-CLI disabled and backend-open failure runs through the changed acquisition owner, with one JSON result per candidate invocation and preserved controls.
Evidence reviewed 8 items Current main still needs the repair: The missing-manager handler logs disabled memory or an acquisition error and returns without writing JSON. The supplied related issue documents the corresponding empty stdout failure.
Latest release retains the same behavior: The v2026.9.2 source also has the missing-manager branch without structured output; the release resolves to 3928bad.
Repair stays at the acquisition owner: The optional unavailable-result writer runs only when acquisition returns no manager. Existing diagnostics, exit codes, acquisition parameters, and successful-manager cleanup are preserved; status does not opt into per-agent documents.
Findings None None.
Security None None.

How this fits together

The bundled Memory Core plugin handles memory CLI commands and acquires each agent's search backend before doing work. This change makes acquisition outcomes readable by scripts while preserving successful results and aggregate status output.

flowchart TD
  A[Memory CLI command] --> B[Resolve agent and configuration]
  B --> C[Acquire memory backend]
  C --> D{Backend available?}
  D -->|Yes| E[Run command and close backend]
  D -->|No| F[Emit availability JSON and diagnostics]
  E --> G[Normal command result]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -1, Tests +120, Docs +14. Total +133 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 5 44 45 -1
Tests 1 122 2 +120
Docs 1 14 0 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 180 47 +133

Review metrics

None.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/memory-core/src/cli-runtime-common.ts, vector/embedding metadata: extensions/memory-core/src/cli-index-search.runtime.ts, vector/embedding metadata: extensions/memory-core/src/cli-rem.runtime.ts, vector/embedding metadata: extensions/memory-core/src/cli-runtime-common.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #140184
Summary: This PR is the implementation candidate for the linked unavailable-memory JSON report; the issue should remain open until the fix lands.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep availability reporting in the shared acquisition owner, with distinct disabled and failed outcomes and unchanged successful command contracts.

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

Yes, from source: disable memory search and invoke memory search with --json; current main returns from acquisition before writing a result. The linked report supplies a matching built-CLI reproduction; this review did not execute it.

Is this the best way to solve the issue?

Yes. The patch repairs the shared early-return path, reuses the canonical error envelope, and avoids changing successful results, status aggregation, or backend lifecycle behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This fixes script parsing for unavailable memory backends without evidence of data loss or a broader runtime outage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies a MEMBER-authored PR, so the external-contributor proof gate does not apply. Its pinned body additionally reports real built-CLI disabled and backend-open failure runs through the changed acquisition owner, with one JSON result per candidate invocation and preserved controls.

Label justifications:

  • P2: This fixes script parsing for unavailable memory backends without evidence of data loss or a broader runtime outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies a MEMBER-authored PR, so the external-contributor proof gate does not apply. Its pinned body additionally reports real built-CLI disabled and backend-open failure runs through the changed acquisition owner, with one JSON result per candidate invocation and preserved controls.

Evidence

What I checked:

  • Current main still needs the repair: The missing-manager handler logs disabled memory or an acquisition error and returns without writing JSON. The supplied related issue documents the corresponding empty stdout failure. (extensions/memory-core/src/cli-runtime-common.ts:185, 62da492b5207)
  • Latest release retains the same behavior: The v2026.9.2 source also has the missing-manager branch without structured output; the release resolves to 3928bad. (extensions/memory-core/src/cli-runtime-common.ts, 3928bad9badf)
  • Repair stays at the acquisition owner: The optional unavailable-result writer runs only when acquisition returns no manager. Existing diagnostics, exit codes, acquisition parameters, and successful-manager cleanup are preserved; status does not opt into per-agent documents. (extensions/memory-core/src/cli-runtime-common.ts:197, 90b87fa859f2)
  • Structured output uses the existing runtime: writeJson directly serializes to stdout without relying on method binding. Existing CLI JSON routing sends incidental console diagnostics to stderr, while withManager returns before command work when acquisition fails. (src/runtime.ts:94, 90b87fa859f2)
  • Private host bridge, not a new public plugin contract: The SDK reference explicitly classifies memory-core-host-runtime-cli as private-local; the private-subpath inventory agrees. The added export reuses the canonical CLI failure formatter through that existing bridge. Public docs: docs/plugins/sdk-subpaths.md. (docs/plugins/sdk-subpaths.md:475, 90b87fa859f2)
  • Regression coverage protects observable results: The tests exercise Commander entrypoints for disabled and failed acquisition across all six commands, plus aggregate status, enabled empty search, exit codes, cleanup, and human-output controls. Tests were inspected, not executed during this read-only review; git diff --check passed. (extensions/memory-core/src/cli.test.ts:1985, 90b87fa859f2)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • xingzhou: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit d1e5a1b into main Sep 6, 2026
258 checks passed
@steipete
steipete deleted the codex/qa-memory-json-20260906 branch September 6, 2026 16:09
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
Report disabled memory and backend acquisition failures through the existing
single-command JSON writers. Reuse the canonical CLI error envelope and
preserve status aggregation, diagnostics, exit codes, and manager cleanup.
Absorb the redundant acquisition wrapper into its command owner.

Closes openclaw#140184.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

[Bug]: memory search --json emits no JSON when memory search is disabled

1 participant