Skip to content

fix(memory): preserve requested corpus outcomes - #126530

Merged
steipete merged 1 commit into
mainfrom
steipete/memory-corpus-outcomes-20260820
Aug 20, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/memory-corpus-outcomes-20260820

Conversation

@steipete

@steipete steipete commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Related: #125978

AI-assisted implementation; reviewed and verified by the maintainer.

What Problem This Solves

Fixes an issue where memory_search and memory_get could hide requested-corpus failures. A corpus=all request could fail as one unit, or a cooldown retry could silently omit memory, even when another corpus still had usable results.

Why This Change Was Made

Memory-core now represents each requested corpus with one closed ok, unavailable, or not-registered attempt. Search and exact reads share one metadata composer and one bounded supplement settlement path. corpus=all executes memory and wiki independently under one deadline, keeps surviving results, and reports deterministic outcomes and warnings; exact reads retain memory payload precedence while still reporting the wiki outcome after a successful memory read.

This is PR 2 of the split memory contract repair and builds on merged PR #125979's explicit ok/not_found read contract.

Production LOC: +574/-451 (net +123). Tests: +415/-208. The new corpus owner adds 225 lines, while the refactor removes 135 net lines from tools.ts, removes duplicate supplement paths, and replaces repetitive exact-read tests with a behavior matrix.

User Impact

Agents receive usable memory or wiki results when another requested corpus is unavailable, with explicit warnings instead of silent omission. Cooldown retries remain visible. memory_get corpus=all reports both corpus outcomes even when memory succeeds.

Evidence

Validated on base 916eef4e996008d387207c53044afd8cf02dcc30; current head is b740adf3bcfe5de1cf7a278d3c6716113db083bd.

  • Focused corpus/search/get and memory-wiki suites: 43 tests passed.
  • Per-commit assertion-safety ratchet and git diff --check: passed.
  • Fresh Codex autoreview: clean, no accepted/actionable findings; correctness 0.91.
  • Authenticated isolated exact-head live proof with anthropic/claude-sonnet-4-6:
    • memory_search(corpus="all") returned the indexed AQUAMARINE-84 result with memory=ok, wiki=not-registered, and an explicit warning.
    • memory_get(corpus="all") returned the memory file with the same two outcomes and warning.
    • Both model turns consumed the tool results successfully; 18 transcript events were decoded and verified.
  • Exact-base clean changed-surface gate passed: changed-surface classification, format, extension and extension-test typechecks, extension and script lint, plugin boundaries, assertion/max-lines ratchets, dead-export scans, database-first guard, runtime sidecar guard, and import-cycle check.

No operator gateway or normal OpenClaw state was touched. No LanceDB path, SQLite schema version, protocol version, lockfile, docs, or changelog is changed.

@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete steipete self-assigned this Aug 20, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 20, 2026
@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 11:37 PM ET / August 20, 2026, 03:37 UTC.

ClawSweeper review

What this changes

The PR centralizes memory and wiki corpus attempts so memory_search and memory_get retain usable results while explicitly reporting unavailable or unregistered requested corpora.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. This maintainer-authored draft provides a coherent owner-boundary repair for silent partial corpus outcomes; no concrete patch defect was found, but it still needs the promised exact-base changed-surface gate before readiness review.

Priority: P1
Reviewed head: b740adf3bcfe5de1cf7a278d3c6716113db083bd

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has a coherent canonical owner and strong focused coverage, with the planned exact-base gate still needed before readiness.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored draft is exempt from the external-contributor proof gate; its body additionally records an isolated exact-head live tool exercise.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored draft is exempt from the external-contributor proof gate; its body additionally records an isolated exact-head live tool exercise.
Evidence reviewed 8 items Current-main failure path: Before this PR, an all exact read returned a successful memory result immediately, without attempting or recording wiki; after a memory failure it swallowed supplement lookup failures and returned only the original disabled error.
Canonical repair boundary: The new coordinator settles registered supplements deterministically, preserves partial values, and converts unavailable and unregistered states into explicit metadata.
Search caller: corpus=all now runs built-in memory and wiki under one deadline, merges surviving results, and attaches both attempts to the response.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw memory --help

