[GH-ISSUE #1450] [Issue]: Long-Term Memory: misleading drop messages, lost relationship summary lines in recall, and a restored retry set that differs from live #736

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

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

Originally assigned to: @Promansis on GitHub.

Summary

Three small, unrelated defects that share no files with the other open extraction work (tracker items EX-I6, EX-I8 and EX-I7):

  1. Validation diagnostics mislead. A unit dropped for a missing link target is reported as "used the wrong memory stream", and the low-lexical-evidence warning compares each unit against only the first 500 tokens of the source, and is emitted even for units the same pass then drops.
  2. The recall prompt deletes a relationship memory's "Summary:" line. For relationship chunks the scores line is prepended first, so a section whose text starts with a label loses that line in the chat prompt.
  3. A restored source task offers a different retry set than a live one. Restored results add missingSourceIds to the retry list; live results do not. Retrying a missing source re-requests the same id and gets the same result.

Affected package

long-term-memory 1.4.48 (upstream/staging 1f7954305).

  • S = packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory
  • C = packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory

Expected behavior

  1. The user-facing drop message for unknown_link_target names the missing target. The lexical warning compares against the whole source and is attached only to kept units.
  2. A relationship chunk whose text is Summary: Ash trusts Damo after the gate incident.\nDamo keeps her secret. renders all three lines: scores, the summary sentence, the second sentence.
  3. Live and restored results derive the same retry set: retryable imported rows plus retryable write failures.

Actual behavior

  1. diagnosticToDropReason maps unknown_link_target to unsupported_bucket (S/evidence-unit-validation.ts:791-794); userFacingDropMessageForDiagnostic (:836-847) routes that code to userFacingDropMessageForCode (:829-834), which has no case for it and falls back to "Dropped a candidate that used the wrong memory stream for source-summary extraction." (:860). In the audit's real-run sample, 5 of 11 drops carried this message. lexicalOverlap (:41-50) tokenizes the full source once per unit through tokenize, which keeps only the first 500 tokens (shared utils.ts:26-33); the warning is pushed straight into diagnostics (:332-340) before the drop check.
  2. normalizeBulletLines (S/prompt.ts:35-52) keeps a text:/summary: line only when it is the first normalized line. formatLtmChunkPromptText (S/prompt-text.ts:63-71) prepends the scores line for relationship chunks, so the labelled line is never first. Probe H: the chunk above renders as - Relationship scores: trust 62/100\n Damo keeps her secret.
  3. Live: C/sources/SourcesWorkspace.tsx:573-577 and :1088-1091. Restored: :1340-1346, where :1344 adds restoredImportResult.missingSourceIds.

Checked at 1f7954305.

Steps to reproduce

  1. Extract a source whose unit links to an id outside the retrieval window. The Sources result lists the drop as a wrong memory stream.
  2. Give a relationship memory a section starting with "Summary:" and recall it: the chat prompt lacks that sentence (visible in the Debug tab's prompt).
  3. Import a source list where one id is missing; reload the page so the result is restored from the task: the missing id is now in the retry selection, where it was not before the reload.

Minimal fix

One PR, patch bump.

1. S/evidence-unit-validation.ts only

  • Message: give unknown_link_target its own user-facing text that names the target (or let it fall through to the diagnostic's own message at :846, which already does). No new drop reason: that would touch the shared type and the client labels.
  • Lexical warning: tokenize the source once, outside the unit loop (:145), without the 500-token cap (tokenize takes minLength only; add an optional limit or build the set with the same regex). Push the warning into unitDiagnostics instead of diagnostics (:333) so it reaches the result only for kept units.
  • Leave the dead else at :354-356 alone unless the diff touches it.

2. S/prompt-text.ts (formatLtmChunkPromptText): strip a leading text:/summary: label from the first raw line of the chunk text before the scores line is prepended. normalizeBulletLines keeps its rule, because the legacyBullets case in the runtime test (:439-456) relies on a later text: duplicate line being dropped.

3. C/source-task.ts and C/sources/SourcesWorkspace.tsx: one helper, retryableSourceIds(result), that returns retryable imported rows plus retryable write failures. Use it at :573-577, :1088-1091 and :1340-1346, which deletes the missingSourceIds line. Missing ids stay listed in the result panel (:1409).

CHANGELOG under ## Unreleased: three short bullets (drop message, relationship summaries in recall, retry selection after a reload).

Not included

  • Resolving link targets outside the retrieval window instead of dropping the unit (audit F7, part 2). Needs a contract decision first.
  • Re-closing links after late drops (EX-I1) and the prompt-envelope work (EX-I5): separate issues on evidence-unit-extraction.ts.

Regression proof

  • tests/long-term-memory-extraction-reliability.regression.ts: a unit linking to an unknown target is dropped with a message that names the target and not "wrong memory stream"; a unit drawn from past the 500th token of a long source gets no low_lexical_evidence warning; a dropped unit contributes no warning. No test covers low_lexical_evidence today.
  • tests/long-term-memory-runtime.regression.ts (the relationshipScores case at :428-437): the probe-H chunk renders the scores line, the summary sentence and the second sentence; legacyBullets (:439-456) still passes.
  • tests/long-term-memory-source-task.regression.ts: retryableSourceIds returns [] for a result whose only entries are missingSourceIds, and the retryable ids for a mixed result. Also run feedback-clarity-ui.

Environment

  • Marinara Engine version: 2.5.0 line (staging 2039583ca)
  • Package version: long-term-memory 1.4.48 (upstream/staging 1f7954305)
  • Install type: source (code audit)
  • OS + version: not platform-specific
  • Browser or app shell: any

Logs, screenshots, or video

None. Found by the extraction stages audit (F7, F8, F9 with probe H, CLIENT-001) and confirmed by reading the code at 1f7954305.

Additional context

Tracker items EX-I6, EX-I7 and EX-I8. Shares no source file with the other batch-1 issues.

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 (Oct 18, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1450 Originally assigned to: @Promansis on GitHub. ## Summary Three small, unrelated defects that share no files with the other open extraction work (tracker items EX-I6, EX-I8 and EX-I7): 1. **Validation diagnostics mislead.** A unit dropped for a missing link target is reported as "used the wrong memory stream", and the low-lexical-evidence warning compares each unit against only the first 500 tokens of the source, and is emitted even for units the same pass then drops. 2. **The recall prompt deletes a relationship memory's "Summary:" line.** For relationship chunks the scores line is prepended first, so a section whose text starts with a label loses that line in the chat prompt. 3. **A restored source task offers a different retry set than a live one.** Restored results add `missingSourceIds` to the retry list; live results do not. Retrying a missing source re-requests the same id and gets the same result. ## Affected package `long-term-memory` 1.4.48 (`upstream/staging` 1f7954305). - `S` = `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory` - `C` = `packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory` ## Expected behavior 1. The user-facing drop message for `unknown_link_target` names the missing target. The lexical warning compares against the whole source and is attached only to kept units. 2. A relationship chunk whose text is `Summary: Ash trusts Damo after the gate incident.\nDamo keeps her secret.` renders all three lines: scores, the summary sentence, the second sentence. 3. Live and restored results derive the same retry set: retryable imported rows plus retryable write failures. ## Actual behavior 1. `diagnosticToDropReason` maps `unknown_link_target` to `unsupported_bucket` (`S/evidence-unit-validation.ts:791-794`); `userFacingDropMessageForDiagnostic` (`:836-847`) routes that code to `userFacingDropMessageForCode` (`:829-834`), which has no case for it and falls back to "Dropped a candidate that used the wrong memory stream for source-summary extraction." (`:860`). In the audit's real-run sample, 5 of 11 drops carried this message. `lexicalOverlap` (`:41-50`) tokenizes the full source once per unit through `tokenize`, which keeps only the first 500 tokens (`shared utils.ts:26-33`); the warning is pushed straight into `diagnostics` (`:332-340`) before the drop check. 2. `normalizeBulletLines` (`S/prompt.ts:35-52`) keeps a `text:`/`summary:` line only when it is the first normalized line. `formatLtmChunkPromptText` (`S/prompt-text.ts:63-71`) prepends the scores line for relationship chunks, so the labelled line is never first. Probe H: the chunk above renders as `- Relationship scores: trust 62/100\n Damo keeps her secret.` 3. Live: `C/sources/SourcesWorkspace.tsx:573-577` and `:1088-1091`. Restored: `:1340-1346`, where `:1344` adds `restoredImportResult.missingSourceIds`. Checked at 1f7954305. ## Steps to reproduce 1. Extract a source whose unit links to an id outside the retrieval window. The Sources result lists the drop as a wrong memory stream. 2. Give a relationship memory a section starting with "Summary:" and recall it: the chat prompt lacks that sentence (visible in the Debug tab's prompt). 3. Import a source list where one id is missing; reload the page so the result is restored from the task: the missing id is now in the retry selection, where it was not before the reload. ## Minimal fix One PR, patch bump. **1. `S/evidence-unit-validation.ts` only** - Message: give `unknown_link_target` its own user-facing text that names the target (or let it fall through to the diagnostic's own message at `:846`, which already does). No new drop reason: that would touch the shared type and the client labels. - Lexical warning: tokenize the source once, outside the unit loop (`:145`), without the 500-token cap (`tokenize` takes `minLength` only; add an optional limit or build the set with the same regex). Push the warning into `unitDiagnostics` instead of `diagnostics` (`:333`) so it reaches the result only for kept units. - Leave the dead `else` at `:354-356` alone unless the diff touches it. **2. `S/prompt-text.ts`** (`formatLtmChunkPromptText`): strip a leading `text:`/`summary:` label from the first raw line of the chunk text before the scores line is prepended. `normalizeBulletLines` keeps its rule, because the `legacyBullets` case in the runtime test (`:439-456`) relies on a later `text:` duplicate line being dropped. **3. `C/source-task.ts` and `C/sources/SourcesWorkspace.tsx`**: one helper, `retryableSourceIds(result)`, that returns retryable imported rows plus retryable write failures. Use it at `:573-577`, `:1088-1091` and `:1340-1346`, which deletes the `missingSourceIds` line. Missing ids stay listed in the result panel (`:1409`). **CHANGELOG under `## Unreleased`**: three short bullets (drop message, relationship summaries in recall, retry selection after a reload). **Not included** - Resolving link targets outside the retrieval window instead of dropping the unit (audit F7, part 2). Needs a contract decision first. - Re-closing links after late drops (EX-I1) and the prompt-envelope work (EX-I5): separate issues on `evidence-unit-extraction.ts`. ## Regression proof - **`tests/long-term-memory-extraction-reliability.regression.ts`**: a unit linking to an unknown target is dropped with a message that names the target and not "wrong memory stream"; a unit drawn from past the 500th token of a long source gets no `low_lexical_evidence` warning; a dropped unit contributes no warning. No test covers `low_lexical_evidence` today. - **`tests/long-term-memory-runtime.regression.ts`** (the `relationshipScores` case at `:428-437`): the probe-H chunk renders the scores line, the summary sentence and the second sentence; `legacyBullets` (`:439-456`) still passes. - **`tests/long-term-memory-source-task.regression.ts`**: `retryableSourceIds` returns `[]` for a result whose only entries are `missingSourceIds`, and the retryable ids for a mixed result. Also run `feedback-clarity-ui`. ## Environment - Marinara Engine version: 2.5.0 line (`staging` 2039583ca) - Package version: long-term-memory 1.4.48 (`upstream/staging` 1f7954305) - Install type: source (code audit) - OS + version: not platform-specific - Browser or app shell: any ## Logs, screenshots, or video None. Found by the extraction stages audit (F7, F8, F9 with probe H, CLIENT-001) and confirmed by reading the code at 1f7954305. ## Additional context Tracker items EX-I6, EX-I7 and EX-I8. Shares no source file with the other batch-1 issues. ## 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:30:13 +07:00
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#736
No description provided.