[PR #2246] [MERGED] Fix legacy context injection normalization #5507

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-2170-context-injection-strings


📝 Commits (4)

  • 7629fdd Fix legacy context injection normalization
  • b284201 Record PR verification metadata
  • a19332c Harden regenerate context injection merge
  • 5d04b97 Merge upstream refactor into issue 2170 fix

📊 Changes

3 files changed (+198 additions, -57 deletions)

View changed files

📝 scratch/bugfix-verification.json (+56 -49)
📝 src/engine/generation/start-generation.test.ts (+118 -8)
📝 src/engine/generation/start-generation.ts (+24 -0)

📄 Description

Linked issue

Closes #2170

Why this change

  • Legacy persisted extra.contextInjections can contain bare strings. The refactor engine path dropped those rows during regenerate/retry merges, so legacy prose-guardian guidance could silently disappear.

What changed

  • Normalize string context-injection entries as { agentType: "prose-guardian", text } in the engine generation normalizer.
  • Merge regenerate agent-injection updates against the target message's existing extra, so legacy/current cached rows survive when a regenerated message receives new agent output.
  • Added a focused regression test covering legacy string rows, existing object rows, and blank-string skip behavior.

Refactor impact

Primary owner:

  • engine generation

Impact areas reviewed:

  • src/engine/generation/start-generation.ts
  • src/engine/generation/start-generation.test.ts
  • scratch/bugfix-verification.json

Boundary notes:

  • Stays in src/engine; no React, Tauri, shared API, storage schema, dependency, or release metadata changes.

Pressure points touched:

  • Regenerate save path and context-injection normalization inside engine generation.

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 proof: pnpm exec vitest run src\engine\generation\start-generation.test.ts --reporter=json --outputFile=scratch\issue-2170-before.json failed before the fix with the legacy prose-guardian row missing.
  • Codex proof: pnpm exec vitest run src\engine\generation\start-generation.test.ts --reporter=json --outputFile=scratch\issue-2170-after.json passed after the fix.
  • Codex proof: pnpm exec vitest run src\engine\generation\start-generation.test.ts --reporter=json --outputFile=scratch\issue-2170-after-review.json passed after the review follow-up covering direct target lookup fallback.
  • Codex proof: pnpm exec vitest run src\engine\generation\start-generation.test.ts --reporter=json --outputFile=scratch\issue-2170-after-conflict-resolution.json passed after resolving upstream/refactor conflicts.
  • Codex proof: pnpm exec vitest run src\engine\generation\active-lorebook-scanner.test.ts passed after merging upstream/refactor.
  • Codex proof: node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed.
  • Codex proof: pnpm typecheck passed.
  • Codex proof: pnpm check passed.
  • Manual verification needed: none for the core claim; this is non-UI engine normalization logic.

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:

  • Compatibility bugfix only; no new user-facing feature or workflow.

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 bug is pure engine normalization behavior; proof is captured in Vitest output and scratch/bugfix-verification.json.

🔄 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/2246 **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-2170-context-injection-strings` --- ### 📝 Commits (4) - [`7629fdd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7629fdd48c9634bb7b4154e80cf5c387b58bc0b3) Fix legacy context injection normalization - [`b284201`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b2842013a4155e5b0e5db9e726ba78002be0d91f) Record PR verification metadata - [`a19332c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a19332cd826cdf33248dd8f3e6c4b62896af230f) Harden regenerate context injection merge - [`5d04b97`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5d04b979caadce76ee10331d0a778d451fd3335e) Merge upstream refactor into issue 2170 fix ### 📊 Changes **3 files changed** (+198 additions, -57 deletions) <details> <summary>View changed files</summary> 📝 `scratch/bugfix-verification.json` (+56 -49) 📝 `src/engine/generation/start-generation.test.ts` (+118 -8) 📝 `src/engine/generation/start-generation.ts` (+24 -0) </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 #2170 ## Why this change - Legacy persisted `extra.contextInjections` can contain bare strings. The refactor engine path dropped those rows during regenerate/retry merges, so legacy prose-guardian guidance could silently disappear. ## What changed - Normalize string context-injection entries as `{ agentType: "prose-guardian", text }` in the engine generation normalizer. - Merge regenerate agent-injection updates against the target message's existing `extra`, so legacy/current cached rows survive when a regenerated message receives new agent output. - Added a focused regression test covering legacy string rows, existing object rows, and blank-string skip behavior. ## Refactor impact Primary owner: - engine generation Impact areas reviewed: - `src/engine/generation/start-generation.ts` - `src/engine/generation/start-generation.test.ts` - `scratch/bugfix-verification.json` Boundary notes: - Stays in `src/engine`; no React, Tauri, shared API, storage schema, dependency, or release metadata changes. Pressure points touched: - Regenerate save path and context-injection normalization inside engine generation. ## 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 proof: `pnpm exec vitest run src\engine\generation\start-generation.test.ts --reporter=json --outputFile=scratch\issue-2170-before.json` failed before the fix with the legacy prose-guardian row missing. - Codex proof: `pnpm exec vitest run src\engine\generation\start-generation.test.ts --reporter=json --outputFile=scratch\issue-2170-after.json` passed after the fix. - Codex proof: `pnpm exec vitest run src\engine\generation\start-generation.test.ts --reporter=json --outputFile=scratch\issue-2170-after-review.json` passed after the review follow-up covering direct target lookup fallback. - Codex proof: `pnpm exec vitest run src\engine\generation\start-generation.test.ts --reporter=json --outputFile=scratch\issue-2170-after-conflict-resolution.json` passed after resolving upstream/refactor conflicts. - Codex proof: `pnpm exec vitest run src\engine\generation\active-lorebook-scanner.test.ts` passed after merging upstream/refactor. - Codex proof: `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed. - Codex proof: `pnpm typecheck` passed. - Codex proof: `pnpm check` passed. - Manual verification needed: none for the core claim; this is non-UI engine normalization logic. ## 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: - Compatibility bugfix only; no new user-facing feature or workflow. ## 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 bug is pure engine normalization behavior; proof is captured in Vitest output and `scratch/bugfix-verification.json`. --- <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:55 +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#5507
No description provided.