[GH-ISSUE #885] [Issue]: LTM import passes extraction scope to a batch API that ignores it #466

Closed
opened 2026-10-20 17:27:49 +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/885

Originally assigned to: @Promansis on GitHub.

Summary

The Long-Term Memory import interop caller passes an extraction scope to the
source batch processor, but the batch options type does not declare it and the
worker does not forward it to source preparation.

Affected package

long-term-memory

Expected behavior

The batch API should have one explicit, type-correct scope contract. If the
caller-provided scope is intentionally authoritative, it must be declared and
forwarded for every item. If persisted source-note destination scope is the
authority, the unused caller argument should be removed. Mixed-source batches
must not accidentally apply the first item's scope to every item.

Actual behavior

importPackageInterop passes scope: extractionScope to
processLongTermMemorySourceBatch, but that inline options type has no scope
field. The worker also omits scope when calling
prepareLongTermMemorySource, so preparation falls back to
sourceNote.destinationScope ?? sourceNote.scope.

A targeted probe passed an explicit { chatId: "explicit" } scope for a note
persisted with { chatId: "persisted" }. The call succeeded, but the captured
extraction prompt used chatId: "persisted"; the explicit scope was ignored.

Steps to reproduce

  1. Persist/import a source note with destination scope { chatId: "persisted" }.
  2. Invoke the batch processor through the import interop path with an explicit
    extraction scope { chatId: "explicit" }.
  3. Observe the type mismatch in the caller and that source preparation/prompt
    context uses the persisted scope rather than the supplied scope.

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 extraction path

Logs, screenshots, or video

Relevant locations:

interop.ts:968-983          caller supplies scope
source-processing.ts:316-329  batch options omit scope
source-processing.ts:346-359  worker omits scope when preparing
source-processing.ts:136-140   preparation falls back to persisted scope

The earlier neighboring compiler run recorded TS2353 for the excess scope
property. The current package helper is not a full excess-property compiler
check.

Additional context

Audit finding: EXTRACT-001.

Recommended minimal direction is to remove the unused batch scope argument and
keep each persisted source note's destination authoritative, unless the API
owner explicitly decides that a per-item scope contract is required. Blindly
forwarding one batch scope is unsafe for mixed-source imports.

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/885 Originally assigned to: @Promansis on GitHub. ## Summary The Long-Term Memory import interop caller passes an extraction `scope` to the source batch processor, but the batch options type does not declare it and the worker does not forward it to source preparation. ## Affected package `long-term-memory` ## Expected behavior The batch API should have one explicit, type-correct scope contract. If the caller-provided scope is intentionally authoritative, it must be declared and forwarded for every item. If persisted source-note destination scope is the authority, the unused caller argument should be removed. Mixed-source batches must not accidentally apply the first item's scope to every item. ## Actual behavior `importPackageInterop` passes `scope: extractionScope` to `processLongTermMemorySourceBatch`, but that inline options type has no `scope` field. The worker also omits `scope` when calling `prepareLongTermMemorySource`, so preparation falls back to `sourceNote.destinationScope ?? sourceNote.scope`. A targeted probe passed an explicit `{ chatId: "explicit" }` scope for a note persisted with `{ chatId: "persisted" }`. The call succeeded, but the captured extraction prompt used `chatId: "persisted"`; the explicit scope was ignored. ## Steps to reproduce 1. Persist/import a source note with destination scope `{ chatId: "persisted" }`. 2. Invoke the batch processor through the import interop path with an explicit extraction scope `{ chatId: "explicit" }`. 3. Observe the type mismatch in the caller and that source preparation/prompt context uses the persisted scope rather than the supplied scope. ## 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 extraction path ## Logs, screenshots, or video Relevant locations: ```text interop.ts:968-983 caller supplies scope source-processing.ts:316-329 batch options omit scope source-processing.ts:346-359 worker omits scope when preparing source-processing.ts:136-140 preparation falls back to persisted scope ``` The earlier neighboring compiler run recorded `TS2353` for the excess `scope` property. The current package helper is not a full excess-property compiler check. ## Additional context Audit finding: `EXTRACT-001`. Recommended minimal direction is to remove the unused batch scope argument and keep each persisted source note's destination authoritative, unless the API owner explicitly decides that a per-item scope contract is required. Blindly forwarding one batch scope is unsafe for mixed-source imports. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:27:49 +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#466
No description provided.