Repository navigation
improve(memory): reduce text loaded during vector recall - #146380
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: needs maintainer review before merge. Reviewed September 12, 2026, 3:58 PM ET / 19:58 UTC. ClawSweeper reviewWhat this changesMemory Core limits text fetched during vector search while preserving existing snippets, with regression coverage for Unicode and embedded NUL characters. Merge readiness✅ Ready for maintainer review This remains a useful, focused optimization absent from current main and the latest release. No actionable correctness or security defect was found; the maintainer-protected PR should remain open for landing. Priority: P2 Review scores
Verification
How this fits togetherMemory Core searches indexed notes and session content using query embeddings. Its SQLite worker returns ranked matches and short snippets to the memory search manager. flowchart LR
A[Query embedding] --> B[Memory search manager]
B --> C[SQLite vector worker]
D[Indexed note chunks] --> C
C --> E[Bounded text projection]
E --> F[Unicode-safe truncation]
F --> G[Ranked search snippets]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +10, Tests +80. Total +90 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep bounded snippet projection inside the existing SQLite query owner, preserving stored text and the established ranking and truncation contracts. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug: current source establishes excess full-text fetching, and the supplied paired benchmark measures its cost. Is this the best way to solve the issue? Yes. Narrowing the existing query projection avoids a second hydration pass and preserves snapshot consistency; the byte-prefix branch handles the NUL behavior that plain TEXT substring would lose. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 63bafe6492ec. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…#146380) Co-authored-by: Peter Steinberger <[email protected]>
Related: #146197
What Problem This Solves
Vector memory recall loads complete note chunks from SQLite even when it only displays a short snippet.
User Impact
Memory search returns the same snippets and rankings while transferring less temporary text from SQLite. Typical 1,600-byte chunks need 56% fewer fetched body bytes; very large stored chunks benefit more. Small chunks can incur a small query overhead. No migration or user action is required.
Why This Change Was Made
Limit the text projection in the existing KNN query. A bounded byte check preserves embedded NUL characters, and the existing Unicode-safe truncation remains authoritative. Query count, filtering, widening, and read consistency stay unchanged.
Evidence
These are native query measurements, not end-to-end search latency or disk-I/O savings. Current fresh indexing bounds ordinary chunks near 1,600 characters; the larger rows exercise existing oversized stored data.
Validation also passed extension production/test typechecks, targeted lint, six plugin contract guard tests, formatting, and the remaining changed-file guards. Fresh independent review found no actionable P0–P2 issues.
The broad unused-export scan still reports two unchanged tooling exports (
canonicalProviderNameandlistPackagedStaticExtensionAssetOutputs), matching the baseline. The Windows lint launcher required direct invocation of its canonical declaration preparer, followed by lint with the supported skip-already-prepared flag; both completed successfully.