[PR #1860] [MERGED] Fix greeting macro variable persistence #5319

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-1857-greeting-macro-vars


📝 Commits (1)

  • 2ebb855 Fix greeting macro variable persistence

📊 Changes

3 files changed (+260 additions, -4 deletions)

View changed files

📝 src/engine/generation/prompt-assembly.test.ts (+185 -2)
📝 src/engine/generation/prompt-assembly.ts (+72 -2)
📝 src/engine/generation/start-generation.ts (+3 -0)

📄 Description

Linked issue

Closes #1857

Why this change

  • Character greetings can set chat-scoped macro variables, but prompt assembly did not seed those greeting side effects before later character fields rendered.
  • A roleplay character whose greeting sets {{setvar::coat::{{random::...}}}} could send {{getvar::coat}} in appearance/personality as empty, or could re-roll instead of staying stable.

What changed

  • Prompt assembly now scans leading assistant greeting messages before the first user turn for macro variable side effects.
  • Real generation assemblies persist newly discovered greeting variables to top-level chat.promptVariables and chat.variableValues, while prompt preview remains non-persistent.
  • Existing persisted chat variables win over raw greeting macros, so already-started chats keep a stable selected value instead of re-rolling.
  • Added prompt-assembly regressions for first-use seeding, existing persisted variables, and repeated assemblies on the same chat object.

Refactor impact

Primary owner:

Engine generation / prompt assembly

Impact areas reviewed:

  • Roleplay prompt section rendering
  • Start generation prompt assembly calls
  • Prompt preview non-persistence boundary
  • Chat prompt variable compatibility between promptVariables and variableValues

Boundary notes:

  • Engine-only prompt assembly change plus generation call-site opt-in.
  • No React feature UI, shared API wrapper, Rust storage command, remote runtime route, schema, dependency, or version-file changes.

Pressure points touched:

  • startGeneration prompt assembly calls now opt into variable persistence for real generation.
  • assembleGenerationPrompt keeps prompt preview callers non-persistent by default.

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

  • Before proof: applied the new regression test to untouched upstream/refactor in C:\tmp\Marinara-Engine-issue-1857-before; pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts failed because the prompt contained Appearance: He is wearing . and left the raw greeting {{setvar}} in history.
  • After proof: pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts passed with 11 tests.
  • Baseline: pnpm check passed after the final diff.
  • Proof gate: node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed locally.
  • Bunny review: passed before opening this draft; it caught and the diff now covers the repeated-assembly random-stability case.

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 for existing roleplay prompt macro behavior; no new discoverable 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 is engine prompt assembly behavior with before/after command proof, not a visible UI layout or interaction 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/1860 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/1/2026 **Status:** ✅ Merged **Merged:** 6/1/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1857-greeting-macro-vars` --- ### 📝 Commits (1) - [`2ebb855`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2ebb8551b5553022ace353aae3fa062e2a3f5a5e) Fix greeting macro variable persistence ### 📊 Changes **3 files changed** (+260 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation/prompt-assembly.test.ts` (+185 -2) 📝 `src/engine/generation/prompt-assembly.ts` (+72 -2) 📝 `src/engine/generation/start-generation.ts` (+3 -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 #1857 ## Why this change - Character greetings can set chat-scoped macro variables, but prompt assembly did not seed those greeting side effects before later character fields rendered. - A roleplay character whose greeting sets `{{setvar::coat::{{random::...}}}}` could send `{{getvar::coat}}` in appearance/personality as empty, or could re-roll instead of staying stable. ## What changed - Prompt assembly now scans leading assistant greeting messages before the first user turn for macro variable side effects. - Real generation assemblies persist newly discovered greeting variables to top-level `chat.promptVariables` and `chat.variableValues`, while prompt preview remains non-persistent. - Existing persisted chat variables win over raw greeting macros, so already-started chats keep a stable selected value instead of re-rolling. - Added prompt-assembly regressions for first-use seeding, existing persisted variables, and repeated assemblies on the same chat object. ## Refactor impact Primary owner: Engine generation / prompt assembly Impact areas reviewed: - Roleplay prompt section rendering - Start generation prompt assembly calls - Prompt preview non-persistence boundary - Chat prompt variable compatibility between `promptVariables` and `variableValues` Boundary notes: - Engine-only prompt assembly change plus generation call-site opt-in. - No React feature UI, shared API wrapper, Rust storage command, remote runtime route, schema, dependency, or version-file changes. Pressure points touched: - `startGeneration` prompt assembly calls now opt into variable persistence for real generation. - `assembleGenerationPrompt` keeps prompt preview callers non-persistent by default. ## 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 - Before proof: applied the new regression test to untouched `upstream/refactor` in `C:\tmp\Marinara-Engine-issue-1857-before`; `pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts` failed because the prompt contained `Appearance: He is wearing .` and left the raw greeting `{{setvar}}` in history. - After proof: `pnpm exec vitest run src/engine/generation/prompt-assembly.test.ts` passed with 11 tests. - Baseline: `pnpm check` passed after the final diff. - Proof gate: `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed locally. - Bunny review: passed before opening this draft; it caught and the diff now covers the repeated-assembly random-stability case. ## 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 for existing roleplay prompt macro behavior; no new discoverable 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 is engine prompt assembly behavior with before/after command proof, not a visible UI layout or interaction 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:15:12 +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#5319
No description provided.