[PR #4377] [MERGED] Fix startup crash from legacy visual_novel mode in packaged agent manifests #6354

Closed
opened 2026-10-23 04:09:37 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4377
Author: @Gunterlie
Created: 7/31/2026
Status: ✅ Merged
Merged: 7/31/2026
Merged by: @Gunterlie

Base: staging ← Head: fix/visual-novel-startup


📝 Commits (4)

  • 73b0d18 Fix startup crash from legacy visual_novel mode in packaged agent manifests
  • ba6cf4f Normalize retired visual_novel mode on load instead of orphaning rows
  • 49f3f12 Merge branch 'staging' into fix/visual-novel-startup
  • 62c3348 Merge branch 'staging' into fix/visual-novel-startup

📊 Changes

3 files changed (+42 additions, -3 deletions)

View changed files

📝 packages/server/src/db/file-backed-store.ts (+12 -2)
➕ packages/server/src/db/retired-chat-mode-migration.ts (+17 -0)
📝 packages/shared/src/schemas/capability-package.schema.ts (+13 -1)

📄 Description

Fixes #4375

Why

#4369 removed visual_novel from supported enums without migrating data that already exists on users' machines.

Startup crash. Installed capability packages still list visual_novel in modeAllowlist (world-state@1.0.1 is the reported case). readInstalledAgentDefinitions parses those manifests strictly, so one stale package throws a ZodError during buildApp and the server never starts:

Invalid enum value. Expected 'conversation' | 'roleplay' | 'game', received 'visual_novel'
  at readInstalledAgentDefinitions (.../package-manager.service.js:254)
  at async buildApp (.../app.js:179)
[startup] Unhandled error during server bootstrap

Orphaned rows. Chats, chat folders, and chat settings profiles stored with mode: "visual_novel" do not crash anything — the file-backed store does not validate enum columns — but every lookup filters by one of the three live modes, so that data silently stops showing up.

What

Both halves normalize visual_novel to roleplay, its behavioural successor, rather than dropping it.

  • packages/shared/src/schemas/capability-package.schema.ts — modeAllowlist maps the retired value before the enum parse (and dedupes, since ["roleplay", "visual_novel"] is the common shape). Filtering it out instead would turn a visual_novel-only allowlist into an empty one, which the agent policy reads as "available in every mode".
  • packages/server/src/db/retired-chat-mode-migration.ts (new) + file-backed-store.ts — rewrites mode on load for chats, chat_folders, and chat_presets, following the existing migrateLegacyNoodleAccountRow hook. Marks the table dirty so the rewrite persists once instead of re-running every boot.

Test plan

  • Manually verify the server starts with world-state@1.0.1 installed (modeAllowlist: ["roleplay", "visual_novel"])
  • Manually verify that agent still appears in Roleplay chats and not in Conversation/Game
  • Manually verify a pre-existing visual_novel chat opens and behaves as a Roleplay chat
  • Manually verify a visual_novel chat settings profile appears in the Roleplay profile list
  • Manually verify the on-disk table files are rewritten once, and a second boot logs no further migration churn
  • Manually verify packages/rows with no legacy mode are untouched
  • pnpm check

Summary by CodeRabbit

  • Bug Fixes
    • Updated legacy chat-mode data from “visual novel” to “roleplay” during loading and validation.
    • Automatically saves normalized values so the migration is applied consistently.
    • Removed duplicate entries when processing supported chat-mode settings.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/4377 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 7/31/2026 **Status:** ✅ Merged **Merged:** 7/31/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `fix/visual-novel-startup` --- ### 📝 Commits (4) - [`73b0d18`](https://github.com/Pasta-Devs/Marinara-Engine/commit/73b0d18614f9696ee2b7db40117edc9059f8dd2d) Fix startup crash from legacy visual_novel mode in packaged agent manifests - [`ba6cf4f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ba6cf4fda7692c2597d0a06d82d18d880d6e8db1) Normalize retired visual_novel mode on load instead of orphaning rows - [`49f3f12`](https://github.com/Pasta-Devs/Marinara-Engine/commit/49f3f1220bdec5cb68e42616c9757fd3a83b0bef) Merge branch 'staging' into fix/visual-novel-startup - [`62c3348`](https://github.com/Pasta-Devs/Marinara-Engine/commit/62c3348795390a666bc04f3cc0f54099c5822462) Merge branch 'staging' into fix/visual-novel-startup ### 📊 Changes **3 files changed** (+42 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/db/file-backed-store.ts` (+12 -2) ➕ `packages/server/src/db/retired-chat-mode-migration.ts` (+17 -0) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+13 -1) </details> ### 📄 Description Fixes #4375 ## Why #4369 removed `visual_novel` from supported enums without migrating data that already exists on users' machines. **Startup crash.** Installed capability packages still list `visual_novel` in `modeAllowlist` (`world-state@1.0.1` is the reported case). `readInstalledAgentDefinitions` parses those manifests strictly, so one stale package throws a `ZodError` during `buildApp` and the server never starts: ``` Invalid enum value. Expected 'conversation' | 'roleplay' | 'game', received 'visual_novel' at readInstalledAgentDefinitions (.../package-manager.service.js:254) at async buildApp (.../app.js:179) [startup] Unhandled error during server bootstrap ``` **Orphaned rows.** Chats, chat folders, and chat settings profiles stored with `mode: "visual_novel"` do not crash anything — the file-backed store does not validate enum columns — but every lookup filters by one of the three live modes, so that data silently stops showing up. ## What Both halves normalize `visual_novel` to `roleplay`, its behavioural successor, rather than dropping it. - `packages/shared/src/schemas/capability-package.schema.ts` — `modeAllowlist` maps the retired value before the enum parse (and dedupes, since `["roleplay", "visual_novel"]` is the common shape). Filtering it out instead would turn a `visual_novel`-only allowlist into an empty one, which the agent policy reads as "available in every mode". - `packages/server/src/db/retired-chat-mode-migration.ts` (new) + `file-backed-store.ts` — rewrites `mode` on load for `chats`, `chat_folders`, and `chat_presets`, following the existing `migrateLegacyNoodleAccountRow` hook. Marks the table dirty so the rewrite persists once instead of re-running every boot. ## Test plan - [ ] Manually verify the server starts with `world-state@1.0.1` installed (`modeAllowlist: ["roleplay", "visual_novel"]`) - [ ] Manually verify that agent still appears in Roleplay chats and not in Conversation/Game - [ ] Manually verify a pre-existing `visual_novel` chat opens and behaves as a Roleplay chat - [ ] Manually verify a `visual_novel` chat settings profile appears in the Roleplay profile list - [ ] Manually verify the on-disk table files are rewritten once, and a second boot logs no further migration churn - [ ] Manually verify packages/rows with no legacy mode are untouched - [ ] `pnpm check` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Updated legacy chat-mode data from “visual novel” to “roleplay” during loading and validation. * Automatically saves normalized values so the migration is applied consistently. * Removed duplicate entries when processing supported chat-mode settings. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:09:37 +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#6354
No description provided.