Skip to content

fix(memory): emit one JSON result for command failures - #147366

Merged
steipete merged 2 commits into
mainfrom
codex/qa-memory-single-result-20260913
Sep 13, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/qa-memory-single-result-20260913

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Memory commands can exit with empty JSON output after invalid input or an execution error. Historical REM commands can also print success before temporary-workspace cleanup fails, producing two JSON documents.

User Impact

Scripts receive one standard CLI error document and exit code 1 for terminal command failures. Successful results and the existing disabled/backend-acquisition responses retain their shapes. Human-readable diagnostics remain on stderr.

Why This Change Was Made

Command execution now passes failures to the existing root CLI error owner. Historical scratch ownership covers preparation through awaited cleanup, and the command publishes success only after that scope completes. Contextual errors preserve their original causes. This removes duplicated error handling and reduces production code by 56 lines. The required test-build declaration adds two tooling lines, for a combined reduction of 54.

The change leaves memory storage, migrations, manager acquisition, nonfatal manager-close diagnostics, aggregate status, and human-only multi-agent indexing unchanged. It extends the execution boundary; #140229 covered backend acquisition before command work begins.

Evidence

  • Tests-first reproduction: 31 intended failures on the original implementation. After relocating the root integration test to its owning core boundary, all three cases were reproduced again on unchanged production code.
  • All 155 focused tests pass. Required changed checks pass as a documented composite; the initial failed attempts and successful owning checks are retained. Fresh independent P0–P2 review found no actionable findings.
  • Both normal builds passed. Eleven ordinary built CLI commands ran per phase with isolated synthetic state. Missing-query and loopback HTTP 400 failures changed from exit 1 with empty stdout to exit 1 with exactly one error document. Successful searches, disabled acquisition, historical previews and diary staging/rollback controls passed.
  • All 22 raw CLI stderr streams were inspected: no manager-close or unhandled-rejection diagnostics. Four embedding requests per phase completed their responses; the fixture servers and captured processes shut down. The actual before/after verifier exited 0, and a separate audit verified the completed proof.

Native proof uses local simulated embeddings, not hosted inference. Filesystem cleanup faults are covered by deterministic tests. Historical native proof verifies diary readback and reported short-term counters; it does not independently verify short-term-store rollback completeness. Source validation was performed on bc183cbbf7a387e9cea8991a2da539b92a0a70b2 plus this patch. Exact-head hosted CI is required before landing.

Data compatibility

The review’s generated data-model checklist is not applicable to this patch. The full diff changes no schema, version, migration, stored representation, retention rule, or storage writer. dreaming-dreams-file.ts, short-term-promotion.ts, session-backfill.ts, memory-forget.ts, the acquisition owner, and the root failure formatter have identical Git blobs between the base and this PR. Their existing operations and arguments are retained; only command error propagation and the temporary scratch scope change. Successful JSON fields and disabled/acquisition envelopes are unchanged and covered by the passing controls. No upgrade migration or operator action is needed. This does not claim transactional rollback across historical diary and short-term writes; those existing semantics remain unchanged.

Clean-checkout CI verification

The first hosted run exposed a missing prerequisite in the new integration test: native plugin loading needs the built JavaScript SDK, which the local built checkout already had. A source-only checkout reproduced all three failures. Declaring this test in the existing runtime-consumer registry now makes the ordinary runner build the runtime before workers start. The original test and its assertions remain unchanged. The automatic build and all three cases pass; 112 prerequisite-routing cases, two CI partition checks, the complete two-file changed gate and fresh scoped P0–P2 review also pass. The initial failed hosted run is retained; this correction requires a fresh green exact-head run before landing.

@clawsweeper

clawsweeper Bot commented Sep 13, 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: XL maintainer Maintainer-authored PR labels Sep 13, 2026
@steipete
steipete marked this pull request as ready for review September 13, 2026 20:08
@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 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 13, 2026, 5:11 PM ET / 21:11 UTC (Revision 3).

ClawSweeper review

What this changes

