[GH-ISSUE #1249] [Issue]: Refactor lorebook activation gates ignore game state and fail open #610

Closed
opened 2026-10-20 17:30:42 +07:00 by bsakaguchi · 0 comments
Owner

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

Originally assigned to: @cha1latte on GitHub.

Summary

Lorebook activation conditions and schedules can fail open during prompt assembly because lorebook scanning is called without visible game state, and the scanner treats missing game state as "condition passed."

Expected behavior

Lorebook entries with game-state activation gates should only activate when the current visible game state satisfies those gates. If game state is unavailable for a gated entry, the behavior should be explicit and tested rather than silently passing the condition.

Actual behavior

Prompt assembly calls lorebook scanning without game state. In the scanner, missing game state causes activation conditions and schedules to pass.

Steps to reproduce

  1. On the refactor branch, create or attach a lorebook entry with a game-state activation gate, such as a location/time/weather condition.
  2. Open a chat/game state where the visible game state does not satisfy that condition.
  3. Generate a response with a prompt context that would otherwise keyword-match the lorebook entry.
  4. Inspect the assembled prompt or debug output to see whether the gated entry activated anyway.

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, identified during 2026-05-26 failpath audit
  • Run mode: generation/prompt assembly path
  • OS + version: not OS-specific
  • Node + pnpm versions: not captured
  • Rust version, if relevant: not relevant
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: any text generation provider

Logs, screenshots, or video

Relevant code paths:

src/engine/generation/prompt-assembly.ts
src/engine/generation-core/lorebooks/keyword-scanner.ts

Audit finding:

Prompt assembly calls scanForActivatedEntries without gameState.
The keyword scanner returns true for condition/schedule checks when gameState is missing.

Regression notes

Found by source inspection during the 2026-05-26 failpath audit. Needs a focused lorebook activation regression test.

Additional context

This can leak conditional lore into prompts in the wrong location/time/weather/state, which affects generation quality and mode consistency.

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 (May 26, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1249 Originally assigned to: @cha1latte on GitHub. ## Summary Lorebook activation conditions and schedules can fail open during prompt assembly because lorebook scanning is called without visible game state, and the scanner treats missing game state as "condition passed." ## Expected behavior Lorebook entries with game-state activation gates should only activate when the current visible game state satisfies those gates. If game state is unavailable for a gated entry, the behavior should be explicit and tested rather than silently passing the condition. ## Actual behavior Prompt assembly calls lorebook scanning without game state. In the scanner, missing game state causes activation conditions and schedules to pass. ## Steps to reproduce 1. On the `refactor` branch, create or attach a lorebook entry with a game-state activation gate, such as a location/time/weather condition. 2. Open a chat/game state where the visible game state does not satisfy that condition. 3. Generate a response with a prompt context that would otherwise keyword-match the lorebook entry. 4. Inspect the assembled prompt or debug output to see whether the gated entry activated anyway. ## 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`, identified during 2026-05-26 failpath audit - Run mode: generation/prompt assembly path - OS + version: not OS-specific - Node + pnpm versions: not captured - Rust version, if relevant: not relevant - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: any text generation provider ## Logs, screenshots, or video Relevant code paths: ```text src/engine/generation/prompt-assembly.ts src/engine/generation-core/lorebooks/keyword-scanner.ts ``` Audit finding: ```text Prompt assembly calls scanForActivatedEntries without gameState. The keyword scanner returns true for condition/schedule checks when gameState is missing. ``` ## Regression notes Found by source inspection during the 2026-05-26 failpath audit. Needs a focused lorebook activation regression test. ## Additional context This can leak conditional lore into prompts in the wrong location/time/weather/state, which affects generation quality and mode consistency. ## 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-20 17:30:42 +07:00
  • closed this issue
  • added the
    shared
    bug
    labels
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#610
No description provided.