[PR #1213] [MERGED] Fix Lorebook Keeper backfill cadence #4986

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/refactor-issue-1211-lorebook-keeper


📝 Commits (2)

  • eddd020 Fix Lorebook Keeper backfill cadence
  • 5378a32 Merge upstream refactor into issue 1211 fix

📊 Changes

3 files changed (+290 additions, -21 deletions)

View changed files

📝 src/engine/generation/agent-runner.ts (+1 -0)
📝 src/engine/generation/start-generation.test.ts (+76 -3)
📝 src/engine/generation/start-generation.ts (+213 -18)

📄 Description

Linked issue

Closes #1211

Why this change

  • Lorebook Keeper's refactor path passed a lorebookKeeperBackfill option from the UI, but the generation engine ignored it and only retried the latest assistant message.
  • Automatic generation also ran Lorebook Keeper through the normal post-processing agent path, which cannot honor read-behind because the target assistant message has not been saved yet.

What changed

  • Route normal automatic Lorebook Keeper work through a post-save backfill pass so run interval, read-behind, processed-message history, and target-scoped context are all applied.
  • Make manual Backfill Unprocessed select unprocessed interval anchors instead of the latest assistant message only.
  • Reuse the targeted retry runtime with message history sliced before each selected assistant target, so the agent context window batches around the intended target.
  • Skip Lorebook Keeper from the normal automatic agent runtime; targeted retries still run it directly.
  • Added focused regression coverage for run interval, read-behind exclusion, already-processed anchors, and target-scoped prompt context.

Refactor impact

Primary owner:

  • Engine generation

Impact areas reviewed:

  • startGeneration automatic post-save agent flow
  • retryGenerationAgents targeted retry/backfill flow
  • Agent resolution for normal automatic runs
  • Agent-run persistence via agent-runs.messageId

Boundary notes:

  • Change stays inside engine generation and tests. No React feature code, shared API wrapper, Rust command, schema, dependency, or prompt-template changes.

Pressure points touched:

  • Engine generation runtime only; no ModeSurface/GameSurface/shared mode UI/Rust command registration/import modules touched.

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

  • Codex ran pnpm exec vitest run src/engine/generation/agent-runner.test.ts src/engine/generation/start-generation.test.ts and the focused repro passed.
  • Codex ran pnpm check, covering architecture, TypeScript, Rust workspace cargo check, and docs checks.
  • Codex ran node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json; the proof gate passed.
  • No browser/Tauri manual verification was performed because this is engine generation logic with no visible UI change.

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 - engine generation logic only.


🔄 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/1213 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/25/2026 **Status:** ✅ Merged **Merged:** 5/25/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/refactor-issue-1211-lorebook-keeper` --- ### 📝 Commits (2) - [`eddd020`](https://github.com/Pasta-Devs/Marinara-Engine/commit/eddd0202d3e95686ed57b1a868e4ed263c65875a) Fix Lorebook Keeper backfill cadence - [`5378a32`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5378a32bc1ebcc6ce1bb06ef75a6716095b27918) Merge upstream refactor into issue 1211 fix ### 📊 Changes **3 files changed** (+290 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation/agent-runner.ts` (+1 -0) 📝 `src/engine/generation/start-generation.test.ts` (+76 -3) 📝 `src/engine/generation/start-generation.ts` (+213 -18) </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 #1211 ## Why this change - Lorebook Keeper's refactor path passed a `lorebookKeeperBackfill` option from the UI, but the generation engine ignored it and only retried the latest assistant message. - Automatic generation also ran Lorebook Keeper through the normal post-processing agent path, which cannot honor read-behind because the target assistant message has not been saved yet. ## What changed - Route normal automatic Lorebook Keeper work through a post-save backfill pass so run interval, read-behind, processed-message history, and target-scoped context are all applied. - Make manual Backfill Unprocessed select unprocessed interval anchors instead of the latest assistant message only. - Reuse the targeted retry runtime with message history sliced before each selected assistant target, so the agent context window batches around the intended target. - Skip Lorebook Keeper from the normal automatic agent runtime; targeted retries still run it directly. - Added focused regression coverage for run interval, read-behind exclusion, already-processed anchors, and target-scoped prompt context. ## Refactor impact Primary owner: - Engine generation Impact areas reviewed: - `startGeneration` automatic post-save agent flow - `retryGenerationAgents` targeted retry/backfill flow - Agent resolution for normal automatic runs - Agent-run persistence via `agent-runs.messageId` Boundary notes: - Change stays inside engine generation and tests. No React feature code, shared API wrapper, Rust command, schema, dependency, or prompt-template changes. Pressure points touched: - Engine generation runtime only; no ModeSurface/GameSurface/shared mode UI/Rust command registration/import modules touched. ## 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 - Codex ran `pnpm exec vitest run src/engine/generation/agent-runner.test.ts src/engine/generation/start-generation.test.ts` and the focused repro passed. - Codex ran `pnpm check`, covering architecture, TypeScript, Rust workspace `cargo check`, and docs checks. - Codex ran `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json`; the proof gate passed. - No browser/Tauri manual verification was performed because this is engine generation logic with no visible UI change. ## 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 - engine generation logic only. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:12:16 +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#4986
No description provided.