[GH-ISSUE #1541] [Issue]: Long-Term Memory: a failed background rebuild shows its raw error text in Vault health #1513

Closed
opened 2026-10-22 04:02:50 +07:00 by bsakaguchi · 0 comments
Owner

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

Originally assigned to: @Promansis on GitHub.

Summary

When a recall index rebuild fails, Long-Term Memory stores the raw error message in its index state, and GET /integrity and GET /status return it. Maintenance prints the integrity message as is, so a failed rebuild can put the vault's absolute path on screen, for example EISDIR: illegal operation on a directory, rename '/…/long-term-memory/indexes/recall.json.tmp-…' -> '/…/long-term-memory/indexes/recall.json'. The path includes the data folder and with it, usually, the OS user name.

The rest of the package already keeps an unexpected failure's text in the server log and sends fixed text to the client (routeError, rebuildAfterMutation, the scope-link rebuild). Since the debounced background rebuild (#1523), a failed rebuild after Accept no longer reaches the draft (Accept answers pending and the draft stores no error); it reaches the index state, which is the remaining gap.

One rebuild path does not log its failure at all: the index refresh the Engine runs after an embedding-connection change catches a failed rebuild and drops it.

Affected package

long-term-memory 1.4.72 (upstream/staging bcaebd07d), which has the debounced background rebuild. Line numbers below are on bcaebd07d (refreshed 2026-10-21; first checked on 8b72729f1).

  • S = packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory
  • C = packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory

Expected behavior

  • After a failed rebuild, /integrity and /status say that the latest index rebuild failed and to see the server log. They return no file paths or library messages.
  • The server log keeps the full error, on every rebuild path that the server log covers.
  • A cancelled rebuild (stopped on package deactivation) keeps its own short message, since nothing is logged for it.
  • The draft-accept response and the stored draft carry no rebuild error text (true today).

Actual behavior

  • Every failed rebuild ends in markLtmIndexesFailed (S/persistence/index-state.ts:209-218): the synchronous rebuild (S/recall/rebuild.ts:234) and each background attempt (:298). It stores error.message, up to 2,000 characters, in indexes/state.json.
  • GET /integrity returns it as the index_rebuild_failed issue's message (S/maintenance/maintenance.ts:185) whenever the recall index itself is readable. Maintenance shows each issue as {severity}: {message} (C/settings/MaintenancePanel.tsx:627).
  • GET /status returns it in indexes.warnings (S/routes/maintenance.ts:126). No client code reads warnings today; the health pill and Activity show rebuildState through localized labels.
  • refreshLongTermMemoryIndexes (S/recall/rebuild.ts:436) runs a rebuild for the new embedding source in a try whose catch (:445-447) rethrows only a cancellation; any other failure is dropped without a log line. The refresh then reports "could not embed the vault with the new embedding source" without the cause.
  • The other rebuild failures are logged: the background job (S/recall/rebuild-job.ts:46), rebuildAfterMutation, the scope-link rebuild, routeError (restore, identity repair), the Engine's error handler (POST /rebuild, POST /repair) and the Engine's recall. The three logger.warn ones keep their error in the log: the package's warn puts an error passed first into the message. Source extraction's inline index load records its failure in the package's debug log (shown in Activity) and on the Sources page instead, as it does for every extraction failure.

Steps to reproduce

  1. With a vault that has a built recall index, replace long-term-memory/indexes/recall.json in the Engine's data folder with an empty folder.
  2. In Memory Settings, save a change that rebuilds the index, for example a new stop word. The save succeeds and reports the rebuild as deferred.
  3. Call GET /api/long-term-memory/status. indexes.warnings is ["EISDIR: illegal operation on a directory, rename '<data folder>/long-term-memory/indexes/recall.json.tmp-…' -> '<data folder>/long-term-memory/indexes/recall.json'"].
  4. Put a readable recall.json back (the integrity check stops at an unreadable or missing index) and run the integrity check in Maintenance (GET /api/long-term-memory/integrity). The index_rebuild_failed issue shows the same text with both absolute paths.

A background rebuild after Accept that fails on the disk the same way ends in the same function and stores its error the same way.

Minimal fix

One PR, patch bump. Two source files. The new text sends users to the server log, and the warnings that log a failed rebuild now carry the cause (the fix for warnings dropping their cause is already in).

  • In markLtmIndexesFailed, store "The latest index rebuild failed; see the server log." for any failure, except a cancellation (AbortError), which keeps its own message ("This operation was aborted"). Both routes then serve the fixed text. The thrown error is unchanged, so every caller that logs it still does.
  • In refreshLongTermMemoryIndexes, log the failed rebuild it catches: logger.warn(error, "[ltm] Index rebuild for the new embedding source failed").
  • CHANGELOG under ## Unreleased: "After a recall index rebuild fails, the integrity check in Maintenance and the package status no longer show the raw error, which could include the vault's file paths. They now say that the latest index rebuild failed and to see the server log, which records the full error. A rebuild that fails while the Engine switches to a new embedding connection is now logged there too."

Not included

  • Sanitizing at the two readers. Once stored, a cancellation's text and a raw one cannot be told apart, and the writer covers both routes and both rebuild paths.
  • Keeping a LtmServiceError's message. No rebuild step throws one today.
  • Rewriting an error already stored by an earlier version. A failed state is dirty, so the next recall rebuilds and clears it.
  • Localizing integrity messages. Every integrity issue's message is server-written English today.
  • Source extraction failure messages and where they are recorded (see Actual behavior).

Regression proof

In tests/long-term-memory-routes.regression.ts, in the existing settings case that replaces recall.json with a folder so the settings rebuild fails:

  • /status indexes.warnings equals the fixed text. Today it holds the EISDIR … rename message with the vault's absolute paths.
  • With the built index written back, the /integrity index_rebuild_failed message equals the fixed text. Today it is the same raw message.

The refresh's new log line is one line and has no dedicated test.

Environment

  • Marinara Engine version: 2.5.1 (staging 87d1ccadc)
  • Package version: long-term-memory 1.4.72 (upstream/staging bcaebd07d)
  • Install type: source (code reading and the regression suite)
  • OS + version: not platform-specific
  • Browser or app shell: any

Logs, screenshots, or video

None needed; the reproduction above uses a folder in place of the index file.

Additional context

Tracker item: hygiene add-on. Builds on #1523 (the debounced background rebuild), which moves the draft-accept failure into the index state, and on #1508, which makes the server log keep the cause. Both are merged. The error-message clean-up (#1506) deferred the draft-accept case until #1523.

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 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1541 Originally assigned to: @Promansis on GitHub. ## Summary When a recall index rebuild fails, Long-Term Memory stores the raw error message in its index state, and `GET /integrity` and `GET /status` return it. Maintenance prints the integrity message as is, so a failed rebuild can put the vault's absolute path on screen, for example `EISDIR: illegal operation on a directory, rename '/…/long-term-memory/indexes/recall.json.tmp-…' -> '/…/long-term-memory/indexes/recall.json'`. The path includes the data folder and with it, usually, the OS user name. The rest of the package already keeps an unexpected failure's text in the server log and sends fixed text to the client (`routeError`, `rebuildAfterMutation`, the scope-link rebuild). Since the debounced background rebuild (#1523), a failed rebuild after Accept no longer reaches the draft (Accept answers `pending` and the draft stores no error); it reaches the index state, which is the remaining gap. One rebuild path does not log its failure at all: the index refresh the Engine runs after an embedding-connection change catches a failed rebuild and drops it. ## Affected package `long-term-memory` 1.4.72 (`upstream/staging` bcaebd07d), which has the debounced background rebuild. Line numbers below are on bcaebd07d (refreshed 2026-10-21; first checked on 8b72729f1). - `S` = `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory` - `C` = `packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory` ## Expected behavior - After a failed rebuild, `/integrity` and `/status` say that the latest index rebuild failed and to see the server log. They return no file paths or library messages. - The server log keeps the full error, on every rebuild path that the server log covers. - A cancelled rebuild (stopped on package deactivation) keeps its own short message, since nothing is logged for it. - The draft-accept response and the stored draft carry no rebuild error text (true today). ## Actual behavior - Every failed rebuild ends in `markLtmIndexesFailed` (`S/persistence/index-state.ts:209-218`): the synchronous rebuild (`S/recall/rebuild.ts:234`) and each background attempt (`:298`). It stores `error.message`, up to 2,000 characters, in `indexes/state.json`. - `GET /integrity` returns it as the `index_rebuild_failed` issue's `message` (`S/maintenance/maintenance.ts:185`) whenever the recall index itself is readable. Maintenance shows each issue as `{severity}: {message}` (`C/settings/MaintenancePanel.tsx:627`). - `GET /status` returns it in `indexes.warnings` (`S/routes/maintenance.ts:126`). No client code reads `warnings` today; the health pill and Activity show `rebuildState` through localized labels. - `refreshLongTermMemoryIndexes` (`S/recall/rebuild.ts:436`) runs a rebuild for the new embedding source in a `try` whose `catch` (`:445-447`) rethrows only a cancellation; any other failure is dropped without a log line. The refresh then reports "could not embed the vault with the new embedding source" without the cause. - The other rebuild failures are logged: the background job (`S/recall/rebuild-job.ts:46`), `rebuildAfterMutation`, the scope-link rebuild, `routeError` (restore, identity repair), the Engine's error handler (`POST /rebuild`, `POST /repair`) and the Engine's recall. The three `logger.warn` ones keep their error in the log: the package's `warn` puts an error passed first into the message. Source extraction's inline index load records its failure in the package's debug log (shown in Activity) and on the Sources page instead, as it does for every extraction failure. ## Steps to reproduce 1. With a vault that has a built recall index, replace `long-term-memory/indexes/recall.json` in the Engine's data folder with an empty folder. 2. In Memory Settings, save a change that rebuilds the index, for example a new stop word. The save succeeds and reports the rebuild as deferred. 3. Call `GET /api/long-term-memory/status`. `indexes.warnings` is `["EISDIR: illegal operation on a directory, rename '<data folder>/long-term-memory/indexes/recall.json.tmp-…' -> '<data folder>/long-term-memory/indexes/recall.json'"]`. 4. Put a readable `recall.json` back (the integrity check stops at an unreadable or missing index) and run the integrity check in Maintenance (`GET /api/long-term-memory/integrity`). The `index_rebuild_failed` issue shows the same text with both absolute paths. A background rebuild after Accept that fails on the disk the same way ends in the same function and stores its error the same way. ## Minimal fix One PR, patch bump. Two source files. The new text sends users to the server log, and the warnings that log a failed rebuild now carry the cause (the fix for warnings dropping their cause is already in). - In `markLtmIndexesFailed`, store "The latest index rebuild failed; see the server log." for any failure, except a cancellation (`AbortError`), which keeps its own message ("This operation was aborted"). Both routes then serve the fixed text. The thrown error is unchanged, so every caller that logs it still does. - In `refreshLongTermMemoryIndexes`, log the failed rebuild it catches: `logger.warn(error, "[ltm] Index rebuild for the new embedding source failed")`. - **CHANGELOG under `## Unreleased`:** "After a recall index rebuild fails, the integrity check in Maintenance and the package status no longer show the raw error, which could include the vault's file paths. They now say that the latest index rebuild failed and to see the server log, which records the full error. A rebuild that fails while the Engine switches to a new embedding connection is now logged there too." **Not included** - Sanitizing at the two readers. Once stored, a cancellation's text and a raw one cannot be told apart, and the writer covers both routes and both rebuild paths. - Keeping a `LtmServiceError`'s message. No rebuild step throws one today. - Rewriting an error already stored by an earlier version. A failed state is dirty, so the next recall rebuilds and clears it. - Localizing integrity messages. Every integrity issue's message is server-written English today. - Source extraction failure messages and where they are recorded (see Actual behavior). ## Regression proof In `tests/long-term-memory-routes.regression.ts`, in the existing settings case that replaces `recall.json` with a folder so the settings rebuild fails: - `/status` `indexes.warnings` equals the fixed text. Today it holds the `EISDIR … rename` message with the vault's absolute paths. - With the built index written back, the `/integrity` `index_rebuild_failed` message equals the fixed text. Today it is the same raw message. The refresh's new log line is one line and has no dedicated test. ## Environment - Marinara Engine version: 2.5.1 (`staging` 87d1ccadc) - Package version: long-term-memory 1.4.72 (`upstream/staging` bcaebd07d) - Install type: source (code reading and the regression suite) - OS + version: not platform-specific - Browser or app shell: any ## Logs, screenshots, or video None needed; the reproduction above uses a folder in place of the index file. ## Additional context Tracker item: hygiene add-on. Builds on #1523 (the debounced background rebuild), which moves the draft-accept failure into the index state, and on #1508, which makes the server log keep the cause. Both are merged. The error-message clean-up (#1506) deferred the draft-accept case until #1523. ## 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-22 04:02:50 +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#1513
No description provided.