[GH-ISSUE #181] [Issue]: World Map JSON loses lore links when imported lore entries receive new IDs #91

Closed
opened 2026-10-20 17:24:17 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @thetopham on GitHub (Aug 1, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/181

Originally assigned to: @thetopham on GitHub.

User report

I exported my map to JSON and saw lorebookEntryIds, but no lorebookId. When the JSON is imported back into Marinara Engine, how does it know which lorebook contains each entry? What happens if the lorebook ID changes during import? Should the sequence be character with embedded lorebook, then World JSON; or standalone lorebook, character without lorebook, then World JSON?

Confirmed behavior

Lorebook entry IDs are global primary keys in Marinara Engine. On the same installation, Maps can resolve an entry directly by its ID and then read that entry row's lorebookId, so the map does not need to store the book ID separately.

That does not survive a normal cross-installation or clean re-import workflow:

  • World Map export stores only each location's lorebookEntryIds.
  • World Map import preserves those IDs and has no lore-reference remapping step.
  • Character import intentionally discards a carried embedded lorebookId, creates a new lorebook, and creates new lorebook entry IDs.
  • Standalone Marinara and compatible lorebook imports also create new entry IDs.
  • If the original IDs no longer exist, Maps retains broken references, reports lorebook_entry_missing, and displays "Missing lore entry." It does not reconnect them to the newly imported entries.

Therefore neither expected migration sequence preserves the links:

  1. Character with embedded lorebook, then World JSON: the embedded lorebook and entries receive new IDs, while the map retains the old entry IDs.
  2. Standalone lorebook, character without embedded lorebook, then World JSON: the imported lorebook entries still receive new IDs, while the map retains the old entry IDs.

Same-installation map re-import works only while the original lorebook entries still exist. A complete database restore that preserves IDs is a different path and should continue to work.

Expected behavior

World Map export/import should support portable lore links when the corresponding character or lorebook has been imported with new IDs.

A safe solution should:

  • Resolve an exact existing entry ID first.
  • Include enough portable lore-reference metadata in new map exports to identify the original lorebook and entry when IDs change. Adding only lorebookId is insufficient because both IDs can change.
  • Reuse an old-to-new ID map from character/lorebook import when available, or provide an explicit relinking UI after map import.
  • Never silently bind by entry name alone when matches are ambiguous.
  • Preserve visible missing-reference warnings when no safe match exists.
  • Continue accepting existing format-version 2 and 3 map exports.

If import-session ID mapping requires a new host API or changes to the character/lorebook importers, track that as a paired Marinara-Engine change while keeping the World Map format and UI work package-owned here.

Acceptance coverage

  • Same-installation map export/import retains existing links.
  • Character-with-embedded-lorebook import followed by World Map import can reconnect entries whose IDs changed.
  • Standalone lorebook import followed by World Map import can reconnect entries whose IDs changed.
  • Duplicate lorebook or entry names do not cause an incorrect automatic attachment.
  • Truly missing entries remain visible and detachable.
  • Chat maps, templates, and shared worlds handle the same portable-reference contract.
  • Existing v2/v3 map files remain importable.

Current workaround

Import the lorebook or embedded character first, import the map, and manually replace each "Missing lore entry" attachment. An advanced workaround is to export the newly imported destination lorebook, build an old-entry-ID to new-entry-ID mapping, and update the World Map JSON before importing it.

Originally created by @thetopham on GitHub (Aug 1, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/181 Originally assigned to: @thetopham on GitHub. ## User report > I exported my map to JSON and saw `lorebookEntryIds`, but no `lorebookId`. When the JSON is imported back into Marinara Engine, how does it know which lorebook contains each entry? What happens if the lorebook ID changes during import? Should the sequence be character with embedded lorebook, then World JSON; or standalone lorebook, character without lorebook, then World JSON? ## Confirmed behavior Lorebook entry IDs are global primary keys in Marinara Engine. On the same installation, Maps can resolve an entry directly by its ID and then read that entry row's `lorebookId`, so the map does not need to store the book ID separately. That does not survive a normal cross-installation or clean re-import workflow: - World Map export stores only each location's `lorebookEntryIds`. - World Map import preserves those IDs and has no lore-reference remapping step. - Character import intentionally discards a carried embedded `lorebookId`, creates a new lorebook, and creates new lorebook entry IDs. - Standalone Marinara and compatible lorebook imports also create new entry IDs. - If the original IDs no longer exist, Maps retains broken references, reports `lorebook_entry_missing`, and displays "Missing lore entry." It does not reconnect them to the newly imported entries. Therefore neither expected migration sequence preserves the links: 1. Character with embedded lorebook, then World JSON: the embedded lorebook and entries receive new IDs, while the map retains the old entry IDs. 2. Standalone lorebook, character without embedded lorebook, then World JSON: the imported lorebook entries still receive new IDs, while the map retains the old entry IDs. Same-installation map re-import works only while the original lorebook entries still exist. A complete database restore that preserves IDs is a different path and should continue to work. ## Expected behavior World Map export/import should support portable lore links when the corresponding character or lorebook has been imported with new IDs. A safe solution should: - Resolve an exact existing entry ID first. - Include enough portable lore-reference metadata in new map exports to identify the original lorebook and entry when IDs change. Adding only `lorebookId` is insufficient because both IDs can change. - Reuse an old-to-new ID map from character/lorebook import when available, or provide an explicit relinking UI after map import. - Never silently bind by entry name alone when matches are ambiguous. - Preserve visible missing-reference warnings when no safe match exists. - Continue accepting existing format-version 2 and 3 map exports. If import-session ID mapping requires a new host API or changes to the character/lorebook importers, track that as a paired Marinara-Engine change while keeping the World Map format and UI work package-owned here. ## Acceptance coverage - Same-installation map export/import retains existing links. - Character-with-embedded-lorebook import followed by World Map import can reconnect entries whose IDs changed. - Standalone lorebook import followed by World Map import can reconnect entries whose IDs changed. - Duplicate lorebook or entry names do not cause an incorrect automatic attachment. - Truly missing entries remain visible and detachable. - Chat maps, templates, and shared worlds handle the same portable-reference contract. - Existing v2/v3 map files remain importable. ## Current workaround Import the lorebook or embedded character first, import the map, and manually replace each "Missing lore entry" attachment. An advanced workaround is to export the newly imported destination lorebook, build an old-entry-ID to new-entry-ID mapping, and update the World Map JSON before importing it.
Author
Owner

@thetopham commented on GitHub (Aug 1, 2026):

Proposed preferred UX: add an optional self-contained World Map export that embeds its lore dependencies, similar to a character with an embedded lorebook.

Export modes

  1. Map only — preserve the current lightweight behavior.
  2. Map + linked entries — recommended default for distribution; embed only the lorebook entries referenced by map locations, plus the book/folder metadata needed to preserve their behavior.
  3. Map + complete lorebooks — embed every entry from each referenced lorebook for creators distributing a complete setting. The export dialog should disclose the included book names, entry counts, approximate size, and the risk of including unrelated/private material.

Portable reference contract

The portable bundle should not depend solely on database IDs. A new format version could include:

  • embedded lorebook/book settings, folders, and entries;
  • stable bundle-local keys for books and entries;
  • each original book and entry ID as provenance, not as the only identity;
  • location-to-entry references using the bundle-local keys; and
  • optional artwork through the existing bundled-artwork mechanism.

Import sequence

The World Map importer can handle the complete operation atomically from the user's perspective:

  1. Resolve exact entry IDs that already exist.
  2. Import or reuse the embedded lorebooks and entries.
  3. Record the old/bundle entry key to destination entry ID mapping.
  4. Rewrite every location's lorebookEntryIds before saving the map, template, or shared world.
  5. Report only references that genuinely could not be restored.

This removes the required character/lorebook-versus-map import order and avoids asking users with large maps to repair every location manually.

Duplicate and safety behavior

  • Offer Reuse existing, Import separate copy, or an explicit choice when a safe match is not unique.
  • Never silently match by lorebook or entry name alone.
  • Do not delete an imported lorebook automatically when a map is deleted; it may be used by another map, character, or chat.
  • Keep disabled/excluded lorebook, folder, and entry behavior intact.
  • Continue reading v2/v3 exports as map-only files.
  • Ensure chat maps, templates, and shared worlds all use the same remapping contract.

For character bundles that also contain the same lorebook, provenance/fingerprints or a shared import-session map could prevent duplicate lorebooks. If that requires host importer support, it can be a paired Marinara-Engine change while the World Map bundle format remains package-owned here.

<!-- gh-comment-id:5153293015 --> @thetopham commented on GitHub (Aug 1, 2026): Proposed preferred UX: add an optional self-contained World Map export that embeds its lore dependencies, similar to a character with an embedded lorebook. ### Export modes 1. **Map only** — preserve the current lightweight behavior. 2. **Map + linked entries** — recommended default for distribution; embed only the lorebook entries referenced by map locations, plus the book/folder metadata needed to preserve their behavior. 3. **Map + complete lorebooks** — embed every entry from each referenced lorebook for creators distributing a complete setting. The export dialog should disclose the included book names, entry counts, approximate size, and the risk of including unrelated/private material. ### Portable reference contract The portable bundle should not depend solely on database IDs. A new format version could include: - embedded lorebook/book settings, folders, and entries; - stable bundle-local keys for books and entries; - each original book and entry ID as provenance, not as the only identity; - location-to-entry references using the bundle-local keys; and - optional artwork through the existing bundled-artwork mechanism. ### Import sequence The World Map importer can handle the complete operation atomically from the user's perspective: 1. Resolve exact entry IDs that already exist. 2. Import or reuse the embedded lorebooks and entries. 3. Record the old/bundle entry key to destination entry ID mapping. 4. Rewrite every location's `lorebookEntryIds` before saving the map, template, or shared world. 5. Report only references that genuinely could not be restored. This removes the required character/lorebook-versus-map import order and avoids asking users with large maps to repair every location manually. ### Duplicate and safety behavior - Offer **Reuse existing**, **Import separate copy**, or an explicit choice when a safe match is not unique. - Never silently match by lorebook or entry name alone. - Do not delete an imported lorebook automatically when a map is deleted; it may be used by another map, character, or chat. - Keep disabled/excluded lorebook, folder, and entry behavior intact. - Continue reading v2/v3 exports as map-only files. - Ensure chat maps, templates, and shared worlds all use the same remapping contract. For character bundles that also contain the same lorebook, provenance/fingerprints or a shared import-session map could prevent duplicate lorebooks. If that requires host importer support, it can be a paired Marinara-Engine change while the World Map bundle format remains package-owned here.
Author
Owner

@thetopham commented on GitHub (Aug 2, 2026):

Additional beta feedback suggests a useful manual-recovery layer even before automatic cross-import remapping is available.

When exporting a World Map, preserve human-readable source metadata for each linked lore entry so a user can understand and repair a missing link after importing the character/lorebook and map elsewhere. The recovery display should be able to show at least:

Location name -> original lorebook name -> original lorebook entry name -> original entry ID

Possible delivery options:

  • include the original lorebook and entry names as non-authoritative metadata beside each exported lore reference, then display those names in lorebook_entry_missing warnings and the relinking UI; and/or
  • offer a human-readable mapping export, such as world-map-lore-mapping.txt or JSON, that the map creator can distribute with the map, characters, and lorebooks.

This metadata should guide manual relinking, not silently match by name. Duplicate lorebook or entry names remain ambiguous, so exact IDs/import-session mappings and explicit user confirmation should stay authoritative.

Suggested acceptance additions:

  • A missing imported link identifies the original location, lorebook, and entry names rather than showing only an opaque missing ID.
  • A creator can export or inspect a complete location-to-lore mapping for distribution with a World Map bundle.
  • Existing exports without descriptive metadata remain importable.
  • Renamed or duplicate entries are never silently attached by name alone.
<!-- gh-comment-id:5159051558 --> @thetopham commented on GitHub (Aug 2, 2026): Additional beta feedback suggests a useful manual-recovery layer even before automatic cross-import remapping is available. When exporting a World Map, preserve human-readable source metadata for each linked lore entry so a user can understand and repair a missing link after importing the character/lorebook and map elsewhere. The recovery display should be able to show at least: `Location name -> original lorebook name -> original lorebook entry name -> original entry ID` Possible delivery options: - include the original lorebook and entry names as non-authoritative metadata beside each exported lore reference, then display those names in `lorebook_entry_missing` warnings and the relinking UI; and/or - offer a human-readable mapping export, such as `world-map-lore-mapping.txt` or JSON, that the map creator can distribute with the map, characters, and lorebooks. This metadata should guide manual relinking, not silently match by name. Duplicate lorebook or entry names remain ambiguous, so exact IDs/import-session mappings and explicit user confirmation should stay authoritative. Suggested acceptance additions: - A missing imported link identifies the original location, lorebook, and entry names rather than showing only an opaque missing ID. - A creator can export or inspect a complete location-to-lore mapping for distribution with a World Map bundle. - Existing exports without descriptive metadata remain importable. - Renamed or duplicate entries are never silently attached by name alone.
Author
Owner

@thetopham commented on GitHub (Aug 2, 2026):

Manual review confirmed portable lore copies persist and remap correctly, but the main Lorebooks library remains stale until refresh and linked-lore Open navigation has regressed. Starting follow-up work on branch agent/fix-world-map-lore-refresh. Owner: @thetopham.

<!-- gh-comment-id:5160878090 --> @thetopham commented on GitHub (Aug 2, 2026): Manual review confirmed portable lore copies persist and remap correctly, but the main Lorebooks library remains stale until refresh and linked-lore Open navigation has regressed. Starting follow-up work on branch agent/fix-world-map-lore-refresh. Owner: @thetopham.
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-Agents#91
No description provided.