[PR #2354] [MERGED] Fix cross-lorebook recursive frontier seeding #5556

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-2279-cross-lorebook-recursion


📝 Commits (2)

  • 0cd2a0e Fix cross-lorebook recursive frontier seeding
  • 2489c9e Clarify lorebook recursion contract

📊 Changes

5 files changed (+66 additions, -13 deletions)

View changed files

📝 src/engine/contracts/schemas/lorebook.schema.ts (+4 -0)
📝 src/engine/contracts/types/lorebook.ts (+7 -2)
📝 src/engine/generation/active-lorebook-scanner.test.ts (+48 -2)
📝 src/engine/generation/active-lorebook-scanner.ts (+1 -4)
📝 src/features/catalog/lorebooks/components/editor/LorebookOverviewTab.tsx (+6 -5)

📄 Description

Linked issue

Closes #2279

Why this change

  • Refactor still seeded recursive lorebook passes only from entries whose own lorebook had recursiveScanning enabled.
  • Main treats recursion as globally enabled for the scan once any active lorebook enables it, so selected non-preventRecursion entries from character/persona or other non-recursive books can chain-trigger related lore in recursive books.

What changed

  • Changed active lorebook recursive frontier seeding to use every selected, budgeted entry unless that entry has preventRecursion.
  • Updated the cross-lorebook regression row so a selected entry from a non-recursive book can seed the next recursive pass when recursion is enabled elsewhere.
  • Added a negative-control regression row proving recursion still does not run when every active lorebook disables recursiveScanning.

Refactor impact

Primary owner:

engine generation

Impact areas reviewed:

  • Chat, roleplay, and game prompt assembly share scanActiveLorebooks.
  • Recursive scanning, preventRecursion, recursion depth, chat lorebook budget skipping, and selected-entry frontier behavior.

Boundary notes:

  • React-free engine change only. No feature UI, shared API wrapper, Tauri/Rust storage, remote runtime, schema, dependency, auth, or release metadata changes.

Pressure points touched:

  • Shared engine lorebook activation in 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 proof before production fix: pnpm test src/engine/generation/active-lorebook-scanner.test.ts failed on the new #2279 regression row. Expected [entry-a, entry-b, entry-c], received [entry-a, entry-b].
  • Codex proof after fix: pnpm test src/engine/generation/active-lorebook-scanner.test.ts passed with 9 tests.
  • Codex lane validation: pnpm typecheck passed.
  • Codex full gate: pnpm check passed.
  • Codex proof gate: node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed.
  • Bunny review: pass. No blocking manual verification remains for the core claim.

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 for existing lorebook runtime behavior; no new user-discoverable product surface.

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 React-free engine prompt assembly logic with focused command proof; there is no meaningful visible UI state to screenshot.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed lorebook recursion behavior to correctly include selected entries when global recursion is enabled, regardless of individual entry recursion settings.
    • Fixed recursive content propagation to properly stop when all active lorebooks have recursion disabled.

🔄 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/2354 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/5/2026 **Status:** ✅ Merged **Merged:** 6/6/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `fix/issue-2279-cross-lorebook-recursion` --- ### 📝 Commits (2) - [`0cd2a0e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0cd2a0e05fcebb921557cd6c6787f30dd167b064) Fix cross-lorebook recursive frontier seeding - [`2489c9e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2489c9ec9347cd4e871a5a5c7d5408211d8be307) Clarify lorebook recursion contract ### 📊 Changes **5 files changed** (+66 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/contracts/schemas/lorebook.schema.ts` (+4 -0) 📝 `src/engine/contracts/types/lorebook.ts` (+7 -2) 📝 `src/engine/generation/active-lorebook-scanner.test.ts` (+48 -2) 📝 `src/engine/generation/active-lorebook-scanner.ts` (+1 -4) 📝 `src/features/catalog/lorebooks/components/editor/LorebookOverviewTab.tsx` (+6 -5) </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 #2279 ## Why this change <!-- What user problem, bug, refactor goal, or maintenance need does this solve? --> - Refactor still seeded recursive lorebook passes only from entries whose own lorebook had `recursiveScanning` enabled. - Main treats recursion as globally enabled for the scan once any active lorebook enables it, so selected non-`preventRecursion` entries from character/persona or other non-recursive books can chain-trigger related lore in recursive books. ## What changed <!-- List the key changes in this PR. --> - Changed active lorebook recursive frontier seeding to use every selected, budgeted entry unless that entry has `preventRecursion`. - Updated the cross-lorebook regression row so a selected entry from a non-recursive book can seed the next recursive pass when recursion is enabled elsewhere. - Added a negative-control regression row proving recursion still does not run when every active lorebook disables `recursiveScanning`. ## 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: - Chat, roleplay, and game prompt assembly share `scanActiveLorebooks`. - Recursive scanning, `preventRecursion`, recursion depth, chat lorebook budget skipping, and selected-entry frontier behavior. Boundary notes: <!-- Note engine/shared-api/feature/Rust/remote-runtime boundaries. Say "none" only if you checked. --> - React-free engine change only. No feature UI, shared API wrapper, Tauri/Rust storage, remote runtime, schema, dependency, auth, or release metadata changes. Pressure points touched: <!-- Mention ModeSurface, GameSurface, shared mode UI, src-tauri/src/lib.rs command registration, or import modules if touched. --> - Shared engine lorebook activation in `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. --> - [x] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [x] 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 proof before production fix: `pnpm test src/engine/generation/active-lorebook-scanner.test.ts` failed on the new #2279 regression row. Expected `[entry-a, entry-b, entry-c]`, received `[entry-a, entry-b]`. - Codex proof after fix: `pnpm test src/engine/generation/active-lorebook-scanner.test.ts` passed with 9 tests. - Codex lane validation: `pnpm typecheck` passed. - Codex full gate: `pnpm check` passed. - Codex proof gate: `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed. - Bunny review: pass. No blocking manual verification remains for the core claim. ## 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. - [x] 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 for existing lorebook runtime behavior; no new user-discoverable product surface. ## Docs and release impact - [x] 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 <!-- Add before/after screenshots or recordings for visible UI changes. --> N/A. This is React-free engine prompt assembly logic with focused command proof; there is no meaningful visible UI state to screenshot. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed lorebook recursion behavior to correctly include selected entries when global recursion is enabled, regardless of individual entry recursion settings. * Fixed recursive content propagation to properly stop when all active lorebooks have recursion disabled. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <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:21 +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#5556
No description provided.