Skip to content

fix(memory): stop cancelled searches before returning results - #124118

Merged
steipete merged 2 commits into
mainfrom
fix/autoqa-refill-memory-vector-cancel-v2
Aug 15, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/autoqa-refill-memory-vector-cancel-v2

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #124050

What Problem This Solves

Fixes an issue where cancelling built-in memory search after query embedding could leave an in-process vector fallback scan running and allow hybrid search to return ordinary keyword matches as if the cancelled request had succeeded.

Why This Change Was Made

Carry the caller cancellation signal through vector readiness and fallback SQLite scanning, check it at the existing 256-row cooperative yield boundary, and let cancellation win in hybrid orchestration before the existing vector-error degradation path. Genuine un-aborted vector failures still degrade to keyword results.

The change stays inside Memory Core search ownership. It does not change provider health policy, auth/routing, configuration/defaults, SQLite schema or data, SDK/protocol contracts, retention, or migrations.

User Impact

Cancelled memory searches now reject with the exact caller reason, stop within one bounded scan batch, perform no later SQLite scan work, and never surface keyword results as successful output. Later healthy searches continue to work on the same provider and index. Large indexes avoid CPU work after the caller has already abandoned the search.

Evidence

  • Rebased pre-fix manager reproduction: hybrid search resolved a keyword result from memory/2026-01-12.md after caller abort instead of rejecting.
  • Real 4,096-row manager and direct SQLite regressions: exact abort reason, one 256-row batch, no work in later event-loop turns, and a successful subsequent search.
  • Genuine un-aborted vector-store failure still returns the keyword result.
  • Focused tests: 36 direct vector/SQLite, 2 manager cancellation, 4 deadline, 2 Gateway memory_search, and 2 CLI search/output tests passed.
  • Exact-head changed gate passed: unskipped deadcode, production/test types, changed-file lint, format, plugin/dependency/database-first/sidecar guards, and zero runtime import cycles.
  • Full production build passed, including compiler shards, Plugin SDK declaration verification, postbuild checks, and Control UI production build.
  • Madge import cycles: 0. git diff --check: clean.
  • Fresh branch autoreview: clean; no accepted/actionable findings.
  • Production LOC: +12/-1 (net +11). Tests: +128/-0. The production growth carries one existing caller signal through the vector owner and enforces it at readiness, scan, and hybrid-result boundaries.
  • No changelog entry: normal PR changelogs are release-owned; this body records the release-note context.

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: S maintainer Maintainer-authored PR labels Aug 15, 2026
@steipete
steipete marked this pull request as ready for review August 15, 2026 08:48
@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 Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 4:54 AM ET / 08:54 UTC.

ClawSweeper review

What this changes

The PR passes a caller cancellation signal through Memory Core’s vector search so aborted hybrid searches stop fallback scanning and reject instead of returning keyword results.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No blocking correctness or security finding: the PR repairs the missing cancellation propagation at the vector-search owner. Likely related people: steipete (high) and nitinjwadhawan (medium).

Priority: P2
Reviewed head: aef52d81302c2c34ee60581295e2289572fd9d71

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with useful direct and orchestration regressions, pending normal exact-head refresh after rebase.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless records after-fix 4,096-row manager and SQLite runs.
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 PR is exempt from the external-contributor proof gate; its body nevertheless records after-fix 4,096-row manager and SQLite runs.
Evidence reviewed 5 items Production caller carries cancellation: The memory_search tool creates a deadline signal and passes it into the active manager search, so the changed vector path is on the real tool request boundary.
Current-main gap: Current main calls the vector search without the caller signal and converts every vector rejection into an empty vector result, allowing hybrid keyword results to continue.
Owner-boundary repair: The branch passes the signal through the private wrapper, checks it before and after vector readiness, and checks it after each cooperative fallback-scan yield.
Findings None None.
Security None None.

How this fits together

Memory Core turns an embedding query into vector and keyword retrieval results for the memory_search tool. This path decides whether vector retrieval continues, falls back to keyword results, or ends because the caller cancelled.

flowchart LR
A[Memory search request] --> B[Deadline and caller signal]
B --> C[Hybrid memory search]
C --> D[Vector readiness]
D --> E[Vector or fallback scan]
E --> F{Caller cancelled?}
F -->|Yes| G[Reject with abort reason]
F -->|No| H[Merge and return results]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main, so its exact merged result and exact-head checks need refresh before landing.
  • Resolve merge risk (P1) - Production code is net +11 lines; the signal parameter and three distinct cancellation checkpoints appear necessary, but the rebase should not add further cancellation plumbing.
  • Complete next step (P2) - This active maintainer-owned fix should receive normal rebase and exact-head validation rather than a parallel repair job.
