[GH-ISSUE #2188] [Issue]: Lorebook prompt assembly consumes runtime state before marker insertion is known #1089

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

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

Originally assigned to: @cha1latte on GitHub.

Summary

The lorebook runtime rescan found that refactor scans and mutates lorebook runtime state before confirming that the selected prompt preset has lorebook or world-info markers. Legacy scanned lorebooks only when a lorebook/world-info marker expanded.

Expected behavior

Prompt assembly should only consume lorebook runtime side effects when lorebook content is actually part of the prompt, or it should explicitly document and prove that markerless prompts intentionally still scan and consume sticky/cooldown/delay/ephemeral state.

Actual behavior

Refactor calls scanActiveLorebooks before iterating the selected preset sections. If the selected preset lacks lorebook, world_info_before, or world_info_after markers, activated lore may not be inserted, but timing and ephemeral state can still be returned and later persisted after generation.

Steps to reproduce

  1. Select or create a prompt preset that has no lorebook/world-info marker.
  2. Create an active lorebook entry with sticky, cooldown, delay, or ephemeral behavior.
  3. Generate a response where the entry would match.
  4. Inspect chat metadata after generation.
  5. Observe that runtime state can change even though no lorebook marker inserted the content.

Impact area

  • 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
  • Run mode: Tauri desktop / web shell / remote runtime, wherever prompt assembly uses the shared engine scanner
  • OS + version: not OS-specific
  • Node + pnpm versions: not relevant
  • 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

Static trace:

  • Refactor scans before marker processing in src/engine/generation/prompt-assembly.ts.
  • Refactor marker insertion uses already-scanned worldBefore / worldAfter values in sectionContent.
  • Legacy marker expansion scans only for lorebook, world_info_before, or world_info_after in packages/server/src/services/prompt/marker-expander.ts on main.

Regression notes

Legacy main cached a scan inside marker expansion and applied side effects once per prompt build only when lorebook/world-info markers were encountered.

Additional context

Parity row: 07-LB-RUNTIME-prompt-markers.

Classification from rescan: Confirmed regression.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Jun 4, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2188 Originally assigned to: @cha1latte on GitHub. ## Summary The lorebook runtime rescan found that refactor scans and mutates lorebook runtime state before confirming that the selected prompt preset has lorebook or world-info markers. Legacy scanned lorebooks only when a lorebook/world-info marker expanded. ## Expected behavior Prompt assembly should only consume lorebook runtime side effects when lorebook content is actually part of the prompt, or it should explicitly document and prove that markerless prompts intentionally still scan and consume sticky/cooldown/delay/ephemeral state. ## Actual behavior Refactor calls `scanActiveLorebooks` before iterating the selected preset sections. If the selected preset lacks `lorebook`, `world_info_before`, or `world_info_after` markers, activated lore may not be inserted, but timing and ephemeral state can still be returned and later persisted after generation. ## Steps to reproduce 1. Select or create a prompt preset that has no lorebook/world-info marker. 2. Create an active lorebook entry with sticky, cooldown, delay, or ephemeral behavior. 3. Generate a response where the entry would match. 4. Inspect chat metadata after generation. 5. Observe that runtime state can change even though no lorebook marker inserted the content. ## Impact area - [x] 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` - Run mode: Tauri desktop / web shell / remote runtime, wherever prompt assembly uses the shared engine scanner - OS + version: not OS-specific - Node + pnpm versions: not relevant - 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 Static trace: - Refactor scans before marker processing in `src/engine/generation/prompt-assembly.ts`. - Refactor marker insertion uses already-scanned `worldBefore` / `worldAfter` values in `sectionContent`. - Legacy marker expansion scans only for `lorebook`, `world_info_before`, or `world_info_after` in `packages/server/src/services/prompt/marker-expander.ts` on `main`. ## Regression notes Legacy `main` cached a scan inside marker expansion and applied side effects once per prompt build only when lorebook/world-info markers were encountered. ## Additional context Parity row: `07-LB-RUNTIME-prompt-markers`. Classification from rescan: `Confirmed regression`. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:26: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#1089
No description provided.