[PR #2502] [MERGED] Fix regen context and Secret Plot guidance #5622

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/context-secret-plot-regen


📝 Commits (1)

  • c508059 Fix regen context and Secret Plot guidance

📊 Changes

6 files changed (+261 additions, -14 deletions)

View changed files

📝 src/engine/generation/agent-memory-runtime.ts (+41 -2)
📝 src/engine/generation/agent-runner.ts (+32 -6)
📝 src/engine/generation/generation-replay.ts (+34 -0)
📝 src/engine/generation/start-generation.ts (+11 -6)
➕ tests/unit/agent-memory-runtime.spec.ts (+105 -0)
➕ tests/unit/generation-replay.spec.ts (+38 -0)

📄 Description

Linked issue

Closes #2491
Closes #2492

Why this change

  • Regenerating a message could ignore the target message's cached context injections, so rerolls lost the same Knowledge Router / Prose Guardian / Director guidance that shaped the original turn.
  • Secret Plot Driver memory was loaded too broadly and its hidden arc/directions were not reliably fed back into the main prompt, leaving gaps between memory, prompt assembly, and reroll behavior.

What changed

  • Reapply cached extra.contextInjections to regeneration input even when replay metadata is missing or the chat summary fingerprint no longer matches.
  • Normalize cached injection shapes, preserve explicit agentInjectionOverrides, and filter Secret Plot Driver cached guidance out of generic context injection replay.
  • Scope Secret Plot memory to the resolved Secret Plot Driver agent config, then format active arc and unfulfilled scene directions into hidden main-prompt guidance.
  • Allow full Secret Plot rerolls to persist an explicit cleared arc while preserving the arc on turn-only rerolls.
  • Add focused unit specs for regeneration context replay and Secret Plot memory/prompt/reroll invariants.

Refactor impact

Primary owner:

Engine generation

Impact areas reviewed:

  • Regeneration replay input shaping
  • Agent runtime context/memory loading
  • Prompt assembly agentData insertion path
  • Secret Plot Driver memory persistence
  • Saved message extra.contextInjections reuse
  • Chat/roleplay/game mode boundary impact from shared generation changes

Boundary notes:

  • Engine-only change; no React, Tauri, shared API, Rust, or remote-runtime boundary changes.
  • Prompt/generation changes stay inside src/engine and use existing storage/LLM capability ports.

Pressure points touched:

  • Runtime generation agent pre-generation flow
  • Prompt assembly agent-data injection path
  • Regeneration replay metadata path

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

Durable test rationale:

  • Regression/risky invariant: regeneration must reuse cached context injections, and Secret Plot Driver must preserve hidden memory/prompt/reroll semantics without leaking stale generic cached injections.
  • Existing proof was insufficient because these are silent prompt-shaping regressions that can pass typecheck while changing generated behavior.
  • The added tests are narrow helper/runtime-memory specs around normalization, explicit override preservation, hidden prompt guidance formatting, and full-vs-turn-only reroll persistence.

Commands run:

  • git diff --check
  • pnpm exec vitest run tests/unit/generation-replay.spec.ts tests/unit/agent-memory-runtime.spec.ts
  • pnpm typecheck
  • pnpm check:architecture
  • pnpm check
  • Failpath and Bunny-style review found no confirmed issues; residual risk is no live provider/browser regeneration run.

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:

  • Existing regeneration and Secret Plot behavior is fixed; no new user-discoverable feature or setting is added.

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; no visible UI changes.

🔄 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/2502 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 6/6/2026 **Status:** ✅ Merged **Merged:** 6/6/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `refactor` ← **Head:** `fix/context-secret-plot-regen` --- ### 📝 Commits (1) - [`c508059`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c5080599ed61922be19bf3b55d66911e53a94531) Fix regen context and Secret Plot guidance ### 📊 Changes **6 files changed** (+261 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation/agent-memory-runtime.ts` (+41 -2) 📝 `src/engine/generation/agent-runner.ts` (+32 -6) 📝 `src/engine/generation/generation-replay.ts` (+34 -0) 📝 `src/engine/generation/start-generation.ts` (+11 -6) ➕ `tests/unit/agent-memory-runtime.spec.ts` (+105 -0) ➕ `tests/unit/generation-replay.spec.ts` (+38 -0) </details> ### 📄 Description ## Linked issue Closes #2491 Closes #2492 ## Why this change - Regenerating a message could ignore the target message's cached context injections, so rerolls lost the same Knowledge Router / Prose Guardian / Director guidance that shaped the original turn. - Secret Plot Driver memory was loaded too broadly and its hidden arc/directions were not reliably fed back into the main prompt, leaving gaps between memory, prompt assembly, and reroll behavior. ## What changed - Reapply cached `extra.contextInjections` to regeneration input even when replay metadata is missing or the chat summary fingerprint no longer matches. - Normalize cached injection shapes, preserve explicit `agentInjectionOverrides`, and filter Secret Plot Driver cached guidance out of generic context injection replay. - Scope Secret Plot memory to the resolved Secret Plot Driver agent config, then format active arc and unfulfilled scene directions into hidden main-prompt guidance. - Allow full Secret Plot rerolls to persist an explicit cleared arc while preserving the arc on turn-only rerolls. - Add focused unit specs for regeneration context replay and Secret Plot memory/prompt/reroll invariants. ## Refactor impact Primary owner: Engine generation Impact areas reviewed: - Regeneration replay input shaping - Agent runtime context/memory loading - Prompt assembly `agentData` insertion path - Secret Plot Driver memory persistence - Saved message `extra.contextInjections` reuse - Chat/roleplay/game mode boundary impact from shared generation changes Boundary notes: - Engine-only change; no React, Tauri, shared API, Rust, or remote-runtime boundary changes. - Prompt/generation changes stay inside `src/engine` and use existing storage/LLM capability ports. Pressure points touched: - Runtime generation agent pre-generation flow - Prompt assembly agent-data injection path - Regeneration replay metadata path ## 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 Durable test rationale: - Regression/risky invariant: regeneration must reuse cached context injections, and Secret Plot Driver must preserve hidden memory/prompt/reroll semantics without leaking stale generic cached injections. - Existing proof was insufficient because these are silent prompt-shaping regressions that can pass typecheck while changing generated behavior. - The added tests are narrow helper/runtime-memory specs around normalization, explicit override preservation, hidden prompt guidance formatting, and full-vs-turn-only reroll persistence. Commands run: - `git diff --check` - `pnpm exec vitest run tests/unit/generation-replay.spec.ts tests/unit/agent-memory-runtime.spec.ts` - `pnpm typecheck` - `pnpm check:architecture` - `pnpm check` - Failpath and Bunny-style review found no confirmed issues; residual risk is no live provider/browser regeneration run. ## 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: - Existing regeneration and Secret Plot behavior is fixed; no new user-discoverable feature or setting is added. ## 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 - N/A; no visible UI changes. --- <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:54 +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#5622
No description provided.