[PR #1654] [MERGED] [codex] Wire mutation schemas at storage boundaries #5187

Closed
opened 2026-10-22 04:14:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1654
Author: @Xelvanis
Created: 5/30/2026
Status: ✅ Merged
Merged: 5/30/2026
Merged by: @Xelvanis

Base: refactor ← Head: codex/mutation-schema-boundaries


📝 Commits (3)

  • ea1a37e Wire mutation schema boundaries
  • 8c46d5a Route remaining mutation helpers through schemas
  • 6d8742e Address schema review feedback

📊 Changes

28 files changed (+479 additions, -110 deletions)

View changed files

➕ src/engine/contracts/schemas/connection.schema.test.ts (+22 -0)
📝 src/engine/contracts/schemas/connection.schema.ts (+12 -0)
📝 src/engine/contracts/schemas/lorebook.schema.test.ts (+82 -1)
📝 src/engine/contracts/schemas/lorebook.schema.ts (+19 -3)
➕ src/engine/contracts/schemas/prompt.schema.test.ts (+32 -0)
📝 src/engine/contracts/schemas/prompt.schema.ts (+29 -12)
➕ src/engine/contracts/schemas/regex.schema.test.ts (+18 -0)
📝 src/engine/contracts/schemas/regex.schema.ts (+3 -1)
➕ src/engine/contracts/schemas/theme.schema.test.ts (+18 -0)
📝 src/engine/contracts/schemas/theme.schema.ts (+3 -1)
📝 src/engine/contracts/types/lorebook.ts (+2 -2)
📝 src/features/catalog/agents/components/EditAgentModal.tsx (+7 -2)
📝 src/features/catalog/agents/hooks/use-agents.ts (+16 -3)
📝 src/features/catalog/agents/hooks/use-custom-tools.ts (+5 -2)
📝 src/features/catalog/agents/hooks/use-regex-scripts.ts (+7 -3)
📝 src/features/catalog/connections/hooks/use-connection-folders.ts (+2 -1)
📝 src/features/catalog/connections/hooks/use-connections.ts (+2 -1)
📝 src/features/catalog/lorebooks/components/CreateLorebookModal.tsx (+2 -1)
📝 src/features/catalog/lorebooks/components/LorebookMakerModal.tsx (+12 -2)
📝 src/features/catalog/lorebooks/components/LorebooksPanel.tsx (+7 -1)

...and 8 more files

📄 Description

Linked issue

None. This follows the unused-export cleanup triage for mutation schemas.

Why this change

  • Several exported mutation schemas existed but were not consistently used at the feature/storage write boundary.
  • Wiring them in keeps create/update payload contracts explicit instead of leaving validation behavior split across callers.
  • The branch preserves current lorebook helper behavior by allowing existing storage metadata patches such as ordering and embedding clears.

What changed

  • Routed theme, extension, lorebook, prompt preset, agent, custom tool, regex script, and connection mutation payloads through their contract schemas before storageApi writes.
  • Expanded schema coverage for behavior-compatible update patches, including connection folder moves, prompt defaults/order fields, lorebook game metadata, lorebook entry/folder ordering, embedding clears, and regex reorder metadata.
  • Added focused schema tests for narrow update patches so default-filled create schemas do not accidentally overwrite partial updates.

Refactor impact

Primary owner:

Engine contracts and catalog/shell feature mutation hooks.

Impact areas reviewed:

  • Settings theme and extension mutations.
  • Catalog agents, custom tools, regex scripts, connections, lorebooks, lorebook folders/entries, and prompt presets.
  • Game-session lorebook creation and generated lorebook metadata.
  • Lorebook Keeper, copy/move/reorder, unvectorize, and generated-entry helper paths.

Boundary notes:

  • Engine schemas remain React-free contract code.
  • Feature hooks/components parse payloads before calling the shared storageApi wrapper.
  • No Rust storage, Tauri command registration, or remote runtime route changes.

Pressure points touched:

  • Catalog and shell mutation hooks/components.
  • Game-session lorebook API helper.
  • No ModeSurface, GameSurface, src-tauri/src/lib.rs command registration, or import modules touched.

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

Automated validation run after rebasing onto current origin/refactor:

  • pnpm test -- src/engine/contracts/schemas/connection.schema.test.ts src/engine/contracts/schemas/prompt.schema.test.ts src/engine/contracts/schemas/theme.schema.test.ts src/engine/contracts/schemas/lorebook.schema.test.ts src/engine/contracts/schemas/regex.schema.test.ts passed: 5 files, 14 tests.
  • pnpm typecheck passed.
  • pnpm check:architecture passed.
  • pnpm check:line-endings passed.
  • git diff origin/refactor...HEAD --check passed.
  • pnpm build passed with the existing Vite large-chunk warning.

Native Tauri manual CRUD QA was not run.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

Code-only contract-boundary cleanup; no docs or release-note updates were made.

UI evidence

No screenshots or recordings. This change does not intentionally alter visible layout; it changes mutation validation behavior at storage boundaries.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added "Game" category for lorebooks
    • Added support for ordering and embedding management in lorebook entries and folders
    • Added variable ordering and default status management for prompt presets
    • Added reordering capability for regex scripts
    • Added active status tracking for themes
    • Enhanced connection folder management
  • Improvements

    • Improved data validation across lorebooks, connections, presets, and themes

Review Change Stack


🔄 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/1654 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/30/2026 **Status:** ✅ Merged **Merged:** 5/30/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `codex/mutation-schema-boundaries` --- ### 📝 Commits (3) - [`ea1a37e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ea1a37e78e5d2c88e4000c8d83d417a092fa1bc9) Wire mutation schema boundaries - [`8c46d5a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8c46d5aa6184a551114c75a4e2fdb11aadb80b8a) Route remaining mutation helpers through schemas - [`6d8742e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6d8742ef955d3a5809eb7fd78503c6db08dd7173) Address schema review feedback ### 📊 Changes **28 files changed** (+479 additions, -110 deletions) <details> <summary>View changed files</summary> ➕ `src/engine/contracts/schemas/connection.schema.test.ts` (+22 -0) 📝 `src/engine/contracts/schemas/connection.schema.ts` (+12 -0) 📝 `src/engine/contracts/schemas/lorebook.schema.test.ts` (+82 -1) 📝 `src/engine/contracts/schemas/lorebook.schema.ts` (+19 -3) ➕ `src/engine/contracts/schemas/prompt.schema.test.ts` (+32 -0) 📝 `src/engine/contracts/schemas/prompt.schema.ts` (+29 -12) ➕ `src/engine/contracts/schemas/regex.schema.test.ts` (+18 -0) 📝 `src/engine/contracts/schemas/regex.schema.ts` (+3 -1) ➕ `src/engine/contracts/schemas/theme.schema.test.ts` (+18 -0) 📝 `src/engine/contracts/schemas/theme.schema.ts` (+3 -1) 📝 `src/engine/contracts/types/lorebook.ts` (+2 -2) 📝 `src/features/catalog/agents/components/EditAgentModal.tsx` (+7 -2) 📝 `src/features/catalog/agents/hooks/use-agents.ts` (+16 -3) 📝 `src/features/catalog/agents/hooks/use-custom-tools.ts` (+5 -2) 📝 `src/features/catalog/agents/hooks/use-regex-scripts.ts` (+7 -3) 📝 `src/features/catalog/connections/hooks/use-connection-folders.ts` (+2 -1) 📝 `src/features/catalog/connections/hooks/use-connections.ts` (+2 -1) 📝 `src/features/catalog/lorebooks/components/CreateLorebookModal.tsx` (+2 -1) 📝 `src/features/catalog/lorebooks/components/LorebookMakerModal.tsx` (+12 -2) 📝 `src/features/catalog/lorebooks/components/LorebooksPanel.tsx` (+7 -1) _...and 8 more files_ </details> ### 📄 Description ## Linked issue None. This follows the unused-export cleanup triage for mutation schemas. ## Why this change - Several exported mutation schemas existed but were not consistently used at the feature/storage write boundary. - Wiring them in keeps create/update payload contracts explicit instead of leaving validation behavior split across callers. - The branch preserves current lorebook helper behavior by allowing existing storage metadata patches such as ordering and embedding clears. ## What changed - Routed theme, extension, lorebook, prompt preset, agent, custom tool, regex script, and connection mutation payloads through their contract schemas before `storageApi` writes. - Expanded schema coverage for behavior-compatible update patches, including connection folder moves, prompt defaults/order fields, lorebook game metadata, lorebook entry/folder ordering, embedding clears, and regex reorder metadata. - Added focused schema tests for narrow update patches so default-filled create schemas do not accidentally overwrite partial updates. ## Refactor impact Primary owner: Engine contracts and catalog/shell feature mutation hooks. Impact areas reviewed: - Settings theme and extension mutations. - Catalog agents, custom tools, regex scripts, connections, lorebooks, lorebook folders/entries, and prompt presets. - Game-session lorebook creation and generated lorebook metadata. - Lorebook Keeper, copy/move/reorder, unvectorize, and generated-entry helper paths. Boundary notes: - Engine schemas remain React-free contract code. - Feature hooks/components parse payloads before calling the shared `storageApi` wrapper. - No Rust storage, Tauri command registration, or remote runtime route changes. Pressure points touched: - Catalog and shell mutation hooks/components. - Game-session lorebook API helper. - No `ModeSurface`, `GameSurface`, `src-tauri/src/lib.rs` command registration, or import modules touched. ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> - [x] `pnpm check` passes locally - [x] `pnpm typecheck` passes locally - [x] `pnpm build` passes locally - [x] `pnpm check:architecture` passes locally - [x] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant ### Manual verification notes Automated validation run after rebasing onto current `origin/refactor`: - `pnpm test -- src/engine/contracts/schemas/connection.schema.test.ts src/engine/contracts/schemas/prompt.schema.test.ts src/engine/contracts/schemas/theme.schema.test.ts src/engine/contracts/schemas/lorebook.schema.test.ts src/engine/contracts/schemas/regex.schema.test.ts` passed: 5 files, 14 tests. - `pnpm typecheck` passed. - `pnpm check:architecture` passed. - `pnpm check:line-endings` passed. - `git diff origin/refactor...HEAD --check` passed. - `pnpm build` passed with the existing Vite large-chunk warning. Native Tauri manual CRUD QA was not run. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [x] Confirmed this PR does not restore old staging/package-workspace/release claims Code-only contract-boundary cleanup; no docs or release-note updates were made. ## UI evidence No screenshots or recordings. This change does not intentionally alter visible layout; it changes mutation validation behavior at storage boundaries. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added "Game" category for lorebooks * Added support for ordering and embedding management in lorebook entries and folders * Added variable ordering and default status management for prompt presets * Added reordering capability for regex scripts * Added active status tracking for themes * Enhanced connection folder management * **Improvements** * Improved data validation across lorebooks, connections, presets, and themes <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/1654?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- 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-22 04:14:03 +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#5187
No description provided.