[PR #1517] [MERGED] fix(long-term-memory): send each extraction rule once and stop asking the model for server-owned values (1.4.65) #1525

Closed
opened 2026-10-22 04:03:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: staging ← Head: fix(long-term-memory)/extraction-envelope


📝 Commits (5)

  • d602e28 fix(long-term-memory): send each extraction rule once and stop asking the model for server-owned values (#1512)
  • a934fdf chore(long-term-memory): release 1.4.60 (#1512)
  • 0363646 Merge upstream/staging into fix(long-term-memory)/extraction-envelope; release long-term-memory 1.4.65
  • 720802d fix(long-term-memory): name an imported card's character as the Vault lists it
  • 9dee5a7 fix(long-term-memory): write a listed character's name exactly as trustedSubjects lists it

📊 Changes

16 files changed (+248 additions, -170 deletions)

View changed files

➕ artifacts/long-term-memory-1.4.65.zip (+0 -0)
📝 catalog/catalog.json (+8 -8)
📝 catalog/notes.json (+6 -6)
📝 catalog/v2/catalog.json (+8 -8)
📝 catalog/v2/notes.json (+6 -6)
📝 catalog/v3/catalog.json (+8 -8)
📝 catalog/v3/notes.json (+6 -6)
📝 packages/long-term-memory/CHANGELOG.md (+4 -0)
📝 packages/long-term-memory/client.js (+4 -4)
📝 packages/long-term-memory/manifest.json (+5 -5)
📝 packages/long-term-memory/server.mjs (+35 -35)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/extraction/evidence-unit-extraction.ts (+19 -55)
📝 packages/long-term-memory/src/engine/packages/shared/src/features/agents/long-term-memory/constants.ts (+3 -10)
📝 scripts/build-feature-packages.mjs (+1 -1)
📝 tests/long-term-memory-extraction-graph.regression.ts (+120 -7)
📝 tests/long-term-memory-routes.regression.ts (+15 -11)

📄 Description

Pull request

Linked issue

Closes #1512

Why this change

  • Every extraction request sent the link rules three times (system prompt, validationRules, targetNoteRules), asked the model to copy sourceHash and the source evidence that the server sets anyway, and sent keys no rule reads, including the scope's chat, character and persona ids. About 17–19% of Claude Haiku's answer text was copied hash and evidence.
  • A unit with evidence: [], title: "" or a null optional field was dropped as malformed.
  • A provider without response_format never saw the link object shape, and the relation list left out extracted_from.

What changed

  • long-term-memory: each server link rule is stated once, in the system message. The request no longer carries validationRules, requiredEvidence, scope, modes, allowedStatuses, allowedImportance, streamAllowedStatuses, streamScanOrder or the source note's status, tags, evidence and hash. allowedLinkRelations lists all 12 relations. The links field describes {"target", "relation"}. The "change" rule says the event must be in the same response.
  • An imported character card gets one system line saying it describes the character, not the chat: its backstory is recorded as static facts, not timeline events, and its scenario does not become a thread, and the card's character is named exactly as trustedSubjects lists it. The card's tags and evidence that used to hint at this are no longer sent.
  • The general naming rule asks for a listed character's name or alias exactly as trustedSubjects lists it; other names are still copied from the source text. The resolver matches a listed name before its source-visibility check, so a listed name is accepted where the text uses a longer form.
  • The mode prompts drop the evidence and sourceHash lines; the roleplay return line names summary and units.
  • The server treats top-level null fields as absent, a blank title as absent, and always sets evidence to the trusted source evidence. The provider schema no longer has evidence.
  • Each request is 2,862–3,466 characters shorter on real sources (mean 3,097, about 775 tokens). In a live test on 15 sources, Haiku's answers were 233 → 184 visible tokens per unit, and answers over the 8,192-token default fell from 6 to 2–3 of 15.
  • Tests: extraction-graph asserts each rule once, the removed keys and ids, the link shape and relations, the parser cases for empty evidence, a blank title and null fields and the schema; routes' fixture model keys on summary text, the imports scenario's imported summary is now current, and the rejected-suggestion count drops from 11 to 4: 8 rejections came from the fixture's fixed evidence string, and of those units 7 are now kept and 1 is rejected for its link.
  • Generated outputs rebuilt: packages/long-term-memory bundles, artifact and catalog entry.
  • Release: long-term-memory 1.4.65 on staging f260dd3d7, with the CHANGELOG entry, version, manifest, rebuilt client.js and server.mjs, artifact and catalog entries.

Package and security impact

  • Affected package IDs: long-term-memory
  • Engine compatibility impact: none
  • New or changed permissions/entrypoints: none
  • Restart, storage, update, or uninstall impact: none.
  • Security-sensitive: executable server code and the provider prompt contract.
    • Sent to the provider: less. No scope ids (chat, group, character, persona), no source note status, tags, evidence or hash, no requiredEvidence.
    • Asked of the provider: no sourceHash or evidence. The response schema loses evidence; additionalProperties: false is unchanged and subjectNames stays required when names are resolved.
    • Server-owned values: sourceHash was already overwritten; evidence is now always the trusted source evidence (source_note:<id> plus the source's own evidence), so a provider can no longer add its own strings.
    • Input handling: a top-level null is treated as an omitted field (defaults apply: claimKind change, importance moderate, links and keywords []); a blank title is omitted. Nothing else is coerced; wrong types, bad identifiers, unknown buckets and invalid links are still rejected by the same schemas, and every link rule is still enforced after the answer.
    • Compatibility: a custom prompt template that refers to requiredEvidence, sourceHash or validationRules names keys that are no longer sent; whatever the model returns for them is replaced by the server.
    • Not run live: the schema path (openai, google, local sidecar with response_format). The live checks used claude -p without a schema.

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

  • Live before/after on 15 sources of a private vault with claude-haiku-5-5 and claude-sonnet-5-5 through claude -p (no response schema), under pass rules written before the runs. Sonnet passed; a three-run Haiku re-check passed every rule. Only aggregate counts are shared (issue).
  • Imported character cards and lorebook entries lose their source-kind tags and evidence. A synthetic Haiku check (one card, one lorebook with 3 entries, 3 runs per side, same rules) passed every rule. Without the hints Haiku turned the card's backstory into an event and its scenario into a thread in all 3 runs; with the card rule line it did neither in 3 runs, and still passed every rule.
  • Real character cards from a real install (7 cards: one is over the 24,000-character import limit on both sides, two have no character facts), claude-haiku-5-5 through claude -p, staging f260dd3d7 against this branch, pass rules written before each run. Without the naming rules, the card with a one-word name lost its character's facts to a name variant (untrusted_subject_identity) in 3 of 6 runs, against 0 of 6 on staging. With them: 0 of 6 on that card, 0 of 3 on another, and no timeline event or thread from any card in 15 runs (staging: 7 of 24 runs). Of two cards whose long titles the text never uses (a pre-existing loss on staging, 3 of 3 runs each), one now keeps its facts in 3 of 3 runs and the other still loses them. Kept units, parser and validation rejections and link drops stayed within staging's range.
  • Real roster: unknown-character drops on three real chat summaries (one conversation, two roleplay) with that install's character and persona roster, 3 runs per side, same model and method. Before the general naming rule this branch dropped 12-20 units per run against staging's 5-13, because it wrote listed names with extra words; with it, 6-8 per run, and the other rejections, kept units and link drops stayed within staging's range. Known limit: on one roleplay source every run finds one relationship between two listed characters that staging never extracts, writes the second name with extra words, and drops it. That fails the rule written before the runs (no listed character newly dropped), though nothing staging keeps is lost.

Documentation impact

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

UI evidence (if applicable)

Not applicable (server only).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Long-Term Memory updated to version 1.4.65.
    • Character-card imports are interpreted more clearly as character sheets, using exact character names.
    • Suggested memories are retained when optional fields are empty.
  • Improvements
    • Memory extraction requests are shorter and contain less repeated metadata.
    • Evidence and timeline relationships are handled more consistently.
    • Import extraction status and identity handling are more accurate.
  • Documentation
    • Added release notes for the Long-Term Memory 1.4.65 update.

🔄 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/1517 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 10/21/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `fix(long-term-memory)/extraction-envelope` --- ### 📝 Commits (5) - [`d602e28`](https://github.com/Pasta-Devs/Marinara-Agents/commit/d602e2839ce6d385a710134e216e03114088cb6b) fix(long-term-memory): send each extraction rule once and stop asking the model for server-owned values (#1512) - [`a934fdf`](https://github.com/Pasta-Devs/Marinara-Agents/commit/a934fdfc2c235869b021a26f62a93cfb1eb8ab7f) chore(long-term-memory): release 1.4.60 (#1512) - [`0363646`](https://github.com/Pasta-Devs/Marinara-Agents/commit/0363646dbbb8b34c915a5baed97e37480f6dc0f8) Merge upstream/staging into fix(long-term-memory)/extraction-envelope; release long-term-memory 1.4.65 - [`720802d`](https://github.com/Pasta-Devs/Marinara-Agents/commit/720802d48dbf4b2f8ec85ee71c376bf705aa3e75) fix(long-term-memory): name an imported card's character as the Vault lists it - [`9dee5a7`](https://github.com/Pasta-Devs/Marinara-Agents/commit/9dee5a7ee680fdd4979531e57b76ff4e630b5bcc) fix(long-term-memory): write a listed character's name exactly as trustedSubjects lists it ### 📊 Changes **16 files changed** (+248 additions, -170 deletions) <details> <summary>View changed files</summary> ➕ `artifacts/long-term-memory-1.4.65.zip` (+0 -0) 📝 `catalog/catalog.json` (+8 -8) 📝 `catalog/notes.json` (+6 -6) 📝 `catalog/v2/catalog.json` (+8 -8) 📝 `catalog/v2/notes.json` (+6 -6) 📝 `catalog/v3/catalog.json` (+8 -8) 📝 `catalog/v3/notes.json` (+6 -6) 📝 `packages/long-term-memory/CHANGELOG.md` (+4 -0) 📝 `packages/long-term-memory/client.js` (+4 -4) 📝 `packages/long-term-memory/manifest.json` (+5 -5) 📝 `packages/long-term-memory/server.mjs` (+35 -35) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/extraction/evidence-unit-extraction.ts` (+19 -55) 📝 `packages/long-term-memory/src/engine/packages/shared/src/features/agents/long-term-memory/constants.ts` (+3 -10) 📝 `scripts/build-feature-packages.mjs` (+1 -1) 📝 `tests/long-term-memory-extraction-graph.regression.ts` (+120 -7) 📝 `tests/long-term-memory-routes.regression.ts` (+15 -11) </details> ### 📄 Description # Pull request ## Linked issue Closes #1512 ## Why this change - Every extraction request sent the link rules three times (system prompt, `validationRules`, `targetNoteRules`), asked the model to copy `sourceHash` and the source evidence that the server sets anyway, and sent keys no rule reads, including the scope's chat, character and persona ids. About 17–19% of Claude Haiku's answer text was copied hash and evidence. - A unit with `evidence: []`, `title: ""` or a `null` optional field was dropped as malformed. - A provider without `response_format` never saw the link object shape, and the relation list left out `extracted_from`. ## What changed - `long-term-memory`: each server link rule is stated once, in the system message. The request no longer carries `validationRules`, `requiredEvidence`, `scope`, `modes`, `allowedStatuses`, `allowedImportance`, `streamAllowedStatuses`, `streamScanOrder` or the source note's status, tags, evidence and hash. `allowedLinkRelations` lists all 12 relations. The links field describes `{"target", "relation"}`. The "change" rule says the event must be in the same response. - An imported character card gets one system line saying it describes the character, not the chat: its backstory is recorded as static facts, not timeline events, and its scenario does not become a thread, and the card's character is named exactly as `trustedSubjects` lists it. The card's tags and evidence that used to hint at this are no longer sent. - The general naming rule asks for a listed character's name or alias exactly as `trustedSubjects` lists it; other names are still copied from the source text. The resolver matches a listed name before its source-visibility check, so a listed name is accepted where the text uses a longer form. - The mode prompts drop the evidence and `sourceHash` lines; the roleplay return line names `summary` and `units`. - The server treats top-level `null` fields as absent, a blank title as absent, and always sets `evidence` to the trusted source evidence. The provider schema no longer has `evidence`. - Each request is 2,862–3,466 characters shorter on real sources (mean 3,097, about 775 tokens). In a live test on 15 sources, Haiku's answers were 233 → 184 visible tokens per unit, and answers over the 8,192-token default fell from 6 to 2–3 of 15. - Tests: extraction-graph asserts each rule once, the removed keys and ids, the link shape and relations, the parser cases for empty evidence, a blank title and null fields and the schema; routes' fixture model keys on summary text, the imports scenario's imported summary is now `current`, and the rejected-suggestion count drops from 11 to 4: 8 rejections came from the fixture's fixed evidence string, and of those units 7 are now kept and 1 is rejected for its link. - Generated outputs rebuilt: `packages/long-term-memory` bundles, artifact and catalog entry. - **Release:** `long-term-memory` 1.4.65 on staging f260dd3d7, with the CHANGELOG entry, version, manifest, rebuilt `client.js` and `server.mjs`, artifact and catalog entries. ## Package and security impact - Affected package IDs: `long-term-memory` - Engine compatibility impact: none - New or changed permissions/entrypoints: none - Restart, storage, update, or uninstall impact: none. - Security-sensitive: executable server code and the provider prompt contract. - Sent to the provider: less. No scope ids (chat, group, character, persona), no source note status, tags, evidence or hash, no `requiredEvidence`. - Asked of the provider: no `sourceHash` or `evidence`. The response schema loses `evidence`; `additionalProperties: false` is unchanged and `subjectNames` stays required when names are resolved. - Server-owned values: `sourceHash` was already overwritten; `evidence` is now always the trusted source evidence (`source_note:<id>` plus the source's own evidence), so a provider can no longer add its own strings. - Input handling: a top-level `null` is treated as an omitted field (defaults apply: `claimKind` `change`, `importance` `moderate`, `links` and `keywords` `[]`); a blank title is omitted. Nothing else is coerced; wrong types, bad identifiers, unknown buckets and invalid links are still rejected by the same schemas, and every link rule is still enforced after the answer. - Compatibility: a custom prompt template that refers to `requiredEvidence`, `sourceHash` or `validationRules` names keys that are no longer sent; whatever the model returns for them is replaced by the server. - Not run live: the schema path (openai, google, local sidecar with `response_format`). The live checks used `claude -p` without a schema. ## 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 - Live before/after on 15 sources of a private vault with `claude-haiku-5-5` and `claude-sonnet-5-5` through `claude -p` (no response schema), under pass rules written before the runs. Sonnet passed; a three-run Haiku re-check passed every rule. Only aggregate counts are shared (issue). - Imported character cards and lorebook entries lose their source-kind tags and evidence. A synthetic Haiku check (one card, one lorebook with 3 entries, 3 runs per side, same rules) passed every rule. Without the hints Haiku turned the card's backstory into an event and its scenario into a thread in all 3 runs; with the card rule line it did neither in 3 runs, and still passed every rule. - Real character cards from a real install (7 cards: one is over the 24,000-character import limit on both sides, two have no character facts), `claude-haiku-5-5` through `claude -p`, staging f260dd3d7 against this branch, pass rules written before each run. Without the naming rules, the card with a one-word name lost its character's facts to a name variant (`untrusted_subject_identity`) in 3 of 6 runs, against 0 of 6 on staging. With them: 0 of 6 on that card, 0 of 3 on another, and no timeline event or thread from any card in 15 runs (staging: 7 of 24 runs). Of two cards whose long titles the text never uses (a pre-existing loss on staging, 3 of 3 runs each), one now keeps its facts in 3 of 3 runs and the other still loses them. Kept units, parser and validation rejections and link drops stayed within staging's range. - Real roster: unknown-character drops on three real chat summaries (one conversation, two roleplay) with that install's character and persona roster, 3 runs per side, same model and method. Before the general naming rule this branch dropped 12-20 units per run against staging's 5-13, because it wrote listed names with extra words; with it, 6-8 per run, and the other rejections, kept units and link drops stayed within staging's range. Known limit: on one roleplay source every run finds one relationship between two listed characters that staging never extracts, writes the second name with extra words, and drops it. That fails the rule written before the runs (no listed character newly dropped), though nothing staging keeps is lost. ## Documentation impact - [ ] No documentation changes needed - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation ## UI evidence (if applicable) Not applicable (server only). 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Long-Term Memory updated to version 1.4.65. * Character-card imports are interpreted more clearly as character sheets, using exact character names. * Suggested memories are retained when optional fields are empty. * **Improvements** * Memory extraction requests are shorter and contain less repeated metadata. * Evidence and timeline relationships are handled more consistently. * Import extraction status and identity handling are more accurate. * **Documentation** * Added release notes for the Long-Term Memory 1.4.65 update. <!-- 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-22 04:03:06 +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#1525
No description provided.