[PR #1861] [MERGED] Fix semantic active lorebook scan #5323

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-1858-semantic-lorebook


📝 Commits (2)

  • 235039e Fix semantic active lorebook scan
  • 212d4cf Add semantic lorebook negative control

📊 Changes

3 files changed (+247 additions, -1 deletions)

View changed files

➕ src/engine/generation/active-lorebooks.test.ts (+201 -0)
📝 src/engine/generation/active-lorebooks.ts (+6 -0)
📝 src/features/catalog/lorebooks/hooks/use-lorebooks.ts (+40 -1)

📄 Description

Linked issue

Closes #1858

Why this change

  • Active World Info could only show keyword/constant lorebook matches because its scan wrapper never supplied the semantic embedding source that the core active-lorebook scanner already supports.
  • This made vectorized, keywordless lorebook entries appear unavailable in the visible active-info panel even though the semantic scanner can activate them when an embedding source is present.

What changed

  • Let scanActiveLorebookEntries accept the same abstract embedding source used by the active lorebook scanner.
  • Build an Active World Info embedding source from the chat's generation connection in the lorebook query hook, using llmApi.embed.
  • Added a regression test for semantic-only vectorized entries plus the keyword-only fallback path when semantic search is unavailable.

Refactor impact

Primary owner:

  • Engine generation / catalog lorebook UI

Impact areas reviewed:

  • Active World Info lorebook scan
  • Semantic-only vectorized lorebook activation
  • Keyword lorebook activation when no embedding source is available
  • Generation prompt scanner boundary, to keep engine code depending only on an abstract embedding source

Boundary notes:

  • Engine code still does not import React, Tauri APIs, or shared API adapters.
  • Feature code owns llmApi and passes only an abstract { embed } source into the engine scanner.
  • No storage schema, dependency, prompt preset, or Rust command changes.

Pressure points touched:

  • Active World Info query path via useActiveLorebookEntries

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 reproduced the issue with pnpm exec vitest run src/engine/generation/active-lorebooks.test.ts --reporter=verbose: before the fix, Active World Info returned only Gordon keyword and reported missing_embedding_source, while the direct semantic scanner returned Gordon.
  • Codex verified the fix with pnpm exec vitest run src/engine/generation/active-lorebooks.test.ts --reporter=verbose: 3 tests passed, covering semantic-only activation, keyword-only fallback when semantic search is unavailable, and an unrelated semantic should-not-match row.
  • Codex ran pnpm typecheck: passed.
  • Codex ran full pnpm check: passed.
  • Codex ran node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json: passed.
  • Bunny review pass: passed before opening the draft PR.
  • No true manual verification blocker remains for the core claim. A human can still sanity-check the panel with a real embedding provider in the desktop app before merge.

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 to an existing Active World Info/lorebook semantic matching path; no new discoverable feature or workflow.

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

  • No browser screenshot was captured. The proof is a focused harness for the Active World Info scanner path because the core bug is whether the panel's query supplies semantic embeddings; real-provider desktop visual verification remains a useful reviewer sanity check but is not blocking the core claim.

Summary by CodeRabbit

Release Notes

  • New Features

    • World info entries now support semantic/vector-based matching in addition to keyword matching
    • Integration with generation connection embeddings for improved context relevance
    • Graceful fallback to keyword matching when semantic embedding is unavailable
  • Tests

    • Comprehensive test coverage for semantic world info entry scanning and matching

🔄 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/1861 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/1/2026 **Status:** ✅ Merged **Merged:** 6/1/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1858-semantic-lorebook` --- ### 📝 Commits (2) - [`235039e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/235039e0db3c3f63bec2111595b62b82cee2cee3) Fix semantic active lorebook scan - [`212d4cf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/212d4cf2451ba837ed2c3a900a63c30e46feb1f7) Add semantic lorebook negative control ### 📊 Changes **3 files changed** (+247 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `src/engine/generation/active-lorebooks.test.ts` (+201 -0) 📝 `src/engine/generation/active-lorebooks.ts` (+6 -0) 📝 `src/features/catalog/lorebooks/hooks/use-lorebooks.ts` (+40 -1) </details> ### 📄 Description ## Linked issue Closes #1858 ## Why this change - Active World Info could only show keyword/constant lorebook matches because its scan wrapper never supplied the semantic embedding source that the core active-lorebook scanner already supports. - This made vectorized, keywordless lorebook entries appear unavailable in the visible active-info panel even though the semantic scanner can activate them when an embedding source is present. ## What changed - Let `scanActiveLorebookEntries` accept the same abstract embedding source used by the active lorebook scanner. - Build an Active World Info embedding source from the chat's generation connection in the lorebook query hook, using `llmApi.embed`. - Added a regression test for semantic-only vectorized entries plus the keyword-only fallback path when semantic search is unavailable. ## Refactor impact Primary owner: - Engine generation / catalog lorebook UI Impact areas reviewed: - Active World Info lorebook scan - Semantic-only vectorized lorebook activation - Keyword lorebook activation when no embedding source is available - Generation prompt scanner boundary, to keep engine code depending only on an abstract embedding source Boundary notes: - Engine code still does not import React, Tauri APIs, or shared API adapters. - Feature code owns `llmApi` and passes only an abstract `{ embed }` source into the engine scanner. - No storage schema, dependency, prompt preset, or Rust command changes. Pressure points touched: - Active World Info query path via `useActiveLorebookEntries` ## 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 reproduced the issue with `pnpm exec vitest run src/engine/generation/active-lorebooks.test.ts --reporter=verbose`: before the fix, Active World Info returned only `Gordon keyword` and reported `missing_embedding_source`, while the direct semantic scanner returned `Gordon`. - Codex verified the fix with `pnpm exec vitest run src/engine/generation/active-lorebooks.test.ts --reporter=verbose`: 3 tests passed, covering semantic-only activation, keyword-only fallback when semantic search is unavailable, and an unrelated semantic should-not-match row. - Codex ran `pnpm typecheck`: passed. - Codex ran full `pnpm check`: passed. - Codex ran `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json`: passed. - Bunny review pass: passed before opening the draft PR. - No true manual verification blocker remains for the core claim. A human can still sanity-check the panel with a real embedding provider in the desktop app before merge. ## 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 to an existing Active World Info/lorebook semantic matching path; no new discoverable feature or workflow. ## 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 - No browser screenshot was captured. The proof is a focused harness for the Active World Info scanner path because the core bug is whether the panel's query supplies semantic embeddings; real-provider desktop visual verification remains a useful reviewer sanity check but is not blocking the core claim. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * World info entries now support semantic/vector-based matching in addition to keyword matching * Integration with generation connection embeddings for improved context relevance * Graceful fallback to keyword matching when semantic embedding is unavailable * **Tests** * Comprehensive test coverage for semantic world info entry scanning and matching <!-- 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:15:14 +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#5323
No description provided.