[PR #1032] [MERGED] fix(long-term-memory): canonicalize subject name variants to trusted identities (#1026) #1255

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

📋 Pull Request Information

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

Base: staging ← Head: fix(long-term-memory)/canonicalize-subject-name-variants


📝 Commits (3)

  • 5474ebc fix(long-term-memory): canonicalize subject name variants to trusted identities (#1026)
  • cf0cc3f fix(long-term-memory): align identityKeyForUnit with resolved source-backed target (#1026)
  • 52c7d24 fix(long-term-memory): narrow source-backed identity union accesses (#1026)

📊 Changes

13 files changed (+403 additions, -137 deletions)

View changed files

➕ artifacts/long-term-memory-1.3.11.zip (+0 -0)
📝 catalog/catalog.json (+6 -6)
📝 catalog/notes.json (+6 -6)
📝 catalog/v2/catalog.json (+6 -6)
📝 catalog/v2/notes.json (+6 -6)
📝 catalog/v3/catalog.json (+6 -6)
📝 catalog/v3/notes.json (+6 -6)
📝 packages/long-term-memory/CHANGELOG.md (+4 -0)
📝 packages/long-term-memory/manifest.json (+3 -3)
📝 packages/long-term-memory/server.mjs (+59 -59)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/subject-identity.ts (+119 -38)
📝 scripts/build-feature-packages.mjs (+1 -1)
📝 tests/long-term-memory-local-characters.regression.ts (+181 -0)

📄 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 #1026

Why this change

  • Long-Term Memory treated surface variants of the same name (Ash, Ashleigh, Ashleigh Kestrel, Ashleigh Kestral) as separate subjects, forking parallel character notes instead of canonicalizing them onto one trusted identity.
  • Keyless, source-backed NPC units could additionally select a fresh canonical note target even when the vault already had an established note for that identity, splitting memory across two notes.
  • Ambiguous short forms (for example Ashley matching more than one trusted record) needed to fail closed with the competing identities recorded instead of guessing.

What changed

  • packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/subject-identity.ts
    • Added a shared trusted-name relation matcher used by batch pre-resolution, on-demand resolution, and the keyless source-backed NPC path.
    • Unique relations reuse the trusted subject; multiple relations fail closed with collision diagnostics.
    • The keyless source-backed path now reuses an existing trusted/legacy note target via chooseIdentityTarget(...) before falling back to the canonical note ID, so it cannot fork a parallel note.
    • Fixed the accepted-path diagnostic to report the resolved entry name.
  • tests/long-term-memory-local-characters.regression.ts: variant canonicalization, ambiguous short-form rejection, keyless trusted-identity reuse, and keyless legacy-target reuse.
  • packages/long-term-memory/CHANGELOG.md: 1.3.11 entry.
  • Regenerated outputs: packages/long-term-memory/server.mjs, manifest.json, artifacts/long-term-memory-1.3.11.zip, and catalog/{,v2/,v3/}{catalog,notes}.json.

Package and security impact

  • Affected package IDs: long-term-memory (1.3.10 → 1.3.11).
  • Engine compatibility impact: none; engine.min / engine.maxExclusive remain 2.4.1 / 4.0.0.
  • New or changed permissions/entrypoints: none; the generated manifest changed only the version and the server.mjs hash/size in this PR.
  • Restart, storage, update, or uninstall impact: none expected. Installation, offline restart, backup inclusion, uninstall, and reinstall are covered by the LTM installation regression in test-ltm.sh all.

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

  • Rebuilt the package from the committed source with MARINARA_ENGINE_ROOT=/home/damo/dev/Marinara-Engine node scripts/build-feature-packages.mjs long-term-memory; the working tree stayed clean afterwards, confirming the committed generated outputs match their source.
  • Ran the full LTM suite test-ltm.sh all on final HEAD: exit 0, including the local-character regression, the 1.3.11 install/restart/backup/uninstall/reinstall suite, routes, storage, and runtime regressions.
  • Ran the repository PR gate test-ci.sh on final HEAD: exit 0, including Prettier/ESLint, security, catalog, locale, lane, release-note, and PR-triage checks.
  • Captured and re-asserted publication proof against the tested inputs (HEAD 5474ebc5ed71b5a12358978bb19a2b935b92e38f, clean tree, Engine checkout) with assertPublishProof; the second assertion matched the tested snapshot.
  • Checkboxes above are intentionally left unticked; they are a human verification list.

Documentation impact

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

UI evidence (if applicable)

  • Not applicable; no package UI changes in this PR.

Summary by CodeRabbit

  • New Features

    • Long-Term Memory recognizes short names, first-name-only forms, and minor spelling variations as the same trusted identity, reducing duplicate memories.
    • Ambiguous shared names fail safely and identify the competing matches.
    • Existing trusted or legacy note targets are reused instead of creating parallel identities.
  • Release

    • Updated the Long-Term Memory package to version 1.3.11.

🔄 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/1032 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 9/22/2026 **Status:** ✅ Merged **Merged:** 9/22/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `fix(long-term-memory)/canonicalize-subject-name-variants` --- ### 📝 Commits (3) - [`5474ebc`](https://github.com/Pasta-Devs/Marinara-Agents/commit/5474ebc5ed71b5a12358978bb19a2b935b92e38f) fix(long-term-memory): canonicalize subject name variants to trusted identities (#1026) - [`cf0cc3f`](https://github.com/Pasta-Devs/Marinara-Agents/commit/cf0cc3f08dd6813ca674fabdec3851efe8adce95) fix(long-term-memory): align identityKeyForUnit with resolved source-backed target (#1026) - [`52c7d24`](https://github.com/Pasta-Devs/Marinara-Agents/commit/52c7d24a66b0b372cc1a65d30bac41f6a3f5a4c1) fix(long-term-memory): narrow source-backed identity union accesses (#1026) ### 📊 Changes **13 files changed** (+403 additions, -137 deletions) <details> <summary>View changed files</summary> ➕ `artifacts/long-term-memory-1.3.11.zip` (+0 -0) 📝 `catalog/catalog.json` (+6 -6) 📝 `catalog/notes.json` (+6 -6) 📝 `catalog/v2/catalog.json` (+6 -6) 📝 `catalog/v2/notes.json` (+6 -6) 📝 `catalog/v3/catalog.json` (+6 -6) 📝 `catalog/v3/notes.json` (+6 -6) 📝 `packages/long-term-memory/CHANGELOG.md` (+4 -0) 📝 `packages/long-term-memory/manifest.json` (+3 -3) 📝 `packages/long-term-memory/server.mjs` (+59 -59) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/subject-identity.ts` (+119 -38) 📝 `scripts/build-feature-packages.mjs` (+1 -1) 📝 `tests/long-term-memory-local-characters.regression.ts` (+181 -0) </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`. ## Linked issue Closes #1026 ## Why this change - Long-Term Memory treated surface variants of the same name (`Ash`, `Ashleigh`, `Ashleigh Kestrel`, `Ashleigh Kestral`) as separate subjects, forking parallel character notes instead of canonicalizing them onto one trusted identity. - Keyless, source-backed NPC units could additionally select a fresh canonical note target even when the vault already had an established note for that identity, splitting memory across two notes. - Ambiguous short forms (for example `Ashley` matching more than one trusted record) needed to fail closed with the competing identities recorded instead of guessing. ## What changed - `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/subject-identity.ts` - Added a shared trusted-name relation matcher used by batch pre-resolution, on-demand resolution, and the keyless source-backed NPC path. - Unique relations reuse the trusted subject; multiple relations fail closed with collision diagnostics. - The keyless source-backed path now reuses an existing trusted/legacy note target via `chooseIdentityTarget(...)` before falling back to the canonical note ID, so it cannot fork a parallel note. - Fixed the accepted-path diagnostic to report the resolved entry name. - `tests/long-term-memory-local-characters.regression.ts`: variant canonicalization, ambiguous short-form rejection, keyless trusted-identity reuse, and keyless legacy-target reuse. - `packages/long-term-memory/CHANGELOG.md`: `1.3.11` entry. - Regenerated outputs: `packages/long-term-memory/server.mjs`, `manifest.json`, `artifacts/long-term-memory-1.3.11.zip`, and `catalog/{,v2/,v3/}{catalog,notes}.json`. ## Package and security impact - Affected package IDs: `long-term-memory` (`1.3.10` → `1.3.11`). - Engine compatibility impact: none; `engine.min` / `engine.maxExclusive` remain `2.4.1` / `4.0.0`. - New or changed permissions/entrypoints: none; the generated manifest changed only the version and the `server.mjs` hash/size in this PR. - Restart, storage, update, or uninstall impact: none expected. Installation, offline restart, backup inclusion, uninstall, and reinstall are covered by the LTM installation regression in `test-ltm.sh all`. ## 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 - Rebuilt the package from the committed source with `MARINARA_ENGINE_ROOT=/home/damo/dev/Marinara-Engine node scripts/build-feature-packages.mjs long-term-memory`; the working tree stayed clean afterwards, confirming the committed generated outputs match their source. - Ran the full LTM suite `test-ltm.sh all` on final HEAD: exit 0, including the local-character regression, the `1.3.11` install/restart/backup/uninstall/reinstall suite, routes, storage, and runtime regressions. - Ran the repository PR gate `test-ci.sh` on final HEAD: exit 0, including Prettier/ESLint, security, catalog, locale, lane, release-note, and PR-triage checks. - Captured and re-asserted publication proof against the tested inputs (HEAD `5474ebc5ed71b5a12358978bb19a2b935b92e38f`, clean tree, Engine checkout) with `assertPublishProof`; the second assertion matched the tested snapshot. - Checkboxes above are intentionally left unticked; they are a human verification list. ## Documentation impact - [ ] No documentation changes needed - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation ## UI evidence (if applicable) - Not applicable; no package UI changes in this PR. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Long-Term Memory recognizes short names, first-name-only forms, and minor spelling variations as the same trusted identity, reducing duplicate memories. - Ambiguous shared names fail safely and identify the competing matches. - Existing trusted or legacy note targets are reused instead of creating parallel identities. - **Release** - Updated the Long-Term Memory package to version 1.3.11. <!-- 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:54 +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#1255
No description provided.