Memory commands now send execution failures through the shared CLI JSON formatter, finish historical scratch cleanup before reporting success, and register the integration test’s runtime-build prerequisite.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR remains useful: current main still contains the reported failure paths, and no actionable patch defect was found. The previous migration-proof blocker is inapplicable because stored formats, storage writers, and their arguments remain unchanged.

Priority: P2
Reviewed head: 44b370c253d602c114690c0fc6073669ee26d554

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused ownership repair with meaningful regression coverage and recorded real CLI verification; no additional code or migration blocker remains.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The captured body records built-CLI before/after execution of the changed memory handlers with isolated state and real loopback HTTP requests, showing one error JSON instead of empty stdout and successful control cases. Historical cleanup failures are covered separately by root-boundary fault tests; the latest commit changes only test prerequisites.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured body records built-CLI before/after execution of the changed memory handlers with isolated state and real loopback HTTP requests, showing one error JSON instead of empty stdout and successful control cases. Historical cleanup failures are covered separately by root-boundary fault tests; the latest commit changes only test prerequisites.
Evidence reviewed 9 items Current main still needs the repair: At the fetched main revision, queryless search and search execution failures log diagnostics, set exitCode, and return without writing JSON or throwing to the root formatter.
Existing output owner: The root command-error handler writes the canonical JSON failure envelope and sets exit code 1. The existing manager wrapper awaits closure while retaining nonfatal close diagnostics, so propagating command failures reaches the appropriate owner.
Cleanup precedes publication: Both historical commands await the shared scratch scope before publishing their result. The scope covers copying, command work, and awaited removal, including preparation failures.
Findings None None.
Security None None.

How this fits together

The Memory Core plugin handles CLI requests to search, inspect, and manage agent memory. Its command handlers pass failures to the root CLI, which produces machine-readable stdout and human-readable stderr.

flowchart TD
  A[Memory CLI request] --> B[Validate input and acquire backend]
  B --> C[Run memory operation]
  C --> D[Finish historical scratch cleanup]
  D --> E[Publish success JSON]
  B -->|Failure| F[Root CLI error formatter]
  C -->|Failure| F
  D -->|Failure| F
  F --> G[One error JSON and stderr diagnostics]
Loading

Before merge

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

Security

None.

PR surface

Source -56, Tests +614, Docs +4, Other +2. Total +564 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 2 266 322 -56
Tests 3 666 52 +614
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 1 8 6 +2
Total 7 944 380 +564

Review metrics

Metric Value Why it matters
Runtime versus regression coverage Production −56 lines; tooling +2; tests +614 The larger diff adds failure and cleanup coverage while reducing production code through shared ownership.

Stored data model

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

Technical review

Best possible solution:

Keep the root CLI as the failure-output owner and publish historical command results only after fallible scratch cleanup settles.

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

Yes, source establishes a clear path: current-main memory search --json without a query returns after setting exitCode and never reaches the JSON failure formatter. No runtime reproduction was executed in this review.

Is this the best way to solve the issue?

Yes. Reusing the existing error formatter and consolidating scratch ownership repairs the output contract without introducing another formatter, plugin API, or storage migration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8fd2838b57cf.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured body records built-CLI before/after execution of the changed memory handlers with isolated state and real loopback HTTP requests, showing one error JSON instead of empty stdout and successful control cases. Historical cleanup failures are covered separately by root-boundary fault tests; the latest commit changes only test prerequisites.

Label justifications:

  • P2: This repairs machine-readable memory-command failures with a bounded CLI impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured body records built-CLI before/after execution of the changed memory handlers with isolated state and real loopback HTTP requests, showing one error JSON instead of empty stdout and successful control cases. Historical cleanup failures are covered separately by root-boundary fault tests; the latest commit changes only test prerequisites.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body records built-CLI before/after execution of the changed memory handlers with isolated state and real loopback HTTP requests, showing one error JSON instead of empty stdout and successful control cases. Historical cleanup failures are covered separately by root-boundary fault tests; the latest commit changes only test prerequisites.

Evidence

