[GH-ISSUE #2266] [Issue]: 08-PRESET-RUNTIME-choice-variable-selection drops choice sanitizer and nested macro resolution #1107

Closed
opened 2026-10-21 05:26:48 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2266

Originally assigned to: @Xelvanis on GitHub.

Summary

08-PRESET-RUNTIME-choice-variable-selection: the refactor prompt assembly path accepts stale or invalid choice-variable values from preset defaults or per-chat choices, and it does not resolve macros inside selected option values before substituting {{variableName}}.

Linked parity tracker: #2259.

Expected behavior

Legacy choice-variable behavior should be preserved:

  • Saved preset defaults and per-chat choices are sanitized against the choice block's current option values.
  • Missing or invalid selections fall back to the first option where one exists.
  • Single-select and multi-select choices resolve through the same runtime sanitizer.
  • Multi-select choices either join selected values with the configured separator or pick one selected value at random when random-pick is enabled.
  • Macros inside selected option values, such as {{user}}, are resolved before prompt sections consume the choice variable through {{variableName}}.

Actual behavior

The refactor UI type-normalizes choices, but it does not validate existing/default selections against the choice block's option values. Runtime prompt assembly converts saved choice values directly into prompt variables, joins arrays, or random-picks array entries without checking that each value is still a valid option. It also passes selected choice values into the macro context without first resolving macros inside those values, so a choice value containing {{user}} can remain unresolved when {{variableName}} is expanded.

Steps to reproduce

  1. On refactor, create or import a prompt preset with a choice variable whose option value contains a macro, for example POV: "{{user}} watches from above".
  2. Save a default or per-chat presetChoices value for that variable, then change the choice block options so the saved value is stale or invalid.
  3. Generate with that preset selected and inspect the assembled prompt or prompt variables.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor
  • Run mode: not runtime-tested; static parity trace
  • OS + version: not runtime-tested
  • Node + pnpm versions: not runtime-tested
  • Rust version, if relevant: not relevant
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: prompt assembly before provider call

Logs, screenshots, or video

Static proof from parityscan Batch 10:

  • Refactor UI reads per-chat metadata.presetChoices and opens ChoiceSelectionModal for assigned prompt-variable presets: src/features/catalog/presets/components/PresetsPanel.tsx:31, src/features/catalog/presets/components/PresetsPanel.tsx:73, src/features/catalog/presets/components/PresetsPanel.tsx:425.
  • Refactor selection modal derives existing/default/first-option selections, but normalizeChoiceSelections only type-filters values and does not validate them against options: src/features/catalog/presets/components/ChoiceSelectionModal.tsx:95, src/features/catalog/presets/lib/choice-selections.ts:7.
  • Refactor runtime converts raw preset.defaultChoices and chat presetChoices into prompt variables, with array join/random-pick support but no option-value sanitizer or first-option runtime fallback for invalid values: src/engine/generation/prompt-assembly.ts:249, src/engine/generation/prompt-assembly.ts:889.
  • Refactor macro context receives those variables directly, and catch-all {{name}} replacement returns the stored variable value without recursively resolving macros inside it: src/engine/generation/prompt-assembly.ts:2862, src/engine/shared/macros/macro-engine.ts:902.
  • Legacy UI sanitized existing/default selections against valid option values and fell back to the first option: main:packages/client/src/components/presets/ChoiceSelectionModal.tsx:38, main:packages/client/src/components/presets/ChoiceSelectionModal.tsx:103.
  • Legacy server prompt assembly sanitized selected values against parsed options, handled single/multi/random/separator/fallback, and then resolved macros inside variableValues: main:packages/server/src/services/prompt/assembler.ts:56, main:packages/server/src/services/prompt/assembler.ts:228, main:packages/server/src/services/prompt/assembler.ts:272.

Regression notes

Legacy main preserves the sanitizer, first-option fallback, multi-select/random/separator handling, and macro-inside-choice-value resolution. Current refactor preserves the broad UI/runtime path but drops the sanitizer/fallback and nested macro resolution pieces.

Acceptance criteria:

  • 08-PRESET-RUNTIME-choice-variable-selection validates preset default choices and per-chat choices against the selected preset's current choice block option values before injecting prompt variables.
  • Invalid single-select values fall back to the first option when one exists.
  • Invalid multi-select entries are removed; an empty or fully invalid selection follows the legacy fallback behavior.
  • Multi-select random-pick and separator joins continue to work after sanitization.
  • Macros inside selected choice values are resolved before prompt sections consume the variable through {{variableName}}.
  • Add focused proof for stale invalid choices and a choice value containing a macro.

Additional context

Surface ID: 08-PRESET-RUNTIME-choice-variable-selection.

Batch 10 result: confirmed parity gap, static trace only. Do not rebatch #2259; update that tracker row when this is fixed or explicitly de-scoped.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Jun 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2266 Originally assigned to: @Xelvanis on GitHub. ## Summary `08-PRESET-RUNTIME-choice-variable-selection`: the refactor prompt assembly path accepts stale or invalid choice-variable values from preset defaults or per-chat choices, and it does not resolve macros inside selected option values before substituting `{{variableName}}`. Linked parity tracker: #2259. ## Expected behavior Legacy choice-variable behavior should be preserved: - Saved preset defaults and per-chat choices are sanitized against the choice block's current option values. - Missing or invalid selections fall back to the first option where one exists. - Single-select and multi-select choices resolve through the same runtime sanitizer. - Multi-select choices either join selected values with the configured separator or pick one selected value at random when random-pick is enabled. - Macros inside selected option values, such as `{{user}}`, are resolved before prompt sections consume the choice variable through `{{variableName}}`. ## Actual behavior The refactor UI type-normalizes choices, but it does not validate existing/default selections against the choice block's option values. Runtime prompt assembly converts saved choice values directly into prompt variables, joins arrays, or random-picks array entries without checking that each value is still a valid option. It also passes selected choice values into the macro context without first resolving macros inside those values, so a choice value containing `{{user}}` can remain unresolved when `{{variableName}}` is expanded. ## Steps to reproduce 1. On `refactor`, create or import a prompt preset with a choice variable whose option value contains a macro, for example `POV: "{{user}} watches from above"`. 2. Save a default or per-chat `presetChoices` value for that variable, then change the choice block options so the saved value is stale or invalid. 3. Generate with that preset selected and inspect the assembled prompt or prompt variables. ## Impact area <!-- Check the areas you think are relevant. Leave uncertain items unchecked. --> - [ ] App shell, navigation, startup, or providers - [x] Catalog resources - [ ] Chat mode - [x] Roleplay mode - [x] Game mode - [x] Shared mode UI - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [x] React-free engine behavior, contracts, agents, or capability ports - [ ] Shared API wrapper or remote runtime routing - [ ] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: `refactor` - Run mode: not runtime-tested; static parity trace - OS + version: not runtime-tested - Node + pnpm versions: not runtime-tested - Rust version, if relevant: not relevant - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: prompt assembly before provider call ## Logs, screenshots, or video Static proof from parityscan Batch 10: - Refactor UI reads per-chat `metadata.presetChoices` and opens `ChoiceSelectionModal` for assigned prompt-variable presets: `src/features/catalog/presets/components/PresetsPanel.tsx:31`, `src/features/catalog/presets/components/PresetsPanel.tsx:73`, `src/features/catalog/presets/components/PresetsPanel.tsx:425`. - Refactor selection modal derives existing/default/first-option selections, but `normalizeChoiceSelections` only type-filters values and does not validate them against options: `src/features/catalog/presets/components/ChoiceSelectionModal.tsx:95`, `src/features/catalog/presets/lib/choice-selections.ts:7`. - Refactor runtime converts raw `preset.defaultChoices` and chat `presetChoices` into prompt variables, with array join/random-pick support but no option-value sanitizer or first-option runtime fallback for invalid values: `src/engine/generation/prompt-assembly.ts:249`, `src/engine/generation/prompt-assembly.ts:889`. - Refactor macro context receives those variables directly, and catch-all `{{name}}` replacement returns the stored variable value without recursively resolving macros inside it: `src/engine/generation/prompt-assembly.ts:2862`, `src/engine/shared/macros/macro-engine.ts:902`. - Legacy UI sanitized existing/default selections against valid option values and fell back to the first option: `main:packages/client/src/components/presets/ChoiceSelectionModal.tsx:38`, `main:packages/client/src/components/presets/ChoiceSelectionModal.tsx:103`. - Legacy server prompt assembly sanitized selected values against parsed options, handled single/multi/random/separator/fallback, and then resolved macros inside `variableValues`: `main:packages/server/src/services/prompt/assembler.ts:56`, `main:packages/server/src/services/prompt/assembler.ts:228`, `main:packages/server/src/services/prompt/assembler.ts:272`. ## Regression notes Legacy `main` preserves the sanitizer, first-option fallback, multi-select/random/separator handling, and macro-inside-choice-value resolution. Current `refactor` preserves the broad UI/runtime path but drops the sanitizer/fallback and nested macro resolution pieces. Acceptance criteria: - `08-PRESET-RUNTIME-choice-variable-selection` validates preset default choices and per-chat choices against the selected preset's current choice block option values before injecting prompt variables. - Invalid single-select values fall back to the first option when one exists. - Invalid multi-select entries are removed; an empty or fully invalid selection follows the legacy fallback behavior. - Multi-select random-pick and separator joins continue to work after sanitization. - Macros inside selected choice values are resolved before prompt sections consume the variable through `{{variableName}}`. - Add focused proof for stale invalid choices and a choice value containing a macro. ## Additional context Surface ID: `08-PRESET-RUNTIME-choice-variable-selection`. Batch 10 result: confirmed parity gap, static trace only. Do not rebatch #2259; update that tracker row when this is fixed or explicitly de-scoped. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:26:48 +07:00
  • closed this issue
  • added the
    bug
    label
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#1107
No description provided.