[GH-ISSUE #2702] [Issue]: Marinara chat jsonl export→import silently deletes narrator/system messages, drops swipes and per-message metadata #1347

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

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Marinara's own chat export→import (the "SillyTavern-compatible" .jsonl) is lossy in several ways, the worst being that re-importing an exported chat silently deletes every narrator and /sys (system) message. Swipes, message metadata (reasoning/model/tokens/attachments), and branch identity are also lost.

Expected behavior

Exporting a Marinara chat to .jsonl and re-importing it should reproduce the chat faithfully — all messages (including narrator/system), all swipes, and per-message metadata.

Actual behavior

  1. Narrator/system messages deleted on round-trip (critical). serializeChatTranscript writes is_system: msg.role === "system" || msg.role === "narrator" — so narrator rows are exported as is_system:true. The Marinara jsonl importer then runs if (stMsg.is_system && !stMsg.is_user) continue;, discarding exactly those rows. Export→import drops every narrator message (often the bulk of RP scene text) and every /sys message.
  2. Swipes dropped both directions. Export writes only mes: msg.content (the active swipe) with no swipes[]/swipe_id; the importer has no swipe handling. All regenerated alternate swipes are lost on export, and multi-swipe messages collapse to one on import.
  3. Original mes discarded for regex display_text. When a message has a regex display_text, the importer keeps the display text and discards the original mes.
  4. Per-message metadata + branch lost. Export hardcodes chat_metadata: {} and emits no per-message extra, so branch name, reasoning blocks, model/token usage, and attachments are dropped.

How it breaks the pipeline

Code trace (staging @ b826f8f4):

  • (1) Export: packages/server/src/routes/chats.routes.ts:2272-2273 (is_user/is_system; narrator→is_system:true). Import: packages/server/src/services/import/st-chat.importer.ts:153 (if (stMsg.is_system && !stMsg.is_user) continue;). Round-trip wired via import.routes.ts:508/:584. Roles enum: shared/types/chat.ts:48.
  • (2) Export mes: msg.content (chats.routes.ts:2274), no swipes; import reads only mes/extra.display_text (st-chat.importer.ts:156). Swipe storage exists (chats.storage.ts, getSwipes).
  • (3) Importer display_text handling (st-chat.importer.ts:156).
  • (4) chat_metadata: {} (chats.routes.ts:2264); per-message object (:2270-2276) omits extra; rich extra persisted at chats.storage.ts:624,688-746.

Steps to reproduce

  1. Narrator deletion: create a chat with a Narrator (and/or /sys) message → Export as jsonl → Import that exact file → the narrator/system messages are gone.
  2. Swipes: generate 2–3 swipes on a message → export → the jsonl has only the active swipe; re-import yields a single-swipe message.
  3. Metadata: export a chat with branch name / reasoning / attachments → chat_metadata is {} and no message carries reasoning/model/attachment data.

Suggested fix

  • (1) Stop conflating narrator with system on export — emit a role marker (e.g. extra.type='narrator' or a role field) so the importer can reconstruct it, and/or make the importer not unconditionally drop is_system rows that carry recoverable role info. Round-trip the role explicitly.
  • (2) Serialize swipes in ST shape (swipes: [...], swipe_id: <active>) and teach the importer to recreate them via the swipe storage APIs.
  • (3) Preserve the original mes (store both raw and display_text) so the regex original isn't lost.
  • (4) Populate chat_metadata (at least { branchName }) and a per-message extra (reasoning/model/tokens/attachment refs); have the importer read them back.

Environment

  • Marinara Engine version: 2.0.0 (staging @ b826f8f4)
  • Install type: source
  • OS + version: All (code-level defect, platform-independent)
  • Browser or app shell: All

Additional context

Found via a systematic multi-agent audit of import/export round-trips. (1) is the highest-severity finding in the audit — Marinara's own export→import silently deletes user content. Part of a set of import/export fidelity issues filed together.

Template check

Please uncheck (untick) 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 @kolacheee on GitHub (Jun 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2702 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Marinara's own chat export→import (the "SillyTavern-compatible" `.jsonl`) is lossy in several ways, the worst being that **re-importing an exported chat silently deletes every narrator and `/sys` (system) message**. Swipes, message metadata (reasoning/model/tokens/attachments), and branch identity are also lost. ## Expected behavior Exporting a Marinara chat to `.jsonl` and re-importing it should reproduce the chat faithfully — all messages (including narrator/system), all swipes, and per-message metadata. ## Actual behavior 1. **Narrator/system messages deleted on round-trip (critical).** `serializeChatTranscript` writes `is_system: msg.role === "system" || msg.role === "narrator"` — so narrator rows are exported as `is_system:true`. The Marinara jsonl importer then runs `if (stMsg.is_system && !stMsg.is_user) continue;`, discarding exactly those rows. Export→import drops **every narrator message** (often the bulk of RP scene text) and every `/sys` message. 2. **Swipes dropped both directions.** Export writes only `mes: msg.content` (the active swipe) with no `swipes[]`/`swipe_id`; the importer has no swipe handling. All regenerated alternate swipes are lost on export, and multi-swipe messages collapse to one on import. 3. **Original `mes` discarded for regex display_text.** When a message has a regex `display_text`, the importer keeps the display text and discards the original `mes`. 4. **Per-message metadata + branch lost.** Export hardcodes `chat_metadata: {}` and emits no per-message `extra`, so branch name, reasoning blocks, model/token usage, and attachments are dropped. ## How it breaks the pipeline Code trace (staging @ `b826f8f4`): - (1) Export: `packages/server/src/routes/chats.routes.ts:2272-2273` (`is_user`/`is_system`; narrator→`is_system:true`). Import: `packages/server/src/services/import/st-chat.importer.ts:153` (`if (stMsg.is_system && !stMsg.is_user) continue;`). Round-trip wired via `import.routes.ts:508`/`:584`. Roles enum: `shared/types/chat.ts:48`. - (2) Export `mes: msg.content` (`chats.routes.ts:2274`), no swipes; import reads only `mes`/`extra.display_text` (`st-chat.importer.ts:156`). Swipe storage exists (`chats.storage.ts`, `getSwipes`). - (3) Importer `display_text` handling (`st-chat.importer.ts:156`). - (4) `chat_metadata: {}` (`chats.routes.ts:2264`); per-message object (`:2270-2276`) omits `extra`; rich `extra` persisted at `chats.storage.ts:624,688-746`. ## Steps to reproduce 1. **Narrator deletion:** create a chat with a Narrator (and/or `/sys`) message → Export as jsonl → Import that exact file → the narrator/system messages are gone. 2. **Swipes:** generate 2–3 swipes on a message → export → the jsonl has only the active swipe; re-import yields a single-swipe message. 3. **Metadata:** export a chat with branch name / reasoning / attachments → `chat_metadata` is `{}` and no message carries reasoning/model/attachment data. ## Suggested fix - (1) Stop conflating narrator with system on export — emit a role marker (e.g. `extra.type='narrator'` or a `role` field) so the importer can reconstruct it, and/or make the importer not unconditionally drop `is_system` rows that carry recoverable role info. Round-trip the role explicitly. - (2) Serialize swipes in ST shape (`swipes: [...]`, `swipe_id: <active>`) and teach the importer to recreate them via the swipe storage APIs. - (3) Preserve the original `mes` (store both raw and `display_text`) so the regex original isn't lost. - (4) Populate `chat_metadata` (at least `{ branchName }`) and a per-message `extra` (reasoning/model/tokens/attachment refs); have the importer read them back. ## Environment - Marinara Engine version: 2.0.0 (staging @ `b826f8f4`) - Install type: source - OS + version: All (code-level defect, platform-independent) - Browser or app shell: All ## Additional context Found via a systematic multi-agent audit of import/export round-trips. (1) is the highest-severity finding in the audit — Marinara's own export→import silently deletes user content. Part of a set of import/export fidelity issues filed together. ## Template check Please **uncheck (untick)** 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.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 21, 2026):

Fixed on the issue sweep branch. Marinara JSONL export now writes explicit message roles, branch/chat metadata, per-message extra, swipe contents, active swipe index, and per-swipe metadata. Import now preserves narrator/system messages instead of dropping pure system rows, keeps mes as canonical content while translating display_text into display metadata, and restores swipes/active swipe/metadata through the existing batch storage path. Final pnpm validation is deferred until the full sweep is complete.

<!-- gh-comment-id:4761575585 --> @SpicyMarinara commented on GitHub (Jun 21, 2026): Fixed on the issue sweep branch. Marinara JSONL export now writes explicit message roles, branch/chat metadata, per-message extra, swipe contents, active swipe index, and per-swipe metadata. Import now preserves narrator/system messages instead of dropping pure system rows, keeps mes as canonical content while translating display_text into display metadata, and restores swipes/active swipe/metadata through the existing batch storage path. Final pnpm validation is deferred until the full sweep is complete.
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#1347
No description provided.