[GH-ISSUE #1179] [Issue]: Long-Term Memory: invalidate quarantined notes and expose private vault-mutation hooks #603

Closed
opened 2026-10-20 17:28:57 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Oct 1, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1179

Originally assigned to: @Promansis on GitHub.

Summary

Official malformed-note quarantine can leave a previously healthy vault snapshot and recall index serving the quarantined note. The package also lacks a private runtime boundary through which an Engine-owned profile import can coordinate active-vault publication and cache reset; this issue fixes quarantine invalidation and prepares that package-owned boundary only.

Affected package

long-term-memory (Long-Term Memory), package-owned server maintenance, storage caches, and runtime-service registration. This is the safety prerequisite for later A6 fingerprint caching, not the caching implementation itself.

Expected behavior

  • A successful official quarantine must invalidate the cached vault snapshot under the vault lock. The next full read and recall must exclude quarantined notes and their text.
  • Keep the existing malformed-note policy: a full read surfaces malformed-note errors until official maintenance resolves them; do not silently accept malformed content or weaken typed-folder validation.
  • Expose a narrow private method on long-term-memory:runtime that lets a trusted host operation execute within the existing vault lock and reset package-owned initialization/snapshot caches around publication and rollback.
  • Hold serialization across the complete supplied mutation operation, including its rollback. Clear the relevant caches before releasing the lock after either success or failure, and preserve the operation's return value or error.
  • Keep the existing runtime recall and recordPromptAccepted methods compatible. This is not a public HTTP filesystem-mutation endpoint or a new permission grant.

Actual behavior

  • After warming a healthy two-note snapshot, replacing one note file with malformed JSON, and running repairLongTermMemory(["quarantine_malformed_notes"], root), maintenance quarantines one file but the cached list and rebuilt/loaded recall index still contain that note.
  • server-entry.ts currently registers only recall and recordPromptAccepted on long-term-memory:runtime; there is no coordinated host vault-mutation/cache-reset method.
  • A separate fixture using the actual Engine profile-asset stage/publication/rollback helpers confirmed that publication replaces note bytes while the active package continues returning the old cached text. The subsequent rollback restores disk bytes. This is asset-helper proof, not proof of the full profile-import HTTP/database transaction.

Steps to reproduce

  1. Activate the package against a disposable vault. Create two synthetic notes, build the recall index, and call storage.listNotes() to warm a healthy snapshot.
  2. Replace one note's JSON with {, then invoke official repairLongTermMemory(["quarantine_malformed_notes"], root). Confirm that the quarantine action reports one affected file.
  3. Call storage.listNotes() and loadOrRebuildLongTermMemoryIndexes(root, null, []). Both still contain the quarantined note. Clearing the store/snapshot cache removes it from subsequent reads.

Environment

  • Marinara Engine version: 2.4.6, source checkout 227e3e12c87a55c40074413f1f32e57d732217da.
  • Package version: 1.3.34; Agents checkout d5bd5c2a8b17503df2b4145869f5d5dade684217. The package-owned server/shared trees also match upstream staging at 2336c3ca59f743f6c03afe9c574c0cdaab8ddc9f.
  • Install type: source-module/runtime fixture; not an installed ZIP-package test.
  • OS + version: Linux; exact distribution/version not captured.
  • Browser or app shell: not applicable; Node v24.15.0, installed tsx 4.23.13.

Logs, screenshots, or video

Observed output from disposable fixtures:

{"case":"maintenance-quarantine","cachedQuarantinedNote":true,"indexedQuarantinedNote":true}
{"case":"core-profile-asset-publication","actualStagePublishRollbackHelpers":true,"diskReplacedWhileActiveSnapshotStayedOld":true,"rollbackRestoredDisk":true,"coverage":"asset-helper boundary, not full import HTTP/transaction"}

Current-behavior characterization exited 0. Separate desired-invariant runs exited 1 with:

Official quarantine must invalidate a previously healthy cached scan
true !== false

Core profile asset publication must invalidate the active vault snapshot before recall resumes
actual: 'Observatory revised brass telescope.'
expected: 'Replacement from a core profile asset.'

The second failure is evidence for the follow-up Engine integration; it is not a promise that this package-only issue repairs the Engine import route. No private chat data or real provider/model calls were used.

Additional context

Dependencies and ownership

  • Depends on https://github.com/Pasta-Devs/Marinara-Agents/issues/1178 for the shared vault/index lifecycle foundation.
  • Implement this issue against Agents staging, without Engine source edits or private Engine imports.
  • Primary owners: packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/{maintenance,vault-snapshot,storage,server-entry}.ts; inspect package restore/recovery helpers to reuse the existing reset behavior rather than creating a second cache system.
  • Package owns locking, cache invalidation, and the private runtime service. Engine owns database transactions and profile asset publication/rollback.
  • A separate future Engine issue must acquire this boundary before its import transaction/publication, keep it through rollback, and handle active older packages that lack the method without silently performing unsafe hot restoration.
  • Merely exporting the method does not make existing Engine hot imports safe. Do not claim that guarantee or broaden compatibility metadata until the coordinated Engine integration is validated.

Scope limits

  • Fix official quarantine invalidation and expose only the narrow trusted-host vault-mutation/reset boundary needed by profile import.
  • Reuse the existing reentrant vault lock and package-owned cache reset mechanisms. Do not add a filesystem watcher, polling, arbitrary external-edit support, or a public mutation endpoint.
  • Do not implement A6 fingerprint caching, A18 vector reuse, sidecar identity, Engine import-route changes, or A21 configuration-save rebuild notification in this issue.
  • Preserve normal note mutations, package backup restore/recovery, malformed-note safeguards, and existing runtime registration/cleanup semantics. Package activation/uninstall must not leave a callable stale mutation hook.

Validation plan

  • Warm a healthy snapshot/index, quarantine a malformed note through official maintenance, then verify that full reads and recall no longer contain its ID or text without restarting the package.
  • Verify that unresolved malformed notes still fail full reads while unrelated typed-folder reads retain their documented behavior.
  • Exercise the private runtime hook with successful publication and a failing publication plus rollback; verify cache reload, original return/error propagation, and lock release on both paths.
  • Prove concurrent recall/read/mutation cannot observe a partially published vault; after rollback it must see restored disk state rather than imported or pre-reset cached data.
  • Cover initialization/snapshot reset, ordinary mutations, package backup restore/recovery, and service activation/cleanup; run affected storage, runtime, maintenance, and backup-route regressions.
  • Run repository-required validation and rebuild/validate the package and generated catalog outputs from source before publication.

Proof above is characterization, not repaired behavior or release validation. Installed dependencies differ from the repository's pins; install locked dependencies in the implementation workspace before claiming repository gates. Full Engine profile-import HTTP/transaction integration, installed-package/browser behavior, and the future caching feature remain outside this issue's proof claim.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Oct 1, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1179 Originally assigned to: @Promansis on GitHub. ## Summary Official malformed-note quarantine can leave a previously healthy vault snapshot and recall index serving the quarantined note. The package also lacks a private runtime boundary through which an Engine-owned profile import can coordinate active-vault publication and cache reset; this issue fixes quarantine invalidation and prepares that package-owned boundary only. ## Affected package `long-term-memory` (Long-Term Memory), package-owned server maintenance, storage caches, and runtime-service registration. This is the safety prerequisite for later A6 fingerprint caching, not the caching implementation itself. ## Expected behavior - A successful official quarantine must invalidate the cached vault snapshot under the vault lock. The next full read and recall must exclude quarantined notes and their text. - Keep the existing malformed-note policy: a full read surfaces malformed-note errors until official maintenance resolves them; do not silently accept malformed content or weaken typed-folder validation. - Expose a narrow private method on `long-term-memory:runtime` that lets a trusted host operation execute within the existing vault lock and reset package-owned initialization/snapshot caches around publication and rollback. - Hold serialization across the complete supplied mutation operation, including its rollback. Clear the relevant caches before releasing the lock after either success or failure, and preserve the operation's return value or error. - Keep the existing runtime `recall` and `recordPromptAccepted` methods compatible. This is not a public HTTP filesystem-mutation endpoint or a new permission grant. ## Actual behavior - After warming a healthy two-note snapshot, replacing one note file with malformed JSON, and running `repairLongTermMemory(["quarantine_malformed_notes"], root)`, maintenance quarantines one file but the cached list and rebuilt/loaded recall index still contain that note. - `server-entry.ts` currently registers only `recall` and `recordPromptAccepted` on `long-term-memory:runtime`; there is no coordinated host vault-mutation/cache-reset method. - A separate fixture using the actual Engine profile-asset stage/publication/rollback helpers confirmed that publication replaces note bytes while the active package continues returning the old cached text. The subsequent rollback restores disk bytes. This is asset-helper proof, not proof of the full profile-import HTTP/database transaction. ## Steps to reproduce 1. Activate the package against a disposable vault. Create two synthetic notes, build the recall index, and call `storage.listNotes()` to warm a healthy snapshot. 2. Replace one note's JSON with `{`, then invoke official `repairLongTermMemory(["quarantine_malformed_notes"], root)`. Confirm that the quarantine action reports one affected file. 3. Call `storage.listNotes()` and `loadOrRebuildLongTermMemoryIndexes(root, null, [])`. Both still contain the quarantined note. Clearing the store/snapshot cache removes it from subsequent reads. ## Environment - Marinara Engine version: `2.4.6`, source checkout `227e3e12c87a55c40074413f1f32e57d732217da`. - Package version: `1.3.34`; Agents checkout `d5bd5c2a8b17503df2b4145869f5d5dade684217`. The package-owned server/shared trees also match upstream `staging` at `2336c3ca59f743f6c03afe9c574c0cdaab8ddc9f`. - Install type: source-module/runtime fixture; not an installed ZIP-package test. - OS + version: Linux; exact distribution/version not captured. - Browser or app shell: not applicable; Node `v24.15.0`, installed `tsx` `4.23.13`. ## Logs, screenshots, or video Observed output from disposable fixtures: ```json {"case":"maintenance-quarantine","cachedQuarantinedNote":true,"indexedQuarantinedNote":true} {"case":"core-profile-asset-publication","actualStagePublishRollbackHelpers":true,"diskReplacedWhileActiveSnapshotStayedOld":true,"rollbackRestoredDisk":true,"coverage":"asset-helper boundary, not full import HTTP/transaction"} ``` Current-behavior characterization exited 0. Separate desired-invariant runs exited 1 with: ```text Official quarantine must invalidate a previously healthy cached scan true !== false Core profile asset publication must invalidate the active vault snapshot before recall resumes actual: 'Observatory revised brass telescope.' expected: 'Replacement from a core profile asset.' ``` The second failure is evidence for the follow-up Engine integration; it is not a promise that this package-only issue repairs the Engine import route. No private chat data or real provider/model calls were used. ## Additional context ### Dependencies and ownership - Depends on https://github.com/Pasta-Devs/Marinara-Agents/issues/1178 for the shared vault/index lifecycle foundation. - Implement this issue against Agents `staging`, without Engine source edits or private Engine imports. - Primary owners: `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/{maintenance,vault-snapshot,storage,server-entry}.ts`; inspect package restore/recovery helpers to reuse the existing reset behavior rather than creating a second cache system. - Package owns locking, cache invalidation, and the private runtime service. Engine owns database transactions and profile asset publication/rollback. - A separate future Engine issue must acquire this boundary before its import transaction/publication, keep it through rollback, and handle active older packages that lack the method without silently performing unsafe hot restoration. - Merely exporting the method does **not** make existing Engine hot imports safe. Do not claim that guarantee or broaden compatibility metadata until the coordinated Engine integration is validated. ### Scope limits - Fix official quarantine invalidation and expose only the narrow trusted-host vault-mutation/reset boundary needed by profile import. - Reuse the existing reentrant vault lock and package-owned cache reset mechanisms. Do not add a filesystem watcher, polling, arbitrary external-edit support, or a public mutation endpoint. - Do not implement A6 fingerprint caching, A18 vector reuse, sidecar identity, Engine import-route changes, or A21 configuration-save rebuild notification in this issue. - Preserve normal note mutations, package backup restore/recovery, malformed-note safeguards, and existing runtime registration/cleanup semantics. Package activation/uninstall must not leave a callable stale mutation hook. ### Validation plan - [ ] Warm a healthy snapshot/index, quarantine a malformed note through official maintenance, then verify that full reads and recall no longer contain its ID or text without restarting the package. - [ ] Verify that unresolved malformed notes still fail full reads while unrelated typed-folder reads retain their documented behavior. - [ ] Exercise the private runtime hook with successful publication and a failing publication plus rollback; verify cache reload, original return/error propagation, and lock release on both paths. - [ ] Prove concurrent recall/read/mutation cannot observe a partially published vault; after rollback it must see restored disk state rather than imported or pre-reset cached data. - [ ] Cover initialization/snapshot reset, ordinary mutations, package backup restore/recovery, and service activation/cleanup; run affected storage, runtime, maintenance, and backup-route regressions. - [ ] Run repository-required validation and rebuild/validate the package and generated catalog outputs from source before publication. Proof above is characterization, not repaired behavior or release validation. Installed dependencies differ from the repository's pins; install locked dependencies in the implementation workspace before claiming repository gates. Full Engine profile-import HTTP/transaction integration, installed-package/browser behavior, and the future caching feature remain outside this issue's proof claim. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:28:57 +07:00
  • closed this issue
  • added the
    bug
    label
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#603
No description provided.