[GH-ISSUE #1153] [Issue]: LTM activation aborts and rolls back when a vault note is schema-invalid #589

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

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

Originally assigned to: @Promansis on GitHub.

Summary

Long-Term Memory fails its activation self-check and rolls back to an old version when any vault note is schema-invalid. A legacy or malformed source note without provenance makes initializeLtmStore throw, so the package can never activate and the in-product repair path can never run.

Affected package

long-term-memory (LTM)

Expected behavior

A vault note that fails schema validation should be tolerated during activation and surfaced as a read error (as readAllNotesUnlocked already does), so LTM activates and the existing quarantine_malformed_notes repair action becomes reachable. Full reads may still surface the failure.

Actual behavior

selfCheck() -> initializeLtmStore() -> readLtmNoteSummary() -> rebuildLtmNoteSummary() hard-parses every vault note with parseStoredLtmNote. When the note-summary index is missing or invalid, the rebuild re-reads the whole vault, and the first type:"source" note without provenance throws:

ZodError: [{ code: "custom", path: ["provenance"], message: "Source notes must store import provenance." }]

The throw propagates out of CapabilityModuleRuntime.activateOne, so the package is rolled back (observed: long-term-memory@1.3.33 rolled back to 1.0.2020).

Steps to reproduce

  1. Have a vault note at packages/server/data/long-term-memory/vault/sources/<id>.json with "type": "source" and no provenance field.
  2. Ensure indexes/note-summary.json is absent so the summary rebuild runs.
  3. Start the Engine and activate Long-Term Memory.
  4. Observe the activation ZodError and rollback.

Minimal direct reproduction of the failing parse:

node_modules/.bin/tsx --tsconfig tests/tsconfig.regressions.json -e "import {parseStoredLtmNote} from './packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/stored-note.ts'"

Environment

  • Marinara Engine version: 2.4.x (staging)
  • Package version: long-term-memory@1.3.33
  • Install type: source
  • OS + version: Linux
  • Browser or app shell: n/a

Logs, screenshots, or video

ERROR: Failed to activate capability package long-term-memory@1.3.33
ZodError: [{ "code": "custom", "path": ["provenance"], "message": "Source notes must store import provenance." }]
  ...
  at CapabilityModuleRuntime.activateOne (.../capability-module-runtime.service.js:192:29)
WARN: Rolling capability package long-term-memory back to 1.0.2020

Additional context

The tolerance already exists for note listing (LongTermMemoryStorage.readAllNotesUnlocked collects malformed notes as errors) and maintenance.ts has a quarantine_malformed_notes repair action built on the tolerant parse. rebuildLtmNoteSummary bypasses that tolerance, which is the gap. vault-snapshot.ts documents that malformed notes should be picked up by a later quarantine/repair rather than replayed as a hard failure.

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 (Sep 30, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1153 Originally assigned to: @Promansis on GitHub. ## Summary Long-Term Memory fails its activation self-check and rolls back to an old version when any vault note is schema-invalid. A legacy or malformed `source` note without `provenance` makes `initializeLtmStore` throw, so the package can never activate and the in-product repair path can never run. ## Affected package `long-term-memory` (LTM) ## Expected behavior A vault note that fails schema validation should be tolerated during activation and surfaced as a read error (as `readAllNotesUnlocked` already does), so LTM activates and the existing `quarantine_malformed_notes` repair action becomes reachable. Full reads may still surface the failure. ## Actual behavior `selfCheck()` -> `initializeLtmStore()` -> `readLtmNoteSummary()` -> `rebuildLtmNoteSummary()` hard-parses every vault note with `parseStoredLtmNote`. When the note-summary index is missing or invalid, the rebuild re-reads the whole vault, and the first `type:"source"` note without `provenance` throws: ``` ZodError: [{ code: "custom", path: ["provenance"], message: "Source notes must store import provenance." }] ``` The throw propagates out of `CapabilityModuleRuntime.activateOne`, so the package is rolled back (observed: `long-term-memory@1.3.33` rolled back to `1.0.2020`). ## Steps to reproduce 1. Have a vault note at `packages/server/data/long-term-memory/vault/sources/<id>.json` with `"type": "source"` and no `provenance` field. 2. Ensure `indexes/note-summary.json` is absent so the summary rebuild runs. 3. Start the Engine and activate Long-Term Memory. 4. Observe the activation ZodError and rollback. Minimal direct reproduction of the failing parse: ``` node_modules/.bin/tsx --tsconfig tests/tsconfig.regressions.json -e "import {parseStoredLtmNote} from './packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/stored-note.ts'" ``` ## Environment - Marinara Engine version: 2.4.x (staging) - Package version: `long-term-memory@1.3.33` - Install type: source - OS + version: Linux - Browser or app shell: n/a ## Logs, screenshots, or video ``` ERROR: Failed to activate capability package long-term-memory@1.3.33 ZodError: [{ "code": "custom", "path": ["provenance"], "message": "Source notes must store import provenance." }] ... at CapabilityModuleRuntime.activateOne (.../capability-module-runtime.service.js:192:29) WARN: Rolling capability package long-term-memory back to 1.0.2020 ``` ## Additional context The tolerance already exists for note listing (`LongTermMemoryStorage.readAllNotesUnlocked` collects malformed notes as `errors`) and `maintenance.ts` has a `quarantine_malformed_notes` repair action built on the tolerant parse. `rebuildLtmNoteSummary` bypasses that tolerance, which is the gap. `vault-snapshot.ts` documents that malformed notes should be picked up by a later quarantine/repair rather than replayed as a hard failure. ## 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:50 +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#589
No description provided.