[PR #779] [MERGED] Fix Lorebook Keeper overwrite updates #4770

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/779
Author: @Promansis
Created: 5/13/2026
Status: ✅ Merged
Merged: 5/13/2026
Merged by: @Promansis

Base: main ← Head: fix/issue-768-lorebook-update-overwrite


📝 Commits (1)

📊 Changes

2 files changed (+106 additions, -5 deletions)

View changed files

📝 packages/server/src/routes/generate/lorebook-keeper-utils.ts (+15 -5)
📝 packages/server/test/lorebook-keeper-utils.test.ts (+91 -0)

📄 Description

Linked issue

Closes #768

Why this change

  • Lorebook automation could receive an explicit action: "update" payload with replacement content for an existing entry, but the persistence helper treated it like append-style Keeper content.
  • That caused relationship or lore entries to accumulate repeated historical versions instead of containing only the newly synthesized state.

What changed

  • Detect explicit Lorebook Keeper update payloads that include non-empty replacement content and replace the existing entry body with that content.
  • Preserve the existing append-only behavior for newFacts updates so the built-in Keeper flow can still append durable facts without erasing prior details.
  • Added focused regression tests for overwrite updates and append-style newFacts updates.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Codex ran pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/lorebook-keeper-utils.test.ts successfully.
  • Codex ran pnpm check successfully.
  • Codex ran git diff --check successfully.
  • Human manual verification: with an existing TargetEntry containing OLD_CONTENT_MARKER, a Lorebook Keeper update replaced it with only NEW_CONTENT_MARKER: Keeper overwrite succeeded cleanly.; the old marker was gone.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

No docs or release/version files changed.

UI evidence (if applicable)

N/A. Server-side persistence behavior only.

Summary by CodeRabbit

  • New Features

    • Lorebook entries now support explicit replacement updates for content. Associated metadata is intelligently managed during updates, including key merging and tag preservation.
  • Tests

    • Expanded test coverage for lorebook update behaviors including content replacement and metadata handling.

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/779 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 5/13/2026 **Status:** ✅ Merged **Merged:** 5/13/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `main` ← **Head:** `fix/issue-768-lorebook-update-overwrite` --- ### 📝 Commits (1) - [`0f87fbe`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0f87fbe293652f785a22f5167d9ab867c8688326) Fix lorebook keeper overwrite updates (#768) ### 📊 Changes **2 files changed** (+106 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/generate/lorebook-keeper-utils.ts` (+15 -5) 📝 `packages/server/test/lorebook-keeper-utils.test.ts` (+91 -0) </details> ### 📄 Description ## Linked issue Closes #768 ## Why this change - Lorebook automation could receive an explicit `action: "update"` payload with replacement `content` for an existing entry, but the persistence helper treated it like append-style Keeper content. - That caused relationship or lore entries to accumulate repeated historical versions instead of containing only the newly synthesized state. ## What changed - Detect explicit Lorebook Keeper `update` payloads that include non-empty replacement `content` and replace the existing entry body with that content. - Preserve the existing append-only behavior for `newFacts` updates so the built-in Keeper flow can still append durable facts without erasing prior details. - Added focused regression tests for overwrite updates and append-style `newFacts` updates. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Codex ran `pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/lorebook-keeper-utils.test.ts` successfully. - Codex ran `pnpm check` successfully. - Codex ran `git diff --check` successfully. - Human manual verification: with an existing `TargetEntry` containing `OLD_CONTENT_MARKER`, a Lorebook Keeper update replaced it with only `NEW_CONTENT_MARKER: Keeper overwrite succeeded cleanly.`; the old marker was gone. ## Docs and release impact - [x] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [x] Version/release files updated (only if this PR includes a version bump) No docs or release/version files changed. ## UI evidence (if applicable) N/A. Server-side persistence behavior only. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Lorebook entries now support explicit replacement updates for content. Associated metadata is intelligently managed during updates, including key merging and tag preservation. * **Tests** * Expanded test coverage for lorebook update behaviors including content replacement and metadata handling. <!-- 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/779) <!-- 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:10:30 +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#4770
No description provided.