mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2627] [Issue]: /party/recruit merges party/cards from a stale snapshot, not the queued fresh metadata #1297
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#1297
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 18, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2627
Originally assigned to: @Romuromylus on GitHub.
Summary
In game mode,
POST /game/party/recruitcomputes the new party / character-cards / setup-config from a metadata snapshot read before the (multi-second) recruit-card LLM call, then writes them viachats.patchMetadata. Because the callback ignores the fresh metadata it is handed, two recruits (or a recruit racing a/party/remove) that overlap can drop or resurrect a party member.Expected behavior
Concurrent recruit/remove operations on the same chat should each observe prior committed party state, so no member addition or removal is lost. The recruit's party/card/setup-config merge should happen against the fresh metadata read inside the
patchMetadataupdater.Actual behavior
game.routes.ts/party/recruitprecomputesupdatedPartyIds,updatedCards, andupdatedSetupConfigfrom the pre-LLMmetasnapshot, and thepatchMetadata(chat.id, () => ({ ... }))callback returns those precomputed values without re-readingfreshMeta. Thechats.update(chat.id, { characterIds })sync is likewise derived from the stale party list. A concurrent recruit/remove committed during the LLM window is overwritten on the final blob-level write ofgamePartyCharacterIds/gameCharacterCards/gameSetupConfig.This is the residual concurrency facet of #2613 for the recruit handler specifically. PR #2623 routed the handler through
patchMetadata(so unrelated metadata keys — journal, quest, party arcs, etc. — are no longer clobbered), but the recruit's own party/card derivation is still based on the stale read. Flagged by CodeRabbit review on PR #2623.Steps to reproduce
/party/recruitcalls (or a recruit + a/party/remove) close together so both read party state before either writes.Environment
staging(post-#2623)Logs, screenshots, or video
Static review follow-up; cited to
packages/server/src/routes/game.routes.ts/party/recruit(thepatchMetadatacallback around thegameSetupConfig/gamePartyCharacterIds/gameCharacterCardswrite).Additional context
Fix sketch: inside the
patchMetadataupdater, re-readgamePartyCharacterIds,gameCharacterCards, andgameSetupConfigfrom thefreshMetaargument, merge this recruit'srecruitId/ generated card / setup-config there (matching the existing card by id), and derive thechats.update(... characterIds ...)sync from the merged party. Deferred from PR #2623 to keep that batch's scope bounded, since a correct merge has to reconcile party-NPC ids and card identity.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: