Skip to content

fix(memory): report closed storage scopes accurately - #178187

Merged
steipete merged 2 commits into
mainfrom
fix/memory-search-scope-closed-diagnostic
Oct 20, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/memory-search-scope-closed-diagnostic

Conversation

@steipete

@steipete steipete commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Related: #177882

What Problem This Solves

Fixes the misleading embedding/provider diagnosis when memory_search fails because its SQLite read-only storage scope has closed.

User Impact

The unavailable result now identifies the closed storage scope and advises openclaw plugins reload memory-core or a Gateway restart before retrying. Provider failures keep their existing diagnostic, including when their message happens to mention a closed scope. Scope retirement, cancellation, and search recovery behavior are unchanged; this does not fix or automatically reopen the persistent closed-scope condition reported in #177882.

Why This Change Was Made

The SQLite owner emitted a plain error, and manager initialization discarded error codes when turning failures into text. The owner now emits a typed SQLITE_READONLY_WORKER_SCOPE_CLOSED error, and Memory Core preserves that code through initialization and search classification. Classification uses the code, never the message. The parameter-forwarding cleanup removes a duplicate input shape and field projection from the same diagnostic path.

The lifecycle investigation remains unresolved: Gateway startup owns a reader scope that closes on shutdown or failed startup. Deferred agent admission uses temporary scopes after plugins attach, and prepared workspace registries adopt matching Gateway-owned tool registrations. We have not identified which temporary binding survives into the reported failing memory_search, or why that tool would not use the Gateway-owned registration. Deliberate retirement still rejects work; automatically reviving it would violate that contract.

To investigate that remaining issue, collect the exact OpenClaw version/commit, the failing tool's error/warning/action and any recorded error code, and timestamped startup-admission and plugin load/reload events. Targeted tracing should correlate scope creation and closure with the Memory Core instance/registry generation and the selected tool registration, including whether source/config matching caused Gateway tool adoption to be skipped. Exclude credentials, message content, and unrelated private data from shared evidence.

Evidence

  • Exact-head CI run passed for d0f33d7f36932dcd8f4e9da5a675c92bc32f407e: 60 successful jobs, 25 skipped, no failures or reruns.
  • Changed-file oxlint with config/tsconfig/oxlint.core.json: passed. Oxfmt on all 11 changed files and git diff --check: passed.
  • Regression coverage for CI: classifies a closed storage scope by code during initialization/search; does not classify a provider error by storage-scope wording; preserves the builtin initialization error code. Existing captured-scope and descendant-inspection tests now also require the typed code while preserving rejection and no-launch assertions.
  • PR CI is the test/typecheck gate. Tests and local typechecks were intentionally not run, and live Gateway/Crabbox/Testbox proof was intentionally skipped per maintainer policy. No reopening behavior is claimed.
  • P2 Codex autoreview: scoped-clean; no actionable P0–P2 findings. GitHub Codex review also completed with no findings. ClawSweeper review found no code findings or before-merge blockers. Its optional live-proof suggestion is intentionally deferred: PR CI is the proof gate per maintainer policy; the CI run above has now completed successfully.
  • Simplification: production +42/-42 (net 0), tests (including the test-only mock helper) +58/-5, docs +5/-0 against the task base.

Preserve the SQLite scope error code through manager initialization and report storage recovery advice without changing scope retirement or provider diagnostics. Related: #177882.
@clawsweeper

clawsweeper Bot commented Oct 20, 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.

@steipete
steipete marked this pull request as ready for review October 20, 2026 06:58
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T07:06:24.524354Z d0f33d7 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-core Extension: memory-core size: S labels Oct 20, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves closed SQLite scope error codes and returns storage-specific recovery advice from memory_search.

Example: memory_search encounters SQLITE_READONLY_WORKER_SCOPE_CLOSED.

  • Before: The result blames the embedding provider and recommends checking provider configuration.
  • After: The result identifies the closed storage scope and recommends reloading memory-core or restarting the Gateway.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-consistent diagnostic repair with useful regression coverage; runtime confidence is limited and the linked issue is only partially addressed.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied validation covers mocked initialization/search failures and exact-head CI, with live Gateway proof explicitly skipped.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: A storage lifecycle failure tells operators to repair a healthy embedding provider.
Reason: The maintainer-authored direction improves a demonstrated misleading diagnosis and correctly uses Related rather than claiming to resolve the lifecycle report.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR provides a useful, narrowly scoped diagnostic correction; no introduced correctness or security defect was found.

Priority: P2
Reviewed head: d0f33d7f36932dcd8f4e9da5a675c92bc32f407e

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped memory_search execution with an actual retired reader scope or demonstrated red-base/green-head regression run was supplied.
Agent review details

How this fits together

Memory Core acquires an index manager and runs searches through lifecycle-owned SQLite readers, then translates failures into model-visible tool results.

flowchart LR
  A[Agent memory_search] --> B[Memory Core tool]
  B --> C[Index manager]
  C --> D[SQLite reader scope]
  D --> E[Typed closed scope error]
  E --> F[Storage diagnostic]
  F --> A
Loading

Technical review

Best possible solution:

Preserve this diagnostic correction while tracking the unresolved reader-binding failure in #177882.

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

Source confirms that closed reader scopes throw while current main drops initialization codes and defaults to provider advice; no current-main runtime reproduction was executed.

Is this the best way to solve the issue?

The patch uses the existing reader and diagnostic owners, preserves retirement, and makes the smallest complete correction to the stated diagnostic bug.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 23af78ff67ae.

Provenance checked

  • Captured reader retirement keeps the original intent (43d85e5: Detached callbacks retain their owning reader scope and must reject after its shutdown.)
  • Initialization error formatting keeps the original intent (3417dba: The refactor standardized Memory Core error formatting; this patch retains that formatting while carrying structured codes alongside it.)
  • Failure classification keeps the original intent (6e296ea: Deadline failures must retain owner-provided provenance because provider messages can contain identical wording.)
  • Memory manager forwarding keeps the original intent (bb70261: Consolidate repeated runtime preparation and lifecycle bookkeeping without changing behavior; direct parameter forwarding continues that ownership.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 43d85e5 adds src/infra/sqlite-readonly-worker-context.ts:37 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 43d85e5f9ac3; files: src/infra/sqlite-readonly-worker-context.ts)
  • Ilya Kuprov: Raw commit 6e296ea adds extensions/memory-core/src/tools.shared.ts:106 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 6e296ea32495; files: extensions/memory-core/src/tools.shared.ts)

PR surface

Source +1, Tests +52, Docs +5. Total +58 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 43 42 +1
Tests 4 57 5 +52
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 105 47 +58

Labels

Label changes:

  • add P2: This PR corrects misleading recovery advice without repairing the underlying loss of recall.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: This PR corrects misleading recovery advice without repairing the underlying loss of recall.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • For stronger confidence, capture memory_search returning the storage diagnosis after an actual reader scope closes.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 20, 2026, 3:15 AM ET / 07:15 UTC.

@steipete
steipete merged commit ce3f47b into main Oct 20, 2026
237 of 240 checks passed
@steipete
steipete deleted the fix/memory-search-scope-closed-diagnostic branch October 20, 2026 07:37
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…enclaw#178187)

Preserve the SQLite scope error code through manager initialization and report storage recovery advice without changing scope retirement or provider diagnostics. Related: openclaw#177882.
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 P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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