mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6118] A Game turn that rolls dice can lose the move or world change it just narrated #3394
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#3394
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 @kolacheee on GitHub (Sep 13, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6118
Originally assigned to: @SpicyMarinara on GitHub.
When a Game-mode turn resolves a skill check or dice tag, the engine rewrites the whole narration in a second model call. Any command the first narration issued - moving the party to a new place on the map, or an Experience package command like granting an item or changing the weather - is thrown away at that point. The player reads a narration saying they walked into the crypt or picked up the key, but the location readout never changes and the item never appears, with no warning anywhere.
How to reproduce (try it yourself)
ChapelandCrypt, connect them, and setChapelas the starting location. Save and confirm the location readout saysChapel.I walk from the chapel into the crypt.One narration streams in and the readout flips toCrypt. This turn asked for no dice, so only one model request fires.Chapelagain (delete that turn, or start a fresh game from the same map).I walk into the crypt and search the sarcophagus.The arrival is stated by the player, so the game master is allowed to emit the movement command in its first draft, while the search is what draws the dice roll. Do not phrase it as "the door is stuck, I force it open" - the game master is told to describe an unresolved attempt and stop, so no movement command is written in the first place and there is nothing to lose.What you'll see: on the turns where the rewritten narration does not happen to restate the command, the narration says you are in the crypt and the location readout still says
Chapel. Nothing warns you, nothing is logged. Because the second call may restate the command on its own, some attempts look fine - expect to try this a few times.What should happen: the location should flip to
Crypt, exactly as it did on the control turn, unless the roll itself invalidated the move. A dice roll in the same turn must not be able to quietly delete a movement or an item grant.Same bug in the Experience-package flavour: on a game whose Experience package ships commands (inventory grants, quest updates, weather), phrase one message that both requires a check and should trigger one, e.g.
I pick the lock on the chest and take whatever is inside.The check resolves and the narration says you took the item; the world state often does not change. The same sentence with no check in it (I open the unlocked chest and take what is inside.) does change it.The rewrite only fires when the engine itself resolved a
[skill_check:]or[dice:]text tag. A turn whose dice came only from the built-in roll_dice tool leaves a fully filled-in tag, skips the rewrite, and keeps its commands. That is why the bug reads as flaky rather than broken.Where it is
packages/server/src/routes/generate.routes.tsat staging52799569c, in the streaming generate handler::7896-fullResponse = parsedSpatial.cleanContentremoves the[spatial_move:]text from the draft.:7930-fullResponse = verbScan.content(afterparseAndStripGmVerbCalls) removes every package command from the draft.:7960- the rewrite gateif (rolled.resolved || generalRolls.rolled) {.:7971- the assistant message handed to the rewrite call is that already-strippedfullResponse.:7974- the rewrite instruction:Include only commands still justified by these outcomes.:8042and:8045-assistantSpatialDirective = ... spatial.directiveandcollectedGmVerbCalls = [], both reassigned unconditionally from the rewritten text.:8346/:8356-executeCollectedGmVerbCalls(...)andmaterializeAssistantSpatialState({ ..., directive: assistantSpatialDirective }), the consumers that read whatever those two lines left behind.What's happening
The commands are pulled out of the draft before the rewrite prompt is built, so the second model call is shown a narration with its own commands deleted, and is then told to keep only the commands still justified. It still has the command grammar and the current map state from the ordinary game prompt, so it can write a command again from scratch - but it has no record of what the first draft decided. Whatever it does not restate is gone, because the two variables holding the first draft's results are overwritten unconditionally right after the rewrite, one of them emptied outright. There is no fallback, no log line, and no frame on the wire, so the state change simply never happens and nothing says so.
A scripted run against the real route with a matched pair of turns - the same first draft, differing only by one skill-check tag - showed the no-roll turn applying both the movement and the package command, and the rolling turn applying neither.
Suggested fix
Build the assistant message for the rewrite call from the pre-strip text, so the model can see the commands it is being asked to filter. That matches the instruction already in the prompt, and it lets the model legitimately drop a command the roll invalidated (you failed the check, so you did not get inside), which appears to be what the design wanted.
Then make the post-rewrite assignment conditional: replace the carried movement directive and package command list only when the rewritten text actually emitted its own. Carrying them forward is not sufficient on its own and should not be done alone - reinstating a movement decided before the die was rolled is the state-level version of the contradiction that issue #5961 was filed about, so the rewrite must keep the power to drop a command.
This needs a regression in the game dice lane pinning the matched pair: the same draft with and without a check, both applying the same movement and package command. All four existing dice regression suites pass against this today.
Context
Introduced by PR #5979 ("keep every roll and resolve text dice requests"), merged 2026-09-09, which closed issues #5956, #5959, #5960 and #5961 and added the post-roll rewrite. The package command surface it discards comes from the game-master write-back work in #5798. The PR body describes this as discarding "superseded package/movement commands", but the code discards them whether or not anything superseded them. Unreleased on staging - it landed after v2.4.4, so no released build is affected. Practical blast radius today is limited - the only package shipping game-master commands is Pixelforge, which is pre-alpha and whose two commands are set-until-set-again states that the next turn usually re-asserts - so the sharper edge is the map movement loss.
Found by an AI-assisted sweep of merged PR #5979 against its original issues, then re-verified against staging
52799569con 2026-09-13. Please verify before fixing.@SpicyMarinara commented on GitHub (Sep 13, 2026):
@SpicyMarinara is taking this report through the issue sweep in draft PR #6137, with Codex assisting. The affected current-code path has been checked; implementation and focused regression verification are in progress.
@SpicyMarinara commented on GitHub (Sep 13, 2026):
Fixed in #6137, now merged to staging (
e044997a2). Dice correction retains valid world commands from the original draft and applies only the corrected result.