[PR #2240] [MERGED] Fix character field macro scoping #5503

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-2162-character-field-macros


📝 Commits (2)

  • c03684f Fix character field macro scoping
  • 56a1740 Address nested character field macros

📊 Changes

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

View changed files

📝 src/engine/generation/prompt-assembly.test.ts (+73 -0)
📝 src/engine/generation/prompt-assembly.ts (+16 -3)

📄 Description

Linked issue

Closes #2162

Why this change

  • In multi-character roleplay prompts, character marker sections rendered all character fields raw and then resolved the whole assembled section with the global first-character macro context. A bare field macro such as {{personality}} inside Bob's card could therefore expand to Alice's personality.

What changed

  • Resolve character marker field values with the existing per-character macro context before the later global prompt-section macro pass.
  • Added a focused prompt assembly regression row that proves Bob's card-owned {{personality}}, nested {{scenario}}, and {{char}} resolve against Bob while an ordinary preset section {{char}} still resolves against the global first character.

Refactor impact

Primary owner:

Engine generation.

Impact areas reviewed:

  • Character prompt marker rendering in assembleGenerationPrompt.
  • Existing character depth-prompt macro scoping helper path.
  • Global preset-section macro resolution boundary.

Boundary notes:

  • Stays inside src/engine; no React, shared API, Tauri, storage, provider, or remote-runtime boundary changes.
  • No schema, dependency, version, import/export, or persisted-data changes.

Pressure points touched:

  • src/engine/generation/prompt-assembly.ts character marker rendering only.

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 before-fix repro: pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts -t "resolves character field macros" --reporter=verbose failed because Bob's rendered description contained Alice's personality.
  • Codex after-fix original repro: pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts -t "resolves character field macros" --reporter=verbose passed.
  • Codex adjacent check: pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts --reporter=verbose passed, including the nested field macro row added after Bunny's first review.
  • Codex lane check: pnpm typecheck passed.
  • Codex baseline: pnpm check passed.
  • Codex proof gate: node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed.
  • Bunny: initial nested-field finding was addressed in commit 56a17402; current-head Bunny review reports no actionable defects.
  • CodeRabbit: review command completed on the current head and the status context is success.
  • No manual UI verification needed for the core claim; this is React-free prompt assembly behavior.

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:

  • Bugfix only; no new user-discoverable feature, setting, mode, panel, import path, agent, media capability, or tool.

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 changed. The affected behavior is generated prompt text from React-free engine prompt assembly; proof is the before/after command output above.


🔄 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/2240 **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-2162-character-field-macros` --- ### 📝 Commits (2) - [`c03684f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c03684f4c4f61879d55f766912a5cc679eb431b6) Fix character field macro scoping - [`56a1740`](https://github.com/Pasta-Devs/Marinara-Engine/commit/56a17402ed02a12c41102cc138afb1faadcb38ea) Address nested character field macros ### 📊 Changes **2 files changed** (+89 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation/prompt-assembly.test.ts` (+73 -0) 📝 `src/engine/generation/prompt-assembly.ts` (+16 -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 <!-- Every user-facing PR should reference a feature request or issue report when practical. --> Closes #2162 ## Why this change <!-- What user problem, bug, refactor goal, or maintenance need does this solve? --> - In multi-character roleplay prompts, character marker sections rendered all character fields raw and then resolved the whole assembled section with the global first-character macro context. A bare field macro such as `{{personality}}` inside Bob's card could therefore expand to Alice's personality. ## What changed <!-- List the key changes in this PR. --> - Resolve character marker field values with the existing per-character macro context before the later global prompt-section macro pass. - Added a focused prompt assembly regression row that proves Bob's card-owned `{{personality}}`, nested `{{scenario}}`, and `{{char}}` resolve against Bob while an ordinary preset section `{{char}}` still resolves against the global first character. ## Refactor impact Primary owner: <!-- Examples: app shell, catalog, chat mode, roleplay mode, game mode, runtime generation, world-state, shared API, engine generation, Rust storage, imports, remote runtime. --> Engine generation. Impact areas reviewed: - Character prompt marker rendering in `assembleGenerationPrompt`. - Existing character depth-prompt macro scoping helper path. - Global preset-section macro resolution boundary. Boundary notes: <!-- Note engine/shared-api/feature/Rust/remote-runtime boundaries. Say "none" only if you checked. --> - Stays inside `src/engine`; no React, shared API, Tauri, storage, provider, or remote-runtime boundary changes. - No schema, dependency, version, import/export, or persisted-data changes. Pressure points touched: <!-- Mention ModeSurface, GameSurface, shared mode UI, src-tauri/src/lib.rs command registration, or import modules if touched. --> - `src/engine/generation/prompt-assembly.ts` character marker rendering only. ## 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 <!-- Describe exact commands and manual steps, including typecheck/build/docs/architecture/Rust/browser/remote-runtime checks when they apply. If an AI agent filled this out, verify it yourself before ticking boxes. --> - Codex before-fix repro: `pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts -t "resolves character field macros" --reporter=verbose` failed because Bob's rendered description contained Alice's personality. - Codex after-fix original repro: `pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts -t "resolves character field macros" --reporter=verbose` passed. - Codex adjacent check: `pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts --reporter=verbose` passed, including the nested field macro row added after Bunny's first review. - Codex lane check: `pnpm typecheck` passed. - Codex baseline: `pnpm check` passed. - Codex proof gate: `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed. - Bunny: initial nested-field finding was addressed in commit `56a17402`; current-head Bunny review reports no actionable defects. - CodeRabbit: review command completed on the current head and the status context is success. - No manual UI verification needed for the core claim; this is React-free prompt assembly behavior. ## 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: - Bugfix only; no new user-discoverable feature, setting, mode, panel, import path, agent, media capability, or tool. ## 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 <!-- Add before/after screenshots or recordings for visible UI changes. --> N/A: no visible UI changed. The affected behavior is generated prompt text from React-free engine prompt assembly; proof is the before/after command output above. --- <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:53 +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#5503
No description provided.