mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #1328] [Issue]: Long-Term Memory: robustness clean-up from the 1.4.8 architecture audit #677
Labels
No labels
agent: chess
agent: conversation-calls
agent: eightball
agent: haptic
agent: hierarchical-maps
agent: hierarchical-maps
agent: illustrator
agent: poker
agent: rock-paper-scissors
agent: tic-tac-toe
agent: uno
artifacts
bug
bugfix
build
catalog
ci
client
dependencies
docs
documentation
enhancement
feature
fixed-in-staging
in-pr
normal-scope
packages
pull-request
qol
regression
roadmap
scope-risk
server
soup
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Agents#677
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Promansis on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1328
Originally assigned to: @Promansis on GitHub.
Summary
Five robustness fixes left over from a read-only architecture audit of Long-Term Memory 1.4.8, rechecked against 1.4.28:
usage.jsonor receipt file can stop recall or activation.None of these change recall scoring or extraction output. They ship together as one release, one commit per fix.
Affected package
long-term-memory1.4.28, underpackages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/:identity-repair.ts,note-fork-repair.ts,backup-restore.tsrejected-suggestions.tsruntime.ts,usage.ts,storage.ts,rebuild.tsExpected behavior
usage.jsonor injection receipt does not stop the package from activating or from recalling the other memories. Writes still refuse to run over a vault they cannot fully read.Actual behavior
createLtmIdentityRepairBackup(identity-repair.ts:167-185) andapplyLtmNoteForkRepair(note-fork-repair.ts:216-219) copy the whole memory folder into<dataDir>/backups/long-term-memory-{identity-repairs,forks}/<uuid>/. The copy only serves the rollback inside that call; nothing reads or prunes it afterwards.deleteAllLongTermMemoryData(backup-restore.ts:186) replaces the memory folder only, so these copies survive "Delete all data".addRejectedSuggestionsthrows "rejected-suggestion limit reached" once the file holds 10,000 entries (rejected-suggestions.ts:230-231). It runs from the draft store'safterWritehook (draft-store.ts:239), after the new draft is written and older drafts are superseded, so every later extraction that rejects anything fails until suggestions are deleted by hand.selfCheckvalidatesusage.jsonand every injection receipt at activation (runtime.ts:22-23). One malformed file stops activation, and the Engine rolls the package back (the failure class 1.3.34 fixed for vault notes).listNotes()(rebuild.ts:132,:211), which throws on the first note that fails validation (storage.ts:240-241).ltmNoteSchemais.strict(), so a note written by a newer version with one extra field makes recall fail on every turn after a downgrade, until maintenance quarantines the note.loadOrRebuildLongTermMemoryIndexessignals an out-of-date index by throwing "Stale long-term memory recall index." (rebuild.ts:216), and the sharedcatchquarantines it (rebuild.ts:230). Every memory edit followed by a recall moves a fullrecall.json(31 MB at 2,000 memories with 384-dimension vectors in the audit's measurement) intoquarantine/indexes/, where retention keeps it for 90 days.redirectReferences(storage.ts:735-816), used by identity repair and fork repair, rewrites links, section contributions and drafts but not rejected suggestions.renameNoteIddoes (storage.ts:900-915, viarewriteRejectedSuggestions). After a repair, a rejected suggestion whosesource.sourceNoteIdorcandidate.recovery.noteIdnamed the archived duplicate still names it.Steps to reproduce
<dataDir>/backups/long-term-memory-identity-repairs/(orlong-term-memory-forks/) still holds the old memory folder.config/rejected-suggestions.jsonto 10,000 entries, then import a source that produces one rejected candidate. The extraction fails with "rejected-suggestion limit reached", and keeps failing."futureField": trueto one vault note's JSON and send a chat turn: recall fails. Separately, writenot jsontoindexes/usage.jsonand restart: the package does not activate.quarantine/indexes/gains a full copy ofrecall.json.Environment
staging)upstream/stagingeea2a33f9)Logs, screenshots, or video
Not applicable; line references are against
eea2a33f9.Additional context
Minimal changes, one commit each:
pruneLtmRepairBackups(directory, keep = 3)helper besidegetLtmIdentityRepairBackupsRootthat removes all but the newestkeepbackup folders by mtime, like the quarantine sweep inretention.ts:93-100. Call it after a successfulapplyLtmIdentityRepairsandapplyLtmNoteForkRepair. IndeleteAllLongTermMemoryData, remove both backup folders after the replace succeeds. Regression (long-term-memory-storage.regression.ts): a fourth repair leaves three backups; Delete all data leaves none.addRejectedSuggestions, when a new entry would pass the limit, drop the least recently seen entries withoutidentityResolutioninstead of throwing; throw only when every entry holds a saved identity decision. Regression (long-term-memory-storage.regression.ts): at the limit, adding one evicts the oldest unresolved entry and keeps resolved entries.validateLongTermMemoryUsageandvalidateLongTermMemoryInjectionReceiptsfromselfCheckand delete both. A malformed receipt then only affects that chat's last-injection panel. InreadLongTermMemoryUsage, quarantine a malformedusage.jsonwith the existingquarantineLtmIndexArtifact(the file lives inindexes/) and start from empty; it only holds per-chat injection stats and the receipt de-duplication list.skipInvalidoption tolistNotesthat skips notes failing validation and logs how many, and use it only for the two recall-index reads inrebuild.ts. Every other full read, including every write, keeps throwing, so no mutation silently skips a memory. Vault health and maintenance already report and quarantine invalid notes.long-term-memory-storage.regression.ts,long-term-memory-runtime.regression.ts): activation succeeds with a malformed usage file and receipt; recall returns the valid memories while one note has an unknown field.loadOrRebuildLongTermMemoryIndexes, skipquarantineLtmIndexArtifactwhen the index parsed but itssourceHashis out of date; the rebuild's atomic write replaces it. An unreadable or malformed index is still quarantined. Regression (long-term-memory-runtime.regression.ts): a stale index rebuilds without adding toquarantine/indexes/; a corrupt one still does.renameNoteIdinto a shared helper, and callrewriteRejectedSuggestionsfromredirectReferencestoo, adding its file to the samecommitLtmMutation. Regression (long-term-memory-delta-review.regression.ts): after a fork repair, a rejected suggestion that named the archived note names the canonical note.Out of scope:
long-term-memory-storage.regression.ts:284-291pins that ("self-check must reject malformed settings"), so changing it needs its own decision.redirectReferencesandrenameNoteIdboth fail on a draft file that is not valid JSON. The repair rolls back from its backup, so nothing is lost.Template check