Result: PASS (completed)

runner@runnervm76f27:/tmp/clawsweeper-live-proof-126530-ZLe7r8/target$ pnpm openclaw memory --help
$ node scripts/run-node.mjs memory --help
pnpm openclaw memory --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 107.77 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.8s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 14.3s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 4505ms (slowest: built plugin control-plane loads 3722ms)
│
◇

OpenClaw 2026.8.1 (b740adf) — All your chats, one OpenClaw.

Usage: openclaw memory [options] [command]

Search, inspect, and reindex memory files

Options:
  -h, --help        Display help for command

Commands:
  index             Reindex memory files
  promote           Rank short-term recalls and optionally append top entries to MEMORY.md
  promote-explain   Explain a specific promotion candidate and its score breakdown
  rem-backfill      Write grounded historical REM summa
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

Memory Core tools combine built-in memory with registered corpus supplements such as memory-wiki, then return structured recall results to an agent. The new coordinator records each corpus outcome, merges surviving results, and emits warnings into the tool response.

flowchart LR
A[Agent memory request] --> B[Memory Core tool]
B --> C[Corpus coordinator]
C --> D[Built-in memory attempt]
C --> E[Wiki supplement attempt]
D --> F[Outcome metadata]
E --> F
F --> G[Structured tool result]
G --> H[Agent response]
Loading

Before merge

  • Resolve merge risk (P1) - The tool-result contract changes wiki misses from disabled errors to status: "not_found" and adds corpus metadata; bundled wiki coverage is present, but the promised exact-base changed-surface gate should confirm no remaining consumer assumes the old shape.
  • Resolve merge risk (P1) - Production code grows by 123 lines for the shared attempt/deadline owner; the growth is justified only if this remains the single canonical flow rather than accumulating parallel corpus handling.
  • Complete next step (P2) - This maintainer-owned draft needs its stated exact-base changed-surface evidence and normal readiness review; no mechanical repair finding was identified.
Agent review details

Security

None.

PR surface

Source +123, Tests +207, Other 0. Total +330 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 5 574 451 +123
Tests 4 415 208 +207
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 10 990 660 +330

Review metrics

Metric Value Why it matters
Production versus test delta production +123, tests +209, generated baseline 0 The positive production delta creates a reusable corpus outcome owner while the added matrix covers the previously hidden partial-result states.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/memory-core/src/memory-corpus.ts, unknown-data-model-change: extensions/memory-core/src/memory-get-corpus.test.ts, unknown-data-model-change: extensions/memory-core/src/memory-read-tool.ts, unknown-data-model-change: extensions/memory-core/src/memory-search-tool-query.ts, unknown-data-model-change: extensions/memory-core/src/tools.citations.test.ts, unknown-data-model-change: extensions/memory-core/src/tools.shared.ts, and 10 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #125978
Summary: This PR is a candidate repair for the requested-corpus outcome portion of the canonical memory coverage report.

Members:

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

Merge-risk options

Maintainer options:

  1. Validate the output-contract transition before readiness (recommended)
    Run the planned exact-base changed-surface gate and confirm remaining memory-tool consumers accept explicit corpus metadata and status: "not_found".
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Run the exact-base changed-surface gate and include its result in the PR evidence before marking the draft ready.

Technical review

Best possible solution:

Retain one corpus-attempt coordinator for both search and exact reads, complete the exact-base changed-surface validation, and then review the documented result-shape transition as a deliberate compatibility change.

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

Yes—source inspection of current main shows the sequential exact-read flow can return memory without recording wiki and can hide a failed wiki fallback; the PR also reports an exact-head isolated live exercise of both tools.

