[GH-ISSUE #2191] Embedded character-book reimport drops lorebook fields #1094

Closed
opened 2026-10-21 05:26:35 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Jun 4, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2191

Originally assigned to: @Promansis on GitHub.

Summary

Parityscan row 07-LB-COMPAT-embedded-character-book found that the refactor branch loses embedded character-book fields when a user imports or reimports a character's embedded lorebook from the Character Lorebook tab.

The direct character import path still uses the fuller ST/character-book normalization, but the later character_embedded_lorebook_import command uses a narrow converter that only preserves a small subset of entry fields.

Expected behavior

Importing or reimporting a character card character_book as a standalone Marinara lorebook should preserve the same important ST/V2 character-book fields as the legacy main route did:

  • object or array entries
  • keys and secondary keys
  • name/comment/content
  • enabled/disable
  • order/insertion order
  • position, role, depth, scan depth
  • probability/use probability
  • whole-word, case-sensitive, regex flags
  • timing fields such as sticky/cooldown/delay/ephemeral
  • group/group weight
  • recursion and locked flags where present

Linked lorebook sync and character export should keep the embedded character_book mirror compatible enough that reimport/export does not silently drop behavior.

Actual behavior

In the refactor branch, character_embedded_lorebook_import reads character_book.entries only as an array, then maps entries through normalize_character_book_entry.

That helper preserves only:

  • keys/key
  • name/comment
  • content
  • secondary_keys/secondaryKeys
  • constant
  • selective
  • enabled
  • insertion_order/order
  • position, only when it is a string
  • folderId null

This drops or mishandles fields that the full ST lorebook normalizer handles, including depth, scanDepth, probability/useProbability, role, timing fields, caseSensitive/case_sensitive, matchWholeWords/match_whole_words, regex/useRegex, groupWeight, preventRecursion/excludeRecursion, and locked.

Legacy main routed the Character Lorebook tab import through importSTLorebook, passing the embedded character_book entries and extensions into the full ST importer.

Steps to reproduce

  1. On refactor, import or create a character whose data.character_book.entries include non-basic ST/V2 fields such as depth, role, probability, case_sensitive, match_whole_words, sticky, or excludeRecursion.
  2. Open the character editor's Character Lorebook tab.
  3. Click Import Embedded Lorebook or Reimport Embedded Lorebook.
  4. Inspect the created or updated standalone lorebook entries.
  5. Compare against direct ST lorebook import or legacy main behavior.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor at 577de008; legacy comparison was local main at 77a30fa4
  • Run mode: static trace; applies to Tauri desktop and Remote Runtime command dispatch
  • OS + version: not relevant
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not recorded
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: not relevant

Logs, screenshots, or video

Static trace evidence:

  • Refactor command path: src-tauri/src/commands/storage/exports.rs
    • import_character_embedded_lorebook reads the embedded book and creates entries through normalize_character_book_entry.
    • normalize_character_book_entry only maps a narrow field subset.
  • Refactor full ST import path: src-tauri/src/commands/storage/imports/normalization.rs
    • normalize_lorebook_entry maps the broader ST/V2 field surface.
  • Refactor UI/API path: src/features/catalog/characters/components/CharacterLorebookTab.tsx calls characterApi.importEmbeddedLorebook; src/shared/api/character-api.ts invokes character_embedded_lorebook_import.
  • Legacy comparison: main:packages/server/src/routes/characters.routes.ts used importSTLorebook for POST /characters/:id/embedded-lorebook/import, preserving the full importer mapping.

Targeted checks run during parityscan:

cargo test --manifest-path src-tauri/Cargo.toml character_book
6 passed

Regression notes

This worked better on legacy main because the Character Lorebook tab import route delegated to the full ST lorebook importer. The refactor replacement command is narrower and loses compatibility fields.

Additional context

Parityscan batch: Import Export Compat.

Rows scanned:

  • 07-LB-COMPAT-st-import-export
  • 07-LB-COMPAT-native-profile-backup
  • 07-LB-COMPAT-embedded-character-book
  • 07-LB-ASSET-cover-images

Only this row produced a blocking parity gap. The native profile/backup and cover-image rows were refactor-better, and ST import/export had no blocking gap in the named surface.

Likely fix direction: make character_embedded_lorebook_import reuse the same normalization used for ST/character-book import, or extend its converter to preserve the full ST/V2 field set and object-form entries.

Template check

Please uncheck 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 (Jun 4, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2191 Originally assigned to: @Promansis on GitHub. ## Summary Parityscan row `07-LB-COMPAT-embedded-character-book` found that the refactor branch loses embedded character-book fields when a user imports or reimports a character's embedded lorebook from the Character Lorebook tab. The direct character import path still uses the fuller ST/character-book normalization, but the later `character_embedded_lorebook_import` command uses a narrow converter that only preserves a small subset of entry fields. ## Expected behavior Importing or reimporting a character card `character_book` as a standalone Marinara lorebook should preserve the same important ST/V2 character-book fields as the legacy `main` route did: - object or array `entries` - keys and secondary keys - name/comment/content - enabled/disable - order/insertion order - position, role, depth, scan depth - probability/use probability - whole-word, case-sensitive, regex flags - timing fields such as sticky/cooldown/delay/ephemeral - group/group weight - recursion and locked flags where present Linked lorebook sync and character export should keep the embedded `character_book` mirror compatible enough that reimport/export does not silently drop behavior. ## Actual behavior In the refactor branch, `character_embedded_lorebook_import` reads `character_book.entries` only as an array, then maps entries through `normalize_character_book_entry`. That helper preserves only: - keys/key - name/comment - content - secondary_keys/secondaryKeys - constant - selective - enabled - insertion_order/order - position, only when it is a string - folderId null This drops or mishandles fields that the full ST lorebook normalizer handles, including depth, scanDepth, probability/useProbability, role, timing fields, caseSensitive/case_sensitive, matchWholeWords/match_whole_words, regex/useRegex, groupWeight, preventRecursion/excludeRecursion, and locked. Legacy `main` routed the Character Lorebook tab import through `importSTLorebook`, passing the embedded `character_book` entries and extensions into the full ST importer. ## Steps to reproduce 1. On `refactor`, import or create a character whose `data.character_book.entries` include non-basic ST/V2 fields such as `depth`, `role`, `probability`, `case_sensitive`, `match_whole_words`, `sticky`, or `excludeRecursion`. 2. Open the character editor's Character Lorebook tab. 3. Click Import Embedded Lorebook or Reimport Embedded Lorebook. 4. Inspect the created or updated standalone lorebook entries. 5. Compare against direct ST lorebook import or legacy `main` behavior. ## Impact area - [ ] App shell, navigation, startup, or providers - [x] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [x] React-free engine behavior, contracts, agents, or capability ports - [x] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: `refactor` at `577de008`; legacy comparison was local `main` at `77a30fa4` - Run mode: static trace; applies to Tauri desktop and Remote Runtime command dispatch - OS + version: not relevant - Node + pnpm versions: not relevant - Rust version, if relevant: not recorded - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: not relevant ## Logs, screenshots, or video Static trace evidence: - Refactor command path: `src-tauri/src/commands/storage/exports.rs` - `import_character_embedded_lorebook` reads the embedded book and creates entries through `normalize_character_book_entry`. - `normalize_character_book_entry` only maps a narrow field subset. - Refactor full ST import path: `src-tauri/src/commands/storage/imports/normalization.rs` - `normalize_lorebook_entry` maps the broader ST/V2 field surface. - Refactor UI/API path: `src/features/catalog/characters/components/CharacterLorebookTab.tsx` calls `characterApi.importEmbeddedLorebook`; `src/shared/api/character-api.ts` invokes `character_embedded_lorebook_import`. - Legacy comparison: `main:packages/server/src/routes/characters.routes.ts` used `importSTLorebook` for `POST /characters/:id/embedded-lorebook/import`, preserving the full importer mapping. Targeted checks run during parityscan: ```text cargo test --manifest-path src-tauri/Cargo.toml character_book 6 passed ``` ## Regression notes This worked better on legacy `main` because the Character Lorebook tab import route delegated to the full ST lorebook importer. The refactor replacement command is narrower and loses compatibility fields. ## Additional context Parityscan batch: Import Export Compat. Rows scanned: - `07-LB-COMPAT-st-import-export` - `07-LB-COMPAT-native-profile-backup` - `07-LB-COMPAT-embedded-character-book` - `07-LB-ASSET-cover-images` Only this row produced a blocking parity gap. The native profile/backup and cover-image rows were refactor-better, and ST import/export had no blocking gap in the named surface. Likely fix direction: make `character_embedded_lorebook_import` reuse the same normalization used for ST/character-book import, or extend its converter to preserve the full ST/V2 field set and object-form `entries`. ## Template check Please uncheck 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-21 05:26:35 +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-Engine#1094
No description provided.