mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #8091] [MERGED] fix(mari): refuse sections in preset.update so the section order survives #8094
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#8094
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8091
Author: @ylli-selmani
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @ylli-selmani
Base:
staging← Head:fix/mari-preset-update-sections📝 Commits (2)
32d290dfix(mari): refuse sections in preset.update so the order survivesfc26ae1fix(mari): check the section_order alias for quoted ids📊 Changes
3 files changed (+239 additions, -1 deletions)
View changed files
📝
packages/server/src/assets/mari-skills/presets.md(+1 -1)📝
packages/server/src/services/mari-db/mari-db.service.ts(+60 -0)➕
scripts/regressions/mari/preset-update-sections.regression.ts(+178 -0)📄 Description
Linked issue
No issue yet: a user hit this live with Professor Mari. An issue should be opened and linked before merge.
Why this change
preset.updateanddata.sections: [<that section>].normalizePromptPresetChildInsertsrebuildssectionOrderfrom whatever sections are sent, so the preset was left with a one-section order. Every other section dropped out of the prompt while its row survived, so the editor still listed them and nothing looked wrong until the replies changed."\"YZuq…\"", a JSON-encoded id with literal quotes inside. Ids like that never match a real section, so the path wrote a new row instead of editing the existing one.library_folders.itemIds. #7977 added this cleanup to the HTTP routes and a startup prune; Mari's delete path didn't do it.What changed
preset.updaterefuses sections (mari-db.service.ts)sections/promptSections(top-level or insidedata/patch) are refused before anything is planned. The refusal followstool-error.ts: what was refused and what arrived, that nothing was changed, and the exactpreset.updateSection/preset.addSectioncalls to make instead. A completesectionOrderstill reorders.preset.createkeeps takingsections: there's no existing order to lose when the preset is new.Quoted section ids are refused
preset.createandpreset.updaterefuse a section id (insectionsorsectionOrder) that contains"or', saying nothing was changed and to send the id exactly aspreset.sectionsreturns it.Library folders are pruned on Mari's deletes
planDeleteadds anupdateof eachlibrary_foldersrow that lists a deleted preset (scopepresets) or lorebook (scopelorebooks). It's part of the same plan, so the review card shows it and Restore puts the id back. I used plan changes instead of #7977'sremoveItemReferences, because a direct write would happen outside Mari's journal and survive a Restore.mari-db.service.tstouchedlibrary_folders.itemIds. The fix covers both scopes, since it's the same few lines.Handbook (
mari-skills/presets.md)preset.update(with the completesectionOrder) now sayspreset.updatetakes none and namesaddSection/updateSection/deleteSection.Regression (
scripts/regressions/mari/preset-update-sections.regression.ts)apply: true) and asserts the refusal, the unchanged three-section order, no new row and no review card. Also covers top-levelpromptSections, a quoted id insectionOrderand onpreset.create, that a completesectionOrderstill reorders, and that a raw preset/lorebook delete prunes only its own scope's folder and that Restore brings the id back.stagingwithout the fix (preset.update refuses sections).Local CodeRabbit (two runs, 5 findings)
section_orderalias thatnormalizePromptPresetActionDataalso reads. Also fixed: the handbook said to reorder with "every existing id", which would pull sections the user had left out of the order back in. It now says to rearrange thesectionOrderfrompreset.get.planTransformtoo. A transform is a raw script that can writelibrary_foldersitself, so a second planned update of the same row could conflict, and #7977's startup prune heals what a transform leaves.apply: false) lorebook deletes. No entry inCASCADEShaslorebooksorprompt_presetsas its child, so that case can't happen.sectionOrderthat drops ids from the current order. Leaving a section out of the order is a documented way to keep it from being sent, so refusing it changes behavior beyond this fix. Listed as a follow-up.Not changed, follow-up: the permanent prompt in
workspace-agent.service.tsstill says "preset.updatewithdata.sectionsreplacessectionOrderunless you send the complete order". That file is being edited by the output-limit PR, so I left it alone. The refusal now points Mari at the right action anyway. Also,preset.updatewithgroupsrebuildsgroupOrderthe same way.groupOrderonly drives the panel listing (not the prompt), so it isn't part of this fix. AsectionOrderthat leaves ids out still drops those sections by design; whetherpreset.updateshould refuse a partial order is a separate decision.Validation
pnpm checkpasses locallyCONTRIBUTING.mdAgent-run, for reference:
pnpm check,node ./scripts/run-regressions.mjs --filter scripts/regressions/mariand--filter scripts/regressions/professor-mari(results in the PR conversation).Manual verification notes
preset.updateSection(or recover to it after the refusal), and the preset editor should still list every section in its original order afterwards.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)Only Mari's bundled handbook (
packages/server/src/assets/mari-skills/presets.md) changed; nothing underdocs/.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.