[PR #1834] [MERGED] Fix lorebook parity gaps #5304

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-1793-lorebook-parity


📝 Commits (1)

📊 Changes

7 files changed (+457 additions, -70 deletions)

View changed files

📝 src-tauri/src/commands/storage/commands/entities.rs (+154 -0)
📝 src-tauri/src/commands/storage/imports/normalization.rs (+50 -9)
📝 src-tauri/src/commands/storage/imports/service_tests.rs (+34 -0)
📝 src/engine/generation-core/lorebooks/prompt-injector.ts (+44 -27)
📝 src/engine/generation/active-lorebook-scanner.ts (+126 -4)
📝 src/engine/generation/prompt-assembly.ts (+30 -25)
📝 src/engine/generation/start-generation.ts (+19 -5)

📄 Description

Linked issue

Closes #1793

Why this change

  • Restores lorebook parity in the refactor path for deletion cleanup, prompt injection, per-chat finite-use entries, macro-resolved lore content, and SillyTavern import normalization.

What changed

  • Clears deleted lorebook IDs from chat activeLorebookIds metadata/top-level fields and clears imported embedded character lorebook pointers when the linked lorebook is deleted.
  • Resolves lorebook macros before lore prompt insertion/budgeting and persists per-chat ephemeral entry countdown overrides after generation.
  • Anchors depth injection to the original prompt message bounds so inserted entries do not move later depth anchors.
  • Normalizes SillyTavern selectiveLogic numeric values and keeps probability disabled when useProbability / use_probability is false, including after raw imported fields are merged.

Refactor impact

Primary owner:

engine generation, Rust storage, imports

Impact areas reviewed:

  • Lorebook prompt injection and active lorebook scanning
  • Generation prompt assembly and lorebook runtime state persistence
  • Generic storage deletion cascade for lorebooks
  • SillyTavern lorebook/embedded character import normalization

Boundary notes:

  • Engine changes remain React-free and stay inside src/engine.
  • Storage and import cleanup stays inside src-tauri.
  • No shared API/raw Tauri/remote runtime boundary changes.

Pressure points touched:

  • Prompt assembly lorebook pipeline
  • src-tauri storage delete command
  • src-tauri import normalization modules

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

  • Machine proof: pnpm exec vitest run --config scratch/vitest.issue-1793.config.ts --pool=forks passed with 3 focused lorebook parity rows.
  • Machine proof: cargo test --manifest-path src-tauri/Cargo.toml --workspace deleting_lorebook_clears_chat_and_embedded_character_refs passed.
  • Machine proof: cargo test --manifest-path src-tauri/Cargo.toml --workspace normalizes_sillytavern_selective_logic_numbers passed.
  • Machine proof: cargo test --manifest-path src-tauri/Cargo.toml --workspace normalizes_imported_lorebook_entry_after_raw_field_merge passed.
  • Baseline: pnpm check passed.
  • Proof gate: node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed.
  • Bunny review: passed before opening the PR.
  • No manual verification blockers identified for the core claim.

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/compatibility parity work only; no new discoverable surface.

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

N/A: this is engine/storage/import behavior with command and harness proof rather than a visible UI change.


🔄 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/1834 **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-1793-lorebook-parity` --- ### 📝 Commits (1) - [`8f8dabd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8f8dabd9a02c0881b3b76e6a5082cb2e2a933fd3) Fix lorebook parity gaps ### 📊 Changes **7 files changed** (+457 additions, -70 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/commands/entities.rs` (+154 -0) 📝 `src-tauri/src/commands/storage/imports/normalization.rs` (+50 -9) 📝 `src-tauri/src/commands/storage/imports/service_tests.rs` (+34 -0) 📝 `src/engine/generation-core/lorebooks/prompt-injector.ts` (+44 -27) 📝 `src/engine/generation/active-lorebook-scanner.ts` (+126 -4) 📝 `src/engine/generation/prompt-assembly.ts` (+30 -25) 📝 `src/engine/generation/start-generation.ts` (+19 -5) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue Closes #1793 ## Why this change - Restores lorebook parity in the refactor path for deletion cleanup, prompt injection, per-chat finite-use entries, macro-resolved lore content, and SillyTavern import normalization. ## What changed - Clears deleted lorebook IDs from chat `activeLorebookIds` metadata/top-level fields and clears imported embedded character lorebook pointers when the linked lorebook is deleted. - Resolves lorebook macros before lore prompt insertion/budgeting and persists per-chat ephemeral entry countdown overrides after generation. - Anchors depth injection to the original prompt message bounds so inserted entries do not move later depth anchors. - Normalizes SillyTavern `selectiveLogic` numeric values and keeps probability disabled when `useProbability` / `use_probability` is false, including after raw imported fields are merged. ## Refactor impact Primary owner: engine generation, Rust storage, imports Impact areas reviewed: - Lorebook prompt injection and active lorebook scanning - Generation prompt assembly and lorebook runtime state persistence - Generic storage deletion cascade for lorebooks - SillyTavern lorebook/embedded character import normalization Boundary notes: - Engine changes remain React-free and stay inside `src/engine`. - Storage and import cleanup stays inside `src-tauri`. - No shared API/raw Tauri/remote runtime boundary changes. Pressure points touched: - Prompt assembly lorebook pipeline - `src-tauri` storage delete command - `src-tauri` import normalization modules ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> <!-- Do not submit *.test.ts or *.test.tsx files as PR proof; cite existing checks, command output, app/browser/Tauri verification, or manual notes instead. --> - [ ] 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 - Machine proof: `pnpm exec vitest run --config scratch/vitest.issue-1793.config.ts --pool=forks` passed with 3 focused lorebook parity rows. - Machine proof: `cargo test --manifest-path src-tauri/Cargo.toml --workspace deleting_lorebook_clears_chat_and_embedded_character_refs` passed. - Machine proof: `cargo test --manifest-path src-tauri/Cargo.toml --workspace normalizes_sillytavern_selective_logic_numbers` passed. - Machine proof: `cargo test --manifest-path src-tauri/Cargo.toml --workspace normalizes_imported_lorebook_entry_after_raw_field_merge` passed. - Baseline: `pnpm check` passed. - Proof gate: `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed. - Bunny review: passed before opening the PR. - No manual verification blockers identified for the core claim. ## 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/compatibility parity work only; no new discoverable surface. ## 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 N/A: this is engine/storage/import behavior with command and harness proof rather than a visible UI change. --- <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:05 +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#5304
No description provided.