Repository navigation
refactor(memory): own temporary connections in the reindex context - #138145
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 5:52 AM ET / 09:52 UTC. ClawSweeper reviewWhat this changesThe PR moves temporary Memory Core reindex SQLite connection cleanup into the reindex context and removes duplicate close-state tracking from synchronization. Merge readiness⛔ Blocked before merge - 1 item remains Keep open for normal maintainer handling. The refactor preserves the required close-before-publish ordering and failure cleanup while removing duplicated temporary-handle bookkeeping; current main still uses the older orchestration-owned lifetime. Priority: P3 Review scores
Verification
How this fits togetherMemory Core builds a temporary SQLite index during a forced rebuild while the published index continues serving searches. The temporary writer must close before its database file is attached and copied into the published agent database. flowchart LR
A[Forced memory rebuild] --> B[Temporary SQLite index]
B --> C[Reindex context]
C --> D[Close temporary writer]
D --> E[Publish index tables]
E --> F[Published memory search]
C --> G[Failure cleanup]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -3. Total -3 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep the temporary connection lifecycle inside the reindex context, with close completion before publication and a single failure cleanup owner. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR is a behavior-preserving ownership refactor, and existing integration coverage exercises the relevant rebuild/search ordering. Is this the best way to solve the issue? Yes. Moving close responsibility to the reindex context gives the temporary writer one lifetime owner while preserving the caller's publication and file-cleanup responsibilities. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6d228342bdf5. 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.
|
Additional instructions
Keep Allow edits from maintainers enabled for this PR.
What Problem This Solves
Forced memory rebuilds create a temporary SQLite index before publishing it into the agent database. Managing that connection across separate success, error, and cleanup branches makes the rebuild lifecycle harder to maintain.
Why This Change Was Made
The existing reindex database context now closes its temporary connection before returning to the publisher. This removes the orchestration's separate temporary-handle and closed-state bookkeeping while retaining the callback's original escaped-continuation fence, publication revision checks, workspace and generation leases, and final temporary-file cleanup.
User Impact
There is no intended user-visible change. Memory search keeps using the published index during a rebuild; failed rebuilds leave that index intact. This is a bounded preparation refactor with no database schema, configuration, or public API changes.
Evidence
memory-coreruntime build passed in 45.3 seconds, including CLI bootstrap validation and native loading of the built plugin control-plane module. No ineffective dynamic import warning was reported.Focused command:
Changed gate:
Live native validation passed on commit
5dc28ac064c142da809cb105272815d3a29c268d: two realmemory index --forcerebuilds, search before/after corpus replacement, two isolated Gateway starts/stops, preserved unrelated transcript, zero leftover shadow files, and SQLite integrity/foreign-key checks. The materialized source tree36264b0d2812dd0845f81dfe6e7fe12116145cc1matched before and after building and running. Failed publication and stale-generation behavior are covered by the focused SQLite suites above.ClawSweeper's data-model compatibility request is addressed by source comparison: no schema, migration, table definition, row codec, vector/embedding metadata representation, or publication SQL changed. The existing schema and publisher are byte-identical to the base; the live flow opened and reused the same agent database (schema 19) and preserved unrelated canonical state. A migration or new data-model approval is therefore not applicable to this lifetime-only change.
Validation environment: a queued Testbox was stopped without running code; the same actual native flow ran locally in isolated synthetic state. macOS system Bash was used after the installed Homebrew Bash stalled in here-document setup. Follow-up: investigate that local Bash tooling issue separately.