[GH-ISSUE #2184] [Issue]: Lorebook runtime no longer enforces max activated entry cap #1087

Closed
opened 2026-10-21 05:26:31 +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/2184

Originally assigned to: @cha1latte on GitHub.

Summary

The lorebook runtime rescan found that refactor no longer applies the maximum activated lorebook entry cap during prompt-time selection. Legacy capped selected entries with LIMITS.MAX_LOREBOOK_ENTRIES, while refactor defines the same limit but does not apply it in the active scanner.

Expected behavior

Prompt-time lorebook selection should cap injected entries at LIMITS.MAX_LOREBOOK_ENTRIES while preserving the existing budget priority order: constants first, fresh latest-user-message matches next, then injection order.

Actual behavior

Refactor applies per-lorebook and chat token budgets, but the active scanner path does not enforce the max-entry cap. A chat with many small matching entries can inject more than the intended maximum.

Steps to reproduce

  1. Create or import more than LIMITS.MAX_LOREBOOK_ENTRIES small entries that all activate for a chat turn.
  2. Generate a response with enough lorebook token budget for all entries.
  3. Inspect the prompt snapshot or Active World Info data.
  4. Observe that refactor can include more than the configured maximum.

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 defines LIMITS.MAX_LOREBOOK_ENTRIES in src/engine/contracts/constants/defaults.ts.
  • Refactor active scanner applies budgets in src/engine/generation/active-lorebook-scanner.ts but does not use the max-entry limit.
  • Legacy applies the cap in packages/server/src/services/lorebook/index.ts on main.

Regression notes

Legacy main enforces LIMITS.MAX_LOREBOOK_ENTRIES during selection. Refactor preserved the constant but lost enforcement in the prompt-time active scanner.

Additional context

Parity row: 07-LB-RUNTIME-budget-priority.

Classification from rescan: Current refactor defect.

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/2184 Originally assigned to: @cha1latte on GitHub. ## Summary The lorebook runtime rescan found that refactor no longer applies the maximum activated lorebook entry cap during prompt-time selection. Legacy capped selected entries with `LIMITS.MAX_LOREBOOK_ENTRIES`, while refactor defines the same limit but does not apply it in the active scanner. ## Expected behavior Prompt-time lorebook selection should cap injected entries at `LIMITS.MAX_LOREBOOK_ENTRIES` while preserving the existing budget priority order: constants first, fresh latest-user-message matches next, then injection order. ## Actual behavior Refactor applies per-lorebook and chat token budgets, but the active scanner path does not enforce the max-entry cap. A chat with many small matching entries can inject more than the intended maximum. ## Steps to reproduce 1. Create or import more than `LIMITS.MAX_LOREBOOK_ENTRIES` small entries that all activate for a chat turn. 2. Generate a response with enough lorebook token budget for all entries. 3. Inspect the prompt snapshot or Active World Info data. 4. Observe that refactor can include more than the configured maximum. ## 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 defines `LIMITS.MAX_LOREBOOK_ENTRIES` in `src/engine/contracts/constants/defaults.ts`. - Refactor active scanner applies budgets in `src/engine/generation/active-lorebook-scanner.ts` but does not use the max-entry limit. - Legacy applies the cap in `packages/server/src/services/lorebook/index.ts` on `main`. ## Regression notes Legacy `main` enforces `LIMITS.MAX_LOREBOOK_ENTRIES` during selection. Refactor preserved the constant but lost enforcement in the prompt-time active scanner. ## Additional context Parity row: `07-LB-RUNTIME-budget-priority`. Classification from rescan: `Current refactor defect`. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:26:31 +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#1087
No description provided.