Repository navigation
refactor(memory): own source indexing on its database - #145207
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 11, 2026, 5:50 PM ET / 21:50 UTC (Revision 4). ClawSweeper reviewWhat this changesMemory Core moves source replacement and deletion into its database owner, reuses full-text insertion statements per file, and adds rollback, contention, and isolation coverage. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness⛔ Blocked before merge - 1 item remains No blocking findings. The updated compatibility evidence resolves the previous review’s blocker, and current main still lacks this distinct refactor. This maintainer-owned PR remains a valid landing candidate. Priority: P3 Review scores
Verification
How this fits togetherMemory Core turns workspace files and session transcripts into searchable SQLite indexes. Its database owner coordinates source records, text chunks, metadata, full-text search, and vectors while keeping rebuilt indexes separate until publication. flowchart TD
A[Memory files and session transcripts] --> B[Prepare chunks and embeddings]
B --> C[Validate source and admit transaction]
D[Canonical session tombstones] --> E[Database-owned source operation]
C --> E
E --> F[Source records and search indexes]
F --> G[Memory search]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +114, Tests +235. Total +349 across 12 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep source mutations on the existing database owner with the current storage format, admission loop, and publication safeguards intact. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR reorganizes existing indexing behavior rather than reporting a new defect; its preservation scenarios are concrete, but were not executed during this read-only review. Is this the best way to solve the issue? Yes: the extraction reuses existing writers and database state without adding a parallel implementation, public API, schema, or transaction boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 95a7ec0ac2ed. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
56620af to
39fcb38
Compare
|
Compatibility disposition for the remaining generic stored-data-model checklist: this refactor moves the existing tombstone helper and its byte-identical CREATE TABLE definition; it adds no schema, migration, row encoding, or retention change. Existing transaction admission, canonical tombstone checks, conditional deletion, and rollback remain with their current owners. The PR Evidence section records reopening a database created from the prior DDL, preserving its row/schema and agent isolation, with SQLite integrity intact. The current review also confirms that this evidence resolves the previous compatibility blocker and reports no actionable findings. The stored-data compatibility requirement is satisfied for head 39fcb38. |
|
Merged via squash.
|
* refactor(memory): own source indexing on its database * test(memory): compare revoked owners without native traversal
What Problem This Solves
One memory source update currently spreads its SQL across embedding and synchronization code. That makes it difficult to move database execution while preserving the complete chunk, source, recall, provenance, FTS, and vector mutation.
Why This Change Was Made
Give the existing memory database owner a connection-bound source-index kernel for complete replacement and conditional deletion. Ordinary source writes use Kysely, existing prepared chunk writers remain shared, and FTS insertion is prepared once per nonempty file. The native tombstone reader and its unchanged schema guard now live apart from database-opening code.
The existing admission loop still validates filesystem content after every failed BEGIN attempt. Session writes consult the explicit canonical authority connection while updating a shadow. Native transaction callbacks, retry marking, vector rebuild markers, and cleanup behavior remain intact.
User Impact
Memory indexing keeps its current SQLite data and publication behavior, with fewer FTS statement preparations for multi-chunk files. This prepares a complete native operation for the future shared database worker owner; physical execution remains on the current owner.
Evidence
node scripts/check-changed.mjs,git diff --check, and fresh isolated Codex review through P2 passed.Measured on the loaded local host: 20 synthetic ten-chunk replacements had a 7.01 ms median and 13.48 ms p95. These describe the candidate workload; they are not a before/after speedup claim.
CI on the original feature head exposed Vitest 5's eager deep-equality diagnostics in
expect(replacement).not.toBe(first): the diagnostic traversal inspected the revoked native handle. The assertion now uses the adjacent strict boolean-identity pattern. Its original shared-handle, old-release, replacement sync, and search assertions remain intact. The complete borrowed-connection file and native/publication/reindex/search owners passed all 60 tests; the full repaired candidate gate and fresh P2 review passed.Both commits were rebased onto
21b105c0f33f567e433ab700c8e3e00404d5db32, which includes the upstream CI fixture repair and awaited memory lease cleanup. The authored patch and all 12 file hashes are unchanged by that rebase.On the rebased candidate, all 43 coupling tests passed across borrowed connections, native source mutations, generation admission/release, cancellation, and manager teardown.
Storage compatibility: the
memory_session_tombstonesDDL literal is byte-identical between pre-change3ac42154d14a98ab2393e68bb3285df77c512b14and this candidate. A synthetic database created from that prior definition, closed, and reopened with the candidate helper preserved its existing row and schema, retained agent-scoped tombstone lookup, and passed SQLite integrity checking. This verifies the relocated table contract; the refactor introduces no migration.