[PR #2356] [MERGED] Fix linked lorebook header sync #5557

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-2280-lorebook-header-sync


📝 Commits (3)

  • ba58d93 Fix linked lorebook header sync
  • 11d1df1 Invalidate character caches after linked lorebook writes
  • f0eef7b Preserve linked character book metadata

📊 Changes

2 files changed (+360 additions, -2 deletions)

View changed files

📝 src-tauri/src/commands/storage/commands/entities.rs (+344 -0)
📝 src/features/catalog/lorebooks/hooks/use-lorebooks.ts (+16 -2)

📄 Description

Linked issue

Closes #2280

Why this change

  • Linked standalone lorebook metadata edits were patching the lorebooks row without re-syncing the linked character's embedded data.character_book, so later character card exports could carry a stale ST header.

What changed

  • Route lorebooks updates through an atomic lorebook/entries/characters sync path.
  • Rebuild the linked character's embedded character_book header from the updated lorebook row, including name, description, scan_depth, token_budget, and recursive_scanning.
  • Added regression coverage for the metadata update path, preserving entries and proving an unrelated linked character is not changed.

Refactor impact

Primary owner:

Rust storage

Impact areas reviewed:

  • src-tauri/src/commands/storage/commands/entities.rs
  • Character compatible export path, which emits data.character_book verbatim after storage sync.

Boundary notes:

  • Stays inside src-tauri; no React, engine, shared API, remote runtime, schema, dependency, auth, prompt, or release boundary changes.

Pressure points touched:

  • Storage entity update command path for lorebooks.

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 stale-header bug with the new Rust regression test before the production fix: cargo test --manifest-path src-tauri/Cargo.toml updating_linked_lorebook_metadata_syncs_character_book_header -- --nocapture failed because the embedded header stayed {}.
  • After the fix, cargo test --manifest-path src-tauri/Cargo.toml updating_linked_lorebook_metadata_syncs_character_book_header -- --nocapture passed.
  • Adjacent storage coverage passed: cargo test --manifest-path src-tauri/Cargo.toml linked_lorebook -- --nocapture passed, covering linked entry create/update/delete/move, embedded reimport, malformed-book atomic failure, and the metadata sync regression.
  • Full baseline passed after the final diff: pnpm check.
  • Proof gate passed: node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json.
  • Bunny review passed before opening this draft: focused Rust storage diff, direct repro, negative control, pnpm check, and proof gate clean.
  • No human-only verification blocker remains 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 for existing linked lorebook export-state behavior; no new discoverable feature.

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

Backend/export-state bug; no meaningful app UI state changes. Evidence is a GitHub-renderable proof card built from the captured Rust repro and pnpm check outputs:

Issue #2280 proof

Summary by CodeRabbit

  • New Features
    • Lorebook metadata updates now automatically synchronize with linked character books, refreshing headers in real-time while maintaining entry syncing.
    • Atomic update mechanism ensures consistent changes across all characters referencing the updated lorebook.

🔄 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/2356 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/5/2026 **Status:** ✅ Merged **Merged:** 6/6/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `fix/issue-2280-lorebook-header-sync` --- ### 📝 Commits (3) - [`ba58d93`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ba58d93a4997565d19fbd7988c83ccffa2833c6f) Fix linked lorebook header sync - [`11d1df1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/11d1df1058fe993851e5f18e5110a5b7ec0a6a00) Invalidate character caches after linked lorebook writes - [`f0eef7b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f0eef7b63aa02034eed3a808bba30d661c6e76e7) Preserve linked character book metadata ### 📊 Changes **2 files changed** (+360 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/commands/entities.rs` (+344 -0) 📝 `src/features/catalog/lorebooks/hooks/use-lorebooks.ts` (+16 -2) </details> ### 📄 Description ## Linked issue Closes #2280 ## Why this change - Linked standalone lorebook metadata edits were patching the `lorebooks` row without re-syncing the linked character's embedded `data.character_book`, so later character card exports could carry a stale ST header. ## What changed - Route `lorebooks` updates through an atomic lorebook/entries/characters sync path. - Rebuild the linked character's embedded `character_book` header from the updated lorebook row, including `name`, `description`, `scan_depth`, `token_budget`, and `recursive_scanning`. - Added regression coverage for the metadata update path, preserving entries and proving an unrelated linked character is not changed. ## Refactor impact Primary owner: Rust storage Impact areas reviewed: - `src-tauri/src/commands/storage/commands/entities.rs` - Character compatible export path, which emits `data.character_book` verbatim after storage sync. Boundary notes: - Stays inside `src-tauri`; no React, engine, shared API, remote runtime, schema, dependency, auth, prompt, or release boundary changes. Pressure points touched: - Storage entity update command path for `lorebooks`. ## Validation - [x] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [x] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - Codex reproduced the stale-header bug with the new Rust regression test before the production fix: `cargo test --manifest-path src-tauri/Cargo.toml updating_linked_lorebook_metadata_syncs_character_book_header -- --nocapture` failed because the embedded header stayed `{}`. - After the fix, `cargo test --manifest-path src-tauri/Cargo.toml updating_linked_lorebook_metadata_syncs_character_book_header -- --nocapture` passed. - Adjacent storage coverage passed: `cargo test --manifest-path src-tauri/Cargo.toml linked_lorebook -- --nocapture` passed, covering linked entry create/update/delete/move, embedded reimport, malformed-book atomic failure, and the metadata sync regression. - Full baseline passed after the final diff: `pnpm check`. - Proof gate passed: `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json`. - Bunny review passed before opening this draft: focused Rust storage diff, direct repro, negative control, `pnpm check`, and proof gate clean. - No human-only verification blocker remains 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. - [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 for existing linked lorebook export-state behavior; no new discoverable feature. ## 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 ## UI evidence Backend/export-state bug; no meaningful app UI state changes. Evidence is a GitHub-renderable proof card built from the captured Rust repro and `pnpm check` outputs: ![Issue #2280 proof](https://gist.githubusercontent.com/cha1latte/2076e5eaab4fc94164be5093bd59a08c/raw/1fcc0b0075e7bf5cb599acad801ca60f06939a5b/issue-2280-proof.svg) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Lorebook metadata updates now automatically synchronize with linked character books, refreshing headers in real-time while maintaining entry syncing. * Atomic update mechanism ensures consistent changes across all characters referencing the updated lorebook. <!-- 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:17:21 +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#5557
No description provided.