[PR #3031] [MERGED] [codex] Fix preset and prompt issue sweep #5790

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3031
Author: @SpicyMarinara
Created: 6/29/2026
Status: ✅ Merged
Merged: 6/29/2026
Merged by: @SpicyMarinara

Base: staging ← Head: codex/issue-sweep-3022-3030


📝 Commits (5)

  • c8042da Start issue sweep 3022-3030
  • fbc9822 Fix preset prompt issue sweep
  • bbc77fc Fix chat summary fallback placement
  • a3f6da2 Harden prompt block escaping
  • a48d849 Address CodeRabbit preset review fixes

📊 Changes

20 files changed (+753 additions, -129 deletions)

View changed files

📝 CHANGELOG.md (+3 -0)
📝 packages/client/src/components/chat/ChatRoleplaySurface.tsx (+8 -6)
📝 packages/client/src/components/chat/SummaryPopover.tsx (+3 -3)
📝 packages/client/src/components/panels/settings/PromptOverridesEditor.tsx (+11 -7)
📝 packages/client/src/components/presets/PresetEditor.tsx (+2 -6)
📝 packages/server/src/db/seed.ts (+191 -0)
📝 packages/server/src/routes/generate/dry-run-route.ts (+1 -6)
📝 packages/server/src/services/conversation/awareness.service.ts (+3 -2)
📝 packages/server/src/services/generation/character-prompt-context.ts (+5 -2)
📝 packages/server/src/services/generation/conversation-memory-context.ts (+2 -6)
📝 packages/server/src/services/generation/memory-recall-context.ts (+5 -1)
📝 packages/server/src/services/generation/scene-context-runtime.ts (+10 -8)
📝 packages/server/src/services/import/marinara.importer.ts (+19 -1)
📝 packages/server/src/services/prompt/assembler.ts (+74 -37)
📝 packages/server/src/services/prompt/format-engine.ts (+1 -1)
📝 packages/server/src/services/prompt/macro-context.ts (+6 -1)
📝 packages/server/src/services/prompt/marker-expander.ts (+72 -29)
➕ packages/server/src/services/prompt/prompt-escaping.ts (+15 -0)
📝 packages/server/src/services/storage/prompts.storage.ts (+23 -2)
📝 scripts/regressions/prompt.regression.ts (+299 -11)

📄 Description

Linked issue

Addresses #3022
Addresses #3023
Addresses #3024
Addresses #3025
Addresses #3026
Addresses #3027
Addresses #3028
Addresses #3029
Addresses #3030

Why this change

  • Prevent conversation-mode awareness filtering from deleting durable character memories.
  • Preserve preset author defaults and prompt structure across import, duplicate, grouping, dry-run, and preset-parameter edge cases.
  • Keep user edits to the bundled Marinara preset from being silently wiped after the seed snapshot baseline exists.
  • Prevent prompt override and preset-variable editor UI paths from corrupting saved templates/options when examples or local edits overlap.
  • Harden prompt XML/Markdown block assembly against imported/shared content that tries to forge closing tags or system-like prompt structure.

What changed

  • Removed the destructive write-back from conversation memory awareness filtering.
  • Preserved defaultChoices when importing or duplicating presets.
  • Kept Chat History markers out of group wrapping so message boundaries and contextKind: "history" survive.
  • Added read-path generation parameter validation/salvage for stored preset parameters.
  • Reused the canonical normalizeChatTopP in Dry Run so topP=0 matches real generation.
  • Made prompt override reverse-substitution skip ambiguous shared example values.
  • Made preset variable label edits and move up/down use the in-flight local options list.
  • Added a content snapshot hash for the bundled Marinara preset seed path and skip destructive refreshes when current preset content diverges from the stored baseline.
  • Added prompt leaf escaping for character/persona card fields, chat history, summaries, lorebook content, recalled memory, awareness snippets, scene metadata, post-history instructions, and agent-result text before engine-authored wrappers are applied.
  • Updated CHANGELOG.md for v2.0.7.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • git diff --check passed.
  • pnpm --filter @marinara-engine/server lint passed.
  • pnpm --filter @marinara-engine/client lint passed.
  • pnpm --filter @marinara-engine/shared build && pnpm --filter @marinara-engine/server build passed.
  • pnpm check passed.
  • pnpm regression:prompt passed with delimiter-injection regression coverage for recalled memory, awareness memories, identity fallback card text, scene context metadata, chat history, and Chat Summary placement.
  • Temp SQLite DB probe verified imported presets preserve defaultChoices, duplicated presets preserve matching defaultChoices, and a customized bundled preset section survives a forced seed refresh while the seed hash advances and a snapshot is recorded.
  • Production-path assembler/memory probe verified invalid preset temperature/topP fall back to defaults, valid maxTokens is preserved, grouped Chat History emits history messages instead of being group-wrapped, canonical topP normalization preserves 0, old memories are not surfaced in same-day awareness, today memories are surfaced, and memory storage is not pruned.
  • Manual browser verification not performed in this pass.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

  • Not captured; UI changes are editor state-handling fixes validated by lint/build.

Summary by CodeRabbit

  • New Features

    • Preset imports and duplicates now preserve default choice settings more reliably.
    • Preset updates now better protect customized content during bundled refreshes.
  • Bug Fixes

    • Improved preset parameter handling for invalid or partial values.
    • Fixed chat history grouping so it stays on the correct path.
    • Made memory pruning safer by keeping only today’s relevant memories without extra storage changes.
    • Dry runs now consistently retain topP=0.
    • Prompt template editing now avoids replacing ambiguous example values.

🔄 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/3031 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 6/29/2026 **Status:** ✅ Merged **Merged:** 6/29/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `codex/issue-sweep-3022-3030` --- ### 📝 Commits (5) - [`c8042da`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c8042da922f571839f0d6bfb0bc24d4f915c5d93) Start issue sweep 3022-3030 - [`fbc9822`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fbc9822a44d9f591007f1896d7e0fdb425b49761) Fix preset prompt issue sweep - [`bbc77fc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bbc77fc79ea4323e2a96b17bac86659a9db75edf) Fix chat summary fallback placement - [`a3f6da2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a3f6da2549d38a30a686695afa29755507e88fc9) Harden prompt block escaping - [`a48d849`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a48d849fd520bbe76fc4a1bbcb37c46a4b04341e) Address CodeRabbit preset review fixes ### 📊 Changes **20 files changed** (+753 additions, -129 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -0) 📝 `packages/client/src/components/chat/ChatRoleplaySurface.tsx` (+8 -6) 📝 `packages/client/src/components/chat/SummaryPopover.tsx` (+3 -3) 📝 `packages/client/src/components/panels/settings/PromptOverridesEditor.tsx` (+11 -7) 📝 `packages/client/src/components/presets/PresetEditor.tsx` (+2 -6) 📝 `packages/server/src/db/seed.ts` (+191 -0) 📝 `packages/server/src/routes/generate/dry-run-route.ts` (+1 -6) 📝 `packages/server/src/services/conversation/awareness.service.ts` (+3 -2) 📝 `packages/server/src/services/generation/character-prompt-context.ts` (+5 -2) 📝 `packages/server/src/services/generation/conversation-memory-context.ts` (+2 -6) 📝 `packages/server/src/services/generation/memory-recall-context.ts` (+5 -1) 📝 `packages/server/src/services/generation/scene-context-runtime.ts` (+10 -8) 📝 `packages/server/src/services/import/marinara.importer.ts` (+19 -1) 📝 `packages/server/src/services/prompt/assembler.ts` (+74 -37) 📝 `packages/server/src/services/prompt/format-engine.ts` (+1 -1) 📝 `packages/server/src/services/prompt/macro-context.ts` (+6 -1) 📝 `packages/server/src/services/prompt/marker-expander.ts` (+72 -29) ➕ `packages/server/src/services/prompt/prompt-escaping.ts` (+15 -0) 📝 `packages/server/src/services/storage/prompts.storage.ts` (+23 -2) 📝 `scripts/regressions/prompt.regression.ts` (+299 -11) </details> ### 📄 Description ## Linked issue Addresses #3022 Addresses #3023 Addresses #3024 Addresses #3025 Addresses #3026 Addresses #3027 Addresses #3028 Addresses #3029 Addresses #3030 ## Why this change - Prevent conversation-mode awareness filtering from deleting durable character memories. - Preserve preset author defaults and prompt structure across import, duplicate, grouping, dry-run, and preset-parameter edge cases. - Keep user edits to the bundled Marinara preset from being silently wiped after the seed snapshot baseline exists. - Prevent prompt override and preset-variable editor UI paths from corrupting saved templates/options when examples or local edits overlap. - Harden prompt XML/Markdown block assembly against imported/shared content that tries to forge closing tags or system-like prompt structure. ## What changed - Removed the destructive write-back from conversation memory awareness filtering. - Preserved `defaultChoices` when importing or duplicating presets. - Kept Chat History markers out of group wrapping so message boundaries and `contextKind: "history"` survive. - Added read-path generation parameter validation/salvage for stored preset parameters. - Reused the canonical `normalizeChatTopP` in Dry Run so `topP=0` matches real generation. - Made prompt override reverse-substitution skip ambiguous shared example values. - Made preset variable label edits and move up/down use the in-flight local options list. - Added a content snapshot hash for the bundled Marinara preset seed path and skip destructive refreshes when current preset content diverges from the stored baseline. - Added prompt leaf escaping for character/persona card fields, chat history, summaries, lorebook content, recalled memory, awareness snippets, scene metadata, post-history instructions, and agent-result text before engine-authored wrappers are applied. - Updated CHANGELOG.md for v2.0.7. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - `git diff --check` passed. - `pnpm --filter @marinara-engine/server lint` passed. - `pnpm --filter @marinara-engine/client lint` passed. - `pnpm --filter @marinara-engine/shared build && pnpm --filter @marinara-engine/server build` passed. - `pnpm check` passed. - `pnpm regression:prompt` passed with delimiter-injection regression coverage for recalled memory, awareness memories, identity fallback card text, scene context metadata, chat history, and Chat Summary placement. - Temp SQLite DB probe verified imported presets preserve `defaultChoices`, duplicated presets preserve matching `defaultChoices`, and a customized bundled preset section survives a forced seed refresh while the seed hash advances and a snapshot is recorded. - Production-path assembler/memory probe verified invalid preset temperature/topP fall back to defaults, valid maxTokens is preserved, grouped Chat History emits history messages instead of being group-wrapped, canonical topP normalization preserves `0`, old memories are not surfaced in same-day awareness, today memories are surfaced, and memory storage is not pruned. - Manual browser verification not performed in this pass. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) - Not captured; UI changes are editor state-handling fixes validated by lint/build. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Preset imports and duplicates now preserve default choice settings more reliably. * Preset updates now better protect customized content during bundled refreshes. * **Bug Fixes** * Improved preset parameter handling for invalid or partial values. * Fixed chat history grouping so it stays on the correct path. * Made memory pruning safer by keeping only today’s relevant memories without extra storage changes. * Dry runs now consistently retain `topP=0`. * Prompt template editing now avoids replacing ambiguous example values. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:19:32 +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#5790
No description provided.