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#1375
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 (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2735
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Regression introduced by #2730 (the #2722 field-lock rewrite) — half-applied refactor. The new lock-merge helper
findCurrentNamedMatchcorrectly takes ausedCurrent: Set<number>so each emitted row claims a distinct current row. But its two siblings —findCurrentCharacterMatchandfindCurrentQuestMatch— were left without that dedup guard. When the tracker agent emits two rows with the same name (or same id), both resolve to the same current row, both inherit that row's locked field, and the unclaimed current row is then re-appended by the trailing "carry locked rows" loop. Result: the collection grows by a phantom duplicate every turn, and distinct same-named entities lose their individual data.This is a data-corruption regression on a core game-mode persistence path, and same-named NPCs ("Guard", "Bandit", "Villager", "Soldier") are extremely common.
Sub-bugs (same root cause)
1. Characters — HIGH
Two present characters named "Guard" both match
current[0]; both copycurrent[0]'s locked field;current[1]is never marked used and gets re-pushed. Per turn the list grows and the two Guards' mood/outfit/thoughts/stats collapse onto one. The trigger is design-permitted:agent-prompts.ts:262tells the modelcharacterIdmay be "ID or name".2. Quests — LOW (latent)
findCurrentQuestMatchhas the same gap. Currently hard to trigger because every quest reaching the merge has aquestEntryId(so id-matching disambiguates) and the manual UI assigns unique ids — but it's the same defect and a defense-in-depth gap.3. Blank-name / positional-lock rows — LOW
In
mergeNamedRowsWithLocks, the locked index-fallback early-return (return row;) skipsusedCurrent.add(currentIndex), so the trailing loop re-pushes that locked current row → one-row duplicate per affected turn. Affects blank-name stats/inventory/custom rows with a positional lock.How it degrades the UX
A user playing game mode with multiple same-named NPCs (or who locks a field) sees the character/quest/stat list silently accrue duplicate rows turn over turn, and individual NPCs' tracked details bleed together — the exact "tracker shows wrong/duplicated data" class of report, now introduced by the lock fix.
Steps to replicate
Code trace (staging)
packages/shared/src/utils/tracker-field-locks.ts:564-579—findCurrentNamedMatchtakesusedCurrentand checks!usedCurrent.has(index)in both the by-name find (:572) and the fallback (:576). ✅ correct.packages/shared/src/utils/tracker-field-locks.ts:526-545—findCurrentCharacterMatchtakes nousedCurrent; by-id (:533), by-name (:538) and fallback (:542) all use plainfindIndex/index with no used-check. ❌packages/shared/src/utils/tracker-field-locks.ts:547-562—findCurrentQuestMatchsame gap. ❌mergeCharactersWithLocks(~:790) callsfindCurrentCharacterMatchwith no used-set; locked-field copy at ~:802-806; trailing re-push at ~:822-825.packages/server/src/routes/generate.routes.ts(~:7945) →applyTrackerFieldLocksToGameStatePatchagainst the previous snapshot, written back as next-turncurrent, so corruption compounds.46b61440authoredfindCurrentNamedMatchwith the guard butfindCurrentCharacterMatch/findCurrentQuestMatchwithout it.Suggested fix
Thread a
usedCurrent: Set<number>throughfindCurrentCharacterMatchandfindCurrentQuestMatchexactly likefindCurrentNamedMatch(skip already-used indices in the by-id, by-name, and fallback lookups), and instantiate the set once inmergeCharactersWithLocks/mergeQuestsWithLocksbefore the.map(). Additionally, inmergeNamedRowsWithLocks, callusedCurrent.add(currentIndex)before the locked index-fallback early-return so the trailing loop doesn't re-append it.Template checklist
pnpm checkpasses (TypeScript + ESLint)Found by a post-merge verification sweep of #2730; characters case verified by direct read at the cited file:line. Boxes left unchecked for human verification.
@SpicyMarinara commented on GitHub (Jun 21, 2026):
Addressed in PR #2747.