[GH-ISSUE #2279] [Issue]: Cross-lorebook recursive activation is dropped: refactor narrows recursion seeding to per-book recursiveScanning #1117

Closed
opened 2026-10-21 05:27:06 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Romuromylus on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2279

Originally assigned to: @cha1latte on GitHub.

Summary

The refactor only seeds the recursive-activation frontier from entries whose own lorebook has recursiveScanning enabled. Main seeds from every activated non-preventRecursion entry regardless of book, so cross-lorebook recursion (an entry in a non-recursive book chain-triggering lore in another book) is lost.

Expected behavior

When recursion is enabled for the scan, any activated entry that is not preventRecursion should be able to chain-trigger related lore, including entries that live in a book that itself has recursiveScanning off, matching main's global behavior.

Actual behavior

The refactor re-narrows the recursion seed source per-book, so activated entries from books with recursiveScanning off never seed deeper passes. Chained lore that main would have activated is silently never injected.

Steps to reproduce

  1. Enable recursion (recursiveScanning) on one global lorebook, leave it off on a character or persona lorebook.
  2. In the character/persona book, add entry A (matches the message) whose content contains a key that should recursively trigger entry B in the global book.
  3. Generate. A injects but B does not in the refactor; on main B would activate via recursion.

Impact area

  • Chat mode
  • Roleplay mode
  • React-free engine behavior, contracts, agents, or capability ports
  • Runtime systems: generation, world-state, visuals, tracker, or haptics

Regression notes

Worked on main. Main seeds the frontier by !selected.entry.preventRecursion only and gates recursion solely on the global anyRecursive flag (packages/server/src/services/lorebook/index.ts:665-667,837-838; keyword-scanner.ts:544-546); its lorebooksById is typed Pick<Lorebook,"name"|"tokenBudget"> so it structurally cannot gate per-book. The refactor adds a per-book gate lorebooksById.get(selected.entry.lorebookId)?.recursiveScanning && !selected.entry.preventRecursion (src/engine/generation/active-lorebook-scanner.ts:675-681, metadata at :88,:819, loop enabled at :857). Rust references recursiveScanning/preventRecursion only as storage/import/export plumbing (contracts.rs:144, normalization.rs:434, shared.rs:934), so the TS frontier loop is the only authority.

Environment

  • Branch or commit: refactor @ 5ddb9840 (compared against main @ b4ab97f)
  • Run mode: Tauri desktop
  • OS + version: Windows 11
  • Node + pnpm versions: not relevant (static source comparison)
  • Rust version, if relevant: not relevant (static source comparison)
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: see body

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (Jun 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2279 Originally assigned to: @cha1latte on GitHub. ## Summary The refactor only seeds the recursive-activation frontier from entries whose own lorebook has recursiveScanning enabled. Main seeds from every activated non-preventRecursion entry regardless of book, so cross-lorebook recursion (an entry in a non-recursive book chain-triggering lore in another book) is lost. ## Expected behavior When recursion is enabled for the scan, any activated entry that is not preventRecursion should be able to chain-trigger related lore, including entries that live in a book that itself has recursiveScanning off, matching main's global behavior. ## Actual behavior The refactor re-narrows the recursion seed source per-book, so activated entries from books with recursiveScanning off never seed deeper passes. Chained lore that main would have activated is silently never injected. ## Steps to reproduce 1. Enable recursion (recursiveScanning) on one global lorebook, leave it off on a character or persona lorebook. 2. In the character/persona book, add entry A (matches the message) whose content contains a key that should recursively trigger entry B in the global book. 3. Generate. A injects but B does not in the refactor; on main B would activate via recursion. ## Impact area - [x] Chat mode - [x] Roleplay mode - [x] React-free engine behavior, contracts, agents, or capability ports - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics ## Regression notes Worked on main. Main seeds the frontier by `!selected.entry.preventRecursion` only and gates recursion solely on the global `anyRecursive` flag (`packages/server/src/services/lorebook/index.ts:665-667,837-838`; `keyword-scanner.ts:544-546`); its `lorebooksById` is typed `Pick<Lorebook,"name"|"tokenBudget">` so it structurally cannot gate per-book. The refactor adds a per-book gate `lorebooksById.get(selected.entry.lorebookId)?.recursiveScanning && !selected.entry.preventRecursion` (`src/engine/generation/active-lorebook-scanner.ts:675-681`, metadata at `:88,:819`, loop enabled at `:857`). Rust references recursiveScanning/preventRecursion only as storage/import/export plumbing (`contracts.rs:144`, `normalization.rs:434`, `shared.rs:934`), so the TS frontier loop is the only authority. ## Environment - Branch or commit: refactor @ 5ddb9840 (compared against main @ b4ab97f) - Run mode: Tauri desktop - OS + version: Windows 11 - Node + pnpm versions: not relevant (static source comparison) - Rust version, if relevant: not relevant (static source comparison) - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: see body ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:27:06 +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#1117
No description provided.