[GH-ISSUE #913] fix(long-term-memory): defer source context persistence and preserve dedup freshness #478

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

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

Originally assigned to: @Promansis on GitHub.

Summary

Long-Term Memory phase four has two source-processing reliability defects: extraction preparation persists source context before extraction finalization, and a clean LLM batch containing both newly accepted and deduplicated units is not marked current.

Affected package

long-term-memory

Expected behavior

  • Preparing an extraction should not mutate the source note's destinationScope or modes. Context changes should be committed atomically with successful draft finalization and the extraction fingerprint.
  • Validation failures, provider errors, and aborts during preparation should leave the source note unchanged.
  • A batch with accepted units and harmless deduplications, with no validation errors or dropped candidates, should persist its extraction fingerprint and be treated as current.

Actual behavior

  • extractLongTermMemoryFromSourceNoteInner calls bindSourceNoteToExtractionContext, which calls storage.updateNote for destinationScope and modes before source text validation, provider extraction, and draft finalization complete.
  • finalizeLongTermMemoryExtractionDraft verifies the source context fingerprint but does not commit the pending context binding; it only creates the draft. The later source update persists the fingerprint separately.
  • summarizeExtractionOutcome reports any accepted batch with deduplications as partial_success. canMarkCurrent permits this state only for deterministic extraction, so an otherwise clean LLM batch skips fingerprint persistence and is reprocessed on the next extraction.

Steps to reproduce

  1. Use a synthetic LTM source note whose requested destination scope or modes differ from the stored context.
  2. Start extraction and force a validation failure, provider error, or abort after context binding begins; inspect the source note.
  3. Run an LLM extraction whose valid output contains one new unit and one unit deduplicated against an existing note, with no dropped candidates or error diagnostics; inspect the returned outcome and source extraction fingerprint.

Environment

  • Marinara Engine version: Compatible with package manifest >=2.4.1 <4.0.0
  • Package version: 1.3.3
  • Install type: source inspection; no live-provider call performed
  • OS + version: Not applicable
  • Browser or app shell: Not applicable

Logs, screenshots, or video

No private logs or user data included. The behavior is code-confirmed from upstream staging at commit 7b60087a.

Additional context

  • Phase-four scope from the private implementation plan: I06 (defer source-context persistence until successful finalization) and I08 (mark clean mixed new/duplicate extraction current).
  • Direct implementation paths:
    • packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/source-extraction.ts
    • packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/evidence-unit-extraction.ts
    • packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/source-processing.ts
  • Focused regression ownership is in tests/long-term-memory-storage.regression.ts, tests/long-term-memory-extraction-reliability.regression.ts, and tests/long-term-memory-extraction-graph.regression.ts. Add synthetic fixtures at the narrowest owning boundary and preserve review-before-apply behavior.
  • Related phase-three work: https://github.com/Pasta-Devs/Marinara-Agents/pull/912. Phase three is complete there but is not yet live on staging; revalidate the final implementation baseline after it lands.
  • No source changes, tests, builds, or live-provider calls were performed for this issue investigation.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Sep 18, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/913 Originally assigned to: @Promansis on GitHub. ## Summary Long-Term Memory phase four has two source-processing reliability defects: extraction preparation persists source context before extraction finalization, and a clean LLM batch containing both newly accepted and deduplicated units is not marked current. ## Affected package `long-term-memory` ## Expected behavior - Preparing an extraction should not mutate the source note's `destinationScope` or `modes`. Context changes should be committed atomically with successful draft finalization and the extraction fingerprint. - Validation failures, provider errors, and aborts during preparation should leave the source note unchanged. - A batch with accepted units and harmless deduplications, with no validation errors or dropped candidates, should persist its extraction fingerprint and be treated as current. ## Actual behavior - `extractLongTermMemoryFromSourceNoteInner` calls `bindSourceNoteToExtractionContext`, which calls `storage.updateNote` for `destinationScope` and `modes` before source text validation, provider extraction, and draft finalization complete. - `finalizeLongTermMemoryExtractionDraft` verifies the source context fingerprint but does not commit the pending context binding; it only creates the draft. The later source update persists the fingerprint separately. - `summarizeExtractionOutcome` reports any accepted batch with deduplications as `partial_success`. `canMarkCurrent` permits this state only for deterministic extraction, so an otherwise clean LLM batch skips fingerprint persistence and is reprocessed on the next extraction. ## Steps to reproduce 1. Use a synthetic LTM source note whose requested destination scope or modes differ from the stored context. 2. Start extraction and force a validation failure, provider error, or abort after context binding begins; inspect the source note. 3. Run an LLM extraction whose valid output contains one new unit and one unit deduplicated against an existing note, with no dropped candidates or error diagnostics; inspect the returned outcome and source extraction fingerprint. ## Environment - Marinara Engine version: Compatible with package manifest `>=2.4.1 <4.0.0` - Package version: `1.3.3` - Install type: source inspection; no live-provider call performed - OS + version: Not applicable - Browser or app shell: Not applicable ## Logs, screenshots, or video No private logs or user data included. The behavior is code-confirmed from upstream `staging` at commit `7b60087a`. ## Additional context - Phase-four scope from the private implementation plan: I06 (defer source-context persistence until successful finalization) and I08 (mark clean mixed new/duplicate extraction current). - Direct implementation paths: - `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/source-extraction.ts` - `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/evidence-unit-extraction.ts` - `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/source-processing.ts` - Focused regression ownership is in `tests/long-term-memory-storage.regression.ts`, `tests/long-term-memory-extraction-reliability.regression.ts`, and `tests/long-term-memory-extraction-graph.regression.ts`. Add synthetic fixtures at the narrowest owning boundary and preserve review-before-apply behavior. - Related phase-three work: https://github.com/Pasta-Devs/Marinara-Agents/pull/912. Phase three is complete there but is not yet live on `staging`; revalidate the final implementation baseline after it lands. - No source changes, tests, builds, or live-provider calls were performed for this issue investigation. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:27:55 +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#478
No description provided.