[PR #1412] [CLOSED] Fix lorebook vectorization parity #5078

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1412
Author: @Xelvanis
Created: 5/27/2026
Status: ❌ Closed

Base: refactor ← Head: fix/lorebook-secondary-key-vector-parity


📝 Commits (4)

  • 9a7cf7b Fix lorebook vectorization parity
  • 6af5980 Address lorebook vectorization review findings
  • b629b98 Fix custom tool script error contract
  • 175344a Merge refactor into lorebook vectorization parity

📊 Changes

1 file changed (+232 additions, -17 deletions)

View changed files

📝 src-tauri/src/commands/storage/prompts.rs (+232 -17)

📄 Description

Linked issue

Closes #1411

Why this change

Refactor lorebook vectorization missed staging parity in two places: embedding input ignored secondary lorebook keys, and lorebook-level excludeFromVectorization did not skip the native vectorization path. That could make semantic lorebook matching less accurate and could still call an embedding provider for a book the user/imported data marked as excluded.

What changed

  • Include canonical secondaryKeys in lorebook entry embedding text.
  • Support legacy/imported secondary-key aliases secondary_keys and keysecondary at the vectorization boundary.
  • Honor lorebook-level excludeFromVectorization: true as a successful no-op before provider calls.
  • Add focused Rust tests for secondary key text, legacy aliases, exclusion predicates, and provider-skip behavior.
  • Restore the custom tool script-execution error code/message expected by the Rust test suite after rebasing onto current refactor.

Refactor impact

Primary owner:

Rust storage / native lorebook vectorization command.

Impact areas reviewed:

  • Lorebook vectorization input text
  • Legacy/staging lorebook entry key shapes
  • Lorebook-level and entry-level vectorization exclusion behavior
  • Provider-call skip boundary
  • Custom tool script execution error contract exposed by Rust CI

Boundary notes:

  • The lorebook parity change stays in src-tauri/src/commands/storage/prompts.rs.
  • The CI-unblock error-contract fix stays in src-tauri/src/commands/storage/custom_tools.rs.
  • No React UI, TypeScript engine, shared API wrapper, command registration, or HTTP dispatch shape changed.
  • Existing embedded and remote runtime paths continue to call the same native command implementation.

Pressure points touched:

  • Tauri/Rust storage command implementation for lorebook_vectorize.
  • Tauri/Rust custom tool execution error path for legacy script tools.
  • No src-tauri/src/lib.rs command registration, mode surface, GameSurface, or shared mode UI changes.

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, checkboxes left unchecked for human confirmation:

  • cargo test --manifest-path src-tauri/Cargo.toml lorebook --lib passed, 9 tests.
  • cargo test --manifest-path src-tauri/Cargo.toml script_execution_type_returns_actionable_error --lib passed.
  • cargo nextest run --manifest-path src-tauri/Cargo.toml --workspace script_execution_type_returns_actionable_error passed.
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passed.
  • git diff origin/refactor...HEAD --check passed before PR creation; git diff --check passed after the CI-unblock commit.
  • Bunny fanout review was run before PR creation; confirmed findings were fixed in the follow-up commit.

A full local cargo nextest run --manifest-path src-tauri/Cargo.toml --workspace was attempted but blocked on Windows by marinara-assets tests::rejects_paths_that_escape_root_through_symlinked_directory because the local shell lacks symlink creation privilege. The previously failing CI test was rerun directly through nextest and passed.

No live embedding provider call or native Tauri UI pass was run.

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

Changelog: release-notable bugfix, but no CHANGELOG.md exists on this branch.

Docs: no developer docs or repo skill updates needed because this does not change architecture, commands, or workflow guidance.

UI evidence

No UI changes.

Summary by CodeRabbit

  • Bug Fixes

    • Custom tools with script execution type now properly rejected with migration-focused error messaging
    • Improved lorebook vectorization to better handle excluded entries and secondary key field formats
  • New Features

    • Enhanced support for multiple secondary key field aliases in lorebook entries for improved flexibility

Review Change Stack


🔄 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/1412 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/27/2026 **Status:** ❌ Closed **Base:** `refactor` ← **Head:** `fix/lorebook-secondary-key-vector-parity` --- ### 📝 Commits (4) - [`9a7cf7b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9a7cf7bba8461657f08fce4faa9aee2adb57ed5c) Fix lorebook vectorization parity - [`6af5980`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6af59807e32c879f0c50fe377c179f36b6b30501) Address lorebook vectorization review findings - [`b629b98`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b629b98979c1e4b0f6e73950431ee58fc825eb08) Fix custom tool script error contract - [`175344a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/175344a4a65467f9bd2d3a258d9c09c9362112ee) Merge refactor into lorebook vectorization parity ### 📊 Changes **1 file changed** (+232 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/prompts.rs` (+232 -17) </details> ### 📄 Description ## Linked issue Closes #1411 ## Why this change Refactor lorebook vectorization missed staging parity in two places: embedding input ignored secondary lorebook keys, and lorebook-level `excludeFromVectorization` did not skip the native vectorization path. That could make semantic lorebook matching less accurate and could still call an embedding provider for a book the user/imported data marked as excluded. ## What changed - Include canonical `secondaryKeys` in lorebook entry embedding text. - Support legacy/imported secondary-key aliases `secondary_keys` and `keysecondary` at the vectorization boundary. - Honor lorebook-level `excludeFromVectorization: true` as a successful no-op before provider calls. - Add focused Rust tests for secondary key text, legacy aliases, exclusion predicates, and provider-skip behavior. - Restore the custom tool script-execution error code/message expected by the Rust test suite after rebasing onto current `refactor`. ## Refactor impact Primary owner: Rust storage / native lorebook vectorization command. Impact areas reviewed: - Lorebook vectorization input text - Legacy/staging lorebook entry key shapes - Lorebook-level and entry-level vectorization exclusion behavior - Provider-call skip boundary - Custom tool script execution error contract exposed by Rust CI Boundary notes: - The lorebook parity change stays in `src-tauri/src/commands/storage/prompts.rs`. - The CI-unblock error-contract fix stays in `src-tauri/src/commands/storage/custom_tools.rs`. - No React UI, TypeScript engine, shared API wrapper, command registration, or HTTP dispatch shape changed. - Existing embedded and remote runtime paths continue to call the same native command implementation. Pressure points touched: - Tauri/Rust storage command implementation for `lorebook_vectorize`. - Tauri/Rust custom tool execution error path for legacy `script` tools. - No `src-tauri/src/lib.rs` command registration, mode surface, GameSurface, or shared mode UI changes. ## Validation - [x] `pnpm check` passes locally - [x] `pnpm typecheck` passes locally - [x] `pnpm build` passes locally - [x] `pnpm check:architecture` passes locally - [x] `pnpm check:docs` passes locally - [x] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [x] Rust clippy/tests were run for Rust behavior changes - [x] 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, checkboxes left unchecked for human confirmation: - `cargo test --manifest-path src-tauri/Cargo.toml lorebook --lib` passed, 9 tests. - `cargo test --manifest-path src-tauri/Cargo.toml script_execution_type_returns_actionable_error --lib` passed. - `cargo nextest run --manifest-path src-tauri/Cargo.toml --workspace script_execution_type_returns_actionable_error` passed. - `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passed. - `git diff origin/refactor...HEAD --check` passed before PR creation; `git diff --check` passed after the CI-unblock commit. - Bunny fanout review was run before PR creation; confirmed findings were fixed in the follow-up commit. A full local `cargo nextest run --manifest-path src-tauri/Cargo.toml --workspace` was attempted but blocked on Windows by `marinara-assets tests::rejects_paths_that_escape_root_through_symlinked_directory` because the local shell lacks symlink creation privilege. The previously failing CI test was rerun directly through nextest and passed. No live embedding provider call or native Tauri UI pass was run. ## 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 Changelog: release-notable bugfix, but no `CHANGELOG.md` exists on this branch. Docs: no developer docs or repo skill updates needed because this does not change architecture, commands, or workflow guidance. ## UI evidence No UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Custom tools with script execution type now properly rejected with migration-focused error messaging * Improved lorebook vectorization to better handle excluded entries and secondary key field formats * **New Features** * Enhanced support for multiple secondary key field aliases in lorebook entries for improved flexibility <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/1412?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- 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:13:01 +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#5078
No description provided.