[GH-ISSUE #1449] [Issue]: Long-Term Memory: record the reconciliation outcome for every candidate group #735

Closed
opened 2026-10-20 17:30:11 +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/1449

Originally assigned to: @Promansis on GitHub.

Summary

Candidate reconciliation decides, for every non-character candidate group, whether it reuses an existing note, creates a new one, or leaves it for review. Only the match and the warning outcomes are ever recorded. The "no match, so create a new note" outcome, which is the duplicate-creation path, leaves no trace, so the duplicate rate cannot be measured from the debug log. (Tracker item EX-I3; extraction stages audit F4 part 1, pipeline plan step 9.)

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

Expected behavior

Every extraction that runs reconciliation records one candidate_reconciliation debug event with counts for every outcome (groups, matched, created, ambiguous, incomplete) and the match kind (identity or content) for each match, so the create rate can be read from the Activity tab and the debug log.

Actual behavior

  • reconcileEvidenceUnitCandidates (S/candidate-reconciliation.ts:55) returns units, diagnostics, remaps and matches (:39-44). A group with no retrieved candidates continues silently (:134), and "zero plausible targets in a complete window" falls through with no remap and no diagnostic (:205).
  • source-extraction.ts:644-661 records the candidate_reconciliation event only when remaps.size > 0 || diagnostics.length > 0, with counts reconciledNotes and ambiguousCandidates. A create-only run records nothing.
  • The audit measured the predicate: with a descriptive subjectId and no echoed title, a near-verbatim text (Jaccard 1.00) matches, but Jaccard 0.60 and 0.50 rephrasings do not (probe C), so creates are the expected failure mode and the one that is not logged.

Checked at 1f7954305.

Steps to reproduce

  1. Turn on debug logging and import a source whose world or thread candidates match no existing note.
  2. Open Activity → Debug for that operation: there is no reconciliation entry.
  3. Import a source whose candidate matches an existing title: the entry appears, with reconciledNotes only.

Minimal fix

One PR, patch bump.

  1. S/candidate-reconciliation.ts
    • Give each CandidateReconciliationMatch (:34-37) a matchKind: "identity" | "content", already computed at :163 and :178.
    • Add counts: { groups, matched, created, ambiguous, incomplete } to CandidateReconciliationResult (:39-44). Count a group as created at both silent exits (:134, :205), ambiguous and incomplete where those diagnostics are pushed, matched where a remap is recorded. Every group ends in exactly one bucket.
  2. S/source-extraction.ts:644-661: drop the if; always record the event. Replace reconciledNotes/ambiguousCandidates with the new counts (keep the two old keys if the Activity tab's labels depend on them; ActivityView.tsx:94 labels the action, and counts render generically). Status stays warning when ambiguous or incomplete is above zero.
  3. No change to matching behaviour, the prompt, or the client.

CHANGELOG under ## Unreleased: one bullet, that the Debug tab now shows how many memories an import reused versus created.

Not included

  • Broadening the match predicate (audit F4 part 2, tracker EX-I10). It starts only after this event has shown the create rate.
  • Commit-time reconciliation cost (F3, tracker EX-I4), which touches source-processing.ts and the same reconciliation file and follows this PR.

Regression proof

  • tests/long-term-memory-candidate-reconciliation.regression.ts: a create-only run (the single-create case at :262) returns counts.created === 1 and counts.matched === 0; the match at :230 carries matchKind: "identity"; the ambiguous (:278) and incomplete (:690) cases count in their buckets; groups equals the sum of the four.
  • Event always fires: in the regression that already runs preparation against a vault and inspects the result (tests/long-term-memory-reconciliation-recall.regression.ts, the prepared run at :274), read the debug log after a create-only preparation and assert one candidate_reconciliation event with the counts. tests/long-term-memory-debug-log.regression.ts shows how events are read.
  • Also run extraction-reliability, debug-log and routes-drafts.

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 (probe C) and confirmed by reading the code at 1f7954305.

Additional context

Tracker item EX-I3. Prerequisite for EX-I10 and the pipeline plan's duplicate-rate measurement. 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/1449 Originally assigned to: @Promansis on GitHub. ## Summary Candidate reconciliation decides, for every non-character candidate group, whether it reuses an existing note, creates a new one, or leaves it for review. Only the match and the warning outcomes are ever recorded. The "no match, so create a new note" outcome, which is the duplicate-creation path, leaves no trace, so the duplicate rate cannot be measured from the debug log. (Tracker item EX-I3; extraction stages audit F4 part 1, pipeline plan step 9.) ## 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` ## Expected behavior Every extraction that runs reconciliation records one `candidate_reconciliation` debug event with counts for every outcome (groups, matched, created, ambiguous, incomplete) and the match kind (identity or content) for each match, so the create rate can be read from the Activity tab and the debug log. ## Actual behavior - `reconcileEvidenceUnitCandidates` (`S/candidate-reconciliation.ts:55`) returns `units`, `diagnostics`, `remaps` and `matches` (`:39-44`). A group with no retrieved candidates `continue`s silently (`:134`), and "zero plausible targets in a complete window" falls through with no remap and no diagnostic (`:205`). - `source-extraction.ts:644-661` records the `candidate_reconciliation` event only when `remaps.size > 0 || diagnostics.length > 0`, with counts `reconciledNotes` and `ambiguousCandidates`. A create-only run records nothing. - The audit measured the predicate: with a descriptive `subjectId` and no echoed title, a near-verbatim text (Jaccard 1.00) matches, but Jaccard 0.60 and 0.50 rephrasings do not (probe C), so creates are the expected failure mode and the one that is not logged. Checked at 1f7954305. ## Steps to reproduce 1. Turn on debug logging and import a source whose world or thread candidates match no existing note. 2. Open Activity → Debug for that operation: there is no reconciliation entry. 3. Import a source whose candidate matches an existing title: the entry appears, with `reconciledNotes` only. ## Minimal fix One PR, patch bump. 1. **`S/candidate-reconciliation.ts`** - Give each `CandidateReconciliationMatch` (`:34-37`) a `matchKind: "identity" | "content"`, already computed at `:163` and `:178`. - Add `counts: { groups, matched, created, ambiguous, incomplete }` to `CandidateReconciliationResult` (`:39-44`). Count a group as `created` at both silent exits (`:134`, `:205`), `ambiguous` and `incomplete` where those diagnostics are pushed, `matched` where a remap is recorded. Every group ends in exactly one bucket. 2. **`S/source-extraction.ts:644-661`**: drop the `if`; always record the event. Replace `reconciledNotes`/`ambiguousCandidates` with the new counts (keep the two old keys if the Activity tab's labels depend on them; `ActivityView.tsx:94` labels the action, and counts render generically). Status stays `warning` when ambiguous or incomplete is above zero. 3. No change to matching behaviour, the prompt, or the client. **CHANGELOG under `## Unreleased`**: one bullet, that the Debug tab now shows how many memories an import reused versus created. **Not included** - Broadening the match predicate (audit F4 part 2, tracker EX-I10). It starts only after this event has shown the create rate. - Commit-time reconciliation cost (F3, tracker EX-I4), which touches `source-processing.ts` and the same reconciliation file and follows this PR. ## Regression proof - **`tests/long-term-memory-candidate-reconciliation.regression.ts`**: a create-only run (the single-create case at `:262`) returns `counts.created === 1` and `counts.matched === 0`; the match at `:230` carries `matchKind: "identity"`; the ambiguous (`:278`) and incomplete (`:690`) cases count in their buckets; `groups` equals the sum of the four. - **Event always fires**: in the regression that already runs preparation against a vault and inspects the result (`tests/long-term-memory-reconciliation-recall.regression.ts`, the `prepared` run at `:274`), read the debug log after a create-only preparation and assert one `candidate_reconciliation` event with the counts. `tests/long-term-memory-debug-log.regression.ts` shows how events are read. - Also run `extraction-reliability`, `debug-log` and `routes-drafts`. ## 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 (probe C) and confirmed by reading the code at 1f7954305. ## Additional context Tracker item EX-I3. Prerequisite for EX-I10 and the pipeline plan's duplicate-rate measurement. 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:11 +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#735
No description provided.