[PR #1333] [MERGED] fix(long-term-memory): 1.4.29 — robustness clean-up from the 1.4.8 audit (#1328) #1407

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

📋 Pull Request Information

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

Base: staging ← Head: fix(long-term-memory)/robustness-cleanup


📝 Commits (10+)

  • 5c62b6b fix(long-term-memory): evict the least recently seen rejected suggestion at the cap (#1328)
  • 4bc1b3b fix(long-term-memory): rebuild a stale recall index without quarantining it (#1328)
  • c7c0a6e fix(long-term-memory): redirect rejected suggestions when a repair merges notes (#1328)
  • ced493e fix(long-term-memory): keep the newest three repair backups and delete them with all data (#1328)
  • e66ec3e fix(long-term-memory): keep activation and recall working over damaged usage data and one invalid note (#1328)
  • 0e5d5d9 fix(long-term-memory): prove the stale-index rebuild skips an invalid note (#1328)
  • 61efba8 Merge upstream/staging into fix(long-term-memory)/robustness-cleanup
  • e1db385 fix(long-term-memory): skip only invalid notes in recall and cover repair backups in running lanes (#1328)
  • 4f5ffde fix(long-term-memory): keep the current repair backup on a tie and surface a failed usage quarantine (#1328)
  • 093ec9d Merge branch 'staging' into fix(long-term-memory)/robustness-cleanup

📊 Changes

25 files changed (+573 additions, -162 deletions)

View changed files

➕ artifacts/long-term-memory-1.4.29.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 (+53 -53)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/backup-restore.ts (+5 -2)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/identity-repair.ts (+5 -2)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/note-fork-repair.ts (+6 -2)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/rebuild.ts (+7 -3)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/rejected-suggestions.ts (+13 -2)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/retention.ts (+39 -0)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/runtime.ts (+0 -3)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/storage.ts (+46 -24)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/usage.ts (+16 -23)
📝 packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/vault-snapshot.ts (+6 -2)

...and 5 more files

📄 Description

Pull request

Linked issue

Closes #1328

Why this change

A re-check of the Long-Term Memory 1.4.8 architecture audit against 1.4.28 left five robustness gaps where one damaged or unexpected file, or accumulated bookkeeping, could break activation or recall, lose reviewer decisions, or leave data behind:

  • Repair backups piled up forever and survived "Delete all data".
  • The rejected-suggestion list refused new entries at its cap instead of evicting the oldest.
  • A single note with an unknown field (for example after a downgrade) or a damaged usage.json failed activation and every recall.
  • A merely out-of-date recall index was quarantined like a corrupt one, parking a full copy on every edit.
  • Merging notes in a repair left rejected suggestions pointing at ids that no longer exist.

Out of scope, per the issue: the settings unknown-field activation failure (pinned by the storage regression), non-JSON drafts in redirectReferences/renameNoteId, and the performance findings (separate issue after benchmarking).

What changed

One commit per fix (order differs from the issue numbering because the fix-1 test extends the block fix 5 creates), then follow-ups from self-review and CodeRabbit, and a merge of upstream/staging:

  1. Evict the least recently seen rejected suggestion at the cap. Entries with a saved identity decision and entries touched in the same call are never evicted; it throws only when nothing can be evicted.
  2. Rebuild a stale recall index without quarantining it; an unreadable index is still quarantined.
  3. Redirect rejected suggestions when an identity or fork repair merges notes, in the same mutation as the notes (shared with rename).
  4. Keep the newest three repair backups after each successful repair, and remove both repair-backup folders with "Delete all data".
  5. Activation no longer runs the receipt and usage validators; a malformed usage.json is quarantined and restarted from empty, and recall (index load and rebuild) skips invalid notes while full reads and writes still refuse to run over them.
  6. Regression proving the stale-index rebuild skips an invalid note, and a logger.debug argument-order fix.
  7. Recall's skipInvalid skips only files that were read but failed validation; an unreadable vault folder or file still fails the read. The repair-backup regression moved into the storage lane and an identity-repair prune case was added to the routes lane (both run by the LTM test runner), and the schema-invalid usage.json case is covered.
  8. Addressing CodeRabbit: a repair keeps its own backup when backup modification times tie, and a malformed usage.json that cannot be set aside surfaces the failure instead of being replaced by empty statistics.

Package: long-term-memory 1.4.28 -> 1.4.29 (CHANGELOG entry added). Generated outputs rebuilt from source with scripts/build-feature-packages.mjs long-term-memory: manifest, server.mjs, artifacts/long-term-memory-1.4.29.zip, catalog lanes. Rebuilding after the staging merge reproduces them byte for byte.

Known deviations: the prune helper lives in retention.ts; a failed repair leaves its backup until a later successful repair prunes.

Package and security impact

  • Affected package IDs: long-term-memory
  • Engine compatibility impact: none; engine.min / engine.maxExclusive unchanged
  • New or changed permissions/entrypoints: none
  • Restart, storage, update, or uninstall impact: repair-backup folders are now pruned and removed with "Delete all data"; a malformed usage.json is quarantined and restarted from empty

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

Automated runs on the pushed head (agent-run; not a substitute for the human checks above): test-ltm.sh all, the delta-review regression run directly, test-fast.sh, test-ci.sh, npm run typecheck:packages, the catalog/locale/release-notes/lane validators. Nothing was installed or exercised through a running Marinara Engine.

Documentation impact

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

UI evidence (if applicable)

None; no UI change.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Released Long-Term Memory version 1.4.29.
    • Suggestion processing can continue at its 10,000-item limit by replacing the least recently seen eligible suggestion, while preserving saved identity decisions.
    • Identity and fork repairs update references to surviving memories.
  • Bug Fixes
    • Malformed usage data and invalid notes are less likely to interrupt activation or recall of valid notes; writes still stop if the vault cannot be fully read.
    • Outdated recall indexes rebuild without creating unnecessary backup copies.
  • Improvements
    • Repair backups are limited to the three newest copies, and deleting all memory data also removes repair backups.

🔄 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/1333 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/12/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `fix(long-term-memory)/robustness-cleanup` --- ### 📝 Commits (10+) - [`5c62b6b`](https://github.com/Pasta-Devs/Marinara-Agents/commit/5c62b6b3cc89a11e28621c585549d9d8ed2fff30) fix(long-term-memory): evict the least recently seen rejected suggestion at the cap (#1328) - [`4bc1b3b`](https://github.com/Pasta-Devs/Marinara-Agents/commit/4bc1b3b0885bf460acea1624a90be047b080adcb) fix(long-term-memory): rebuild a stale recall index without quarantining it (#1328) - [`c7c0a6e`](https://github.com/Pasta-Devs/Marinara-Agents/commit/c7c0a6e11c5b28ce2b06a1d31340d04801c6410d) fix(long-term-memory): redirect rejected suggestions when a repair merges notes (#1328) - [`ced493e`](https://github.com/Pasta-Devs/Marinara-Agents/commit/ced493e44c486be731864b09517fff9e885dec5c) fix(long-term-memory): keep the newest three repair backups and delete them with all data (#1328) - [`e66ec3e`](https://github.com/Pasta-Devs/Marinara-Agents/commit/e66ec3ebbf8225e08402af8399cea4ca1acee9bf) fix(long-term-memory): keep activation and recall working over damaged usage data and one invalid note (#1328) - [`0e5d5d9`](https://github.com/Pasta-Devs/Marinara-Agents/commit/0e5d5d9df8f30edaf0059607cfd1854cf26a7904) fix(long-term-memory): prove the stale-index rebuild skips an invalid note (#1328) - [`61efba8`](https://github.com/Pasta-Devs/Marinara-Agents/commit/61efba864c3302d7edba411364fc5d7f3f365606) Merge upstream/staging into fix(long-term-memory)/robustness-cleanup - [`e1db385`](https://github.com/Pasta-Devs/Marinara-Agents/commit/e1db385231ba6f1052d7e42542afa3a164ef181f) fix(long-term-memory): skip only invalid notes in recall and cover repair backups in running lanes (#1328) - [`4f5ffde`](https://github.com/Pasta-Devs/Marinara-Agents/commit/4f5ffde7bee7189e7cbf80ffd5444b460e4ccd0d) fix(long-term-memory): keep the current repair backup on a tie and surface a failed usage quarantine (#1328) - [`093ec9d`](https://github.com/Pasta-Devs/Marinara-Agents/commit/093ec9d255b2a01f0d2a133e99f9aa7dbb51def1) Merge branch 'staging' into fix(long-term-memory)/robustness-cleanup ### 📊 Changes **25 files changed** (+573 additions, -162 deletions) <details> <summary>View changed files</summary> ➕ `artifacts/long-term-memory-1.4.29.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` (+53 -53) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/backup-restore.ts` (+5 -2) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/identity-repair.ts` (+5 -2) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/note-fork-repair.ts` (+6 -2) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/rebuild.ts` (+7 -3) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/rejected-suggestions.ts` (+13 -2) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/retention.ts` (+39 -0) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/runtime.ts` (+0 -3) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/storage.ts` (+46 -24) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/usage.ts` (+16 -23) 📝 `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/vault-snapshot.ts` (+6 -2) _...and 5 more files_ </details> ### 📄 Description # Pull request ## Linked issue Closes #1328 ## Why this change A re-check of the Long-Term Memory 1.4.8 architecture audit against 1.4.28 left five robustness gaps where one damaged or unexpected file, or accumulated bookkeeping, could break activation or recall, lose reviewer decisions, or leave data behind: - Repair backups piled up forever and survived "Delete all data". - The rejected-suggestion list refused new entries at its cap instead of evicting the oldest. - A single note with an unknown field (for example after a downgrade) or a damaged `usage.json` failed activation and every recall. - A merely out-of-date recall index was quarantined like a corrupt one, parking a full copy on every edit. - Merging notes in a repair left rejected suggestions pointing at ids that no longer exist. Out of scope, per the issue: the settings unknown-field activation failure (pinned by the storage regression), non-JSON drafts in `redirectReferences`/`renameNoteId`, and the performance findings (separate issue after benchmarking). ## What changed One commit per fix (order differs from the issue numbering because the fix-1 test extends the block fix 5 creates), then follow-ups from self-review and CodeRabbit, and a merge of `upstream/staging`: 1. Evict the least recently seen rejected suggestion at the cap. Entries with a saved identity decision and entries touched in the same call are never evicted; it throws only when nothing can be evicted. 2. Rebuild a stale recall index without quarantining it; an unreadable index is still quarantined. 3. Redirect rejected suggestions when an identity or fork repair merges notes, in the same mutation as the notes (shared with rename). 4. Keep the newest three repair backups after each successful repair, and remove both repair-backup folders with "Delete all data". 5. Activation no longer runs the receipt and usage validators; a malformed `usage.json` is quarantined and restarted from empty, and recall (index load and rebuild) skips invalid notes while full reads and writes still refuse to run over them. 6. Regression proving the stale-index rebuild skips an invalid note, and a `logger.debug` argument-order fix. 7. Recall's `skipInvalid` skips only files that were read but failed validation; an unreadable vault folder or file still fails the read. The repair-backup regression moved into the storage lane and an identity-repair prune case was added to the routes lane (both run by the LTM test runner), and the schema-invalid `usage.json` case is covered. 8. Addressing CodeRabbit: a repair keeps its own backup when backup modification times tie, and a malformed `usage.json` that cannot be set aside surfaces the failure instead of being replaced by empty statistics. Package: `long-term-memory` 1.4.28 -> 1.4.29 (CHANGELOG entry added). Generated outputs rebuilt from source with `scripts/build-feature-packages.mjs long-term-memory`: manifest, `server.mjs`, `artifacts/long-term-memory-1.4.29.zip`, catalog lanes. Rebuilding after the staging merge reproduces them byte for byte. Known deviations: the prune helper lives in `retention.ts`; a failed repair leaves its backup until a later successful repair prunes. ## Package and security impact - Affected package IDs: `long-term-memory` - Engine compatibility impact: none; `engine.min` / `engine.maxExclusive` unchanged - New or changed permissions/entrypoints: none - Restart, storage, update, or uninstall impact: repair-backup folders are now pruned and removed with "Delete all data"; a malformed `usage.json` is quarantined and restarted from empty ## 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 Automated runs on the pushed head (agent-run; not a substitute for the human checks above): `test-ltm.sh all`, the delta-review regression run directly, `test-fast.sh`, `test-ci.sh`, `npm run typecheck:packages`, the catalog/locale/release-notes/lane validators. Nothing was installed or exercised through a running Marinara Engine. ## Documentation impact - [ ] No documentation changes needed - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation ## UI evidence (if applicable) None; no UI change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Released Long-Term Memory version 1.4.29. * Suggestion processing can continue at its 10,000-item limit by replacing the least recently seen eligible suggestion, while preserving saved identity decisions. * Identity and fork repairs update references to surviving memories. * **Bug Fixes** * Malformed usage data and invalid notes are less likely to interrupt activation or recall of valid notes; writes still stop if the vault cannot be fully read. * Outdated recall indexes rebuild without creating unnecessary backup copies. * **Improvements** * Repair backups are limited to the three newest copies, and deleting all memory data also removes repair backups. <!-- 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:10:56 +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#1407
No description provided.