[PR #1386] [MERGED] Fix conditional prompt macro parity #5055

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1386
Author: @Xelvanis
Created: 5/27/2026
Status: ✅ Merged
Merged: 5/27/2026
Merged by: @Xelvanis

Base: refactor ← Head: fix/conditional-prompt-macros


📝 Commits (3)

  • 436527e Fix conditional prompt macro parity
  • 066313a Merge origin/refactor into conditional macro fix
  • e58da8a Address conditional macro review findings

📊 Changes

2 files changed (+384 additions, -4 deletions)

View changed files

📝 src/engine/shared/macros/macro-engine.test.ts (+132 -1)
📝 src/engine/shared/macros/macro-engine.ts (+252 -3)

📄 Description

Linked issue

Closes #1326

Why this change

  • The refactor macro engine regressed from v1.6.1 by dropping conditional prompt block support, so prompt authors could not use {{#if ...}}...{{else}}...{{/if}} parity behavior.

What changed

  • Added conditional prompt block resolution for truthy checks, ==, !=, =, is, is not, contains, includes, and negative contains/includes forms.
  • Added straight and typographic quote handling, nested conditional block support, nested macro operands in condition expressions, and selected-branch-only macro side effects.
  • Preserved malformed conditional openers while continuing to resolve later valid blocks.
  • Evaluated character conditionals per profile inside grouped character bracket expansion.
  • Addressed review findings by preserving caller timeZone in per-character macro contexts and making unset bare conditional identifiers evaluate falsy.
  • Added focused macro engine tests covering normal, nested, malformed, timezone, missing-variable, and negative-control parser behavior.

Refactor impact

Primary owner:

  • src/engine/shared/macros

Impact areas reviewed:

  • Prompt macro resolution used by generation and prompt assembly.
  • Character-scoped group prompt expansion.
  • Variable side effects inside selected conditional branches.
  • Malformed conditional and unknown hash-macro parser failure paths.
  • Caller timezone propagation into grouped character conditional operands.

Boundary notes:

  • Engine-only deterministic macro behavior.
  • No React, Zustand, shared API, Tauri/Rust, storage, provider, or remote-runtime boundary touched by the conditional macro fix.

Pressure points touched:

  • Shared macro engine only.
  • No ModeSurface, GameSurface, shared mode UI, Tauri command registration, or import modules touched by the conditional macro fix.

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

Agent-run validation after addressing CodeRabbit comments:

  • pnpm vitest run src/engine/shared/macros/macro-engine.test.ts --pool threads --maxWorkers 1 --no-file-parallelism passed: 1 file, 15 tests.
  • pnpm vitest run src/engine/generation/prompt-assembly.test.ts --pool threads --maxWorkers 1 --no-file-parallelism passed: 1 file, 13 tests.
  • pnpm vitest run --pool threads --maxWorkers 1 --no-file-parallelism passed: 21 files, 115 tests.
  • pnpm typecheck passed.
  • pnpm check:architecture passed.
  • pnpm build passed. Vite emitted existing chunk/dynamic-import warnings, but exited successfully.
  • git diff --check passed; Git reported CRLF normalization warnings only.

Not run:

  • pnpm check, Rust checks, browser/Tauri manual QA, Playwright, and remote-runtime smoke. This patch is engine-only macro parsing with no Rust, UI, or remote-runtime boundary changes.

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

  • Active refactor branch has no CHANGELOG.md; no changelog entry was added.

  • No developer docs change was made. The in-code supported macro catalog now lists conditional blocks.

UI evidence

N/A; engine-only macro parser behavior.


🔄 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/1386 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/27/2026 **Status:** ✅ Merged **Merged:** 5/27/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `fix/conditional-prompt-macros` --- ### 📝 Commits (3) - [`436527e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/436527e904449d1b7e2984a8bf0e3b4eb08fffe7) Fix conditional prompt macro parity - [`066313a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/066313a914c8f05740cfe78dffc61942aa463a5c) Merge origin/refactor into conditional macro fix - [`e58da8a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e58da8a1631148429e1ac252cf855eb00392b0b7) Address conditional macro review findings ### 📊 Changes **2 files changed** (+384 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/shared/macros/macro-engine.test.ts` (+132 -1) 📝 `src/engine/shared/macros/macro-engine.ts` (+252 -3) </details> ### 📄 Description ## Linked issue Closes #1326 ## Why this change - The refactor macro engine regressed from v1.6.1 by dropping conditional prompt block support, so prompt authors could not use `{{#if ...}}...{{else}}...{{/if}}` parity behavior. ## What changed - Added conditional prompt block resolution for truthy checks, `==`, `!=`, `=`, `is`, `is not`, `contains`, `includes`, and negative contains/includes forms. - Added straight and typographic quote handling, nested conditional block support, nested macro operands in condition expressions, and selected-branch-only macro side effects. - Preserved malformed conditional openers while continuing to resolve later valid blocks. - Evaluated character conditionals per profile inside grouped character bracket expansion. - Addressed review findings by preserving caller `timeZone` in per-character macro contexts and making unset bare conditional identifiers evaluate falsy. - Added focused macro engine tests covering normal, nested, malformed, timezone, missing-variable, and negative-control parser behavior. ## Refactor impact Primary owner: - `src/engine/shared/macros` Impact areas reviewed: - Prompt macro resolution used by generation and prompt assembly. - Character-scoped group prompt expansion. - Variable side effects inside selected conditional branches. - Malformed conditional and unknown hash-macro parser failure paths. - Caller timezone propagation into grouped character conditional operands. Boundary notes: - Engine-only deterministic macro behavior. - No React, Zustand, shared API, Tauri/Rust, storage, provider, or remote-runtime boundary touched by the conditional macro fix. Pressure points touched: - Shared macro engine only. - No ModeSurface, GameSurface, shared mode UI, Tauri command registration, or import modules touched by the conditional macro fix. ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> - [ ] `pnpm check` passes locally - [x] `pnpm typecheck` passes locally - [x] `pnpm build` passes locally - [x] `pnpm check:architecture` passes locally - [x] `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 <!-- Describe exactly what you tested in a real browser/app/runtime, step by step. If an AI agent filled this out, verify it yourself before ticking boxes. --> Agent-run validation after addressing CodeRabbit comments: - `pnpm vitest run src/engine/shared/macros/macro-engine.test.ts --pool threads --maxWorkers 1 --no-file-parallelism` passed: 1 file, 15 tests. - `pnpm vitest run src/engine/generation/prompt-assembly.test.ts --pool threads --maxWorkers 1 --no-file-parallelism` passed: 1 file, 13 tests. - `pnpm vitest run --pool threads --maxWorkers 1 --no-file-parallelism` passed: 21 files, 115 tests. - `pnpm typecheck` passed. - `pnpm check:architecture` passed. - `pnpm build` passed. Vite emitted existing chunk/dynamic-import warnings, but exited successfully. - `git diff --check` passed; Git reported CRLF normalization warnings only. Not run: - `pnpm check`, Rust checks, browser/Tauri manual QA, Playwright, and remote-runtime smoke. This patch is engine-only macro parsing with no Rust, UI, or remote-runtime boundary changes. ## Docs and release impact - [x] 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 - Active `refactor` branch has no `CHANGELOG.md`; no changelog entry was added. - No developer docs change was made. The in-code supported macro catalog now lists conditional blocks. ## UI evidence <!-- Add before/after screenshots or recordings for visible UI changes. --> N/A; engine-only macro parser behavior. --- <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:49 +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#5055
No description provided.