[PR #1005] [MERGED] fix(long-term-memory): resolve trusted subject keys before matching names #1240

Closed
opened 2026-10-21 05:06:33 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Agents/pull/1005
Author: @Promansis
Created: 9/21/2026
Status: ✅ Merged
Merged: 9/21/2026
Merged by: @Promansis

Base: staging ← Head: fix/ltm-trusted-keys-899


📝 Commits (3)

  • d30b316 fix(long-term-memory): resolve trusted subject keys before matching names (#899)
  • cc8f0f6 fix(long-term-memory): reconcile structured backfill with trusted identities (#899)
  • 9db5649 fix(long-term-memory): exclude invalid local notes from identity matching (#899)

📊 Changes

14 files changed (+534 additions, -136 deletions)

View changed files

➕ artifacts/long-term-memory-1.3.8.zip (+0 -0)
📝 catalog/catalog.json (+6 -6)
📝 catalog/notes.json (+6 -0)
📝 catalog/v2/catalog.json (+6 -6)
📝 catalog/v2/notes.json (+6 -0)
📝 catalog/v3/catalog.json (+6 -6)
📝 catalog/v3/notes.json (+6 -0)
📝 packages/long-term-memory/CHANGELOG.md (+5 -0)
📝 packages/long-term-memory/manifest.json (+3 -3)
📝 packages/long-term-memory/server.mjs (+49 -49)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/structured-summary-normalizer.ts (+3 -1)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/subject-identity.ts (+146 -63)
📝 scripts/build-feature-packages.mjs (+1 -1)
📝 tests/long-term-memory-local-characters.regression.ts (+291 -1)

📄 Description

Pull request

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #899

Why this change

  • When extraction units provide valid, trusted subjectKeys alongside subjectNames, Long-Term Memory previously bypassed trusted key lookup and routed through name matching. In environments with duplicate or collision-prone character roster names, this forced ambiguity rejections or short/full-name heuristics even though the caller supplied authoritative catalog keys.
  • Structured-summary backfill could also re-resolve keyless candidates independently, allowing same-name local characters from different chat families to collide and allowing short participant names to fork from an established longer identity.

What changed

  • packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/subject-identity.ts: Prioritize trusted subjectKeys over subjectNames in identityKeyForUnit and resolveLtmSubjectIdentitiesWithContext.
  • Scope the effective identity catalog to the active chat family so same-name local characters from other families cannot collide.
  • Let keyless, nameless backfill units inherit a key already established in the same batch for the same bucket and subject ID; explicit names and explicit keys still resolve or fail closed independently.
  • Match a short participant name to one longer catalog identity when the relationship is unambiguous, while preserving ambiguity rejection when multiple identities remain.
  • packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/structured-summary-normalizer.ts: Treat identifier-valued structured character fields as subject IDs rather than display names.
  • Preserve fail-closed identity resolution: unknown keys, duplicate keys, and cardinality mismatches still reject; explicit keys disable name and legacy fallback.
  • tests/long-term-memory-local-characters.regression.ts: Added synthetic regression coverage for trusted-key precedence, cross-family isolation, short/full-name reuse, batch-established key inheritance, identifier-valued character fields, and invalid key arrays.
  • packages/long-term-memory/CHANGELOG.md: Added release notes for version 1.3.8.
  • Generated outputs: Rebuilt packages/long-term-memory/manifest.json, packages/long-term-memory/server.mjs, artifacts/long-term-memory-1.3.8.zip, catalog/catalog.json, catalog/notes.json, catalog/v2/catalog.json, catalog/v2/notes.json, catalog/v3/catalog.json, and catalog/v3/notes.json.

Package and security impact

  • Affected package IDs: long-term-memory
  • Engine compatibility impact: Unchanged (>=2.4.1 <4.0.0)
  • New or changed permissions/entrypoints: None
  • Restart, storage, update, or uninstall impact: Patch release 1.3.8; preserves storage and update lifecycle; confirmed clean artifact installation and offline restart.

Validation

  • node scripts/validate-catalog.mjs passes locally
  • git diff --check passes locally
  • Rebuilt every affected manifest, payload, artifact, and catalog entry
  • Installed or updated the affected package through Marinara Engine
  • Checked supported modes, restart behavior, and uninstall cleanup
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Ran MARINARA_AGENTS_ROOT=/home/damo/dev/marinara-worktrees/Marinara-Agents-ltm-trusted-keys-899 MARINARA_ENGINE_ROOT=/home/damo/dev/Marinara-Engine /home/damo/.config/opencode/marinara-agents-local/test-ltm.sh all (all 18 LTM test suites passed, including local-characters, extraction-graph, extraction-reliability, and 1.3.8 installation).
  • Ran npm run typecheck:packages and npm run check (0 errors; 897 pre-existing warnings).
  • Ran git diff --check, node scripts/validate-catalog.mjs, node scripts/test-catalog-lanes.mjs, node scripts/validate-package-locales.mjs, and node scripts/tests/catalog-release-notes.regression.mjs successfully.
  • Rebuilt the long-term-memory package with MARINARA_ENGINE_ROOT=/home/damo/dev/Marinara-Engine node scripts/build-feature-packages.mjs long-term-memory, including the 1.3.8 artifact and catalog lanes.
  • The full test-ci.sh wrapper was not run; its relevant formatting, lint, typecheck, security, catalog, localization, and release-note checks were run individually above.

Documentation impact

  • No documentation changes needed
  • Updated this README catalog and package guidance
  • Updated linked Marinara Engine documentation

UI evidence (if applicable)

  • N/A (server-side extraction identity resolution and catalog rebuild).

Summary by CodeRabbit

  • New Features

    • Character and relationship extraction now prioritizes trusted subject keys over name matching.
    • Short participant names map to established full-name identities.
    • Backfilled summaries reuse subject keys established within the same batch.
  • Bug Fixes

    • Invalid keys and ambiguous keyless identities are rejected.
    • Same-name local characters remain isolated to their chat family.
    • Conflicting or invalid subject keys no longer fall back to name-based matching.
  • Release

    • Updated the long-term-memory package to version 1.3.8.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Agents/pull/1005 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 9/21/2026 **Status:** ✅ Merged **Merged:** 9/21/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `fix/ltm-trusted-keys-899` --- ### 📝 Commits (3) - [`d30b316`](https://github.com/Pasta-Devs/Marinara-Agents/commit/d30b31624da8b38cbdf8166b11b46eba4c96dc25) fix(long-term-memory): resolve trusted subject keys before matching names (#899) - [`cc8f0f6`](https://github.com/Pasta-Devs/Marinara-Agents/commit/cc8f0f647893f8fd0dd24524f2a5125621208dba) fix(long-term-memory): reconcile structured backfill with trusted identities (#899) - [`9db5649`](https://github.com/Pasta-Devs/Marinara-Agents/commit/9db5649fa7030fb52809dced55840c450ccb9ef3) fix(long-term-memory): exclude invalid local notes from identity matching (#899) ### 📊 Changes **14 files changed** (+534 additions, -136 deletions) <details> <summary>View changed files</summary> ➕ `artifacts/long-term-memory-1.3.8.zip` (+0 -0) 📝 `catalog/catalog.json` (+6 -6) 📝 `catalog/notes.json` (+6 -0) 📝 `catalog/v2/catalog.json` (+6 -6) 📝 `catalog/v2/notes.json` (+6 -0) 📝 `catalog/v3/catalog.json` (+6 -6) 📝 `catalog/v3/notes.json` (+6 -0) 📝 `packages/long-term-memory/CHANGELOG.md` (+5 -0) 📝 `packages/long-term-memory/manifest.json` (+3 -3) 📝 `packages/long-term-memory/server.mjs` (+49 -49) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/structured-summary-normalizer.ts` (+3 -1) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/subject-identity.ts` (+146 -63) 📝 `scripts/build-feature-packages.mjs` (+1 -1) 📝 `tests/long-term-memory-local-characters.regression.ts` (+291 -1) </details> ### 📄 Description # Pull request > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- Open as a draft while implementation is in progress. Mark Ready for review only after validation and self-review. --> ## Linked issue <!-- Every PR should reference an issue or feature request. --> Closes #899 ## Why this change <!-- What user problem, package bug, or catalog goal does this solve? --> - When extraction units provide valid, trusted `subjectKeys` alongside `subjectNames`, Long-Term Memory previously bypassed trusted key lookup and routed through name matching. In environments with duplicate or collision-prone character roster names, this forced ambiguity rejections or short/full-name heuristics even though the caller supplied authoritative catalog keys. - Structured-summary backfill could also re-resolve keyless candidates independently, allowing same-name local characters from different chat families to collide and allowing short participant names to fork from an established longer identity. ## What changed <!-- Include affected package IDs and generated outputs. --> - `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/subject-identity.ts`: Prioritize trusted `subjectKeys` over `subjectNames` in `identityKeyForUnit` and `resolveLtmSubjectIdentitiesWithContext`. - Scope the effective identity catalog to the active chat family so same-name local characters from other families cannot collide. - Let keyless, nameless backfill units inherit a key already established in the same batch for the same bucket and subject ID; explicit names and explicit keys still resolve or fail closed independently. - Match a short participant name to one longer catalog identity when the relationship is unambiguous, while preserving ambiguity rejection when multiple identities remain. - `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/structured-summary-normalizer.ts`: Treat identifier-valued structured character fields as subject IDs rather than display names. - Preserve fail-closed identity resolution: unknown keys, duplicate keys, and cardinality mismatches still reject; explicit keys disable name and legacy fallback. - `tests/long-term-memory-local-characters.regression.ts`: Added synthetic regression coverage for trusted-key precedence, cross-family isolation, short/full-name reuse, batch-established key inheritance, identifier-valued character fields, and invalid key arrays. - `packages/long-term-memory/CHANGELOG.md`: Added release notes for version `1.3.8`. - Generated outputs: Rebuilt `packages/long-term-memory/manifest.json`, `packages/long-term-memory/server.mjs`, `artifacts/long-term-memory-1.3.8.zip`, `catalog/catalog.json`, `catalog/notes.json`, `catalog/v2/catalog.json`, `catalog/v2/notes.json`, `catalog/v3/catalog.json`, and `catalog/v3/notes.json`. ## Package and security impact - Affected package IDs: `long-term-memory` - Engine compatibility impact: Unchanged (`>=2.4.1 <4.0.0`) - New or changed permissions/entrypoints: None - Restart, storage, update, or uninstall impact: Patch release `1.3.8`; preserves storage and update lifecycle; confirmed clean artifact installation and offline restart. ## Validation <!-- These are human tasks. Never tick a box for a check that was not actually performed. --> - [ ] `node scripts/validate-catalog.mjs` passes locally - [ ] `git diff --check` passes locally - [ ] Rebuilt every affected manifest, payload, artifact, and catalog entry - [ ] Installed or updated the affected package through Marinara Engine - [ ] Checked supported modes, restart behavior, and uninstall cleanup - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes <!-- Describe exactly what you tested, step by step. --> - Ran `MARINARA_AGENTS_ROOT=/home/damo/dev/marinara-worktrees/Marinara-Agents-ltm-trusted-keys-899 MARINARA_ENGINE_ROOT=/home/damo/dev/Marinara-Engine /home/damo/.config/opencode/marinara-agents-local/test-ltm.sh all` (all 18 LTM test suites passed, including local-characters, extraction-graph, extraction-reliability, and 1.3.8 installation). - Ran `npm run typecheck:packages` and `npm run check` (0 errors; 897 pre-existing warnings). - Ran `git diff --check`, `node scripts/validate-catalog.mjs`, `node scripts/test-catalog-lanes.mjs`, `node scripts/validate-package-locales.mjs`, and `node scripts/tests/catalog-release-notes.regression.mjs` successfully. - Rebuilt the long-term-memory package with `MARINARA_ENGINE_ROOT=/home/damo/dev/Marinara-Engine node scripts/build-feature-packages.mjs long-term-memory`, including the 1.3.8 artifact and catalog lanes. - The full `test-ci.sh` wrapper was not run; its relevant formatting, lint, typecheck, security, catalog, localization, and release-note checks were run individually above. ## Documentation impact - [x] No documentation changes needed - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation ## UI evidence (if applicable) <!-- Add before/after screenshots or recordings for package UI changes. --> - N/A (server-side extraction identity resolution and catalog rebuild). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Character and relationship extraction now prioritizes trusted subject keys over name matching. - Short participant names map to established full-name identities. - Backfilled summaries reuse subject keys established within the same batch. - **Bug Fixes** - Invalid keys and ambiguous keyless identities are rejected. - Same-name local characters remain isolated to their chat family. - Conflicting or invalid subject keys no longer fall back to name-based matching. - **Release** - Updated the long-term-memory package to version 1.3.8. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-21 05:06:33 +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#1240
No description provided.