mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5076] Advancing game time or weather can silently wipe concurrent chat metadata writes (can permanently break World Map movement) #2810
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#2810
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 (Aug 15, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5076
Originally assigned to: @kolacheee on GitHub.
What happens
Advancing game time or updating weather can silently undo any other change to the same chat's settings that lands at the same moment. Most changes to a chat's metadata go through a queued, merge-on-latest patch path — but these two game endpoints read the whole metadata blob, modify one key, and write the entire blob back with no queue. Anything written by another request in between is reverted without any error.
The worst case involves World Maps: the map definition (including its
revisioncounter) lives in that same metadata blob, while the party's current location lives in a separate snapshots table. If a World Maps definition write (say, a newly discovered location bumping the revision) lands inside the time-advance window, the definition is rolled back while the snapshot keeps the newer revision number. From then on every map move fails validation asspatial_transition_stale_definition— a permanent, silent movement lock with no visible cause.Try it yourself
GET /api/chats/<chatId>and look at the metadata: when the requests interleave,raceProbeis gone — the time handler wrote back the stale blob it read before the patch landed.The same shape exists with normal app usage (no curl needed): the time/weather buttons in the game UI (
packages/client/src/hooks/use-game.ts:851,872) racing any other metadata write, including the World Maps agent's definition updates during a turn.Why it happens
POST /game/time/advancereadsmeta, then callschats.updateMetadata(chatId, { ...meta, gameTime })—packages/server/src/routes/game.routes.ts:9741(read) and:9767(write).POST /game/weather/updatedoes the same at:9802and:9818.updateMetadatais a bare whole-blobdb.updatewith nowithChatMetadataPatchQueue—packages/server/src/services/storage/chats.storage.ts:744-750. ComparepatchMetadatadirectly below it (:752-773), which queues and re-reads before merging.validateSpatialTransitioncompares the definitionrevisionfrom metadata against the snapshot'sdefinitionRevision—packages/shared/src/utils/spatial-context.ts:565-570.Suggested fix
Convert both handlers to
patchMetadatawith a narrow patch ({ gameTime }/{ gameWeather }) instead of spreading the stalemeta. OtherupdateMetadatacall sites ingame.routes.tswith the same read-modify-write shape are probably worth a follow-up audit, but these two are the ones a player hits every session.Found while exploring the pixel-RPG Experience design (which would call time-advance per move and made this race near-certain); verified against
staging@068d01fad.