[PR #1730] [MERGED] [codex] Tighten Lorebook Keeper target resolution #5242

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

📋 Pull Request Information

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

Base: refactor ← Head: codex/lorebook-keeper-target-resolution


📝 Commits (1)

  • fcf960c Tighten lorebook keeper target resolution

📊 Changes

5 files changed (+187 additions, -33 deletions)

View changed files

📝 src/engine/contracts/types/chat.ts (+1 -1)
➕ src/engine/generation-core/lorebooks/lorebook-keeper-target.ts (+129 -0)
📝 src/engine/generation/agent-runner.ts (+40 -14)
📝 src/features/catalog/lorebooks/lib/lorebook-keeper-updates.ts (+14 -15)
📝 src/features/modes/shared/chat-ui/components/ChatSettingsDrawer.tsx (+3 -3)

📄 Description

Linked issue

Not linked.

Why this change

  • Lorebook Keeper could fall back to an unqualified first enabled lorebook when no explicit target was set, which risked writing updates into a broad/default book.
  • The no-target path could also silently drop generated proposals after a successful agent run.

What changed

  • Added an engine-owned Lorebook Keeper target resolver for configured target, proposed scoped target, and scoped active target selection.
  • Routed Lorebook Keeper agent context and pending update application through that resolver.
  • Removed the first-enabled lorebook fallback from the write path.
  • Added a preflight skip result when Lorebook Keeper has no writable target, avoiding an unnecessary LLM call and surfacing the configuration issue.
  • Updated Chat Settings copy for the target selector and added focused resolver/runtime/update tests.

Refactor impact

Primary owner:

engine generation and generation-core lorebook targeting, with small catalog update-flow and shared chat settings UI touchpoints.

Impact areas reviewed:

  • Lorebook Keeper agent prompt context and result flow.
  • Pending Lorebook Keeper update review/apply path.
  • Chat metadata target contract.
  • Active lorebook scope resolver behavior.

Boundary notes:

  • Target selection lives in React-free src/engine/generation-core/lorebooks.
  • Feature code consumes the focused engine resolver for pending update application.
  • No shared API, Tauri command, Rust, or remote-runtime routing changes.

Pressure points touched:

  • Shared mode UI: ChatSettingsDrawer copy only.
  • No ModeSurface, GameSurface, Tauri command registration, or import modules touched.

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

Agent-run validation:

  • pnpm vitest run src/engine/generation-core/lorebooks/lorebook-keeper-target.test.ts src/features/catalog/lorebooks/lib/lorebook-keeper-updates.test.ts src/engine/generation/agent-runner.test.ts passed: 3 files, 46 tests.
  • pnpm typecheck passed.
  • pnpm check:architecture passed.
  • pnpm build passed; Vite reported existing large chunk warnings and an existing CSS minify warning.
  • git diff --check passed.
  • pnpm check passed after fixing an unused exported type.

Not run: native Tauri UI pass, live provider call, or manual Lorebook Keeper review/apply flow.

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 docs or release files changed; this is a focused engine behavior fix with small settings copy adjustment.

UI evidence

Not added. Visible UI impact is limited to target selector copy; no native UI pass was run.

Summary by CodeRabbit

  • Bug Fixes

    • Added error handling when no target lorebook is available for the Lorebook Keeper agent.
  • Documentation

    • Updated Lorebook Keeper UI help text and labels to reflect scoped lorebook selection behavior.

🔄 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/1730 **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/lorebook-keeper-target-resolution` --- ### 📝 Commits (1) - [`fcf960c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fcf960ca5806bab24d3d97063eafb74b8c08c379) Tighten lorebook keeper target resolution ### 📊 Changes **5 files changed** (+187 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/contracts/types/chat.ts` (+1 -1) ➕ `src/engine/generation-core/lorebooks/lorebook-keeper-target.ts` (+129 -0) 📝 `src/engine/generation/agent-runner.ts` (+40 -14) 📝 `src/features/catalog/lorebooks/lib/lorebook-keeper-updates.ts` (+14 -15) 📝 `src/features/modes/shared/chat-ui/components/ChatSettingsDrawer.tsx` (+3 -3) </details> ### 📄 Description ## Linked issue Not linked. ## Why this change - Lorebook Keeper could fall back to an unqualified first enabled lorebook when no explicit target was set, which risked writing updates into a broad/default book. - The no-target path could also silently drop generated proposals after a successful agent run. ## What changed - Added an engine-owned Lorebook Keeper target resolver for configured target, proposed scoped target, and scoped active target selection. - Routed Lorebook Keeper agent context and pending update application through that resolver. - Removed the first-enabled lorebook fallback from the write path. - Added a preflight skip result when Lorebook Keeper has no writable target, avoiding an unnecessary LLM call and surfacing the configuration issue. - Updated Chat Settings copy for the target selector and added focused resolver/runtime/update tests. ## Refactor impact Primary owner: engine generation and generation-core lorebook targeting, with small catalog update-flow and shared chat settings UI touchpoints. Impact areas reviewed: - Lorebook Keeper agent prompt context and result flow. - Pending Lorebook Keeper update review/apply path. - Chat metadata target contract. - Active lorebook scope resolver behavior. Boundary notes: - Target selection lives in React-free `src/engine/generation-core/lorebooks`. - Feature code consumes the focused engine resolver for pending update application. - No shared API, Tauri command, Rust, or remote-runtime routing changes. Pressure points touched: - Shared mode UI: `ChatSettingsDrawer` copy only. - No `ModeSurface`, `GameSurface`, Tauri command registration, or import modules touched. ## Validation - [x] `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 Agent-run validation: - `pnpm vitest run src/engine/generation-core/lorebooks/lorebook-keeper-target.test.ts src/features/catalog/lorebooks/lib/lorebook-keeper-updates.test.ts src/engine/generation/agent-runner.test.ts` passed: 3 files, 46 tests. - `pnpm typecheck` passed. - `pnpm check:architecture` passed. - `pnpm build` passed; Vite reported existing large chunk warnings and an existing CSS minify warning. - `git diff --check` passed. - `pnpm check` passed after fixing an unused exported type. Not run: native Tauri UI pass, live provider call, or manual Lorebook Keeper review/apply flow. ## 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 docs or release files changed; this is a focused engine behavior fix with small settings copy adjustment. ## UI evidence Not added. Visible UI impact is limited to target selector copy; no native UI pass was run. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Added error handling when no target lorebook is available for the Lorebook Keeper agent. * **Documentation** * Updated Lorebook Keeper UI help text and labels to reflect scoped lorebook selection behavior. <!-- 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:33 +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#5242
No description provided.