[GH-ISSUE #2291] [Issue]: Refactor generation path lacks request contract parity #1130

Closed
opened 2026-10-21 05:27:33 +07:00 by bsakaguchi · 0 comments
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

The refactor generation path no longer has an active request-validation/defaulting boundary equivalent to legacy /api/generate. The legacy generateRequestSchema still exists in the refactor tree, but it is not used by useGenerate -> startGeneration, and the live refactor input shape is split between loose UI args and StartGenerationInput extends JsonRecord.

This creates contract drift and at least one likely missing user-facing behavior: the persisted trimIncompleteModelOutput setting is no longer passed into or read by the normal refactor generation path.

Expected behavior

Refactor generation should have a current, refactor-native input contract that preserves the legacy validation/defaulting that still matters while also covering new engine fields.

The contract should account for current refactor fields such as message, messages, parameters, promptPresetId, imagePromptSettings, hideAutomatedSummarySourceMessages, and runtime debug handling, while preserving legacy checks/defaults for fields such as userStatus, userActivity, generationGuideSource, agentInjectionOverrides, attachments, and trimIncompleteModelOutput where those behaviors still apply.

Actual behavior

Legacy accepted generation requests through generateRequestSchema.parse(req.body) in packages/server/src/routes/generate.routes.ts. That schema covered request defaults and validation for normal generation, including streaming, userStatus, userActivity, userTimeZone, generationGuideSource, agentInjectionOverrides, attachments, and trimIncompleteModelOutput.

In the refactor:

  • src/engine/contracts/schemas/chat.schema.ts still exports generateRequestSchema, but searches show no current imports or parses of it outside the definition.
  • src/features/runtime/generation/hooks/use-generate.ts accepts loose GenerateArgs with [key: string]: unknown and calls startGeneration directly.
  • src/engine/generation/start-generation.ts accepts StartGenerationInput extends JsonRecord, so undeclared and malformed fields can pass through until individual helpers normalize or ignore them.
  • src/engine/generation/prompt-assembly.ts reads request.userStatus and request.userActivity, but those fields are not declared on StartGenerationInput.
  • The UI store still has trimIncompleteModelOutput, but normal refactor generation does not pass it into startGeneration and the engine does not appear to read it.

The old schema cannot be reused directly because it does not match the current runtime shape. For example, current UI sends message, while the legacy schema only had userMessage; parsing with the old schema would likely strip or ignore current fields. It also lacks current fields such as messages, parameters, promptPresetId, imagePromptSettings, hideAutomatedSummarySourceMessages, and debugSink.

Steps to reproduce

  1. Search the refactor tree for generateRequestSchema and confirm it is only defined, not used as a generation boundary.
  2. Trace normal generation from src/features/runtime/generation/hooks/use-generate.ts into src/engine/generation/start-generation.ts.
  3. Compare that live shape against the legacy packages/shared/src/schemas/chat.schema.ts and legacy /api/generate route parsing.
  4. Check trimIncompleteModelOutput: legacy client sent it to /generate and legacy server used it before saving output; refactor keeps the UI setting but does not appear to pass/read it in normal generation.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor worktree at 5ddb9840
  • Run mode: Static trace of the TypeScript generation path
  • OS + version: Not verified
  • Node + pnpm versions: Not relevant for static trace
  • Rust version, if relevant: Not relevant
  • Remote Runtime URL configured? Not relevant
  • Provider, model, or integration, if relevant: Not provider-specific

Logs, screenshots, or video

No runtime logs. Evidence is from static source trace.

Relevant refactor anchors:

  • src/engine/contracts/schemas/chat.schema.ts
  • src/features/runtime/generation/hooks/use-generate.ts
  • src/engine/generation/start-generation.ts
  • src/engine/generation/prompt-assembly.ts
  • src/shared/stores/ui/model.ts

Relevant legacy anchors:

  • packages/shared/src/schemas/chat.schema.ts
  • packages/server/src/routes/generate.routes.ts
  • packages/client/src/hooks/use-generate.ts

Regression notes

Legacy /api/generate parsed generateRequestSchema at the server boundary and used trimIncompleteModelOutput before saving model output. The refactor generation spine moved generation into the TypeScript engine path, but no equivalent refactor-native boundary schema appears to have replaced the legacy route contract.

Additional context

Recommended direction: do not wire the old generateRequestSchema directly into startGeneration. Instead, define a refactor-native generation input schema or normalization boundary near src/engine/generation/start-generation.ts, then remove or split the stale legacy-shaped schema from chat.schema.ts so the contract surface reflects the live path.

Template check

Please uncheck 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 @Xelvanis on GitHub (Jun 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2291 Originally assigned to: @SpicyMarinara on GitHub. ## Summary The refactor generation path no longer has an active request-validation/defaulting boundary equivalent to legacy `/api/generate`. The legacy `generateRequestSchema` still exists in the refactor tree, but it is not used by `useGenerate -> startGeneration`, and the live refactor input shape is split between loose UI args and `StartGenerationInput extends JsonRecord`. This creates contract drift and at least one likely missing user-facing behavior: the persisted `trimIncompleteModelOutput` setting is no longer passed into or read by the normal refactor generation path. ## Expected behavior Refactor generation should have a current, refactor-native input contract that preserves the legacy validation/defaulting that still matters while also covering new engine fields. The contract should account for current refactor fields such as `message`, `messages`, `parameters`, `promptPresetId`, `imagePromptSettings`, `hideAutomatedSummarySourceMessages`, and runtime debug handling, while preserving legacy checks/defaults for fields such as `userStatus`, `userActivity`, `generationGuideSource`, `agentInjectionOverrides`, `attachments`, and `trimIncompleteModelOutput` where those behaviors still apply. ## Actual behavior Legacy accepted generation requests through `generateRequestSchema.parse(req.body)` in `packages/server/src/routes/generate.routes.ts`. That schema covered request defaults and validation for normal generation, including `streaming`, `userStatus`, `userActivity`, `userTimeZone`, `generationGuideSource`, `agentInjectionOverrides`, `attachments`, and `trimIncompleteModelOutput`. In the refactor: - `src/engine/contracts/schemas/chat.schema.ts` still exports `generateRequestSchema`, but searches show no current imports or parses of it outside the definition. - `src/features/runtime/generation/hooks/use-generate.ts` accepts loose `GenerateArgs` with `[key: string]: unknown` and calls `startGeneration` directly. - `src/engine/generation/start-generation.ts` accepts `StartGenerationInput extends JsonRecord`, so undeclared and malformed fields can pass through until individual helpers normalize or ignore them. - `src/engine/generation/prompt-assembly.ts` reads `request.userStatus` and `request.userActivity`, but those fields are not declared on `StartGenerationInput`. - The UI store still has `trimIncompleteModelOutput`, but normal refactor generation does not pass it into `startGeneration` and the engine does not appear to read it. The old schema cannot be reused directly because it does not match the current runtime shape. For example, current UI sends `message`, while the legacy schema only had `userMessage`; parsing with the old schema would likely strip or ignore current fields. It also lacks current fields such as `messages`, `parameters`, `promptPresetId`, `imagePromptSettings`, `hideAutomatedSummarySourceMessages`, and `debugSink`. ## Steps to reproduce 1. Search the refactor tree for `generateRequestSchema` and confirm it is only defined, not used as a generation boundary. 2. Trace normal generation from `src/features/runtime/generation/hooks/use-generate.ts` into `src/engine/generation/start-generation.ts`. 3. Compare that live shape against the legacy `packages/shared/src/schemas/chat.schema.ts` and legacy `/api/generate` route parsing. 4. Check `trimIncompleteModelOutput`: legacy client sent it to `/generate` and legacy server used it before saving output; refactor keeps the UI setting but does not appear to pass/read it in normal generation. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [x] React-free engine behavior, contracts, agents, or capability ports - [ ] Shared API wrapper or remote runtime routing - [ ] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: refactor worktree at `5ddb9840` - Run mode: Static trace of the TypeScript generation path - OS + version: Not verified - Node + pnpm versions: Not relevant for static trace - Rust version, if relevant: Not relevant - Remote Runtime URL configured? Not relevant - Provider, model, or integration, if relevant: Not provider-specific ## Logs, screenshots, or video No runtime logs. Evidence is from static source trace. Relevant refactor anchors: - `src/engine/contracts/schemas/chat.schema.ts` - `src/features/runtime/generation/hooks/use-generate.ts` - `src/engine/generation/start-generation.ts` - `src/engine/generation/prompt-assembly.ts` - `src/shared/stores/ui/model.ts` Relevant legacy anchors: - `packages/shared/src/schemas/chat.schema.ts` - `packages/server/src/routes/generate.routes.ts` - `packages/client/src/hooks/use-generate.ts` ## Regression notes Legacy `/api/generate` parsed `generateRequestSchema` at the server boundary and used `trimIncompleteModelOutput` before saving model output. The refactor generation spine moved generation into the TypeScript engine path, but no equivalent refactor-native boundary schema appears to have replaced the legacy route contract. ## Additional context Recommended direction: do not wire the old `generateRequestSchema` directly into `startGeneration`. Instead, define a refactor-native generation input schema or normalization boundary near `src/engine/generation/start-generation.ts`, then remove or split the stale legacy-shaped schema from `chat.schema.ts` so the contract surface reflects the live path. ## Template check Please uncheck 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.
bsakaguchi 2026-10-21 05:27:33 +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#1130
No description provided.