Repository navigation
improve(memory): keep large-note searches responsive - #146168
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 12, 2026, 2:49 PM ET / 18:49 UTC (Revision 6). ClawSweeper reviewWhat this changesMoves Memory Core’s lexical searches, vector fallback scans, and Markdown preparation into bounded workers while preserving existing indexing and database ownership. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness⛔ Blocked before merge - 1 item remains This remains useful work: current main still performs the affected memory work inline. The previous overload blocker is resolved, the supplied runtime evidence supports the responsiveness improvement, and no blocking introduced defect remains. Priority: P2 Review scores
Verification
How this fits togetherMemory Core turns workspace notes and session content into searchable chunks. Its search manager combines lexical and vector matches for agent recall, while database owners control publication and deletion. flowchart TD
A[Notes and session content] --> B[Shared compute admission]
C[Memory search request] --> B
B --> D[Chunk preparation worker]
B --> E[Retrieval worker]
D --> F[Existing publication owner]
F --> G[Agent memory database]
G --> E
E --> H[Current chunk checks and ranked results]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +337, Tests +205, Docs +15, Config +13, Other +8. Total +578 across 48 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep CPU admission centralized while preserving existing generation leases, provider health, publication checks, and explicit overload failures. Do we have a high-confidence way to reproduce the issue? Yes: current main’s inline retrieval and chunk preparation match the supplied large-note benchmark showing substantial event-loop delays. This review inspected source and recorded evidence without executing the workload. Is this the best way to solve the issue? Yes: reusing shared worker admission and existing algorithms avoids a competing scheduler or storage owner, and the final repair preserves overload failures through mandatory indexing. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7d6eeb9cdae7. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
The remaining data-model checkbox is a path-based false positive on The existing version/owner assertions move unchanged from Compatibility proof includes the 154 passing database cases (six existing platform skips), real worker reads preserving parent SQLite writer locks, and 51 final integration cases covering source/compiled worker registration, read-only admission, ownership/header lifecycle and KNN WAL visibility/dependency isolation. The final 58-case memory suite and both extension type lanes pass; lint passes on the exact published tree. No new schema or migration is being accepted through this PR. The fresh review's actual overload finding is fixed and reproduced: first-search bootstrap and required identity repair now reject saturation instead of reporting no matches, and recover after capacity drains. Its latest exact-head review reports no actionable code or security findings. Required hosted CI remains the landing gate. |
|
Merged via squash.
|
* fix: bound concurrent compute work and pending worker inputs * fix: supply the host response budget in worker checkpoint tests * fix: preserve prepared catalog ownership under admission pressure * improve(memory): keep large-note searches responsive * fix(memory): preserve worker errors and package boundaries * docs: separate worker entrypoint guidance * chore: align metadata extraction with main * chore: align worker registration for main refresh * fix(memory): unify metadata reads and worker registration * fix(memory): preserve overload during index bootstrap and repair
Uses the merged admission owner from #146067. Related: #146166, #127866.
What Problem This Solves
Resolves a problem where searching or indexing large memory collections can stall the Gateway event loop. Lexical fallback scans, cosine fallback, and preparation of large Markdown notes currently compete with request handling on the same thread.
Why This Change Was Made
Memory Core submits retrieval and immutable chunk preparation to separate bounded workers using the shared compute admission contract. The current database owners retain publication, generation leases, source-hash checks, and tombstones. Search results are checked against existing chunks after worker completion so a concurrent forget cannot return a deleted hit.
The worker SDK facades load the existing pure chunking and read-only database primitives directly. This removes unrelated provider/configuration initialization from their import graphs without duplicating algorithms or changing schema, configuration, or dependencies.
User Impact
Large memory searches leave the main event loop available to other work. Background chunk preparation has a separate worker from foreground retrieval. Index publication still uses the existing synchronous database writer, so this does not remove every indexing pause.
Evidence
pnpm build qaRuntimepasses with physical Linux dependencies, including all 92 plugin builds, bootstrap checks and 52 native control-plane load checks. Final exact-head CI 34711809099 and the required openclaw/ci-gate passed before native landing.The shipped-build comparison uses Node 26.8.2, four-CPU affinity, the built public
memory-host-searchfacade, two prewritten 40,000-line workspaces, and 12,000 additional synthetic chunks (15,073 total). One paired baseline/candidate process run measured cold operations and six warmed searches; no source loader or worker substitution was used. Empty-query and positive-hit assertions passed in both processes.The cold search pays about 224 ms of worker startup, and final process RSS increases from 464 to 566 MiB. Indexing retains a synchronous writer pause. These are measured tradeoffs, not a guarantee for every workload or host. Manager-open timing varied with host/cache state and is not claimed as an algorithmic improvement.
A later final-build confirmation uses the same public entrypoint, fixtures and four-CPU affinity while other host validation runs. All positive-hit and chunk assertions pass. Warm searches take 108–164 ms with maximum event-loop delays of 3.4–7.4 ms; cold search takes 570 ms with a 12.2 ms maximum delay, and final RSS is 565 MiB. Cold/warm indexing pauses are 781/738 ms. This additional run confirms responsiveness while showing host variability; it is not a second paired throughput comparison.
Final integration with current main preserves its canonical metadata reader and keeps that schema-admission read free of the query-builder runtime. The newer ownership-header snapshot behavior is retained. Combined KNN, PDF, memory search and memory indexing registrations pass 51 targeted tests: source/compiled worker generation, build configuration, database ownership and read-only admission, full preflight artifacts, native header lifecycle, and real KNN WAL visibility/dependency isolation. Another 202 cases were deliberately outside these focused filters. Independent review of the final six-file integration found no actionable P0-P2 issues. No schema, version, transaction or persistence-policy change is introduced.
Final overload repair preserves typed capacity errors in all three mandatory synchronization catches: first-search bootstrap, its embedding fallback, and required index-identity repair. The background refresh retains its existing behavior of serving published results. The unsupported test-only hybrid configuration is removed rather than restoring retired product configuration. Fresh independent P2 review of the two-file repair has no findings. Production extension types, extension-test types, formatting and diff checks pass. Final targeted lint passes with zero warnings/errors in a separate physical checkout after normal SDK declaration preparation emitted 9,269 files. The original nested checkout preparation refused an ancestor dependency path; its failure is retained and no guard was bypassed. The previous hosted test-type failure was caused by that retired test configuration; final exact-head hosted CI 34711809099 and its required gate passed.