[GH-ISSUE #3341] [Feature]: Embed a linked character lorebook into the card so it exports #1812

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

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

Originally assigned to: @kolacheee on GitHub.

What problem does this solve?

Character cards can carry an embedded lorebook (the V2 character_book) that travels with the card on export — but there's no way to create that state from inside Marinara. If I build a lorebook and attach it with Assign Lorebook, it becomes a linked lorebook: a separate entity that just references the character. Linked lorebooks are not written into the card and do not export with it — GET /characters/:id/export serializes the character's data as-is, and linked lorebooks live in their own rows, so they get left behind.

The practical consequence: the only characters that export with a working lorebook are ones I imported with an embedded book already. Anything I author or link myself can't be shared as a self-contained card, which defeats the point of exporting for backup or sharing.

Concretely (screenshots below): my imported KZK card shows Reimport Embedded Lorebook / Edit Linked Lorebook because it has embedded data. My Floyd card, where I attached the same lorebook via Assign Lorebook, only shows Assign Lorebook — there is no way to embed it, and exporting Floyd silently drops the lorebook.

Proposed solution

An "Embed into card" action on a linked character-category lorebook that writes its current entries into the character's data.character_book and sets the extensions.importMetadata.embeddedLorebook back-pointer — i.e. the inverse of the existing Import Embedded Lorebook (which only goes card → standalone). After embedding:

  • the card exports with the lorebook (native and compatible formats),
  • future edits keep syncing into character_book, exactly like an imported embedded book.

The conversion primitive already exists server-side (toCharacterBook in character-book-sync.ts), so this is mostly wiring plus guards for the single-character_book slot.

Alternatives considered

  • Auto-including linked lorebooks in /export — rejected: linked lorebooks are shared, reusable entities (one book can attach to many characters), so silently baking one into a single card's data would be surprising and could fork/duplicate it. An explicit, opt-in embed action keeps the intent clear.
  • Copying entries into a freshly New-created character lorebook — doesn't help: created lorebooks are still linked, not embedded, so they still don't export.

Additional context

Verified in the v2.1.0 code: the only embedded-lorebook endpoint is POST /characters/:id/embedded-lorebook/import (card → standalone) — there is no standalone → card path. Both export builders (buildNativeCharacterEnvelope, buildCompatibleCharacterExport) serialize charData as-is, and syncCharacterBookFromLorebook is a documented no-op for a lorebook that isn't the character's embedded one. A draft PR implementing this is on the way.

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/3341 Originally assigned to: @kolacheee on GitHub. ## What problem does this solve? Character cards can carry an **embedded** lorebook (the V2 `character_book`) that travels with the card on export — but there's no way to *create* that state from inside Marinara. If I build a lorebook and attach it with **Assign Lorebook**, it becomes a **linked** lorebook: a separate entity that just references the character. Linked lorebooks are **not written into the card and do not export with it** — `GET /characters/:id/export` serializes the character's `data` as-is, and linked lorebooks live in their own rows, so they get left behind. The practical consequence: the only characters that export with a working lorebook are ones I *imported* with an embedded book already. Anything I author or link myself can't be shared as a self-contained card, which defeats the point of exporting for backup or sharing. Concretely (screenshots below): my imported **KZK** card shows *Reimport Embedded Lorebook* / *Edit Linked Lorebook* because it has embedded data. My **Floyd** card, where I attached the same lorebook via **Assign Lorebook**, only shows *Assign Lorebook* — there is no way to embed it, and exporting Floyd silently drops the lorebook. ## Proposed solution An **"Embed into card"** action on a linked character-category lorebook that writes its current entries into the character's `data.character_book` and sets the `extensions.importMetadata.embeddedLorebook` back-pointer — i.e. the inverse of the existing *Import Embedded Lorebook* (which only goes card → standalone). After embedding: - the card exports with the lorebook (native and compatible formats), - future edits keep syncing into `character_book`, exactly like an imported embedded book. The conversion primitive already exists server-side (`toCharacterBook` in `character-book-sync.ts`), so this is mostly wiring plus guards for the single-`character_book` slot. ## Alternatives considered - **Auto-including linked lorebooks in `/export`** — rejected: linked lorebooks are shared, reusable entities (one book can attach to many characters), so silently baking one into a single card's data would be surprising and could fork/duplicate it. An explicit, opt-in embed action keeps the intent clear. - **Copying entries into a freshly *New*-created character lorebook** — doesn't help: created lorebooks are still *linked*, not embedded, so they still don't export. ## Additional context Verified in the v2.1.0 code: the only embedded-lorebook endpoint is `POST /characters/:id/embedded-lorebook/import` (card → standalone) — there is no standalone → card path. Both export builders (`buildNativeCharacterEnvelope`, `buildCompatibleCharacterExport`) serialize `charData` as-is, and `syncCharacterBookFromLorebook` is a documented no-op for a lorebook that isn't the character's embedded one. A draft PR implementing this is on the way. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:42:56 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Jul 7, 2026):

Pushing to staging in a second.

<!-- gh-comment-id:4908039949 --> @SpicyMarinara commented on GitHub (Jul 7, 2026): Pushing to staging in a second.
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#1812
No description provided.