[GH-ISSUE #7043] [Issue]: Profile restores bypass the active LTM vault lock and cache invalidation #3942

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

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

Originally assigned to: @Promansis on GitHub.

Summary

Native profile restore publishes Long-Term Memory (LTM) vault files without coordinating with the active downloadable package. Its in-memory initialization/snapshot caches can continue describing the pre-restore vault, and package reads/rebuilds are not serialized with publication or rollback.

Expected behavior

When a profile import touches an active LTM vault, Engine should delegate coordination to the package's existing private withVaultMutation runtime-service hook. After success, the package should read the restored disk state; after failure, it should read the rolled-back state. No package operation should observe a partially published vault.

Actual behavior

importProfileStorageSnapshot stages assets, enters the profile lifecycle lock and database transaction, promotes the files, and rolls them back on failure. The backup asset set includes long-term-memory, but this path never invokes the LTM runtime hook. Filesystem rollback exists; package lock/cache coordination is missing.

Steps to reproduce

Helper-level reproduction previously exercised during investigation; a full browser/HTTP profile-import reproduction has not been run:

  1. Activate LTM storage, create a synthetic note, and read the vault to prime its validated snapshot.
  2. Use Engine's real profile asset staging and promotion helpers to publish different contents at that note's path while the package remains active.
  3. Read the note through the active package and directly from disk. The earlier fixture observed restored contents on disk but the old text in the package snapshot; Engine's asset rollback then restored the original disk contents.

Environment

  • Marinara Engine version: upstream staging, source inspected at 35621d44bbe7bf3336943e1076e4e8065a8b835a; no release-build reproduction claimed.
  • Install type: source inspection and earlier disposable helper fixtures, not an installer/container test.
  • OS + version: Linux investigation host; distribution/version not recorded.
  • Browser or app shell: not exercised.

Logs, screenshots, or video

No browser screenshots or full-route logs were collected. Earlier helper characterization confirmed disk publication, stale active snapshot text, and successful disk rollback. That historical fixture was not rerun for this filing; current upstream source still lacks the integration.

Current source references:

Additional context

Related package work: Marinara-Agents #1179, implemented by PR #1192. The runtime service already exposes withVaultMutation; this issue is the missing Engine caller.

Implementation boundary:

  • Keep Engine as a thin host adapter. Reuse the existing capability service; locking and initialization/snapshot invalidation remain package-owned. Do not add an Engine LTM cache or lock implementation.
  • Acquire the package vault lock before the outer database transaction and keep publication and rollback inside the same protected operation. Stage/validate the archive before taking the vault lock.
  • Preserve existing archive validation, database behavior, rollback errors and recovery files. Do not silently bypass coordination when an active older package lacks the hook: refuse unsafe live restore with a clear compatibility message. An inactive/uninstalled package must not unnecessarily block restore.
  • This can proceed independently of sidecar embedding-identity work. Fingerprint caching, vector reuse and unrelated cleanup are out of scope.

Persistence-sensitive validation required during implementation: active/inactive/older-package paths; successful publication; transaction/publication failure and rollback; rollback failure; concurrent recall/rebuild; lock ordering/release; cache invalidation on both success and error. Reuse the existing profile-import and capability-runtime regression infrastructure and run repository-required validation. None of these post-fix gates has been run for this filing.

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 4, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7043 Originally assigned to: @Promansis on GitHub. ## Summary Native profile restore publishes Long-Term Memory (LTM) vault files without coordinating with the active downloadable package. Its in-memory initialization/snapshot caches can continue describing the pre-restore vault, and package reads/rebuilds are not serialized with publication or rollback. ## Expected behavior When a profile import touches an active LTM vault, Engine should delegate coordination to the package's existing private `withVaultMutation` runtime-service hook. After success, the package should read the restored disk state; after failure, it should read the rolled-back state. No package operation should observe a partially published vault. ## Actual behavior `importProfileStorageSnapshot` stages assets, enters the profile lifecycle lock and database transaction, promotes the files, and rolls them back on failure. The backup asset set includes `long-term-memory`, but this path never invokes the LTM runtime hook. Filesystem rollback exists; package lock/cache coordination is missing. ## Steps to reproduce Helper-level reproduction previously exercised during investigation; a full browser/HTTP profile-import reproduction has not been run: 1. Activate LTM storage, create a synthetic note, and read the vault to prime its validated snapshot. 2. Use Engine's real profile asset staging and promotion helpers to publish different contents at that note's path while the package remains active. 3. Read the note through the active package and directly from disk. The earlier fixture observed restored contents on disk but the old text in the package snapshot; Engine's asset rollback then restored the original disk contents. ## Environment - Marinara Engine version: upstream `staging`, source inspected at `35621d44bbe7bf3336943e1076e4e8065a8b835a`; no release-build reproduction claimed. - Install type: source inspection and earlier disposable helper fixtures, not an installer/container test. - OS + version: Linux investigation host; distribution/version not recorded. - Browser or app shell: not exercised. ## Logs, screenshots, or video No browser screenshots or full-route logs were collected. Earlier helper characterization confirmed disk publication, stale active snapshot text, and successful disk rollback. That historical fixture was not rerun for this filing; current upstream source still lacks the integration. Current source references: - [Profile import transaction, publication and rollback](https://github.com/Pasta-Devs/Marinara-Engine/blob/35621d44bbe7bf3336943e1076e4e8065a8b835a/packages/server/src/routes/backup.routes.ts#L1292-L1391). - [Package hook implementation](https://github.com/Pasta-Devs/Marinara-Agents/blob/ef64aeb7b4d82a509ce70c98412f2ec89367913e/packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/runtime.ts#L42-L59). ## Additional context Related package work: [Marinara-Agents #1179](https://github.com/Pasta-Devs/Marinara-Agents/issues/1179), implemented by [PR #1192](https://github.com/Pasta-Devs/Marinara-Agents/pull/1192). The runtime service already exposes `withVaultMutation`; this issue is the missing Engine caller. Implementation boundary: - Keep Engine as a thin host adapter. Reuse the existing capability service; locking and initialization/snapshot invalidation remain package-owned. Do not add an Engine LTM cache or lock implementation. - Acquire the package vault lock before the outer database transaction and keep publication and rollback inside the same protected operation. Stage/validate the archive before taking the vault lock. - Preserve existing archive validation, database behavior, rollback errors and recovery files. Do not silently bypass coordination when an active older package lacks the hook: refuse unsafe live restore with a clear compatibility message. An inactive/uninstalled package must not unnecessarily block restore. - This can proceed independently of sidecar embedding-identity work. Fingerprint caching, vector reuse and unrelated cleanup are out of scope. Persistence-sensitive validation required during implementation: active/inactive/older-package paths; successful publication; transaction/publication failure and rollback; rollback failure; concurrent recall/rebuild; lock ordering/release; cache invalidation on both success and error. Reuse the existing profile-import and capability-runtime regression infrastructure and run repository-required validation. None of these post-fix gates has been run for this filing. ## 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-21 06:08: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-Engine#3942
No description provided.