[PR #2249] [MERGED] Fix lorebook marker runtime state gating #5510

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-2188-lorebook-marker-runtime


📝 Commits (2)

  • a890e38 Fix lorebook marker runtime state gating
  • 50fb94b Merge remote-tracking branch 'upstream/refactor' into fix/issue-2188-lorebook-marker-runtime

📊 Changes

3 files changed (+182 additions, -17 deletions)

View changed files

📝 src/engine/generation/active-lorebook-scanner.ts (+17 -3)
📝 src/engine/generation/prompt-assembly.test.ts (+116 -0)
📝 src/engine/generation/prompt-assembly.ts (+49 -14)

📄 Description

Linked issue

Closes #2188

Why this change

  • Markerless prompt presets could still return lorebook activation and runtime-state deltas for world-info entries even though those entries were never inserted into the assembled prompt.
  • That let sticky/cooldown/delay/ephemeral state be consumed outside the prompt path that actually used the lore.

What changed

  • Added a prompt-position scope for active lorebook scans so world-info-before/world-info-after entries are only eligible when those positions can be inserted.
  • Preserved depth-position lore injection, game prompt lore merge behavior, and fallback prompt lore insertion.
  • Added regression coverage for markerless presets, lore marker presets, empty selected-preset fallback, and existing depth injection behavior.

Refactor impact

Primary owner:

  • engine generation

Impact areas reviewed:

  • Prompt assembly marker handling
  • Active lorebook scanner activation, budgeting, semantic embedding selection, and runtime-state updates
  • Lorebook depth injection compatibility
  • Game/fallback prompt lore insertion paths

Boundary notes:

  • Stays inside src/engine; no React, shared API, Tauri/Rust storage, or remote-runtime boundary changes.

Pressure points touched:

  • assembleGenerationPrompt
  • scanActiveLorebooks

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 focused proof: pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts passed with 8 tests after the fix. Before the production fix, the new markerless preset regression failed because activatedLorebookEntries contained the matched world-info entry while the prompt preview did not include lore.
  • Codex conflict-resolution proof: after merging upstream/refactor, pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts passed again with 8 tests.
  • Codex baseline: pnpm check passed after the final diff and passed again after conflict resolution.
  • Bunny review: passed for the original fix and the conflict-resolution diff; post-merge PR diff remains limited to src/engine/generation/active-lorebook-scanner.ts, src/engine/generation/prompt-assembly.ts, and src/engine/generation/prompt-assembly.test.ts.
  • No manual verification needed for the core claim; this is React-free engine prompt assembly behavior covered by focused Vitest and the full repo check.

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:

  • Internal engine bugfix only; no new discoverable product behavior.

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 React-free engine prompt assembly behavior; proof is the focused Vitest repro plus pnpm check.


🔄 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/2249 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/4/2026 **Status:** ✅ Merged **Merged:** 6/4/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-2188-lorebook-marker-runtime` --- ### 📝 Commits (2) - [`a890e38`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a890e3879bfd43cf4f7452665c2ba8c22da795f7) Fix lorebook marker runtime state gating - [`50fb94b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/50fb94b705ab868bea825c0f21606b26924f6637) Merge remote-tracking branch 'upstream/refactor' into fix/issue-2188-lorebook-marker-runtime ### 📊 Changes **3 files changed** (+182 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation/active-lorebook-scanner.ts` (+17 -3) 📝 `src/engine/generation/prompt-assembly.test.ts` (+116 -0) 📝 `src/engine/generation/prompt-assembly.ts` (+49 -14) </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 #2188 ## Why this change - Markerless prompt presets could still return lorebook activation and runtime-state deltas for world-info entries even though those entries were never inserted into the assembled prompt. - That let sticky/cooldown/delay/ephemeral state be consumed outside the prompt path that actually used the lore. ## What changed - Added a prompt-position scope for active lorebook scans so world-info-before/world-info-after entries are only eligible when those positions can be inserted. - Preserved depth-position lore injection, game prompt lore merge behavior, and fallback prompt lore insertion. - Added regression coverage for markerless presets, lore marker presets, empty selected-preset fallback, and existing depth injection behavior. ## Refactor impact Primary owner: - engine generation Impact areas reviewed: - Prompt assembly marker handling - Active lorebook scanner activation, budgeting, semantic embedding selection, and runtime-state updates - Lorebook depth injection compatibility - Game/fallback prompt lore insertion paths Boundary notes: - Stays inside `src/engine`; no React, shared API, Tauri/Rust storage, or remote-runtime boundary changes. Pressure points touched: - `assembleGenerationPrompt` - `scanActiveLorebooks` ## 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 - Codex focused proof: `pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts` passed with 8 tests after the fix. Before the production fix, the new markerless preset regression failed because `activatedLorebookEntries` contained the matched world-info entry while the prompt preview did not include lore. - Codex conflict-resolution proof: after merging `upstream/refactor`, `pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts` passed again with 8 tests. - Codex baseline: `pnpm check` passed after the final diff and passed again after conflict resolution. - Bunny review: passed for the original fix and the conflict-resolution diff; post-merge PR diff remains limited to `src/engine/generation/active-lorebook-scanner.ts`, `src/engine/generation/prompt-assembly.ts`, and `src/engine/generation/prompt-assembly.test.ts`. - No manual verification needed for the core claim; this is React-free engine prompt assembly behavior covered by focused Vitest and the full repo check. ## 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: - Internal engine bugfix only; no new discoverable product behavior. ## 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 React-free engine prompt assembly behavior; proof is the focused Vitest repro plus `pnpm check`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:16:56 +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#5510
No description provided.