Repository navigation
improve(memory): reduce vector replacement overhead - #148201
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 15, 2026, 1:53 AM ET / 05:53 UTC (Revision 6). ClawSweeper reviewWhat this changesMemory Core reuses vector-write statements within each source replacement and strengthens checks for stored bytes, repeated bindings, rollback, and recovery. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful, focused optimization with no actionable correctness finding. The previous migration-proof blocker does not apply: prepared-statement reuse changes neither the persisted data model nor upgrade behavior. Priority: P2 Review scores
Verification
How this fits togetherMemory Core indexes prepared document and session chunks for later search. Its source-index kernel writes chunks, vectors, and search metadata inside a transaction admitted by the existing database owner. flowchart TD
A[Prepared chunks and embeddings] --> B[Database write admission]
B --> C[Source replacement]
C --> D{Eligible vector?}
D -->|Yes| E[Reuse local DELETE and INSERT statements]
E --> F[Commit searchable index]
D -->|No| F
E -->|Write failure| G[Transaction rollback]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -2, Tests +129. Total +127 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep statement reuse scoped to each replacement while preserving the existing SQL, encoding, failure handling, and transaction owner. Do we have a high-confidence way to reproduce the issue? Not applicable as a correctness bug reproduction; repeated statement preparation is directly visible in current main, and the PR reports a bounded native benchmark. Is this the best way to solve the issue? Yes. Replacement-local reuse follows the existing chunk-writer pattern without adding persistent caches, changing SQL strategy, or expanding public APIs. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 45e944b51584. LabelsLabel 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)
|
|
@clawsweeper re-review Please review unchanged head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
* commit '0945dabbe487213e95e84a72ad1aae3659e0e000': (115 commits) fix: omit automation service aliases from squash coauthors (#148883) test: restore services typecheck shard headroom (#148885) perf(trajectory): avoid native probes for truncation records (#148870) improve(gateway): load cron only when reload requests it (#143500) fix: resolve issue #146088 — [Bug]: The most recent Linux AppImage does not ship with the correct versions of libs needed to run (#148174) refactor(theme): share nonvirtual ANSI color lookup (#148717) perf(gateway): scope exact session row topology reads (#148836) improve(memory): reduce vector replacement overhead (#148201) fix(i18n): keep HTTP headers out of native translations (#147119) refactor(plugins): share source-root display formatting (#148646) fix(cron): reject blank script paths before mutations (#148787) refactor(config): share audit positional scanning (#148643) fix(test): restore infrastructure typecheck shard headroom (#148861) fix(release): harden package validation fallbacks (#148729) refactor(config): share leaf and descendant unset pruning (#148216) test: reuse prepared runtime for pristine preflight (#148858) fix(ui): settle global model drafts across agent switches (#148843) fix(queue): avoid repeated scans when cancelling backlogs (#148754) fix(logging): orphaned \\\\?\\ path markers corrupt redacted Windows diagnostics (#147542) refactor(hooks): share optional reply metadata projection (#148641) ...
Related: #134575
What Problem This Solves
Replacing multiple memory vectors repeatedly prepares the same SQL statements, adding avoidable CPU work to indexing.
User Impact
This is an internal indexing optimization. Search results, storage format, transaction boundaries, and failure behavior remain unchanged; no migration or configuration change is required. It does not establish an overall indexing, Gateway responsiveness, allocation, or RSS improvement.
Why This Change Was Made
Reuse independently lazy DELETE and INSERT statements within one replacement, creating the writer only when an eligible vector is encountered. Statements are not retained across replacements. DELETE failures remain caught, INSERT failures still propagate, and vector encoding and operation order stay unchanged.
This does not change source-clearing SQL or take over #140102.
Evidence
Source-bound retained results from the remote Testbox lifecycle run, based on
87891ce2b5c8e7c72f4a8a722d73669f2e221004:24ead1f90a5b0c7e06e9a6110c57906d8e67da21, all four committed files matched the remotely tested formatted bytes.Original validation gap: the original aggregate remains FAILED/UNQUALIFIED. Extension lint reached its fixed command deadline during normal boundary-artifact preparation; no source diagnostic was observed, but lint did not pass. Four following guards were not reached:
check:database-first-legacy-stores,check:media-download-helpers,check:runtime-sidecar-loaders, andcheck:import-cycles. That campaign's owned commands joined, source was restored, and lease cleanup completed. Its linked lifecycle workflow isCANCELLED, not successful required-CI evidence.Fresh scoped P2 autoreview completed with no actionable findings. Exact-head CI and its required gate are SUCCESS for
24ead1f90a5b0c7e06e9a6110c57906d8e67da21, completed September 14, 2026 at 12:28:51 UTC. Its selected successful jobs cover normal extension lint/artifact preparation, architecture including the database-first guard, and import cycles.Residual proof completed for the previous head: On September 15, 2026, both
pnpm check:media-download-helpersandpnpm check:runtime-sidecar-loaderspassed with exit 0 on direct AWS Crabbox after one frozen workspace install at24ead1f90a5b0c7e06e9a6110c57906d8e67da21. Node 24.19.0, pnpm 12.3.4 and the pinned dependency versions were verified, together with the exact committed head/tree and all 43 source pins before and after. Full command captures were retained; all owned processes joined and that lease was confirmed released. This supplements the historical failed aggregate without rewriting it as a pass.Current-head refresh:
189592520aa7b35522c319e9c2b9aa3543ec60e1reconciles the same four-file change with main33aee1b2f7872f2701f283ad26fb854dfb5bdf00. It preserves main's void-returning kernel contract and removal of the kernel-owned tombstone case, while keeping all row, byte, source-metadata, sibling, rollback and retry assertions. The vector writer and its tests are byte-identical to the previously tested versions. Fresh scoped P2 autoreview found no actionable issue.Current CI proof: CI run 34932049788 and its required gate passed for PR head
189592520aa7b35522c319e9c2b9aa3543ec60e1, completing September 15, 2026 at 05:37:25 UTC. This is PR merge-integration proof, not a standalone head checkout: CI checked outc54a52ee1406a55c98f3857eb6bd70807b599f94, merging that PR head intoa62da047dc26b22829a46e1eb443d692eded6ef8. All four changed file blobs exactly match the PR head. On Node 24.19.0, job 104262311640 passed the two current kernel tests and four vector-writer tests, including stored-byte, repeated-binding, sibling-retention and rollback/retry coverage.Formatting job 104262312184 also passed: its log records
FORMAT_CHECK: trueand the actualoxfmt --checkinvocation at 05:19:15 UTC, not merely a successful lint label.Proportional follow-up: The prepared supplemental standalone AWS campaign remains UNRUN and is retired, not counted as a pass. The two additional residual guards are not materially affected by this refresh: the changed production files contain no media remote-read/save roundtrips; runtime-sidecar loaders and tsdown entries are untouched. Their broad extension-path selection does not establish new affected behavior. The previous-head residual passes remain historical, while the qualified current CI integration and six focused tests cover the reconciled change. No benchmark replay or new performance claim is implied. Native preparation and merge still own final admission.
Operational follow-up: Two earlier Testbox dispatch failures returned no unambiguous lease/run identity; their resource disposition and cleanup remain unknown. Four preceding AWS setup attempts also remain recorded failures, with no guard passes claimed from them; their identified leases were released. The successful residual proof does not resolve the two unknown Testbox allocations.
Stored-data compatibility: This changes prepared-statement lifetime only, not a persisted data model. The schema, table and columns, DELETE/INSERT SQL, vector codec, operation order, and transaction boundary are unchanged. The retained real SQLite/vec0 tests and the six passing current CI tests cover independent stored-byte checks, repeated bindings, and rollback/retry; no migration or upgrade behavior is introduced. The generic data-model classification is not applicable to this source change. This addresses the review's compatibility request without claiming an unrun upgrade test or removing any historical validation gap above.