[PR #2349] [MERGED] Fix lorebook conditions without game state #5551

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-2277-lorebook-plain-chat-conditions


📝 Commits (1)

  • 95e0e45 Fix lorebook conditions without game state

📊 Changes

3 files changed (+69 additions, -2 deletions)

View changed files

📝 src/engine/generation-core/lorebooks/keyword-scanner.ts (+1 -1)
📝 src/engine/generation/active-lorebook-scanner.test.ts (+66 -0)
📝 src/engine/generation/active-lorebook-scanner.ts (+2 -1)

📄 Description

Linked issue

Closes #2277

Why this change

  • Plain conversation and roleplay chats can have no game state. In the refactor scanner path, that absence was normalized to an empty object, so lorebook entries with activation conditions were silently blocked even when their keyword matched. This restores the permissive no-game-state behavior expected by existing lorebooks while keeping real game-state gates enforced.

What changed

  • Preserves null as the active lorebook scanner's absent-game-state signal instead of parsing absence into {}.
  • Makes activation conditions pass when no game state exists, matching the legacy plain-chat behavior.
  • Adds regression coverage for the plain roleplay path and a negative control proving a present non-matching game state still blocks the entry.

Refactor impact

Primary owner:

engine generation

Impact areas reviewed:

  • Lorebook active scanner game-state normalization.
  • Shared keyword scanner activation-condition evaluation.
  • Game-state negative control for real condition enforcement.

Boundary notes:

  • Engine-only change. No React, shared API, Rust, storage schema, import/export, dependency, or prompt-pipeline boundary changes.

Pressure points touched:

  • Runtime generation lorebook activation only.

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • Codex reproduced the bug before the fix with pnpm exec vitest run src/engine/generation/active-lorebook-scanner.test.ts: the new regression expected entry-conditional and received [].
  • Codex reran pnpm exec vitest run src/engine/generation/active-lorebook-scanner.test.ts after the fix: 1 file passed, 8 tests passed.
  • Codex ran pnpm typecheck: passed.
  • Codex ran pnpm check: passed.
  • Codex ran node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json: passed.
  • Bunny review before PR: passed with no blocking findings.
  • Manual human verification: none required for the core claim; this is covered by the scanner regression harness and full repo baseline.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • N/A: compatibility bugfix for existing lorebook activation behavior.

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

No docs or release-note files changed. This PR does not restore old staging/package-workspace/release claims.

UI evidence

N/A: engine scanner behavior with no visible UI surface changed. Proof is the before/after scanner regression command and 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/2349 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/5/2026 **Status:** ✅ Merged **Merged:** 6/5/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-2277-lorebook-plain-chat-conditions` --- ### 📝 Commits (1) - [`95e0e45`](https://github.com/Pasta-Devs/Marinara-Engine/commit/95e0e45fdcf08369fa217c96d611462e68a93b67) Fix lorebook conditions without game state ### 📊 Changes **3 files changed** (+69 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation-core/lorebooks/keyword-scanner.ts` (+1 -1) 📝 `src/engine/generation/active-lorebook-scanner.test.ts` (+66 -0) 📝 `src/engine/generation/active-lorebook-scanner.ts` (+2 -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 <!-- Every user-facing PR should reference a feature request or issue report when practical. --> Closes #2277 ## Why this change <!-- What user problem, bug, refactor goal, or maintenance need does this solve? --> - Plain conversation and roleplay chats can have no game state. In the refactor scanner path, that absence was normalized to an empty object, so lorebook entries with activation conditions were silently blocked even when their keyword matched. This restores the permissive no-game-state behavior expected by existing lorebooks while keeping real game-state gates enforced. ## What changed <!-- List the key changes in this PR. --> - Preserves `null` as the active lorebook scanner's absent-game-state signal instead of parsing absence into `{}`. - Makes activation conditions pass when no game state exists, matching the legacy plain-chat behavior. - Adds regression coverage for the plain roleplay path and a negative control proving a present non-matching game state still blocks the entry. ## Refactor impact Primary owner: <!-- Examples: app shell, catalog, chat mode, roleplay mode, game mode, runtime generation, world-state, shared API, engine generation, Rust storage, imports, remote runtime. --> engine generation Impact areas reviewed: - Lorebook active scanner game-state normalization. - Shared keyword scanner activation-condition evaluation. - Game-state negative control for real condition enforcement. Boundary notes: <!-- Note engine/shared-api/feature/Rust/remote-runtime boundaries. Say "none" only if you checked. --> - Engine-only change. No React, shared API, Rust, storage schema, import/export, dependency, or prompt-pipeline boundary changes. Pressure points touched: <!-- Mention ModeSurface, GameSurface, shared mode UI, src-tauri/src/lib.rs command registration, or import modules if touched. --> - Runtime generation lorebook activation only. ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> <!-- Do not submit *.test.ts or *.test.tsx files as PR proof; cite existing checks, command output, app/browser/Tauri verification, or manual notes instead. --> - [ ] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes <!-- Describe exact commands and manual steps, including typecheck/build/docs/architecture/Rust/browser/remote-runtime checks when they apply. If an AI agent filled this out, verify it yourself before ticking boxes. --> - Codex reproduced the bug before the fix with `pnpm exec vitest run src/engine/generation/active-lorebook-scanner.test.ts`: the new regression expected `entry-conditional` and received `[]`. - Codex reran `pnpm exec vitest run src/engine/generation/active-lorebook-scanner.test.ts` after the fix: 1 file passed, 8 tests passed. - Codex ran `pnpm typecheck`: passed. - Codex ran `pnpm check`: passed. - Codex ran `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json`: passed. - Bunny review before PR: passed with no blocking findings. - Manual human verification: none required for the core claim; this is covered by the scanner regression harness and full repo baseline. ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [ ] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - N/A: compatibility bugfix for existing lorebook activation behavior. ## 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 No docs or release-note files changed. This PR does not restore old staging/package-workspace/release claims. ## UI evidence <!-- Add before/after screenshots or recordings for visible UI changes. --> N/A: engine scanner behavior with no visible UI surface changed. Proof is the before/after scanner regression command and `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:17:18 +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#5551
No description provided.