[PR #1720] [MERGED] [codex] Extract active lorebook scanner #5234

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

📋 Pull Request Information

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

Base: refactor ← Head: codex/lorebooks-active-scanner


📝 Commits (2)

  • 0fe46b1 Extract active lorebook scanner
  • bbe0f6f Fix unused remote runtime helper export

📊 Changes

8 files changed (+884 additions, -457 deletions)

View changed files

➕ src/engine/generation/active-lorebook-scanner.ts (+634 -0)
📝 src/engine/generation/active-lorebooks.ts (+29 -15)
📝 src/engine/generation/prompt-assembly.test.ts (+146 -1)
📝 src/engine/generation/prompt-assembly.ts (+42 -433)
📝 src/engine/generation/tools-runtime.ts (+2 -6)
📝 src/features/catalog/lorebooks/hooks/use-lorebooks.ts (+3 -0)
📝 src/features/runtime/visuals/components/WorldInfoPanel.tsx (+27 -1)
📝 src/shared/api/remote-runtime.ts (+1 -1)

📄 Description

Linked issue

N/A

Why this change

  • Extracts lorebook activation into an engine-owned scanner so prompt assembly and Active World Info use the same contract.
  • Fixes semantic lorebook activation in normal prompt assembly by wiring the generation embedding source through the scanner.
  • Removes Active World Info's dependency on resolving an LLM generation connection for keyword/constant previews.

What changed

  • Added src/engine/generation/active-lorebook-scanner.ts for scope selection, entry loading, scanner options, per-lorebook and chat budget diagnostics, timing-state updates, and semantic scan status.
  • Updated prompt assembly to call the scanner and share a per-assembly embedding cache between semantic lorebook activation and memory recall.
  • Updated Active World Info to call the scanner directly and show a semantic-degrade notice when vectorized entries cannot be semantically scanned.
  • Moved lorebook search-tool activation helpers to the scanner module.
  • Added regression coverage for semantic activation, Active World Info without connection resolution, skipped semantic status, embedding reuse, and constant-only vectorized lore.

Refactor impact

Primary owner:

  • Engine generation.

Impact areas reviewed:

  • Prompt assembly lorebook activation and prompt injection.
  • Active World Info preview query path.
  • Lorebook search tool entry loading.
  • Memory recall embedding query path.
  • Game lorebook keeper scope exclusions, timing state, token budgets, recursion, disabled folders, and entry filters through existing prompt assembly tests.

Boundary notes:

  • Engine logic stays in src/engine; no React, Zustand, Tauri, shared API adapter, or feature internals imported into engine code.
  • Feature code continues to call public catalog hooks and engine entrypoints; no raw Tauri or remote runtime calls added.
  • Rust, shared API, and remote-runtime command surfaces are untouched.

Pressure points touched:

  • src/engine/generation/prompt-assembly.ts was reduced by moving lorebook scanner/budget/timing logic into active-lorebook-scanner.ts.
  • Active World Info UI notice touched src/features/runtime/visuals/components/WorldInfoPanel.tsx.

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

  • Ran pnpm check successfully after the final diff.
  • Ran pnpm vitest run src/engine/generation/prompt-assembly.test.ts src/engine/generation-core/lorebooks/keyword-scanner.test.ts successfully: 2 files, 65 tests.
  • Ran pnpm build earlier in the slice; it passed with the existing Vite large chunk warning. Build was not rerun after the final Bunny-only test/unused-export fixes because pnpm check and targeted tests covered the final TypeScript/import surfaces.
  • No native Tauri UI pass was run for Active World Info.
  • No live provider/vectorization call was made; semantic activation is covered with mocked embedding sources.

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 durable docs/source-ownership changes were needed for this internal engine refactor and small Active World Info notice.

UI evidence

No screenshot attached. UI change is limited to the Active World Info semantic-degrade notice; native/manual UI QA remains a gap.

Summary by CodeRabbit

  • New Features
    • Enhanced lore scanning with semantic embedding support for improved entry matching
    • Added visual status indicators displaying semantic scan progress and results in the World Info panel

🔄 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/1720 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/31/2026 **Status:** ✅ Merged **Merged:** 5/31/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `codex/lorebooks-active-scanner` --- ### 📝 Commits (2) - [`0fe46b1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0fe46b14754563b2b69d6bb5edaae5cf4af072fc) Extract active lorebook scanner - [`bbe0f6f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bbe0f6f3dd3f77b8fe9042240eddca7bc8d60a85) Fix unused remote runtime helper export ### 📊 Changes **8 files changed** (+884 additions, -457 deletions) <details> <summary>View changed files</summary> ➕ `src/engine/generation/active-lorebook-scanner.ts` (+634 -0) 📝 `src/engine/generation/active-lorebooks.ts` (+29 -15) 📝 `src/engine/generation/prompt-assembly.test.ts` (+146 -1) 📝 `src/engine/generation/prompt-assembly.ts` (+42 -433) 📝 `src/engine/generation/tools-runtime.ts` (+2 -6) 📝 `src/features/catalog/lorebooks/hooks/use-lorebooks.ts` (+3 -0) 📝 `src/features/runtime/visuals/components/WorldInfoPanel.tsx` (+27 -1) 📝 `src/shared/api/remote-runtime.ts` (+1 -1) </details> ### 📄 Description ## Linked issue N/A ## Why this change - Extracts lorebook activation into an engine-owned scanner so prompt assembly and Active World Info use the same contract. - Fixes semantic lorebook activation in normal prompt assembly by wiring the generation embedding source through the scanner. - Removes Active World Info's dependency on resolving an LLM generation connection for keyword/constant previews. ## What changed - Added `src/engine/generation/active-lorebook-scanner.ts` for scope selection, entry loading, scanner options, per-lorebook and chat budget diagnostics, timing-state updates, and semantic scan status. - Updated prompt assembly to call the scanner and share a per-assembly embedding cache between semantic lorebook activation and memory recall. - Updated Active World Info to call the scanner directly and show a semantic-degrade notice when vectorized entries cannot be semantically scanned. - Moved lorebook search-tool activation helpers to the scanner module. - Added regression coverage for semantic activation, Active World Info without connection resolution, skipped semantic status, embedding reuse, and constant-only vectorized lore. ## Refactor impact Primary owner: - Engine generation. Impact areas reviewed: - Prompt assembly lorebook activation and prompt injection. - Active World Info preview query path. - Lorebook search tool entry loading. - Memory recall embedding query path. - Game lorebook keeper scope exclusions, timing state, token budgets, recursion, disabled folders, and entry filters through existing prompt assembly tests. Boundary notes: - Engine logic stays in `src/engine`; no React, Zustand, Tauri, shared API adapter, or feature internals imported into engine code. - Feature code continues to call public catalog hooks and engine entrypoints; no raw Tauri or remote runtime calls added. - Rust, shared API, and remote-runtime command surfaces are untouched. Pressure points touched: - `src/engine/generation/prompt-assembly.ts` was reduced by moving lorebook scanner/budget/timing logic into `active-lorebook-scanner.ts`. - Active World Info UI notice touched `src/features/runtime/visuals/components/WorldInfoPanel.tsx`. ## Validation - [x] `pnpm check` passes locally - [x] `pnpm typecheck` passes locally - [x] `pnpm build` passes locally - [x] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant ### Manual verification notes - Ran `pnpm check` successfully after the final diff. - Ran `pnpm vitest run src/engine/generation/prompt-assembly.test.ts src/engine/generation-core/lorebooks/keyword-scanner.test.ts` successfully: 2 files, 65 tests. - Ran `pnpm build` earlier in the slice; it passed with the existing Vite large chunk warning. Build was not rerun after the final Bunny-only test/unused-export fixes because `pnpm check` and targeted tests covered the final TypeScript/import surfaces. - No native Tauri UI pass was run for Active World Info. - No live provider/vectorization call was made; semantic activation is covered with mocked embedding sources. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [x] Confirmed this PR does not restore old staging/package-workspace/release claims No durable docs/source-ownership changes were needed for this internal engine refactor and small Active World Info notice. ## UI evidence No screenshot attached. UI change is limited to the Active World Info semantic-degrade notice; native/manual UI QA remains a gap. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Enhanced lore scanning with semantic embedding support for improved entry matching * Added visual status indicators displaying semantic scan progress and results in the World Info panel <!-- 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:14:28 +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#5234
No description provided.