What I checked:

  • Current main still needs the repair: At the fetched main revision, queryless search and search execution failures log diagnostics, set exitCode, and return without writing JSON or throwing to the root formatter. (extensions/memory-core/src/cli-index-search.runtime.ts:204, 8fd2838b57cf)
  • Existing output owner: The root command-error handler writes the canonical JSON failure envelope and sets exit code 1. The existing manager wrapper awaits closure while retaining nonfatal close diagnostics, so propagating command failures reaches the appropriate owner. (src/entry.ts:325, 44b370c253d6)
  • Cleanup precedes publication: Both historical commands await the shared scratch scope before publishing their result. The scope covers copying, command work, and awaited removal, including preparation failures. (extensions/memory-core/src/cli-rem.runtime.ts:465, 44b370c253d6)
  • Prior compatibility concern resolved: The introduced diff leaves the diary writer, promotion storage owner, session-backfill owner, forget owner, acquisition owner, and root failure formatter unchanged. Review of the moved call sites found their storage arguments and ordering preserved. No data-model migration is introduced. (extensions/memory-core/src/cli-rem.runtime.ts:327, 44b370c253d6)
  • Meaningful regression coverage: The new root-boundary tests load the registered memory plugin, parse the entire stdout stream, and verify queryless search plus both historical cleanup failures. Deferred cleanup assertions catch premature success publication. The latest commit declares the required runtime build without weakening these assertions. (src/entry.memory-json.test.ts:139, 44b370c253d6)
  • Recorded real CLI evidence: The captured PR body reports eleven built CLI commands per before/after phase with isolated synthetic state: missing-query and loopback HTTP 400 failures changed from empty stdout to exactly one error document, while successful search, disabled acquisition, historical preview, and diary controls passed. Cleanup faults were tested deterministically; complete short-term rollback was not independently established by the native run. These are contributor-recorded observations, not executions performed during this review. Captured context sourceRevision: 7257fcf22dffd054c4e286a7de10b94bfbdb7a0b899bf370f21acc2f1539fbb1. (5c2871597ec7)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-13T20:17:29.789Z sha 5c28715 :: blocked before merge. :: none
  • reviewed 2026-09-13T20:35:48.038Z sha 5c28715 :: blocked before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 13, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 13, 2026
@steipete
steipete merged commit d0100a4 into main Sep 13, 2026
154 checks passed
@steipete
steipete deleted the codex/qa-memory-single-result-20260913 branch September 13, 2026 21:25
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to Alix-007/openclaw that referenced this pull request Sep 13, 2026
…1-prep

* commit '912ae8d96e5964dfdcdf419b79613fb941cdf0a8': (350 commits)
  fix: keep workspace preparation responsive during cleanup (openclaw#147358)
  docs: alphabetize donors and sponsors and add Red Hat logo (openclaw#147302)
  fix(plugins): retain update authority through doctor effects (openclaw#144316)
  refactor(qa): share Multipass mount retry lifecycle (openclaw#147084)
  fix(memory): emit one JSON result for command failures (openclaw#147366)
  improve(plugins): speed up cold metadata loading (openclaw#147411)
  fix(sessions): avoid duplicate work after waited child replies (openclaw#147394)
  fix(agents): retain outstanding child results in parent context (openclaw#112623)
  test: preserve native workflow loader selection (openclaw#147403)
  fix: reduce repeated work while polling session pull requests (openclaw#147373)
  test(qa): preserve task cancellation across process replacement (openclaw#147382)
  fix: prevent sidebar refresh storms during session activity (openclaw#147400)
  refactor: simplify skills CLI formatting (openclaw#147368)
  fix: prevent Git checkout certificate failures behind egress proxy (openclaw#147410)
  fix(qa): stop live threads after their process leader exits (openclaw#147386)
  refactor(release): share agent turn retry lifecycle (openclaw#147076)
  fix(ui): keep uploaded images aligned with their prompts (openclaw#147389)
  fix(fs): guard skill reads and bound worker bundle staging (openclaw#147336)
  fix(ci): restore Linux service ownership fixtures (openclaw#147398)
  fix(plugins): preserve manifest permissions when building plugins (openclaw#147393)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
* fix(memory): emit one JSON result for command failures

* test(memory): prepare the SDK before root CLI integration tests
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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.

1 participant