[PR #1302] [MERGED] Fix lorebook game-state gates #5022

Closed
opened 2026-10-22 04:12:33 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1302
Author: @cha1latte
Created: 5/26/2026
Status: ✅ Merged
Merged: 5/26/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/refactor-issue-1249-lorebook-gates


📝 Commits (2)

  • e9d9352 Fix lorebook game-state gates
  • 09db458 Merge remote-tracking branch 'upstream/refactor' into fix/refactor-issue-1249-lorebook-gates

📊 Changes

3 files changed (+141 additions, -9 deletions)

View changed files

📝 src/engine/generation-core/lorebooks/keyword-scanner.ts (+33 -8)
📝 src/engine/generation/prompt-assembly.test.ts (+105 -0)
📝 src/engine/generation/prompt-assembly.ts (+3 -1)

📄 Description

Linked issue

Closes #1249

Why this change

  • Lorebook entries with game-state activation conditions or schedules could activate during prompt assembly even when the visible game state did not satisfy their gates.
  • The scanner also treated missing game state as a pass for configured gates, which could leak conditional lore into the assembled prompt.

What changed

  • Pass the chat's visible game state into lorebook scanning during prompt assembly.
  • Make configured activation conditions and schedules fail closed when required game-state data is unavailable.
  • Added prompt assembly regression coverage for mismatched game state, unavailable game state, matching game state, and ungated lore compatibility.

Refactor impact

Primary owner:

  • Engine generation

Impact areas reviewed:

  • Prompt assembly
  • Lorebook keyword scanning
  • Roleplay/chat generation lore injection behavior

Boundary notes:

  • No schema, storage, dependency, prompt preset, UI, or Rust behavior changes.
  • Ungated lore still activates without game state; only entries with game-state gates fail closed when the required state is unavailable or does not match.

Pressure points touched:

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

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

  • Codex reproduced the bug before the fix with pnpm test -- src/engine/generation/prompt-assembly.test.ts; the new mismatch row failed because the gated entry activated.
  • Codex reran pnpm test -- src/engine/generation/prompt-assembly.test.ts after the fix: 6 tests passed.
  • Codex ran pnpm check: architecture, frontend typecheck, Rust check, and docs check passed.
  • Codex ran the Marinara proof gate on scratch/bugfix-verification.json: passed.
  • Bunny review before PR: passed for focused scope, proof quality, and no schema/version/dependency expansion.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

N/A - this is non-UI prompt assembly behavior. The proof is the focused prompt assembly regression plus pnpm check.


🔄 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/1302 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/26/2026 **Status:** ✅ Merged **Merged:** 5/26/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/refactor-issue-1249-lorebook-gates` --- ### 📝 Commits (2) - [`e9d9352`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e9d93527c2e2f3e1e22bf35eb987aa16ac50b8e9) Fix lorebook game-state gates - [`09db458`](https://github.com/Pasta-Devs/Marinara-Engine/commit/09db458c4990bf7f2f49a85ee0a2e83c1fbbc5c9) Merge remote-tracking branch 'upstream/refactor' into fix/refactor-issue-1249-lorebook-gates ### 📊 Changes **3 files changed** (+141 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation-core/lorebooks/keyword-scanner.ts` (+33 -8) 📝 `src/engine/generation/prompt-assembly.test.ts` (+105 -0) 📝 `src/engine/generation/prompt-assembly.ts` (+3 -1) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue Closes #1249 ## Why this change - Lorebook entries with game-state activation conditions or schedules could activate during prompt assembly even when the visible game state did not satisfy their gates. - The scanner also treated missing game state as a pass for configured gates, which could leak conditional lore into the assembled prompt. ## What changed - Pass the chat's visible game state into lorebook scanning during prompt assembly. - Make configured activation conditions and schedules fail closed when required game-state data is unavailable. - Added prompt assembly regression coverage for mismatched game state, unavailable game state, matching game state, and ungated lore compatibility. ## Refactor impact Primary owner: - Engine generation Impact areas reviewed: - Prompt assembly - Lorebook keyword scanning - Roleplay/chat generation lore injection behavior Boundary notes: - No schema, storage, dependency, prompt preset, UI, or Rust behavior changes. - Ungated lore still activates without game state; only entries with game-state gates fail closed when the required state is unavailable or does not match. Pressure points touched: - `src/engine/generation/prompt-assembly.ts` - `src/engine/generation-core/lorebooks/keyword-scanner.ts` ## Validation - [ ] `pnpm check` passes locally - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant ### Manual verification notes - Codex reproduced the bug before the fix with `pnpm test -- src/engine/generation/prompt-assembly.test.ts`; the new mismatch row failed because the gated entry activated. - Codex reran `pnpm test -- src/engine/generation/prompt-assembly.test.ts` after the fix: 6 tests passed. - Codex ran `pnpm check`: architecture, frontend typecheck, Rust check, and docs check passed. - Codex ran the Marinara proof gate on `scratch/bugfix-verification.json`: passed. - Bunny review before PR: passed for focused scope, proof quality, and no schema/version/dependency expansion. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence N/A - this is non-UI prompt assembly behavior. The proof is the focused prompt assembly regression plus `pnpm check`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:12: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#5022
No description provided.