mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
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#5694
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/2629
Author: @Romuromylus
Created: 6/18/2026
Status: ✅ Merged
Merged: 6/18/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/2627-party-stale-snapshot-race📝 Commits (7)
8f399a1fix(game): merge party/cards against fresh metadata in /party/recruit and /party/remove (#2627)58353f0Merge branch 'staging' into fix/2627-party-stale-snapshot-raced5aafb7fix(game): return party chat reloaded after the characterIds mirror writee4ccf42fix(game): serialize the characterIds mirror inside the metadata patch queue1e44bd9fix(game): derive the recruitaddedflag from the fresh queued partyfbaca96Merge branch 'staging' into fix/2627-party-stale-snapshot-racecef8971fix(game): only write a recruit card when the request generated one📊 Changes
2 files changed (+199 additions, -33 deletions)
View changed files
📝
packages/server/src/routes/game.routes.ts(+162 -33)📝
packages/server/src/services/storage/chats.storage.ts(+37 -0)📄 Description
Linked issue
Closes #2627
Why this change
In game mode,
/party/recruitand/party/removepersisted the party, character cards, and setup-config from a metadata snapshot read before their work, then wrote the whole blob back./party/recruitreturned its precomputed party/card/setup-config from apatchMetadataupdater that ignored the freshcurrentargument;/party/removewrote a stale blob through the non-queuedupdateMetadata. Because both derivations were based on the stale read, two overlapping party operations on the same chat — two recruits, or a recruit racing a remove — could drop a freshly added member or resurrect a removed one. This is the residual concurrency facet of #2613 for the two party handlers, deferred from #2623 to keep that batch's scope bounded.#2627 specifically asks that "no member addition or removal is lost" for concurrent recruit/remove. Fixing only the recruit handler would leave the remove-commits-last case broken — a non-queued remove can still overwrite a recruit's queued patch — so this PR converts both handlers.
What changed
mergeRecruitIntoGameMetadata: a pure helper that, inside the/party/recruitpatchMetadataupdater, re-readsgamePartyCharacterIds/gameCharacterCards/gameSetupConfigfrom the freshcurrentmetadata, merges this recruit's id and card (matching an existing card by name), and derives thecharacterIdscolumn mirror from the merged party. The handler now calls it throughpatchMetadata((current) => ...)and writes thecharacterIdsmirror after the queued patch resolves.removeMemberFromGameMetadata: the symmetric helper for/party/remove. The handler now routes throughpatchMetadata((current) => ...)instead of the non-queuedupdateMetadata, prunes the resolved member from the fresh party, and deliberately omitsgameCharacterCardsfrom the patch — removing a member never deletes its card, so leaving the key out preserves a concurrent recruit's freshly added card instead of clobbering it with the stale array.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
pnpm checkpasses locally and the per-package server test suite passes. I added focused regression tests for both handlers — concurrent-recruit-preserved, no-resurrect-on-remove, card-reuse-not-clobbered, no-duplicate-card, NPC-id handling, idempotent remove, and no-stale-card-clobber — kept local-only per our test-file convention. The boxes above are left unticked as a reviewer to-do; below is what I verified directly on a build of this branch deployed to my private instance.Confirmed on the deployed branch (a real game chat, with the original party snapshotted first):
characterIdscolumn mirrored the merged party.characterIdscolumn matched, and the other cards were untouched. (The removed member's card remains ingameCharacterCardsby design — removal never deletes cards.)The concurrency window itself — two overlapping operations during the multi-second recruit-card LLM call — can't be driven deterministically by hand; the added regression tests cover those interleavings.
Docs and release impact
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.