[GH-ISSUE #883] [Issue]: LTM import can process duplicate source IDs and reject the response after a write #465

Closed
opened 2026-10-20 17:27:48 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Sep 16, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/883

Originally assigned to: @Promansis on GitHub.

Summary

Long-Term Memory imports can discover multiple source candidates with the same
requested sourceId. The importer then writes one row and reports a second
write failure, producing an unbalanced response that can be rejected after a
durable write.

Affected package

long-term-memory

Expected behavior

Each requested source ID should resolve to one unambiguous candidate before
source-note writes begin. The import response should remain valid and its counts
should match the per-item results. If the host data is ambiguous, the importer
should report a clear pre-write conflict rather than partially importing one
candidate.

Actual behavior

Candidate ordering uses filtered.filter((item) => item.sourceId === id) and
does not deduplicate duplicate host records. A targeted fixture with two enabled
ordinary summaries sharing id: "same-id" produced two candidates for one
requested ID. The first source note write succeeded; the second collided with
the same canonical note ID and became a write failure. The resulting response
contained one imported row plus one write failure for one requested ID and was
invalid under the response row/count contract.

Steps to reproduce

  1. Provide one chat with two enabled ordinary summary entries that share the
    same non-empty metadata ID, for example same-id.
  2. Request an import for the single source ID formed from that entry ID.
  3. Observe the duplicate candidates, one durable source-note write, one write
    failure, and the unbalanced import response.

Environment

  • Marinara Engine version: staging checkout used by the Long-Term Memory package
  • Package version: current long-term-memory package on staging
  • Install type: source
  • OS + version: Linux
  • Browser or app shell: not applicable; server import interop path

Logs, screenshots, or video

Targeted runtime probe result:

requested: 1
imported: 1
sourceNotesWritten: 1
writeFailures: 1
batchStatus: "failed"
sourceId: "duplicate-chat:same-id"

Relevant path: packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/interop.ts:433-540,904-965.

Additional context

Audit finding: SCOPE-001.

The fix belongs at candidate identity/ordering or at an explicit pre-write
deduplication/conflict boundary. Fixing only response counts would leave the
duplicate durable-write path intact. Identical duplicates may be collapsed;
different content sharing one identity should be surfaced as an ambiguity.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Sep 16, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/883 Originally assigned to: @Promansis on GitHub. ## Summary Long-Term Memory imports can discover multiple source candidates with the same requested `sourceId`. The importer then writes one row and reports a second write failure, producing an unbalanced response that can be rejected after a durable write. ## Affected package `long-term-memory` ## Expected behavior Each requested source ID should resolve to one unambiguous candidate before source-note writes begin. The import response should remain valid and its counts should match the per-item results. If the host data is ambiguous, the importer should report a clear pre-write conflict rather than partially importing one candidate. ## Actual behavior Candidate ordering uses `filtered.filter((item) => item.sourceId === id)` and does not deduplicate duplicate host records. A targeted fixture with two enabled ordinary summaries sharing `id: "same-id"` produced two candidates for one requested ID. The first source note write succeeded; the second collided with the same canonical note ID and became a write failure. The resulting response contained one imported row plus one write failure for one requested ID and was invalid under the response row/count contract. ## Steps to reproduce 1. Provide one chat with two enabled ordinary summary entries that share the same non-empty metadata ID, for example `same-id`. 2. Request an import for the single source ID formed from that entry ID. 3. Observe the duplicate candidates, one durable source-note write, one write failure, and the unbalanced import response. ## Environment - Marinara Engine version: staging checkout used by the Long-Term Memory package - Package version: current `long-term-memory` package on `staging` - Install type: source - OS + version: Linux - Browser or app shell: not applicable; server import interop path ## Logs, screenshots, or video Targeted runtime probe result: ```text requested: 1 imported: 1 sourceNotesWritten: 1 writeFailures: 1 batchStatus: "failed" sourceId: "duplicate-chat:same-id" ``` Relevant path: `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/interop.ts:433-540,904-965`. ## Additional context Audit finding: `SCOPE-001`. The fix belongs at candidate identity/ordering or at an explicit pre-write deduplication/conflict boundary. Fixing only response counts would leave the duplicate durable-write path intact. Identical duplicates may be collapsed; different content sharing one identity should be surfaced as an ambiguity. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:27:48 +07:00
  • closed this issue
  • added the
    bug
    label
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Agents#465
No description provided.