[GH-ISSUE #1506] [Issue]: Long-Term Memory: raw server errors reach the client, and stale comments and help text about usage, backups and existing notes #1494

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

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

Originally assigned to: @Promansis on GitHub.

Summary

Four small clean-ups from the runtime, recall-scoring and pipeline audits, re-checked at the staging tip:

  1. RT-4. Three server paths still send an unexpected error's raw message to the client, and the client shows it as is. Even when the server sends its generic fallback, the screen shows that ("Failed to …") instead of the action's own message.
  2. RT-8. A comment and a log line in recall/usage.ts describe per-chat statistics that 1.4.42 stopped keeping.
  3. RS-4. The backup schema's legacy retrieval block has no comment saying it is legacy, so it looks safe to delete. It isn't.
  4. PL-3.
    • ARCHITECTURE.md doesn't say what the existing-note settings do.
    • One help text says those memories go into the extraction request, which they don't.
    • Compile's skipStructuredBackfill option is always true. It stays, by decision (see Minimal fix).

Re-checking corrected two tracker claims:

  • RT-4. The client does not show localized text when the server sends a message.
  • PL-3. The normalizer's backfill default is not dead. The option that is effectively dead is compile's skipStructuredBackfill.

Affected package

Re-checked 2026-10-21 at upstream/staging edb9c4928 (long-term-memory 1.4.57, built on the Engine's host, capability API 1.341): the fix applies unchanged there; line numbers are at the commit named below.

long-term-memory 1.4.54 (upstream/staging b1873710f). PR #1473 (head c4b1c0192) shifts only the source-processing.ts line below; it is given at both commits.

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

Expected behavior

  • An unexpected server failure is logged on the server. The client gets the route's fallback text, not the internal message (file paths, library errors).
  • For an unexpected failure, the screen shows the action's own message, such as "Could not reset memory settings.". Messages the server writes for users, such as "Memory is locked.", still show as they are.
  • Comments and log lines describe what usage.json holds today.
  • The legacy backup block is marked as kept on purpose.
  • The docs and the help text say what the existing-note settings bound, and that those memories are used on the server, not sent to the model.

Actual behavior

RT-4: raw error messages

The tracker listed five locations. At the tip:

Location What it sends Verdict
S/routes/shared.ts:37 (routeError, fallback branch) error.message of any unexpected error, as a 500 with ltm_unexpected_failure. It is not logged. Fix.
S/routes/shared.ts:80 (rebuildAfterMutation) the raw rebuild error. The client puts it into "saved, but recall is stale: {error}" (C/vault/MemoryVault.tsx:1534, :1704) and into the settings rebuild message (C/settings/MaintenancePanel.tsx:446). Fix. Already logged at :71-77.
S/routes/maintenance.ts:277-281 (identity repair apply) error.message of a non-LtmIdentityRepairError as a 500 with code identity_repair_failed, which nothing reads. It is not logged. Fix.
S/service-error.ts:25-26 (ltmErrorResponse, non-service branch) error.message. Only reachable from routeError's duck-typed branch (S/routes/shared.ts:25-29) for an error-like object that fails isLtmServiceError, such as a library error with a string code and no numeric statusCode. Not in the tracker. Fix. One line.
S/identity/scope-links.ts:60 (applyLtmScopeLinksToDerivedNotes, deferred rebuild) the raw rebuild error, returned by POST /notes/:id/scope/apply-to-derived. Already logged at :57. Found while building the patch; not in the tracker. Fix. Same line as shared.ts:80.
S/drafts/reconciliation.ts:941-949 (draft accept, failed rebuild) the raw rebuild error, both stored on the draft as indexRebuildError and returned as indexRebuild.error, which Review shows (C/review/ReviewQueue.tsx:1180). Logged at :950. Not in this issue. It is stored diagnostic data on the draft, and the debounced background rebuild (RT-1) moves this error out of the draft accept into the index state. It gets its own issue after RT-1.
S/routes/shared.ts:23; maintenance.ts:143, :148; notes.ts:688, :702; settings.ts:55 the Zod message for a request that fails validation (400) Keep. It describes the request, not server internals.
S/routes/maintenance.ts:258 the LtmIdentityRepairError message, written for users Keep. The tracker's :254.
S/routes/notes.ts:586 the Engine's language-model resolver message, which tells the user what to fix in their connection Keep.

The tracker's :275 is today's :279.

Correction. The tracker says that since 1.4.36 (#1375) the client shows localized text instead. It doesn't:

  • failedResponseError (C/api.ts:155-166) keeps the server's error string.
  • errorMessage (:149-152) shows that string, and falls back to localized text only when the server sent none.
  • So after the server fix alone, an unexpected failure would show the route's generic English fallback (for example "Failed to reset settings"). The action's own localized message, such as "Could not reset memory settings.", would not appear.
  • Some routes don't use routeError; Reset (S/routes/settings.ts:30-37) is one. There, a failure reaches the Engine's error handler (Marinara-Engine/packages/server/src/middleware/error-handler.ts:36-42, reached because package routes are added with app.route). The handler logs the error and sends { "error": "Internal Server Error" } with no code, so today a failed Reset shows "Internal Server Error".

RT-8: stale usage comment

  • S/recall/usage.ts:44-45 says the file "only holds per-chat injection stats and the receipt de-duplication list".
  • :48 logs "usage statistics restart from empty".

Since 1.4.42 (#1443), recordLongTermMemoryInjection (:122) and retention (S/persistence/retention.ts:162-163) both empty chats. The file now holds only acceptedReceipts, the receipt de-duplication list.

RS-4: legacy retrieval block

maxVectorCandidates (SH/schema.ts:1340) is one field of ltmRetrievalConfigShape (:1327-1348). That whole block is legacy:

  • Nothing in the server or the client reads it.
  • The backup schema still accepts it as settings.retrieval (:3261), so older backups restore. Restore validates the block and then ignores it.
  • The shape is .strict(), so deleting any of its fields would make older backups that contain that field fail to restore. A comment on the one field would cover only part of this.

The RT-3 probe's check 13c (private) confirms such a backup restores today.

PL-3: existing-note settings and the backfill option

The existing-note settings are not hidden; Settings shows them in the extraction tab (C/settings/MemorySettings.tsx:848-875). What they do is undocumented:

  • getExistingTypedNotes (S/extraction/source-extraction.ts:298-321, called at :484-496) runs normal recall over the source text, bounded by existingNoteMaxChunks and existingNoteMaxTokens.
  • The memories it finds are used on the server:
    • to drop duplicates (S/extraction/dedup.ts:22);
    • to resolve the memories a new unit updates (S/identity/subject-identity.ts:1216-1243);
    • in compile (S/extraction/evidence-unit-compiler.ts:47).
  • They are not part of the model request; baseExtractionOptions (:522-543) has no existingNotes.
  • C/locales/en.json:427 says "Maximum tokens from those existing chunks included in the extraction request." That's wrong. :421 ("considered while checking context and possible overlap") is close enough.
  • ARCHITECTURE.md's Write Flow (packages/long-term-memory/docs/ARCHITECTURE.md:85-102) doesn't mention the step.

Correction: the tracker says the normalizer's backfill default (addStructuredUnits = true, S/extraction/structured-summary-normalizer.ts:210) is dead because every compile caller passes skipStructuredBackfill: true. That's half right:

  • Compile's option is effectively dead. compileEvidenceUnitExtraction turns skipStructuredBackfill into addStructuredUnits: !skip (S/extraction/evidence-unit-extraction.ts:1534, :1546). All three production callers pass true:
    • S/extraction/source-extraction.ts:621;
    • S/extraction/source-processing.ts:234 (:235 at #1473);
    • S/identity/subject-choice-review.ts:179.
  • The normalizer default is live. The first-pass normalizer call (S/extraction/source-extraction.ts:554-565) doesn't pass the flag, so the default backfill runs on every extraction. On the private 15-source vault copy it adds units for 13 sources, 238 units in all (counted with a private script). Deleting the default would change extraction output.

Steps to reproduce

  • RT-4: make a route throw a plain Error("ENOENT: open '/srv/marinara/…'"), for example with an unreadable vault file, and call it. The response body is { "error": "ENOENT: open '/srv/marinara/…'", "code": "ltm_unexpected_failure" }, the UI shows that text, and nothing is logged.
  • RT-8, RS-4, PL-3: read the cited lines.

Minimal fix

One PR, patch bump. Each part is independent and can be dropped from the PR.

  • RT-4

    • S/routes/shared.ts:30-44: log every unexpected error (logger.error(error, "[ltm] Unexpected failure in route")) and send fallback. The AggregateError branch (:30-36) already does this, so the two branches merge into one and the code gets shorter.

    • S/routes/shared.ts:80: send error instanceof LtmServiceError ? error.message : "Index rebuild failed".

    • S/routes/maintenance.ts:277-281: for an error that is not an LtmIdentityRepairError, log it and send the existing fallback text with code ltm_unexpected_failure instead of identity_repair_failed. Nothing reads the old code, which the grep of src and tests confirms. The patch does this by calling routeError, like the fork-repair routes beside it: LtmIdentityRepairError is a service error, so its status, code and message are unchanged.

    • S/service-error.ts:25-26: the patch removes the non-service branch, so ltmErrorResponse takes only an LtmServiceError; its only caller, routeError, checks first. It also exports isLtmServiceError and routeError uses it directly, so every error that is not a service error is logged (the duck-typed branch sent such errors on without logging). A cancelled request (AbortError) is not logged.

    • User-facing plain errors. Route-reachable messages written for users but thrown as plain Error become the existing service-error classes, so their text still shows: draft accept (LtmDraftApplyError, 400 or 409), fork repair, note type change, note not found, backup restore and the rejected-suggestion race (LtmServiceError). Internal and invariant errors stay plain.

    • S/identity/scope-links.ts:60: same change as shared.ts:80.

    • Client, C/api.ts:163: widen the one condition in failedResponseError:

      // An unexpected failure has no message for users: LTM's route fallback, or the Engine's generic 500 for a
      // route without routeError. The caller's own localized message shows instead.
      if (!serverMessage || payload?.code === "ltm_unexpected_failure" || serverMessage === "Internal Server Error")
        withoutUserMessage(error);
      
      • Every errorMessage(error, fallback) caller then shows its own localized message for an unexpected failure, for example "Could not reset memory settings." (C/settings/MaintenancePanel.tsx:455).
      • error.message still holds the server text for debugging.
      • Service errors with their own codes, such as ltm_note_not_found, keep showing the server's message.
      • The browser fixtures that send a 500 with their own text and no code (tests/long-term-memory-browser.regression.ts:1351, :1628, :3642) keep showing it, so no test changes.

      This line was prototyped first; the results are under Regression proof.

  • RT-8: S/recall/usage.ts:44-45: say the file holds only the receipt de-duplication list (acceptedReceipts), because 1.4.42 stopped keeping per-chat counters. :48: say receipt de-duplication restarts from empty.

  • RS-4: above ltmRetrievalConfigShape (SH/schema.ts:1327), add a comment like this:

    Legacy backup input: nothing reads it. Older backups carry it, and restore validates and ignores it. Keep every field, because the shape is strict and removing one fails those backups.

    This is one comment for the whole block instead of one on maxVectorCandidates.

  • PL-3 (docs and help text only)

    • packages/long-term-memory/docs/ARCHITECTURE.md Write Flow (:85-102): add one paragraph. Before compiling, extraction recalls up to existingNoteMaxChunks chunks and existingNoteMaxTokens tokens of existing memories that match the source. The server uses them to drop duplicates and to pick the memories a unit updates, and never sends them to the model.
    • C/locales/en.json:427: change it to something like "Maximum tokens of those existing memories used to match and merge extracted details."
    • Keep compile's skipStructuredBackfill option, and keep the normalizer default. No source or test file changes.
      • Removing the option changes no behaviour, but it would touch 14 test lines in 5 files.
      • It would also mean moving one case. tests/long-term-memory-extraction-graph.regression.ts:1235 passes false to turn backfill on, and so tests the normalizer's "static lore must not synthesize a timeline event" rule through compile.
      • The tracker item's "delete the normalizer's dead backfill default" is dropped, because that default is live.
  • CHANGELOG under ## Unreleased: one bullet for RT-4, such as "Unexpected server errors are logged, and the interface shows the action's own error message instead of the raw server error." RT-8, RS-4 and PL-3 need none; the help-text fix is user-visible but small. Add it to the same bullet if wanted.

Not included

  • The Zod 400 messages. They are hard to read (a JSON list of issues), but they describe the request. A friendlier validation message is separate work.
  • Changing which errors count as LtmServiceError.
  • Paths that still pass an underlying message through: the identity-repair restore failure (identity-repair.ts:155-157), per-source import failures (sources/interop.ts:1018, extraction/source-processing.ts:408, shown at C/sources/SourcesWorkspace.tsx:1380, :2639), and preflight blockers. Draft accept's indexRebuild.error gets its own issue after RT-1, which moves that error into the index state.

Regression proof

Write first:

  • RT-4: in tests/long-term-memory-routes.regression.ts, call routeError(new Error("ENOENT: open '/private/path'"), "Fallback text") and assert:

    • status 500, code ltm_unexpected_failure and error "Fallback text";
    • the logger received the error.

    Make the identity repair apply route fail with a plain Error and assert that the body holds the fallback with ltm_unexpected_failure. A rebuild failure with a plain Error returns error: "Index rebuild failed". As built: the fixture's getChat throws for a chat-unreadable scope, the runtime logger stub records errors, and a library error with a string code and no status covers the old duck-typed branch. The cases sit in the scope-identity scenario after the persona identity repair.

  • RT-4 client: in tests/long-term-memory-source-pagination.regression.ts, beside the existing errorMessage and failedResponseError cases (:255-280), port the five cases of a private probe script. With the fallback "Could not reset memory settings.":

    • a 500 with ltm_unexpected_failure and a 500 { "error": "Internal Server Error" } both show the fallback;
    • an empty 500 shows the fallback, as today;
    • a 404 { "error": "Memory not found.", "code": "ltm_note_not_found" } still shows "Memory not found.";
    • a code-less 500 with its own text still shows that text.

    Today 3 of 5 pass; the two unexpected-failure cases show "Failed to reset settings" and "Internal Server Error". With the prototype line, 5 of 5 pass, and the existing source-pagination regression still exits 0.

  • RT-8, RS-4, PL-3: comment, docs and help text only, so no dedicated test.

Environment

  • Marinara Engine version: 2.5.0 line (local staging checkout, unchanged)
  • Package version: long-term-memory 1.4.54 (upstream/staging b1873710f)
  • Install type: source (code reading; backfill count on the private vault copy; client error probe on a throwaway copy)
  • OS + version: Linux, Node 24.15.0
  • Browser or app shell: n/a

Logs, screenshots, or video

Output of the private backfill-count script on the private vault copy: {"sources":15,"structured":13,"sourcesWithBackfill":13,"unitsAdded":238}.

Additional context

Tracker items:

  • RT-4: runtime audit, finding 12.
  • RT-8: a follow-up from #1443.
  • RS-4: recall scoring audit, finding 12.
  • PL-3: pipeline audit.

Related: #1375, #1443.

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 20, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1506 Originally assigned to: @Promansis on GitHub. ## Summary Four small clean-ups from the runtime, recall-scoring and pipeline audits, re-checked at the staging tip: 1. **RT-4.** Three server paths still send an unexpected error's raw `message` to the client, and the client shows it as is. Even when the server sends its generic fallback, the screen shows that ("Failed to …") instead of the action's own message. 2. **RT-8.** A comment and a log line in `recall/usage.ts` describe per-chat statistics that 1.4.42 stopped keeping. 3. **RS-4.** The backup schema's legacy `retrieval` block has no comment saying it is legacy, so it looks safe to delete. It isn't. 4. **PL-3.** - `ARCHITECTURE.md` doesn't say what the existing-note settings do. - One help text says those memories go into the extraction request, which they don't. - Compile's `skipStructuredBackfill` option is always `true`. It stays, by decision (see Minimal fix). Re-checking corrected two tracker claims: - **RT-4.** The client does not show localized text when the server sends a message. - **PL-3.** The normalizer's backfill default is not dead. The option that is effectively dead is compile's `skipStructuredBackfill`. ## Affected package Re-checked 2026-10-21 at `upstream/staging` edb9c4928 (long-term-memory 1.4.57, built on the Engine's host, capability API 1.341): the fix applies unchanged there; line numbers are at the commit named below. `long-term-memory` 1.4.54 (`upstream/staging` b1873710f). PR #1473 (head c4b1c0192) shifts only the `source-processing.ts` line below; it is given at both commits. - `S` = `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory` - `SH` = `packages/long-term-memory/src/engine/packages/shared/src/features/agents/long-term-memory` - `C` = `packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory` ## Expected behavior - An unexpected server failure is logged on the server. The client gets the route's fallback text, not the internal message (file paths, library errors). - For an unexpected failure, the screen shows the action's own message, such as "Could not reset memory settings.". Messages the server writes for users, such as "Memory is locked.", still show as they are. - Comments and log lines describe what `usage.json` holds today. - The legacy backup block is marked as kept on purpose. - The docs and the help text say what the existing-note settings bound, and that those memories are used on the server, not sent to the model. ## Actual behavior ### RT-4: raw error messages The tracker listed five locations. At the tip: | Location | What it sends | Verdict | |---|---|---| | `S/routes/shared.ts:37` (`routeError`, fallback branch) | `error.message` of any unexpected error, as a 500 with `ltm_unexpected_failure`. It is not logged. | **Fix.** | | `S/routes/shared.ts:80` (`rebuildAfterMutation`) | the raw rebuild error. The client puts it into "saved, but recall is stale: {error}" (`C/vault/MemoryVault.tsx:1534`, `:1704`) and into the settings rebuild message (`C/settings/MaintenancePanel.tsx:446`). | **Fix.** Already logged at `:71-77`. | | `S/routes/maintenance.ts:277-281` (identity repair apply) | `error.message` of a non-`LtmIdentityRepairError` as a 500 with code `identity_repair_failed`, which nothing reads. It is not logged. | **Fix.** | | `S/service-error.ts:25-26` (`ltmErrorResponse`, non-service branch) | `error.message`. Only reachable from `routeError`'s duck-typed branch (`S/routes/shared.ts:25-29`) for an error-like object that fails `isLtmServiceError`, such as a library error with a string `code` and no numeric `statusCode`. Not in the tracker. | **Fix.** One line. | | `S/identity/scope-links.ts:60` (`applyLtmScopeLinksToDerivedNotes`, deferred rebuild) | the raw rebuild error, returned by `POST /notes/:id/scope/apply-to-derived`. Already logged at `:57`. Found while building the patch; not in the tracker. | **Fix.** Same line as `shared.ts:80`. | | `S/drafts/reconciliation.ts:941-949` (draft accept, failed rebuild) | the raw rebuild error, both stored on the draft as `indexRebuildError` and returned as `indexRebuild.error`, which Review shows (`C/review/ReviewQueue.tsx:1180`). Logged at `:950`. | **Not in this issue.** It is stored diagnostic data on the draft, and the debounced background rebuild (RT-1) moves this error out of the draft accept into the index state. It gets its own issue after RT-1. | | `S/routes/shared.ts:23`; `maintenance.ts:143`, `:148`; `notes.ts:688`, `:702`; `settings.ts:55` | the Zod message for a request that fails validation (400) | Keep. It describes the request, not server internals. | | `S/routes/maintenance.ts:258` | the `LtmIdentityRepairError` message, written for users | Keep. The tracker's `:254`. | | `S/routes/notes.ts:586` | the Engine's language-model resolver message, which tells the user what to fix in their connection | Keep. | The tracker's `:275` is today's `:279`. **Correction.** The tracker says that since 1.4.36 (#1375) the client shows localized text instead. It doesn't: - `failedResponseError` (`C/api.ts:155-166`) keeps the server's `error` string. - `errorMessage` (`:149-152`) shows that string, and falls back to localized text only when the server sent none. - So after the server fix alone, an unexpected failure would show the route's generic English fallback (for example "Failed to reset settings"). The action's own localized message, such as "Could not reset memory settings.", would not appear. - Some routes don't use `routeError`; Reset (`S/routes/settings.ts:30-37`) is one. There, a failure reaches the Engine's error handler (`Marinara-Engine/packages/server/src/middleware/error-handler.ts:36-42`, reached because package routes are added with `app.route`). The handler logs the error and sends `{ "error": "Internal Server Error" }` with no code, so today a failed Reset shows "Internal Server Error". ### RT-8: stale usage comment - `S/recall/usage.ts:44-45` says the file "only holds per-chat injection stats and the receipt de-duplication list". - `:48` logs "usage statistics restart from empty". Since 1.4.42 (#1443), `recordLongTermMemoryInjection` (`:122`) and retention (`S/persistence/retention.ts:162-163`) both empty `chats`. The file now holds only `acceptedReceipts`, the receipt de-duplication list. ### RS-4: legacy retrieval block `maxVectorCandidates` (`SH/schema.ts:1340`) is one field of `ltmRetrievalConfigShape` (`:1327-1348`). That whole block is legacy: - Nothing in the server or the client reads it. - The backup schema still accepts it as `settings.retrieval` (`:3261`), so older backups restore. Restore validates the block and then ignores it. - The shape is `.strict()`, so deleting any of its fields would make older backups that contain that field fail to restore. A comment on the one field would cover only part of this. The RT-3 probe's check 13c (private) confirms such a backup restores today. ### PL-3: existing-note settings and the backfill option The existing-note settings are not hidden; Settings shows them in the extraction tab (`C/settings/MemorySettings.tsx:848-875`). What they do is undocumented: - `getExistingTypedNotes` (`S/extraction/source-extraction.ts:298-321`, called at `:484-496`) runs normal recall over the source text, bounded by `existingNoteMaxChunks` and `existingNoteMaxTokens`. - The memories it finds are used on the server: - to drop duplicates (`S/extraction/dedup.ts:22`); - to resolve the memories a new unit updates (`S/identity/subject-identity.ts:1216-1243`); - in compile (`S/extraction/evidence-unit-compiler.ts:47`). - They are not part of the model request; `baseExtractionOptions` (`:522-543`) has no `existingNotes`. - `C/locales/en.json:427` says "Maximum tokens from those existing chunks included in the extraction request." That's wrong. `:421` ("considered while checking context and possible overlap") is close enough. - `ARCHITECTURE.md`'s Write Flow (`packages/long-term-memory/docs/ARCHITECTURE.md:85-102`) doesn't mention the step. **Correction:** the tracker says the normalizer's backfill default (`addStructuredUnits = true`, `S/extraction/structured-summary-normalizer.ts:210`) is dead because every compile caller passes `skipStructuredBackfill: true`. That's half right: - **Compile's option is effectively dead.** `compileEvidenceUnitExtraction` turns `skipStructuredBackfill` into `addStructuredUnits: !skip` (`S/extraction/evidence-unit-extraction.ts:1534`, `:1546`). All three production callers pass `true`: - `S/extraction/source-extraction.ts:621`; - `S/extraction/source-processing.ts:234` (`:235` at #1473); - `S/identity/subject-choice-review.ts:179`. - **The normalizer default is live.** The first-pass normalizer call (`S/extraction/source-extraction.ts:554-565`) doesn't pass the flag, so the default backfill runs on every extraction. On the private 15-source vault copy it adds units for 13 sources, 238 units in all (counted with a private script). Deleting the default would change extraction output. ## Steps to reproduce - **RT-4:** make a route throw a plain `Error("ENOENT: open '/srv/marinara/…'")`, for example with an unreadable vault file, and call it. The response body is `{ "error": "ENOENT: open '/srv/marinara/…'", "code": "ltm_unexpected_failure" }`, the UI shows that text, and nothing is logged. - **RT-8, RS-4, PL-3:** read the cited lines. ## Minimal fix One PR, patch bump. Each part is independent and can be dropped from the PR. - **RT-4** - `S/routes/shared.ts:30-44`: log every unexpected error (`logger.error(error, "[ltm] Unexpected failure in route")`) and send `fallback`. The `AggregateError` branch (`:30-36`) already does this, so the two branches merge into one and the code gets shorter. - `S/routes/shared.ts:80`: send `error instanceof LtmServiceError ? error.message : "Index rebuild failed"`. - `S/routes/maintenance.ts:277-281`: for an error that is not an `LtmIdentityRepairError`, log it and send the existing fallback text with code `ltm_unexpected_failure` instead of `identity_repair_failed`. Nothing reads the old code, which the grep of `src` and `tests` confirms. The patch does this by calling `routeError`, like the fork-repair routes beside it: `LtmIdentityRepairError` is a service error, so its status, code and message are unchanged. - `S/service-error.ts:25-26`: the patch removes the non-service branch, so `ltmErrorResponse` takes only an `LtmServiceError`; its only caller, `routeError`, checks first. It also exports `isLtmServiceError` and `routeError` uses it directly, so every error that is not a service error is logged (the duck-typed branch sent such errors on without logging). A cancelled request (`AbortError`) is not logged. - **User-facing plain errors.** Route-reachable messages written for users but thrown as plain `Error` become the existing service-error classes, so their text still shows: draft accept (`LtmDraftApplyError`, 400 or 409), fork repair, note type change, note not found, backup restore and the rejected-suggestion race (`LtmServiceError`). Internal and invariant errors stay plain. - `S/identity/scope-links.ts:60`: same change as `shared.ts:80`. - **Client, `C/api.ts:163`**: widen the one condition in `failedResponseError`: ```ts // An unexpected failure has no message for users: LTM's route fallback, or the Engine's generic 500 for a // route without routeError. The caller's own localized message shows instead. if (!serverMessage || payload?.code === "ltm_unexpected_failure" || serverMessage === "Internal Server Error") withoutUserMessage(error); ``` - Every `errorMessage(error, fallback)` caller then shows its own localized message for an unexpected failure, for example "Could not reset memory settings." (`C/settings/MaintenancePanel.tsx:455`). - `error.message` still holds the server text for debugging. - Service errors with their own codes, such as `ltm_note_not_found`, keep showing the server's message. - The browser fixtures that send a 500 with their own text and no code (`tests/long-term-memory-browser.regression.ts:1351`, `:1628`, `:3642`) keep showing it, so no test changes. This line was prototyped first; the results are under Regression proof. - **RT-8:** `S/recall/usage.ts:44-45`: say the file holds only the receipt de-duplication list (`acceptedReceipts`), because 1.4.42 stopped keeping per-chat counters. `:48`: say receipt de-duplication restarts from empty. - **RS-4:** above `ltmRetrievalConfigShape` (`SH/schema.ts:1327`), add a comment like this: > Legacy backup input: nothing reads it. Older backups carry it, and restore validates and ignores it. Keep every field, because the shape is strict and removing one fails those backups. This is one comment for the whole block instead of one on `maxVectorCandidates`. - **PL-3** (docs and help text only) - `packages/long-term-memory/docs/ARCHITECTURE.md` Write Flow (`:85-102`): add one paragraph. Before compiling, extraction recalls up to `existingNoteMaxChunks` chunks and `existingNoteMaxTokens` tokens of existing memories that match the source. The server uses them to drop duplicates and to pick the memories a unit updates, and never sends them to the model. - `C/locales/en.json:427`: change it to something like "Maximum tokens of those existing memories used to match and merge extracted details." - **Keep compile's `skipStructuredBackfill` option, and keep the normalizer default.** No source or test file changes. - Removing the option changes no behaviour, but it would touch 14 test lines in 5 files. - It would also mean moving one case. `tests/long-term-memory-extraction-graph.regression.ts:1235` passes `false` to turn backfill on, and so tests the normalizer's "static lore must not synthesize a timeline event" rule through compile. - The tracker item's "delete the normalizer's dead backfill default" is dropped, because that default is live. - **CHANGELOG under `## Unreleased`:** one bullet for RT-4, such as "Unexpected server errors are logged, and the interface shows the action's own error message instead of the raw server error." RT-8, RS-4 and PL-3 need none; the help-text fix is user-visible but small. Add it to the same bullet if wanted. **Not included** - The Zod 400 messages. They are hard to read (a JSON list of issues), but they describe the request. A friendlier validation message is separate work. - Changing which errors count as `LtmServiceError`. - Paths that still pass an underlying message through: the identity-repair restore failure (`identity-repair.ts:155-157`), per-source import failures (`sources/interop.ts:1018`, `extraction/source-processing.ts:408`, shown at `C/sources/SourcesWorkspace.tsx:1380`, `:2639`), and preflight blockers. Draft accept's `indexRebuild.error` gets its own issue after RT-1, which moves that error into the index state. ## Regression proof Write first: - **RT-4:** in `tests/long-term-memory-routes.regression.ts`, call `routeError(new Error("ENOENT: open '/private/path'"), "Fallback text")` and assert: - status 500, `code` `ltm_unexpected_failure` and `error` `"Fallback text"`; - the logger received the error. Make the identity repair apply route fail with a plain `Error` and assert that the body holds the fallback with `ltm_unexpected_failure`. A rebuild failure with a plain `Error` returns `error: "Index rebuild failed"`. As built: the fixture's `getChat` throws for a `chat-unreadable` scope, the runtime logger stub records errors, and a library error with a string `code` and no status covers the old duck-typed branch. The cases sit in the scope-identity scenario after the persona identity repair. - **RT-4 client:** in `tests/long-term-memory-source-pagination.regression.ts`, beside the existing `errorMessage` and `failedResponseError` cases (`:255-280`), port the five cases of a private probe script. With the fallback "Could not reset memory settings.": - a 500 with `ltm_unexpected_failure` and a 500 `{ "error": "Internal Server Error" }` both show the fallback; - an empty 500 shows the fallback, as today; - a 404 `{ "error": "Memory not found.", "code": "ltm_note_not_found" }` still shows "Memory not found."; - a code-less 500 with its own text still shows that text. Today 3 of 5 pass; the two unexpected-failure cases show "Failed to reset settings" and "Internal Server Error". With the prototype line, 5 of 5 pass, and the existing source-pagination regression still exits 0. - **RT-8, RS-4, PL-3:** comment, docs and help text only, so no dedicated test. ## Environment - Marinara Engine version: 2.5.0 line (local `staging` checkout, unchanged) - Package version: long-term-memory 1.4.54 (`upstream/staging` b1873710f) - Install type: source (code reading; backfill count on the private vault copy; client error probe on a throwaway copy) - OS + version: Linux, Node 24.15.0 - Browser or app shell: n/a ## Logs, screenshots, or video Output of the private backfill-count script on the private vault copy: `{"sources":15,"structured":13,"sourcesWithBackfill":13,"unitsAdded":238}`. ## Additional context Tracker items: - **RT-4:** runtime audit, finding 12. - **RT-8:** a follow-up from #1443. - **RS-4:** recall scoring audit, finding 12. - **PL-3:** pipeline audit. Related: #1375, #1443. ## 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:40 +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#1494
No description provided.