Agent review details

Security

None.

PR surface

Source +11, Tests +128. Total +139 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 12 1 +11
Tests 2 128 0 +128
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 140 1 +139

Review metrics

Metric Value Why it matters
Production versus regression coverage production +11/-1; tests +128/-0 The production growth carries one existing cancellation signal through the private vector owner and tests both its direct scan and hybrid orchestration boundaries.

Stored data model

Persistent data-model change detected: serialized state: extensions/memory-core/src/memory/manager-search-orchestration.test.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-search-orchestration.test.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-search.test.ts, vector/embedding metadata: extensions/memory-core/src/memory/manager-search-orchestration.test.ts, vector/embedding metadata: extensions/memory-core/src/memory/manager-search-orchestration.ts, vector/embedding metadata: extensions/memory-core/src/memory/manager-search.test.ts, and 1 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep cancellation owned by the vector-search boundary, with checks at entry, readiness, and the existing cooperative scan yield; rebase and validate that exact head before merge.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep cancellation owned by the vector-search boundary, with checks at entry, readiness, and the existing cooperative scan yield; rebase and validate that exact head before merge.

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

Yes—current main drops the caller signal before vector retrieval and treats its rejection as an ordinary vector error; the added 4,096-row tests provide a focused current-main regression path, though no local test was run in this read-only review.

Is this the best way to solve the issue?

Yes—the repair places cancellation at the vector owner rather than adding a downstream result guard, while retaining existing keyword degradation for genuine un-aborted vector failures.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: A cancelled memory search can return misleading keyword results and continue bounded but unnecessary local scanning, without evidence of a wider outage or data loss.
  • 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 PR is exempt from the external-contributor proof gate; its body nevertheless records after-fix 4,096-row manager and SQLite runs.

Label justifications:

  • P2: A cancelled memory search can return misleading keyword results and continue bounded but unnecessary local scanning, without evidence of a wider outage or data loss.
  • 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 PR is exempt from the external-contributor proof gate; its body nevertheless records after-fix 4,096-row manager and SQLite runs.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the prior merged cancelled-search lifecycle repair and is the dominant recent contributor in both current search-owner files. (role: recent area contributor; confidence: high; commits: 3f6bf166b676, 49e783da74f9; files: extensions/memory-core/src/memory/manager-search-orchestration.ts, extensions/memory-core/src/memory/manager-search.ts)
  • nitinjwadhawan: Introduced the bounded fallback-vector scan yielding that this PR uses as its cancellation checkpoint. (role: adjacent owner; confidence: medium; commits: d761b98adc6f; files: extensions/memory-core/src/memory/manager-search.ts)

Rank-up moves

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

  • Rebase onto current main and let the required checks complete for the rebased head.

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

Copy link
Copy Markdown
Contributor Author

Land-ready proof for aef52d81302c2c34ee60581295e2289572fd9d71:

  • Exact-head CI is green: https://github.com/openclaw/openclaw/actions/runs/31875397708
  • Focused proof passed: 36 direct vector/SQLite tests, 2 manager cancellation tests, 4 deadline tests, 2 Gateway memory_search tests, and 2 CLI tests.
  • Exact-head changed gate, unskipped deadcode, production/test types, changed-file lint, storage/sidecar guards, runtime and Madge cycles, full production build, and fresh autoreview are green.
  • ClawSweeper's production-growth concern is addressed without more plumbing: net +11 is the existing signal handoff plus checks at vector entry/readiness, the pre-existing 256-row scan yield, and hybrid error classification. Tests add +128.
  • ClawSweeper's optional rebase move is intentionally skipped after the green exact-head run because current-main drift is non-conflicting and repository policy avoids chasing moving main; native OPENCLAW_TESTBOX=1 scripts/pr prepare-run will prove the strict current-main merge result.
  • Native review artifacts validate as READY FOR /prepare-pr with zero findings.

No schema/data, provider health/auth/routing, config/default, SDK/protocol, retention, migration, changelog, or release change.

@steipete
steipete merged commit 11bcc0e into main Aug 15, 2026
170 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the fix/autoqa-refill-memory-vector-cancel-v2 branch August 15, 2026 09:00
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 16, 2026
…aw#124118)

* fix(memory): stop vector scan after search cancellation

* fix(memory): preserve cancellation through hybrid search
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 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: 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