[GH-ISSUE #2449] [Issue]: 12-PROMPT-RUNTIME-regex-prompt-transforms skips prompt messages #1203

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

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

Originally assigned to: @Promansis on GitHub.

Summary

12-PROMPT-RUNTIME-regex-prompt-transforms: prompt-only regex scripts do not transform refactor prompt/injection messages, and late group turn prompt messages are appended after the regex pass.

Linked target: #2442.

Expected behavior

Legacy applies macro-aware prompt regex scripts to every mapped prompt message after prompt macro context exists and before provider send.

Actual behavior

Refactor applies prompt regex during prompt assembly, but skips messages marked contextKind: "prompt" or "injection". It also appends group turn prompt messages after the regex pass, so those messages cannot be transformed.

Steps to reproduce

  1. Configure an enabled prompt-only regex script for a prompt/injection message pattern.
  2. Assemble a prompt that contains prompt/injection messages or a group turn prompt.
  3. Inspect the assembled provider-ready prompt content.

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@54a9ffd3 scan target
  • Run mode: not relevant; static prompt assembly trace
  • OS + version: not relevant
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not relevant
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: provider-neutral prompt assembly

Logs, screenshots, or video

Proof:

  • Legacy route applies regex after macro context exists: main:packages/server/src/routes/generate.routes.ts:2334.
  • Legacy helper transforms every mapped message by role/depth: main:packages/server/src/services/regex/regex-application.ts:108.
  • Refactor applies regex at src/engine/generation/prompt-assembly.ts:3421.
  • Refactor helper skips contextKind: "prompt" and "injection" at src/engine/generation-core/regex/regex-application.ts:113.
  • Refactor creates prompt/injection messages at src/engine/generation/prompt-assembly.ts:869 and src/engine/generation-core/lorebooks/prompt-injector.ts:105.
  • Refactor appends group turn prompt messages after the regex pass at src/engine/generation/prompt-assembly.ts:3425; the group turn prompt builders are at src/engine/generation/prompt-assembly.ts:2839.

Files inspected:

  • main:packages/server/src/routes/generate.routes.ts:2334
  • main:packages/server/src/services/regex/regex-application.ts:71
  • main:packages/client/src/hooks/use-apply-regex.ts:41
  • src/engine/generation/prompt-assembly.ts:3421
  • src/engine/generation-core/regex/regex-application.ts:69
  • src/engine/generation/regex-runtime.ts:20
  • src/engine/generation-core/lorebooks/prompt-injector.ts:98

Regression notes

Legacy behavior on main applies prompt regex scripts to all prompt messages in the mapped generation prompt. Refactor omits prompt/injection messages and late group turn prompts from that transform.

Additional context

Acceptance criteria:

  • Prompt-only regex scripts transform prompt and injection messages at the same generation stage as legacy.
  • Group turn prompt messages are included in the prompt regex pass.
  • Macro-aware find/replace/trim behavior remains preserved.
  • Non-prompt runtime user input and AI output regex behavior remains unchanged.
  • Add focused proof or test coverage for prompt/injection messages and late group turn prompts.

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 @Promansis on GitHub (Jun 6, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2449 Originally assigned to: @Promansis on GitHub. ## Summary `12-PROMPT-RUNTIME-regex-prompt-transforms`: prompt-only regex scripts do not transform refactor prompt/injection messages, and late group turn prompt messages are appended after the regex pass. Linked target: #2442. ## Expected behavior Legacy applies macro-aware prompt regex scripts to every mapped prompt message after prompt macro context exists and before provider send. ## Actual behavior Refactor applies prompt regex during prompt assembly, but skips messages marked `contextKind: "prompt"` or `"injection"`. It also appends group turn prompt messages after the regex pass, so those messages cannot be transformed. ## Steps to reproduce 1. Configure an enabled prompt-only regex script for a prompt/injection message pattern. 2. Assemble a prompt that contains prompt/injection messages or a group turn prompt. 3. Inspect the assembled provider-ready prompt content. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [x] Chat mode - [x] Roleplay mode - [x] 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@54a9ffd3` scan target - Run mode: not relevant; static prompt assembly trace - OS + version: not relevant - Node + pnpm versions: not relevant - Rust version, if relevant: not relevant - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: provider-neutral prompt assembly ## Logs, screenshots, or video Proof: - Legacy route applies regex after macro context exists: `main:packages/server/src/routes/generate.routes.ts:2334`. - Legacy helper transforms every mapped message by role/depth: `main:packages/server/src/services/regex/regex-application.ts:108`. - Refactor applies regex at `src/engine/generation/prompt-assembly.ts:3421`. - Refactor helper skips `contextKind: "prompt"` and `"injection"` at `src/engine/generation-core/regex/regex-application.ts:113`. - Refactor creates prompt/injection messages at `src/engine/generation/prompt-assembly.ts:869` and `src/engine/generation-core/lorebooks/prompt-injector.ts:105`. - Refactor appends group turn prompt messages after the regex pass at `src/engine/generation/prompt-assembly.ts:3425`; the group turn prompt builders are at `src/engine/generation/prompt-assembly.ts:2839`. Files inspected: - `main:packages/server/src/routes/generate.routes.ts:2334` - `main:packages/server/src/services/regex/regex-application.ts:71` - `main:packages/client/src/hooks/use-apply-regex.ts:41` - `src/engine/generation/prompt-assembly.ts:3421` - `src/engine/generation-core/regex/regex-application.ts:69` - `src/engine/generation/regex-runtime.ts:20` - `src/engine/generation-core/lorebooks/prompt-injector.ts:98` ## Regression notes Legacy behavior on `main` applies prompt regex scripts to all prompt messages in the mapped generation prompt. Refactor omits prompt/injection messages and late group turn prompts from that transform. ## Additional context Acceptance criteria: - Prompt-only regex scripts transform prompt and injection messages at the same generation stage as legacy. - Group turn prompt messages are included in the prompt regex pass. - Macro-aware find/replace/trim behavior remains preserved. - Non-prompt runtime user input and AI output regex behavior remains unchanged. - Add focused proof or test coverage for prompt/injection messages and late group turn prompts. ## 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:28:59 +07:00
  • closed this issue
  • added the
    bug
    label
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#1203
No description provided.