[PR #1674] [MERGED] Fix Prompt Reviewer JSON handling #5202

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/1561-prompt-reviewer-json


📝 Commits (2)

  • 5e36c1d Fix prompt reviewer JSON handling
  • 7e4ead4 Reject degenerate prompt review JSON

📊 Changes

2 files changed (+127 additions, -3 deletions)

View changed files

➕ src/engine/generation/prompt-reviewer.test.ts (+106 -0)
📝 src/engine/generation/prompt-reviewer.ts (+21 -3)

📄 Description

Linked issue

Closes #1561

Why this change

  • Prompt Reviewer output is consumed as JSON, but the engine was only asking for JSON in prose and emitted the raw provider response as a successful review.
  • GPT 5.5 can return malformed JSON for that path, leaving the preset editor with an invalid review payload instead of a clear contract failure.

What changed

  • reviewPromptPreset now sends parameters.responseFormat = "json_object" through the existing LLM gateway request.
  • Prompt Reviewer responses are parsed before success; valid compact JSON objects are emitted as normalized pretty JSON, and malformed or degenerate JSON emits a clear error event without a done event.
  • Added focused unit coverage for JSON-mode request shape, valid JSON normalization, malformed-response failure, non-object JSON failure, and missing preset behavior.

Refactor impact

Primary owner:

  • engine generation

Impact areas reviewed:

  • Preset editor AI Review event contract
  • Existing LLM request parameter plumbing for responseFormat
  • Prompt Reviewer missing-preset behavior

Boundary notes:

  • Product behavior stays in src/engine; no React, shared API, Rust transport, storage, schema, dependency, or UI layout changes.
  • PromptReviewEvent shape is unchanged, and the existing ReviewTab error path remains the consumer surface.
  • This intentionally uses existing JSON-mode plumbing rather than adding json_schema structured outputs.

Pressure points touched:

  • None.

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 test src/engine/generation/prompt-reviewer.test.ts: passed, 1 file and 4 tests.
  • Codex ran pnpm typecheck: passed.
  • Codex ran pnpm check: passed, including line endings, architecture, frontend/typecheck, Rust check, and docs.
  • Codex ran Bunny on the current diff before opening this PR: pass.
  • Codex ran node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json: passed.
  • Manual limitation: live GPT 5.5 provider verification requires real provider credentials and was not run. The local proof covers the request shape and malformed-response handling.

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-level contract fix with focused unit coverage; no UI layout change.


🔄 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/1674 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/30/2026 **Status:** ✅ Merged **Merged:** 5/30/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/1561-prompt-reviewer-json` --- ### 📝 Commits (2) - [`5e36c1d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5e36c1d2e6d3937531ca0ebb1e3a2c2d81852445) Fix prompt reviewer JSON handling - [`7e4ead4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7e4ead4adb0b36dbbc98f29c272b7108da7729ef) Reject degenerate prompt review JSON ### 📊 Changes **2 files changed** (+127 additions, -3 deletions) <details> <summary>View changed files</summary> ➕ `src/engine/generation/prompt-reviewer.test.ts` (+106 -0) 📝 `src/engine/generation/prompt-reviewer.ts` (+21 -3) </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 #1561 ## Why this change - Prompt Reviewer output is consumed as JSON, but the engine was only asking for JSON in prose and emitted the raw provider response as a successful review. - GPT 5.5 can return malformed JSON for that path, leaving the preset editor with an invalid review payload instead of a clear contract failure. ## What changed - `reviewPromptPreset` now sends `parameters.responseFormat = "json_object"` through the existing LLM gateway request. - Prompt Reviewer responses are parsed before success; valid compact JSON objects are emitted as normalized pretty JSON, and malformed or degenerate JSON emits a clear `error` event without a `done` event. - Added focused unit coverage for JSON-mode request shape, valid JSON normalization, malformed-response failure, non-object JSON failure, and missing preset behavior. ## Refactor impact Primary owner: - engine generation Impact areas reviewed: - Preset editor AI Review event contract - Existing LLM request parameter plumbing for `responseFormat` - Prompt Reviewer missing-preset behavior Boundary notes: - Product behavior stays in `src/engine`; no React, shared API, Rust transport, storage, schema, dependency, or UI layout changes. - `PromptReviewEvent` shape is unchanged, and the existing ReviewTab error path remains the consumer surface. - This intentionally uses existing JSON-mode plumbing rather than adding `json_schema` structured outputs. Pressure points touched: - None. ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> - [ ] `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 test src/engine/generation/prompt-reviewer.test.ts`: passed, 1 file and 4 tests. - Codex ran `pnpm typecheck`: passed. - Codex ran `pnpm check`: passed, including line endings, architecture, frontend/typecheck, Rust check, and docs. - Codex ran Bunny on the current diff before opening this PR: pass. - Codex ran `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json`: passed. - Manual limitation: live GPT 5.5 provider verification requires real provider credentials and was not run. The local proof covers the request shape and malformed-response handling. ## 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-level contract fix with focused unit coverage; no UI layout change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:14:11 +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#5202
No description provided.