[GH-ISSUE #2186] [Issue]: Lorebook entry transfer preserves source folder IDs #1091

Closed
opened 2026-10-21 05:26:33 +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/2186

Originally assigned to: @Promansis on GitHub.

Summary

Lorebook entry transfer in the refactor preserves source folder IDs when copying or moving entries to another lorebook. This can leave moved/copied entries pointing at folders that do not exist in the target lorebook.

Expected behavior

Copying or moving entries between lorebooks should preserve the entry content and activation fields, but should clear or correctly remap folderId for the target lorebook. Legacy transfer placed transferred entries at root in the target (folderId: null) and appended them after existing target entries.

Actual behavior

The refactor implements transfer in the frontend hook:

  • move patches only lorebookId on the existing entry.
  • copy clones the whole entry object, deletes id, and creates it under the target lorebookId.

Both paths can preserve a folderId from the source lorebook. If the target lorebook does not have a folder with the same ID, the stored entry becomes orphaned from the target's folder model.

Steps to reproduce

  1. On refactor, create source lorebook A with a folder and an entry inside that folder.
  2. Create target lorebook B without a matching folder ID.
  3. Use the lorebook editor selection controls to copy or move the entry from A to B.
  4. Inspect the transferred entry in storage.
  5. The entry has lorebookId for B but still carries the source folder ID.

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: upstream/refactor 577de008; compared against legacy upstream/main c49f1d95
  • Run mode: Tauri desktop / remote runtime storage path
  • OS + version: not recorded; static trace only
  • Node + pnpm versions: not recorded
  • Rust version, if relevant: not recorded
  • Remote Runtime URL configured? not relevant to static trace; transfer uses shared storage commands
  • Provider, model, or integration, if relevant: not relevant

Logs, screenshots, or video

Static parity evidence:

  • Refactor transfer implementation lives in src/features/catalog/lorebooks/hooks/use-lorebooks.ts.
  • Refactor move updates only { lorebookId: targetLorebookId }.
  • Refactor copy clones the source entry and creates it with a new lorebookId, without clearing folderId.
  • Legacy transfer uses buildTransferredEntryInput in packages/server/src/routes/lorebooks.routes.ts, explicitly setting folderId: null and assigning a target append order.

Relevant legacy behavior:

folderId: null,

inside the transferred entry input for both copy and move.

Regression notes

This worked in the legacy main branch transfer route. The refactor moved transfer behavior into the frontend hook, but did not preserve the storage safety rule that transferred entries should not keep source-folder ownership.

Additional context

This came from the Batch 3 Storage Safety parityscan row 07-LB-STORAGE-entry-transfer. A robust fix likely belongs in the storage/Rust command layer or a focused lorebook command wrapper, so embedded and remote runtime behavior stay identical and malformed callers cannot create cross-lorebook folder references.

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/2186 Originally assigned to: @Promansis on GitHub. ## Summary Lorebook entry transfer in the refactor preserves source folder IDs when copying or moving entries to another lorebook. This can leave moved/copied entries pointing at folders that do not exist in the target lorebook. ## Expected behavior Copying or moving entries between lorebooks should preserve the entry content and activation fields, but should clear or correctly remap `folderId` for the target lorebook. Legacy transfer placed transferred entries at root in the target (`folderId: null`) and appended them after existing target entries. ## Actual behavior The refactor implements transfer in the frontend hook: - `move` patches only `lorebookId` on the existing entry. - `copy` clones the whole entry object, deletes `id`, and creates it under the target `lorebookId`. Both paths can preserve a `folderId` from the source lorebook. If the target lorebook does not have a folder with the same ID, the stored entry becomes orphaned from the target's folder model. ## Steps to reproduce 1. On `refactor`, create source lorebook A with a folder and an entry inside that folder. 2. Create target lorebook B without a matching folder ID. 3. Use the lorebook editor selection controls to copy or move the entry from A to B. 4. Inspect the transferred entry in storage. 5. The entry has `lorebookId` for B but still carries the source folder ID. ## 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: `upstream/refactor` `577de008`; compared against legacy `upstream/main` `c49f1d95` - Run mode: Tauri desktop / remote runtime storage path - OS + version: not recorded; static trace only - Node + pnpm versions: not recorded - Rust version, if relevant: not recorded - Remote Runtime URL configured? not relevant to static trace; transfer uses shared storage commands - Provider, model, or integration, if relevant: not relevant ## Logs, screenshots, or video Static parity evidence: - Refactor transfer implementation lives in `src/features/catalog/lorebooks/hooks/use-lorebooks.ts`. - Refactor `move` updates only `{ lorebookId: targetLorebookId }`. - Refactor `copy` clones the source entry and creates it with a new `lorebookId`, without clearing `folderId`. - Legacy transfer uses `buildTransferredEntryInput` in `packages/server/src/routes/lorebooks.routes.ts`, explicitly setting `folderId: null` and assigning a target append order. Relevant legacy behavior: ```ts folderId: null, ``` inside the transferred entry input for both copy and move. ## Regression notes This worked in the legacy `main` branch transfer route. The refactor moved transfer behavior into the frontend hook, but did not preserve the storage safety rule that transferred entries should not keep source-folder ownership. ## Additional context This came from the Batch 3 Storage Safety parityscan row `07-LB-STORAGE-entry-transfer`. A robust fix likely belongs in the storage/Rust command layer or a focused lorebook command wrapper, so embedded and remote runtime behavior stay identical and malformed callers cannot create cross-lorebook folder references. ## 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:33 +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#1091
No description provided.