[GH-ISSUE #1513] Legacy import leaves boolean/array lorebook-entry fields as strings, breaking editor display and activation logic #763

Closed
opened 2026-10-20 17:33:04 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Romuromylus on GitHub (May 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1513

Originally assigned to: @Romuromylus on GitHub.

Summary

After a legacy profile import, several lorebook-entry fields are stored as JSON-encoded strings instead of native types. This makes the entry editor display the wrong toggle state, and because one generation path uses raw truthiness, it can also change which entries activate.

What is wrong (confirmed on imported entry "NPC: Kafka", key "Kafka")

Read back via storage_list { entity: "lorebook-entries" }:

  • caseSensitive = "false" (string) (should be boolean)
  • constant = "false" (string)
  • locked = "false" (string)
  • preventRecursion = "false" (string)
  • excludeFromVectorization = "false" (string)
  • selective = "true" (string), selectiveLogic = "and" (string)
  • enabled = "true" (string)
  • matchWholeWords = true (boolean) <- correctly normalized
  • characterFilterIds / characterTagFilters / additionalMatchingSources / activationConditions = "[]" (string, should be arrays)
  • keys / secondaryKeys = arrays <- correctly normalized

All 1492 entries in the dataset share this pattern.

Confirmed symptoms

  1. Editor: opening the entry shows Case Sensitive, Locked, No Recursion, and No Vector toggled ON, even though they are OFF on the source instance. "false" is truthy in JS, so the raw string reads as on. (Whole Words is correct because matchWholeWords is a real boolean.)
  2. Save is NOT corrupting: editing an unrelated field and letting it auto-save round-trips the string values unchanged (verified on disk), so the stored data is not silently flipped to true.
  3. Generation is inconsistent: prompt-assembly.ts uses a boolish() coercion and makers.ts uses === true, but keyword-scanner.ts uses raw truthiness (if (entry.constant) at lines 454/508, .filter((a) => !a.entry.preventRecursion) at 552, and passes caseSensitive raw at 479). With string "false" being truthy, the scanner can wrongly treat entries as constant and wrongly suppress recursion.

Root cause

The legacy normalizer (src-tauri/src/commands/storage/profile/legacy.rs) normalizes some fields (matchWholeWords, keys, secondaryKeys) but not caseSensitive / constant / locked / preventRecursion / excludeFromVectorization / selective, and it does not decode the string-encoded array fields.

Suggested fix

Normalize these boolean and array fields to native types during legacy import (the same treatment matchWholeWords already gets). Optionally make keyword-scanner.ts coerce defensively like prompt-assembly.ts.

Environment

refactor @ ef244c80, Windows 11, Tauri desktop (pnpm tauri dev).


Found during smoke test #1484 (Heavy Data / Legacy / Import Pass). Project board: https://github.com/orgs/Pasta-Devs/projects/4

Originally created by @Romuromylus on GitHub (May 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1513 Originally assigned to: @Romuromylus on GitHub. ## Summary After a legacy profile import, several lorebook-entry fields are stored as JSON-encoded strings instead of native types. This makes the entry editor display the wrong toggle state, and because one generation path uses raw truthiness, it can also change which entries activate. ## What is wrong (confirmed on imported entry "NPC: Kafka", key "Kafka") Read back via `storage_list { entity: "lorebook-entries" }`: - `caseSensitive` = "false" (string) (should be boolean) - `constant` = "false" (string) - `locked` = "false" (string) - `preventRecursion` = "false" (string) - `excludeFromVectorization` = "false" (string) - `selective` = "true" (string), `selectiveLogic` = "and" (string) - `enabled` = "true" (string) - `matchWholeWords` = true (boolean) <- correctly normalized - `characterFilterIds` / `characterTagFilters` / `additionalMatchingSources` / `activationConditions` = "[]" (string, should be arrays) - `keys` / `secondaryKeys` = arrays <- correctly normalized All 1492 entries in the dataset share this pattern. ## Confirmed symptoms 1. Editor: opening the entry shows Case Sensitive, Locked, No Recursion, and No Vector toggled ON, even though they are OFF on the source instance. `"false"` is truthy in JS, so the raw string reads as on. (Whole Words is correct because `matchWholeWords` is a real boolean.) 2. Save is NOT corrupting: editing an unrelated field and letting it auto-save round-trips the string values unchanged (verified on disk), so the stored data is not silently flipped to `true`. 3. Generation is inconsistent: `prompt-assembly.ts` uses a `boolish()` coercion and `makers.ts` uses `=== true`, but `keyword-scanner.ts` uses raw truthiness (`if (entry.constant)` at lines 454/508, `.filter((a) => !a.entry.preventRecursion)` at 552, and passes `caseSensitive` raw at 479). With string `"false"` being truthy, the scanner can wrongly treat entries as constant and wrongly suppress recursion. ## Root cause The legacy normalizer (`src-tauri/src/commands/storage/profile/legacy.rs`) normalizes some fields (`matchWholeWords`, `keys`, `secondaryKeys`) but not `caseSensitive` / `constant` / `locked` / `preventRecursion` / `excludeFromVectorization` / `selective`, and it does not decode the string-encoded array fields. ## Suggested fix Normalize these boolean and array fields to native types during legacy import (the same treatment `matchWholeWords` already gets). Optionally make `keyword-scanner.ts` coerce defensively like `prompt-assembly.ts`. ## Environment refactor @ ef244c80, Windows 11, Tauri desktop (`pnpm tauri dev`). --- Found during smoke test #1484 (Heavy Data / Legacy / Import Pass). Project board: https://github.com/orgs/Pasta-Devs/projects/4
bsakaguchi 2026-10-20 17:33:04 +07:00
Author
Owner

@Romuromylus commented on GitHub (May 29, 2026):

Fixed by #1518 (merged into refactor as a9cc0827). Legacy import now coerces the lorebook-entry boolean and array fields to native types, so the entry editor reads the correct toggle state and the keyword scanner no longer misclassifies entries.

<!-- gh-comment-id:4574413005 --> @Romuromylus commented on GitHub (May 29, 2026): Fixed by #1518 (merged into `refactor` as a9cc0827). Legacy import now coerces the lorebook-entry boolean and array fields to native types, so the entry editor reads the correct toggle state and the keyword scanner no longer misclassifies entries.
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#763
No description provided.