[PR #7764] [MERGED] fix(mari): deep-merge mari characters update --json patches #7916

Closed
opened 2026-10-24 04:08:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7764
Author: @ylli-selmani
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/17/2026
Merged by: @ylli-selmani

Base: staging ← Head: fix/mari-characters-update-deep-merge


📝 Commits (2)

  • 0bd2f19 fix(mari): deep-merge mari characters update --json patches
  • 75382f6 test(mari): seed tags before the array-replace check

📊 Changes

2 files changed (+92 additions, -1 deletions)

View changed files

📝 packages/server/src/services/mari-db/mari-db.service.ts (+1 -1)
➕ scripts/regressions/mari/characters-update-deep-merge.regression.ts (+91 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7761

Why this change

  • When Professor Mari edits a character with mari characters update <id> --json '...' and the patch touches anything under extensions (depth prompt, onboarding, ...), every other extension on the card was wiped: appearance, backstory, and the rest. The CLI merged the patch with a top-level spread, so extensions was replaced instead of merged. The app_data character.update path already deep-merges; only the CLI path didn't.
  • It also blocks #7760 (Mari writing interactive onboarding), which needs safe writes into extensions.

What changed

  • Mari's characters update --json edits now change only the keys in the patch. Other card extensions (appearance, backstory, depth prompt, onboarding) stay. Lists in a patch (like tags) still replace the whole list, same as app_data character.update.
  • New regression scripts/regressions/mari/characters-update-deep-merge.regression.ts drives the real MariDbService CLI against a temp file store. It fails on the old code ("a sibling extension (appearance) survives the patch") and passes with the fix.

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

Local results (agent-run): pnpm check exit 0. node scripts/run-regressions.mjs --filter regressions/mari: 31/32 passed. The new regression failed before the fix and passes after. The one failure, mari-appearance-pack.regression.mjs, is unrelated client sprite tooling: sharp can't find packages/client/public/sprites/mari/basic/pose-greet.webp (it resolves the path as /C:/... on Windows). Local CodeRabbit: 0 findings.

To verify by hand:

  • Manually verify: on a character with Appearance and Backstory filled, ask Professor Mari to run mari characters update <id> --json '{"extensions":{"depth_prompt":{"prompt":"x","depth":4,"role":"system"}}}' --apply, then open the character and confirm Appearance and Backstory are still there and the depth prompt is set.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Server-only change; no UI.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Character updates now preserve nested fields and other existing data that are not included in a JSON patch. Arrays explicitly included in a patch replace their stored values.
  • Tests
    • Added regression coverage for character creation and updates, verifying that unrelated nested and top-level data remain intact when only part of a character is updated. Also verifies that patched arrays replace their previous 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/7764 **Author:** [@ylli-selmani](https://github.com/ylli-selmani) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@ylli-selmani](https://github.com/ylli-selmani) **Base:** `staging` ← **Head:** `fix/mari-characters-update-deep-merge` --- ### 📝 Commits (2) - [`0bd2f19`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0bd2f19f8b4f31b3a7fe113d4f2fe5c45e1f17e4) fix(mari): deep-merge `mari characters update --json` patches - [`75382f6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/75382f66738b872a684eaf324202c3587174003e) test(mari): seed tags before the array-replace check ### 📊 Changes **2 files changed** (+92 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/mari-db/mari-db.service.ts` (+1 -1) ➕ `scripts/regressions/mari/characters-update-deep-merge.regression.ts` (+91 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7761 ## Why this change - When Professor Mari edits a character with `mari characters update <id> --json '...'` and the patch touches anything under `extensions` (depth prompt, onboarding, ...), every other extension on the card was wiped: appearance, backstory, and the rest. The CLI merged the patch with a top-level spread, so `extensions` was replaced instead of merged. The `app_data` `character.update` path already deep-merges; only the CLI path didn't. - It also blocks #7760 (Mari writing interactive onboarding), which needs safe writes into `extensions`. ## What changed - Mari's `characters update --json` edits now change only the keys in the patch. Other card extensions (appearance, backstory, depth prompt, onboarding) stay. Lists in a patch (like `tags`) still replace the whole list, same as `app_data` `character.update`. - New regression `scripts/regressions/mari/characters-update-deep-merge.regression.ts` drives the real `MariDbService` CLI against a temp file store. It fails on the old code ("a sibling extension (appearance) survives the patch") and passes with the fix. ## 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 Local results (agent-run): `pnpm check` exit 0. `node scripts/run-regressions.mjs --filter regressions/mari`: 31/32 passed. The new regression failed before the fix and passes after. The one failure, `mari-appearance-pack.regression.mjs`, is unrelated client sprite tooling: `sharp` can't find `packages/client/public/sprites/mari/basic/pose-greet.webp` (it resolves the path as `/C:/...` on Windows). Local CodeRabbit: 0 findings. To verify by hand: - Manually verify: on a character with Appearance and Backstory filled, ask Professor Mari to run `mari characters update <id> --json '{"extensions":{"depth_prompt":{"prompt":"x","depth":4,"role":"system"}}}' --apply`, then open the character and confirm Appearance and Backstory are still there and the depth prompt is set. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) Server-only change; no UI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Character updates now preserve nested fields and other existing data that are not included in a JSON patch. Arrays explicitly included in a patch replace their stored values. * **Tests** * Added regression coverage for character creation and updates, verifying that unrelated nested and top-level data remain intact when only part of a character is updated. Also verifies that patched arrays replace their previous 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-24 04:08:48 +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#7916
No description provided.