[GH-ISSUE #1193] [Issue]: Long-Term Memory: await index rebuild after settings changes and report saved-but-index-failed #609

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

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

Originally assigned to: @Promansis on GitHub.

Summary

Changing the global custom stop-word list (or the "filter generated" setting) changes the effective recall-index fingerprint, but PUT /settings persists the change without rebuilding. The next recall then performs the whole stale rebuild inline, under the vault lock, and the settings UI reports only a generic "saved" message with no indication that indexing is stale or later fails.

Affected package

long-term-memory (Long-Term Memory), package-owned settings routes and the Memory Settings UI. Findings A21 (package side) and the settings half of A6. This is the package-only half; the Engine-side effective-configuration notification is a separate Engine issue.

Expected behavior

  • Persist settings first. Then, only when the saved change actually alters what the recall index contains, await a rebuild and return its outcome. In the current schema that is longTermMemoryStopWords and longTermMemoryStopWordsFilterGenerated (the effective generated-stop-word set consumed by chunkNotes), plus POST /settings/reset. Recall-only settings that do not change chunking (budgetTokens, maxChunks, scoreThreshold, recallContextMessages, weights, includeResolved, recallPreamble, debug, sourcesAvailabilityModes) must not trigger a rebuild.
  • Reuse the existing rebuildAfterMutation complete/deferred result shape; do not invent a second status vocabulary.
  • Distinguish "settings saved and index rebuilt" from "settings saved but indexing failed/deferred". A failed rebuild must not roll back settings, re-report them as unsaved, or imply the save failed. Persisted fields become clean; genuinely unsaved fields remain dirty.
  • Keep the existing index-state failed reporting (index_rebuild_failed) authoritative for the status surface; do not suppress a failed rebuild behind a success message.
  • Preserve current response compatibility for callers that only read the settings fields; add the rebuild outcome rather than replacing the body shape.

Actual behavior

  • app.put("/settings", ...) calls updateLtmGlobalSettings(...) and returns the saved settings. It never rebuilds.
  • app.post("/settings/reset", ...) calls resetLongTermMemorySettings(...) and returns without rebuilding.
  • A later loadOrRebuildLongTermMemoryIndexes sees the changed effective stop words, fails the sourceHash check, and performs the full rebuild inline while holding the vault lock — the same latency A17/A18 describe.
  • MemorySettings.saveSettings (packages/.../client/src/features/long-term-memory/MemorySettings.tsx) shows memorySettingsSaved on success and a generic save error on failure; it has no saved-but-index-failed state.

Steps to reproduce

  1. Activate the package runtime against a disposable vault, create synthetic notes, and build the index. Record recall.json's sourceHash and modification time.
  2. PUT /settings with a changed longTermMemoryStopWords while longTermMemoryStopWordsFilterGenerated is true. Confirm the settings response reports success and the index file is unchanged.
  3. Call loadOrRebuildLongTermMemoryIndexes(root, null, ltmGeneratedStopWords(settings)). Observe a changed sourceHash and a full inline rebuild that only happens at next recall.
  4. Repeat with a recall-only setting (for example longTermMemoryBudgetTokens): the effective stop-word fingerprint and index must not change.

Environment

  • Marinara Engine version: 2.4.6 (227e3e12c87a55c40074413f1f32e57d732217da).
  • Package version: 1.3.34 at the time of the fixture; package 1.3.36 is current upstream and does not change this behavior.
  • 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

Relevant output from the disposable readiness fixture (/tmp/opencode/ltm-readiness-gaps.mts):

{"case":"effective-stop-words","equivalentSpellingSameKey":true,"filterOffSameFingerprint":true,"filterOnChangesFingerprintWithoutNewScan":true,"resetRestoresFingerprint":true}

Interpretation: toggling "filter generated" changed the index fingerprint but did not replace the cached vault scan; the settings write itself did not rebuild. No private chat data or real providers were used.

Additional context

Scope and ownership

  • Implement against Agents staging. No Engine source change is required for this issue.
  • Primary owners: packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/{routes,settings}.ts and packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory/MemorySettings.tsx (plus its locale catalog for any new message).
  • Reuse rebuildAfterMutation rather than adding a parallel rebuild helper, and reuse the existing index-state failure reporting.
  • Compare the effective index-affecting configuration (normalized/sorted buildStopWordSet output and the filter flag) rather than raw form fields, so equivalent spellings do not cause a spurious rebuild.
  • Do not cache fingerprints on the vault snapshot here (A6), do not change vector reuse (A18), and do not touch sidecar identity (Engine issue 5).
  • Engine connection/agent/sidecar save notifications (issue 8) are out of scope and must not be simulated by the package polling configuration.

Validation plan

  • Add the smallest regression proving a stop-word/filter change saves first, then awaits one rebuild and returns complete, and that a recall-only change performs no rebuild.
  • Prove a failed rebuild leaves settings persisted, reports saved-but-index-failed (not an unsaved/save-failure message), and does not replay the save automatically.
  • Preserve equivalent-stop-word normalization, filter-off and reset semantics, and concurrent settings/recall serialization under the vault lock.
  • Cover the settings UI dirty/saved state and localization for any new message; run affected settings/route/runtime regressions and pnpm localization:check equivalent as required.
  • Run repository-required validation and rebuild/validate the package and generated catalog outputs from source before publication.

Proof above is characterization and a red baseline, 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. No installed-package or browser validation has been performed.

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 2, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1193 Originally assigned to: @Promansis on GitHub. ## Summary Changing the global custom stop-word list (or the "filter generated" setting) changes the effective recall-index fingerprint, but `PUT /settings` persists the change without rebuilding. The next recall then performs the whole stale rebuild inline, under the vault lock, and the settings UI reports only a generic "saved" message with no indication that indexing is stale or later fails. ## Affected package `long-term-memory` (Long-Term Memory), package-owned settings routes and the Memory Settings UI. Findings A21 (package side) and the settings half of A6. This is the package-only half; the Engine-side effective-configuration notification is a separate Engine issue. ## Expected behavior - Persist settings first. Then, only when the saved change actually alters what the recall index contains, await a rebuild and return its outcome. In the current schema that is `longTermMemoryStopWords` and `longTermMemoryStopWordsFilterGenerated` (the effective generated-stop-word set consumed by `chunkNotes`), plus `POST /settings/reset`. Recall-only settings that do not change chunking (`budgetTokens`, `maxChunks`, `scoreThreshold`, `recallContextMessages`, weights, `includeResolved`, `recallPreamble`, `debug`, `sourcesAvailabilityModes`) must not trigger a rebuild. - Reuse the existing `rebuildAfterMutation` `complete`/`deferred` result shape; do not invent a second status vocabulary. - Distinguish "settings saved and index rebuilt" from "settings saved but indexing failed/deferred". A failed rebuild must not roll back settings, re-report them as unsaved, or imply the save failed. Persisted fields become clean; genuinely unsaved fields remain dirty. - Keep the existing index-state `failed` reporting (`index_rebuild_failed`) authoritative for the status surface; do not suppress a failed rebuild behind a success message. - Preserve current response compatibility for callers that only read the settings fields; add the rebuild outcome rather than replacing the body shape. ## Actual behavior - `app.put("/settings", ...)` calls `updateLtmGlobalSettings(...)` and returns the saved settings. It never rebuilds. - `app.post("/settings/reset", ...)` calls `resetLongTermMemorySettings(...)` and returns without rebuilding. - A later `loadOrRebuildLongTermMemoryIndexes` sees the changed effective stop words, fails the `sourceHash` check, and performs the full rebuild inline while holding the vault lock — the same latency A17/A18 describe. - `MemorySettings.saveSettings` (`packages/.../client/src/features/long-term-memory/MemorySettings.tsx`) shows `memorySettingsSaved` on success and a generic save error on failure; it has no saved-but-index-failed state. ## Steps to reproduce 1. Activate the package runtime against a disposable vault, create synthetic notes, and build the index. Record `recall.json`'s `sourceHash` and modification time. 2. `PUT /settings` with a changed `longTermMemoryStopWords` while `longTermMemoryStopWordsFilterGenerated` is `true`. Confirm the settings response reports success and the index file is unchanged. 3. Call `loadOrRebuildLongTermMemoryIndexes(root, null, ltmGeneratedStopWords(settings))`. Observe a changed `sourceHash` and a full inline rebuild that only happens at next recall. 4. Repeat with a recall-only setting (for example `longTermMemoryBudgetTokens`): the effective stop-word fingerprint and index must not change. ## Environment - Marinara Engine version: `2.4.6` (`227e3e12c87a55c40074413f1f32e57d732217da`). - Package version: `1.3.34` at the time of the fixture; package `1.3.36` is current upstream and does not change this behavior. - 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 Relevant output from the disposable readiness fixture (`/tmp/opencode/ltm-readiness-gaps.mts`): ```json {"case":"effective-stop-words","equivalentSpellingSameKey":true,"filterOffSameFingerprint":true,"filterOnChangesFingerprintWithoutNewScan":true,"resetRestoresFingerprint":true} ``` Interpretation: toggling "filter generated" changed the index fingerprint but did not replace the cached vault scan; the settings write itself did not rebuild. No private chat data or real providers were used. ## Additional context ### Scope and ownership - Implement against Agents `staging`. No Engine source change is required for this issue. - Primary owners: `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/{routes,settings}.ts` and `packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory/MemorySettings.tsx` (plus its locale catalog for any new message). - Reuse `rebuildAfterMutation` rather than adding a parallel rebuild helper, and reuse the existing index-state failure reporting. - Compare the effective index-affecting configuration (normalized/sorted `buildStopWordSet` output and the filter flag) rather than raw form fields, so equivalent spellings do not cause a spurious rebuild. - Do not cache fingerprints on the vault snapshot here (A6), do not change vector reuse (A18), and do not touch sidecar identity (Engine issue 5). - Engine connection/agent/sidecar save notifications (issue 8) are out of scope and must not be simulated by the package polling configuration. ### Validation plan - [ ] Add the smallest regression proving a stop-word/filter change saves first, then awaits one rebuild and returns `complete`, and that a recall-only change performs no rebuild. - [ ] Prove a failed rebuild leaves settings persisted, reports saved-but-index-failed (not an unsaved/save-failure message), and does not replay the save automatically. - [ ] Preserve equivalent-stop-word normalization, filter-off and reset semantics, and concurrent settings/recall serialization under the vault lock. - [ ] Cover the settings UI dirty/saved state and localization for any new message; run affected settings/route/runtime regressions and `pnpm localization:check` equivalent as required. - [ ] Run repository-required validation and rebuild/validate the package and generated catalog outputs from source before publication. Proof above is characterization and a red baseline, 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. No installed-package or browser validation has been performed. ## 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:29:00 +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#609
No description provided.