Is this the best way to solve the issue?

Yes—the shared coordinator is the narrowest maintainable fix because it makes deadline, partial-result, ordering, and metadata rules common to search and exact reads instead of preserving two divergent fallback paths.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 916eef4e9960.

Labels

Label changes:

  • add P1: Silent partial recall can cause agents to act on incomplete memory coverage without an explicit warning.
  • add merge-risk: 🚨 compatibility: Memory-tool responses now expose new corpus outcome metadata and use status: "not_found" where wiki misses previously surfaced as disabled errors.
  • 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: This maintainer-authored draft is exempt from the external-contributor proof gate; its body additionally records an isolated exact-head live tool exercise.

Label justifications:

  • P1: Silent partial recall can cause agents to act on incomplete memory coverage without an explicit warning.
  • merge-risk: 🚨 compatibility: Memory-tool responses now expose new corpus outcome metadata and use status: "not_found" where wiki misses previously surfaced as disabled errors.
  • 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: This maintainer-authored draft is exempt from the external-contributor proof gate; its body additionally records an isolated exact-head live tool exercise.

Evidence

What I checked:

Likely related people:

  • steipete: Authored this coordinator and the preceding merged missing-read contract repair; available blame also attributes the prior shared tool implementation to the same area owner. (role: recent memory-tool contract owner; confidence: high; commits: b740adf3bcfe, 35e0bc22ead2; files: extensions/memory-core/src/tools.ts, extensions/memory-core/src/tools.shared.ts, extensions/memory-core/src/memory-corpus.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add the promised exact-base changed-surface gate result to the PR evidence before marking the draft ready.

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 marked this pull request as ready for review August 20, 2026 03:44
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for b740adf3bcfe5de1cf7a278d3c6716113db083bd:

  • Focused boundary suites passed (43 tests):
    • pnpm test extensions/memory-core/src/memory-get-corpus.test.ts extensions/memory-core/src/tools.citations.test.ts extensions/memory-wiki/src/agent-vault-isolation.test.ts extensions/memory-wiki/src/corpus-supplement.visibility.test.ts
  • Exact-base clean changed-surface gate passed against 916eef4e996008d387207c53044afd8cf02dcc30:
    • git diff --name-only -z 916eef4e996008d387207c53044afd8cf02dcc30...HEAD | xargs -0 node scripts/check-changed.mjs --
    • Covered format, extension and extension-test typechecks, extension and script lint, plugin boundaries, assertion/max-lines ratchets, dead exports, database-first, runtime-sidecar, and import-cycle guards.
  • git diff --check and the per-commit assertion-safety ratchet passed.
  • Fresh Codex autoreview found no accepted/actionable findings.
  • Authenticated isolated live proof with anthropic/claude-sonnet-4-6 passed for both memory_search(corpus="all") and memory_get(corpus="all"): the indexed memory payload survived, outcomes were memory=ok and wiki=not-registered, warnings were present, and both model turns completed.
  • Exact-head CI is green: https://github.com/openclaw/openclaw/actions/runs/32329332246
  • Native review artifacts validated with READY FOR /prepare-pr and zero findings.
  • Native prepare passed: OPENCLAW_TESTBOX=1 scripts/pr prepare-run 126530; gate mode was hosted_exact_or_recent_parent on the exact head. The wrapper accepted the exact-head hosted CI, so it did not create a separate Testbox lease/run.
  • ClawSweeper found no concrete patch defect. Its only rank-up move was to add the exact-base changed-surface result; that result is now in the PR evidence.

Known proof gap: the authenticated live fixture had no registered wiki supplement. Registered, unavailable, and multi-supplement wiki paths are covered by focused boundary tests. No operator Gateway or normal OpenClaw state was touched.

@steipete
steipete merged commit 3fe833d into main Aug 20, 2026
229 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

extensions: memory-core Extension: memory-core extensions: memory-wiki maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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