[PR #2247] [MERGED] Fix lorebook active entry cap #5508

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-2184-lorebook-entry-cap


📝 Commits (2)

  • 1d95f2a Fix lorebook active entry cap
  • b107343 Record lorebook cap PR proof

📊 Changes

4 files changed (+122 additions, -70 deletions)

View changed files

📝 scratch/bugfix-verification.json (+48 -62)
📝 src/engine/generation-core/lorebooks/prompt-injector.ts (+19 -8)
📝 src/engine/generation/active-lorebook-scanner.test.ts (+54 -0)
📝 src/engine/generation/active-lorebook-scanner.ts (+1 -0)

📄 Description

Linked issue

Closes #2184

Why this change

  • Refactor preserved LIMITS.MAX_LOREBOOK_ENTRIES but prompt-time active lorebook selection no longer applied that cap, so a chat with many small matching entries could inject more entries than intended.

What changed

  • Reused the lorebook token-budget priority comparator for entry-count capping: constants first, fresh latest-user-message matches next, then injection order.
  • Applied LIMITS.MAX_LOREBOOK_ENTRIES when scanActiveLorebooks builds injectable lore.
  • Added a focused scanner regression with 105 matching entries and unlimited token budget to prove the cap and priority behavior.
  • Updated scratch/bugfix-verification.json with the issue 2184 proof ledger.

Refactor impact

Primary owner:

  • Engine generation

Impact areas reviewed:

  • Shared prompt-time active lorebook scanner.
  • Prompt assembly activated lorebook entries.
  • Active World Info scan data through scanActiveLorebookEntries.

Boundary notes:

  • The fix stays in React-free engine code and the shared lorebook prompt injector. No feature UI, shared API wrapper, Tauri/Rust storage, remote-runtime, schema, dependency, or release files changed.

Pressure points touched:

  • src/engine/generation-core/lorebooks/prompt-injector.ts
  • src/engine/generation/active-lorebook-scanner.ts

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 production fix with pnpm exec vitest run src/engine/generation/active-lorebook-scanner.test.ts: the new regression failed because 105 entries were included instead of LIMITS.MAX_LOREBOOK_ENTRIES (100).
  • After the fix, pnpm exec vitest run src/engine/generation/active-lorebook-scanner.test.ts passed with 2 tests.
  • pnpm typecheck passed.
  • pnpm check passed after the final diff.
  • node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed.
  • Bunny review passed before opening this draft.
  • No human-only manual verification is required for the core claim; this is a React-free engine prompt-selection bug.

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:

  • Bugfix only; no new user-discoverable feature or workflow.

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 a React-free engine prompt-selection fix. The verification proof is command-based and recorded above.


🔄 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/2247 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/4/2026 **Status:** ✅ Merged **Merged:** 6/4/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-2184-lorebook-entry-cap` --- ### 📝 Commits (2) - [`1d95f2a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1d95f2a9a07b797d30320d3d67cbc679689cc135) Fix lorebook active entry cap - [`b107343`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b107343a347bc24668c6350d53093b8574c31411) Record lorebook cap PR proof ### 📊 Changes **4 files changed** (+122 additions, -70 deletions) <details> <summary>View changed files</summary> 📝 `scratch/bugfix-verification.json` (+48 -62) 📝 `src/engine/generation-core/lorebooks/prompt-injector.ts` (+19 -8) 📝 `src/engine/generation/active-lorebook-scanner.test.ts` (+54 -0) 📝 `src/engine/generation/active-lorebook-scanner.ts` (+1 -0) </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 #2184 ## Why this change - Refactor preserved `LIMITS.MAX_LOREBOOK_ENTRIES` but prompt-time active lorebook selection no longer applied that cap, so a chat with many small matching entries could inject more entries than intended. ## What changed - Reused the lorebook token-budget priority comparator for entry-count capping: constants first, fresh latest-user-message matches next, then injection order. - Applied `LIMITS.MAX_LOREBOOK_ENTRIES` when `scanActiveLorebooks` builds injectable lore. - Added a focused scanner regression with 105 matching entries and unlimited token budget to prove the cap and priority behavior. - Updated `scratch/bugfix-verification.json` with the issue 2184 proof ledger. ## Refactor impact Primary owner: - Engine generation Impact areas reviewed: - Shared prompt-time active lorebook scanner. - Prompt assembly activated lorebook entries. - Active World Info scan data through `scanActiveLorebookEntries`. Boundary notes: - The fix stays in React-free engine code and the shared lorebook prompt injector. No feature UI, shared API wrapper, Tauri/Rust storage, remote-runtime, schema, dependency, or release files changed. Pressure points touched: - `src/engine/generation-core/lorebooks/prompt-injector.ts` - `src/engine/generation/active-lorebook-scanner.ts` ## 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 - Codex reproduced the bug before the production fix with `pnpm exec vitest run src/engine/generation/active-lorebook-scanner.test.ts`: the new regression failed because 105 entries were included instead of `LIMITS.MAX_LOREBOOK_ENTRIES` (100). - After the fix, `pnpm exec vitest run src/engine/generation/active-lorebook-scanner.test.ts` passed with 2 tests. - `pnpm typecheck` passed. - `pnpm check` passed after the final diff. - `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed. - Bunny review passed before opening this draft. - No human-only manual verification is required for the core claim; this is a React-free engine prompt-selection bug. ## 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: - Bugfix only; no new user-discoverable feature or workflow. ## 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 a React-free engine prompt-selection fix. The verification proof is command-based and recorded above. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:16:55 +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#5508
No description provided.