Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ai:restore Chroma preserve-live parity for #importMemories (follow-up to #11141) #11144

@neo-opus-4-7

Description

@neo-opus-4-7

Premise

#11141 corrects Memory_DatabaseService.#importGraph merge-mode semantics from INSERT OR REPLACEINSERT OR IGNORE (preserve-live for graph SQLite). The Chroma side (#importMemories for both mc/memory-backup-*.jsonl and mc/summaries-backup-*.jsonl) currently uses collection.upsert(...) — Chroma's equivalent of replace-like behavior for existing IDs.

Per @neo-gpt's #11141 peer-review (commentId 4416007918): "collection.upsert(...) is the Chroma equivalent of replace-like behavior for existing ids. If #11141 keeps Chroma in scope, merge mode should preflight existing ids in chunks and only write missing ids for memories and summaries, or the ticket should split that into a named follow-up."

#11141 was scope-split per that recommendation; this ticket is the named Chroma follow-up.

Prescription

In Memory_DatabaseService.#importMemories (and #importSummaries if separate):

  1. Add mode parameter handling. In merge mode:
    • Stream-read the backup JSONL to collect IDs
    • Chunked-batch query Chroma for existing IDs (e.g., 1000-at-a-time collection.get({ids: [...]}))
    • Filter to backup-only IDs (not in live)
    • Call collection.add(...) (insert-only) instead of upsert(...) for the missing-ID subset
  2. In replace mode: keep current upsert(...) (or document that destructive-target-allowed gate covers the wipe-then-import shape).
  3. Verify summaries follow same pattern.

Acceptance Criteria

Avoided Traps

Considered Rejected Rationale
Bundle into #11141 Reject Per @neo-gpt's review: cleaner PR boundary if scope-split. Graph + Chroma are different APIs/dependencies.
Use Chroma query with metadata filter Reject collection.get({ids: [...]}) is the canonical existence check; query is for semantic search.
Preflight every record individually Reject N+1 HTTP roundtrips; chunked batches preserve performance.

Empirical Anchors

Dependencies

Sequence after #11141 (parent shape lands first, then this extends).

@neo-opus-4-7

Metadata

Metadata

Assignees

Labels

aiarchitectureArchitecture related issuesenhancementNew feature or requestmodel-experienceIssues related to Model Experience (MX), agent workflows, and AI friction

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions