[PR #3916] [MERGED] Refactor shared agent, prompt, and lorebook contracts #6157

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3916
Author: @Xelvanis
Created: 7/21/2026
Status: ✅ Merged
Merged: 7/21/2026
Merged by: @SpicyMarinara

Base: staging ← Head: refactor-simplify-shared-contracts


📝 Commits (3)

  • aa2ac9c refactor: simplify shared prompt and agent contracts
  • d1cd1ae refactor: centralize music source matching
  • c73a990 Merge remote-tracking branch 'origin/staging' into codex/integrate-3916

📊 Changes

12 files changed (+63 additions, -202 deletions)

View changed files

📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+0 -1)
📝 packages/server/src/routes/generate.routes.ts (+0 -1)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+3 -11)
📝 packages/server/src/services/agents/agent-executor.ts (+1 -2)
📝 packages/server/src/services/generation/agent-resolution.ts (+9 -12)
📝 packages/shared/src/features/agents/agent-registry.ts (+0 -4)
📝 packages/shared/src/index.ts (+0 -1)
📝 packages/shared/src/schemas/lorebook.schema.ts (+45 -125)
📝 packages/shared/src/schemas/prompt.schema.ts (+5 -33)
📝 packages/shared/src/types/agent.ts (+0 -7)
📝 scripts/regressions/prompt.regression.ts (+0 -4)
📝 scripts/regressions/roleplay-streaming.regression.ts (+0 -1)

📄 Description

Linked issue

Closes #3915

Why this change

  • Reduce duplicated validation rules and unused shared API surface in the Engine's agent, prompt, and lorebook host contracts.
  • Keep create/update validation aligned while preserving existing runtime behavior.

What changed

  • Derive lorebook folder, lorebook, lorebook-entry, prompt-group, prompt-section, and choice-block update schemas from their create schemas.
  • Remove the unused AgentContext.activatedLorebookEntries field, resolveAgentPromptTemplate.agentType argument, and write-only built-in run-interval mirror.
  • Use the canonical built-in prompt resolver and call the canonical agent-phase normalizer directly.
  • Update affected callers and regression fixtures for the reduced contracts.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • pnpm check passed, including workspace lint/type checks and the production build.
  • pnpm regression:prompt passed the affected prompt, lorebook, and agent cases, then exited non-zero on an unchanged Windows CRLF-sensitive assertion for the Prose Guardian documentation heading. The heading exists in both this branch and origin/staging.
  • In Chromium at localhost:5173, verified default/non-default agent prompt selection and persistence; disposable prompt preset/group/section/choice CRUD; disposable lorebook/folder/entry CRUD and partial updates; cleanup of all disposable records; and an empty browser warning/error log.
  • Provider-backed agent generation, container execution, mobile viewport, and light/dark visual checks were not run because this refactor does not change generated UI or provider behavior.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

No documentation, release metadata, or user-facing UI changes are required.

UI evidence (if applicable)

Not applicable: this is a behavior-preserving contract and schema simplification with no visual changes.

Summary by CodeRabbit

  • Bug Fixes

    • Improved fallback prompt selection for agents, including music-focused agents.
    • Standardized agent phase handling for more consistent execution behavior.
    • Removed obsolete context data that could cause inconsistent agent processing.
  • Validation

    • Updated lorebook and prompt update validation to stay aligned with their creation rules.
    • Preserved lorebook scope conflict checks while simplifying supported update payloads.

🔄 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/3916 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 7/21/2026 **Status:** ✅ Merged **Merged:** 7/21/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `refactor-simplify-shared-contracts` --- ### 📝 Commits (3) - [`aa2ac9c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aa2ac9cff98ed116856fbc3f0ba49db9b5fceb60) refactor: simplify shared prompt and agent contracts - [`d1cd1ae`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d1cd1aeb3257fc89fb4857f523ec3cf138882110) refactor: centralize music source matching - [`c73a990`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c73a99048589036ef4890db6e9c8060f57010b32) Merge remote-tracking branch 'origin/staging' into codex/integrate-3916 ### 📊 Changes **12 files changed** (+63 additions, -202 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+0 -1) 📝 `packages/server/src/routes/generate.routes.ts` (+0 -1) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+3 -11) 📝 `packages/server/src/services/agents/agent-executor.ts` (+1 -2) 📝 `packages/server/src/services/generation/agent-resolution.ts` (+9 -12) 📝 `packages/shared/src/features/agents/agent-registry.ts` (+0 -4) 📝 `packages/shared/src/index.ts` (+0 -1) 📝 `packages/shared/src/schemas/lorebook.schema.ts` (+45 -125) 📝 `packages/shared/src/schemas/prompt.schema.ts` (+5 -33) 📝 `packages/shared/src/types/agent.ts` (+0 -7) 📝 `scripts/regressions/prompt.regression.ts` (+0 -4) 📝 `scripts/regressions/roleplay-streaming.regression.ts` (+0 -1) </details> ### 📄 Description ## Linked issue Closes #3915 ## Why this change - Reduce duplicated validation rules and unused shared API surface in the Engine's agent, prompt, and lorebook host contracts. - Keep create/update validation aligned while preserving existing runtime behavior. ## What changed - Derive lorebook folder, lorebook, lorebook-entry, prompt-group, prompt-section, and choice-block update schemas from their create schemas. - Remove the unused `AgentContext.activatedLorebookEntries` field, `resolveAgentPromptTemplate.agentType` argument, and write-only built-in run-interval mirror. - Use the canonical built-in prompt resolver and call the canonical agent-phase normalizer directly. - Update affected callers and regression fixtures for the reduced contracts. ## Validation - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - `pnpm check` passed, including workspace lint/type checks and the production build. - `pnpm regression:prompt` passed the affected prompt, lorebook, and agent cases, then exited non-zero on an unchanged Windows CRLF-sensitive assertion for the Prose Guardian documentation heading. The heading exists in both this branch and `origin/staging`. - In Chromium at `localhost:5173`, verified default/non-default agent prompt selection and persistence; disposable prompt preset/group/section/choice CRUD; disposable lorebook/folder/entry CRUD and partial updates; cleanup of all disposable records; and an empty browser warning/error log. - Provider-backed agent generation, container execution, mobile viewport, and light/dark visual checks were not run because this refactor does not change generated UI or provider behavior. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) No documentation, release metadata, or user-facing UI changes are required. ## UI evidence (if applicable) Not applicable: this is a behavior-preserving contract and schema simplification with no visual changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved fallback prompt selection for agents, including music-focused agents. * Standardized agent phase handling for more consistent execution behavior. * Removed obsolete context data that could cause inconsistent agent processing. * **Validation** * Updated lorebook and prompt update validation to stay aligned with their creation rules. * Preserved lorebook scope conflict checks while simplifying supported update payloads. <!-- 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:07:38 +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#6157
No description provided.