mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2468] [Issue]: forkRoleplayScene drops three guards main enforces (upToMessageId validation, convert+limit rejection, chronological sort) #1211
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#1211
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?
Originally created by @Romuromylus on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2468
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Severity: Medium — correctness / data-loss regression.
forkRoleplayScenedropped three guards main enforces: it does not validateupToMessageId, does not rejectconvert+upToMessageId, and does not sort messages chronologically before slicing. The first silently clones the whole scene on a stale id; the second can permanently delete scene messages.Expected behavior
Mirror main's scene fork route: reject an
upToMessageIdthat is not in the scene (400), rejectconvertcombined withupToMessageId, and sort messages bycreatedAtbefore applying the cut.Actual behavior
upToMessageIdnever matches, sostopAfterThisis never true and the entire scene is copied — "clone from here" silently becomes "clone everything".convert+ a mid-sceneupToMessageIdcopies only a prefix and then deletes the whole source chat — every message after the cut is permanently lost. The contract docstring (scene.ts:124) even saysupToMessageIdis "Clone only", but the impl never enforces it.listChatMessagesin raw storage order with nocreatedAtsort, so if storage order ever diverges from chronological order the wrong prefix is copied.Steps to reproduce
forkRoleplayScenewith{ mode: "convert", upToMessageId: <mid-scene id> }→ only a prefix survives, the rest of the scene is deleted.Impact area
Environment
1fae2c42Logs, screenshots, or video
Static trace:
scene-service.ts:280-355,messagesForChatat:674-677, contract notescene.ts:124.Regression notes
Regression vs main.
packages/server/src/routes/scene.routes.tsguards all three: rejects an unknownupToMessageId("Message is not part of this scene", ~562), rejectsconvert+ limit ("Convert cannot be limited to a message", ~535), and sorts bycreatedAtbefore slicing (~556-560, with an explanatory comment). The refactor dropped all three.Additional context
Note (b) is a latent guard-drop: no shipped call site currently passes
convert+upToMessageIdtogether (the convert UI prop carries noupToMessageId), but the service signature accepts the combination, so it is a real data-loss hazard for any future caller. Fix: add the three guards at the top offorkRoleplaySceneand materialize+sortmessagesForChatonce before the loop.Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 6, 2026):
Fixed on refactor in
038b7220.forkRoleplayScene now rejects convert plus upToMessageId, validates the cutoff message, and processes messages in chronological order.
Verification: pnpm typecheck; pnpm build; pnpm check:architecture; cargo check --manifest-path src-tauri/Cargo.toml --workspace; focused Rust backup/profile tests; git diff --check; no .test.ts/.test.tsx files present.