[GH-ISSUE #3345] [Bug]: Native export bundles & forks linked (assigned) lorebooks — linked lorebooks should never export; only embedded should #1814

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

Originally created by @kolacheee on GitHub (Jul 7, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3345

Originally assigned to: @kolacheee on GitHub.

Summary

#3342 made native (.marinara.json) Character/Persona export bundle all attached lorebooks (via unfiltered listByCharacter / listByPersona) and re-link them on import. But linked (assigned) lorebooks are not supposed to export at all — they are shared, standalone entities that can be attached to many owners. Only an embedded lorebook (character_book) should travel with a card. So the native bundling is incorrect: it exports linked lorebooks and forks shared ones on import.

Expected behavior

Neither native nor compatible export should include linked/assigned lorebooks. Only the embedded lorebook (character_book, already part of the card data) travels. The intentional, explicit way to make a lorebook part of a card is to embed it (see #3341 / #3343) — not to have it auto-exported because it happens to be assigned.

Actual behavior

buildNativeCharacterEnvelope / buildNativePersonaEnvelope (packages/server/src/routes/characters.routes.ts) call readAttachedLorebooksForCharacter / readAttachedLorebooksForPersona → listByCharacter / listByPersona, which return every owner-linked lorebook with no filter (shared/assigned ones included), and add them as a top-level lorebooks bundle. On import (marinara.importer.ts importBundledLorebooks → importLorebookPayload) each is re-created as a new row linked to the imported owner. Consequences:

  • A genuinely-shared lorebook (e.g. a "World Rules" book assigned to 3 characters) is bundled into each character's native export and forked on every import — a fresh copy linked only to the newly-imported character, while the original shared book is untouched. Silent duplication of shared data.
  • A character with an embedded lorebook exports it twice (once as character_book, once as the bundled standalone), producing the duplicated imported state reported in #3344 — which this issue supersedes, since that double-count is just one symptom of exporting linked lorebooks at all.

Steps to reproduce

  1. Create a lorebook and Assign Lorebook it to two characters, A and B.
  2. Export character A in Native format.
  3. Inspect the .marinara.json: it contains a top-level lorebooks bundle carrying the shared lorebook.
  4. Import into a fresh instance → a new standalone lorebook is created, linked only to the imported A — a fork of the shared book.

Environment

  • Marinara Engine version: 2.1.1 (staging, bb26008b9)
  • Install type: source
  • OS + version: N/A (server-side data-shape issue)
  • Browser or app shell: N/A

Logs, screenshots, or video

N/A (data-shape issue). Code refs: readAttachedLorebooksForCharacter / readAttachedLorebooksForPersona / readLorebookBundles + the lorebooks bundle in buildNativeCharacterEnvelope / buildNativePersonaEnvelope (characters.routes.ts); importBundledLorebooks (marinara.importer.ts); listByCharacter / listByPersona (lorebooks.storage.ts) are unfiltered.

Suggested fix

Revert the attached-lorebook bundling (both the export side and the import re-link) from #3342, so native export — like compatible export — carries only the embedded character_book. Linked/assigned lorebooks stay in their own store and do not travel with the owner. Making a lorebook part of a card remains the user-driven Embed into card action (#3341 / #3343). This also resolves #3344 (the embedded double-count), which is a symptom of the same root cause.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @kolacheee on GitHub (Jul 7, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3345 Originally assigned to: @kolacheee on GitHub. ## Summary #3342 made **native** (`.marinara.json`) Character/Persona export bundle **all attached lorebooks** (via unfiltered `listByCharacter` / `listByPersona`) and re-link them on import. But **linked (assigned) lorebooks are not supposed to export at all** — they are shared, standalone entities that can be attached to many owners. Only an **embedded** lorebook (`character_book`) should travel with a card. So the native bundling is incorrect: it exports linked lorebooks and **forks** shared ones on import. ## Expected behavior Neither native nor compatible export should include linked/assigned lorebooks. Only the embedded lorebook (`character_book`, already part of the card data) travels. The intentional, explicit way to make a lorebook part of a card is to **embed** it (see #3341 / #3343) — not to have it auto-exported because it happens to be assigned. ## Actual behavior `buildNativeCharacterEnvelope` / `buildNativePersonaEnvelope` (`packages/server/src/routes/characters.routes.ts`) call `readAttachedLorebooksForCharacter` / `readAttachedLorebooksForPersona` → `listByCharacter` / `listByPersona`, which return **every** owner-linked lorebook with no filter (shared/assigned ones included), and add them as a top-level `lorebooks` bundle. On import (`marinara.importer.ts` `importBundledLorebooks` → `importLorebookPayload`) each is re-created as a new row linked to the imported owner. Consequences: - A genuinely-shared lorebook (e.g. a "World Rules" book assigned to 3 characters) is bundled into **each** character's native export and **forked** on every import — a fresh copy linked only to the newly-imported character, while the original shared book is untouched. Silent duplication of shared data. - A character with an **embedded** lorebook exports it **twice** (once as `character_book`, once as the bundled standalone), producing the duplicated imported state reported in #3344 — which this issue **supersedes**, since that double-count is just one symptom of exporting linked lorebooks at all. ## Steps to reproduce 1. Create a lorebook and **Assign Lorebook** it to two characters, A and B. 2. Export character A in **Native** format. 3. Inspect the `.marinara.json`: it contains a top-level `lorebooks` bundle carrying the shared lorebook. 4. Import into a fresh instance → a new standalone lorebook is created, linked only to the imported A — a fork of the shared book. ## Environment - Marinara Engine version: 2.1.1 (staging, `bb26008b9`) - Install type: source - OS + version: N/A (server-side data-shape issue) - Browser or app shell: N/A ## Logs, screenshots, or video N/A (data-shape issue). Code refs: `readAttachedLorebooksForCharacter` / `readAttachedLorebooksForPersona` / `readLorebookBundles` + the `lorebooks` bundle in `buildNativeCharacterEnvelope` / `buildNativePersonaEnvelope` (`characters.routes.ts`); `importBundledLorebooks` (`marinara.importer.ts`); `listByCharacter` / `listByPersona` (`lorebooks.storage.ts`) are unfiltered. ## Suggested fix Revert the attached-lorebook bundling (both the export side and the import re-link) from #3342, so native export — like compatible export — carries only the embedded `character_book`. Linked/assigned lorebooks stay in their own store and do not travel with the owner. Making a lorebook part of a card remains the user-driven **Embed into card** action (#3341 / #3343). This also resolves #3344 (the embedded double-count), which is a symptom of the same root cause. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:42:56 +07:00
  • closed this issue
  • added the
    in-pr
    bug
    labels
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#1814
No description provided.