[GH-ISSUE #2722] [Issue]: Tracker field locks drift/orphan/corrupt the wrong row on agent re-runs, swipes, and renames (positional vs name-based identity mismatch) #1365

Closed
opened 2026-10-21 05:32:27 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2722

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Field locks are the user's main defense against tracker re-runs overwriting manually-pinned values, but the lock-key identity scheme for the most common collections (persona/character stats, inventory, generic custom fields, quest objectives) is purely positional, while the server merge re-associates rows by name. The two disagree the moment an agent reorders, inserts, drops, or renames a row — so a pin silently stops protecting the row the user pinned, freezes an unrelated row, or stamps a locked value onto a brand-new row. Several related paths (re-swiping, character/custom-field renames, orphaned-snapshot PATCH) also lose or fail to persist locks. These are the literal source of the recurring "tracker ignored my lock / lost my manually-edited value" reports.


Bug 1 — Positional lock keys drift to the wrong row on agent reorder (high)

How it breaks the pipeline: Lock-key identity for stats/inventory/custom-fields/quest-objectives is a bare array index (persona.stats.${index}.value, player.inventory.${index}.name, etc.), but applyTrackerFieldLocksToGameStatePatch -> mergeStatsWithLocks/mergeInventoryWithLocks/mergeCustomTrackerFieldsWithGenericLocks matches the row by NAME via findCurrentNamedIndex and emits the merged array in the agent's new order. After one reorder the lock key points at a different array slot, so the merge protects the wrong row and the pinned row is freely overwritten on the next turn.

Steps to replicate:

  1. personaStats = [HP, MP]; lock persona.stats.0.value (HP).
  2. Next turn the tracker agent emits reordered [MP, {HP, value:999}].
  3. Merge restores HP this turn but persists order [MP, HP]; the panel now renders the lock badge on index 0 = MP.
  4. Following turn, persona.stats.0.value protects MP; HP is unprotected and overwritten.

Code trace:

  • packages/shared/src/utils/tracker-field-locks.ts:177-179 personaStatTrackerLockKey -> persona.stats.${index}.${field}; :185-187 inventory; :306-308 custom; :278-285 quest objective — all positional.
  • :381-407 mergeNamedRowsWithLocks maps nextRows and keys locks via keyFor(currentIndex,...), output is in agent order.
  • Client renders lock by new position: StatList.tsx getLockKey=(index)=>personaStatTrackerLockKey(index,...), PersonaTrackerPanel.tsx:387, RoleplayHUDPanels.tsx:349-351.
  • Index-shift helper removeIndexedTrackerLocks (tracker-field-locks.ts:92-140) exists but is wired ONLY to manual-delete UI handlers, never to the agent-merge path — proving the maintainers knew positional locks need realignment but only covered user edits.
  • Contrast: characterLockRef (:193-200) and questLockRef (:254-261) use stable id:/name: refs and do NOT drift.

Bug 2 — Carrying a locked-but-dropped row to the array end breaks its positional key (high)

How it breaks the pipeline: When the agent omits a locked row, mergeNamedRowsWithLocks re-appends it at the END of the merged array, but the lock key still encodes the row's ORIGINAL index, so the next merge cannot find the lock and the carried row becomes overwritable.

Steps to replicate:

  1. current [HP(idx0,locked), MP(idx1)]; agent emits only [MP].
  2. merged becomes [MP, HP] (HP re-pushed to index 1) but its lock key is still persona.stats.0.value.
  3. Next turn agent emits [HP, MP]; HP resolves to currentIndex 1, key persona.stats.1.value not locked -> HP value overwritten; MP at index 0 spuriously protected.

Code trace: tracker-field-locks.ts:402-406 tail loop pushes unused-but-locked current rows at merged.length; mergeQuestObjectivesWithLocks:482-485 only carries TRAILING dropped objectives, dropping a locked non-trailing objective entirely. Merged array persisted verbatim via buildLockedPersonaTrackerPatch (generate-route-utils.ts:151) while fieldLocks is carried forward independently; no re-key pass exists.

Bug 3 — Positional fallback stamps a locked value onto an unrelated/renamed row (high)

How it breaks the pipeline: findCurrentNamedIndex falls back to the positional index when the agent's row name matches nothing. Because every row has a (non-matching) name, the merge still resolves to the same slot and applies that slot's lock to the new row, writing the locked value into the wrong field — the lock both fails to protect AND actively corrupts an unrelated field.

Steps to replicate:

  1. current personaStats [HP (value locked), MP].
  2. Agent renames/replaces with [Stamina] (name matches nothing).
  3. findCurrentNamedIndex(Stamina,...,0) byName=-1 -> fallbackIndex 0 -> currentRow=HP -> isTrackerFieldLocked(persona.stats.0.value) true -> Stamina.value = HP's locked value.

Code trace: tracker-field-locks.ts:367-379 (fallback), :409-425/:427-444 (mergeStats/Inventory copy currentStat value when locked). Scenario C: inserting a NEW stat at front while keeping HP/MP named both present causes Stamina to consume slot 0 via fallback, blocking HP's legit name match (usedCurrent), silently losing HP's lock AND transplanting it.

Bug 4 — Quest objectives matched purely by position during locked merge (medium)

How it breaks the pipeline: Quests match by id/name, but objectives have no id (game-state.ts:133 {text;completed}) and mergeQuestObjectivesWithLocks pairs them by raw array index, so any objective reorder/removal mis-pairs the lock.

Steps to replicate: Lock objective 'Find the key' (index 1, completed). Agent marks an earlier objective done and re-emits the list shifted; the lock now pins a different objective while 'Find the key' is overwritten.

Code trace: tracker-field-locks.ts:470-471 const currentObjective = current[index] positional pairing; lock key questObjectiveTrackerLockKey(quest,questIndex,index,...) positional (:278-285); client QuestRow.tsx:223-224 derives the same positional keys; quest-state.ts:261 wholesale replaces objectives on update.

Bug 5 — Locks set on a swipe lost when generating additional swipes / regenerating (high)

How it breaks the pipeline: Locks are stored per (messageId, swipeIndex) row. A new swipe's snapshot is cloned from the PREVIOUS message's snapshot, not from the sibling swipe the user locked, so the just-set lock never enters the new swipe's merge/persist path and disappears from the panel.

Steps to replicate:

  1. On the visible assistant message, lock a tracker field.
  2. Swipe to generate an alternate response (or regenerate).
  3. New swipe overwrites the locked field; lock badge vanishes from the panel.

Code trace: generate.routes.ts:1350-1357 builds visibleAnchor=resolveRegenerationGameStateAnchor(...) which slices messages BEFORE the target, resolving the PREVIOUS assistant message; baseGameStateSnapshot (:3967) = previous message's snapshot. World-state handler creates the new swipe row with fieldLocks: currentGameStateForLocks?.fieldLocks (:7597) = previous message's locks. updateByMessage clone path also sources fieldLocks from baseSnapshot (game-state.storage.ts:337). The locked sibling swipe is never read.

Bug 6 — Renaming a character custom-field orphans its lock and duplicates the field (medium)

How it breaks the pipeline: Character custom-field locks are NAME-keyed via characterCustomFieldTrackerLockKey(...encodeSegment(fieldName)), but updateCustomField deletes the old key and adds the new key without migrating the lock; additionally the server's mergeCharacterCustomFieldsWithLocks re-adds the locked old-name key alongside the agent's renamed key, producing a duplicate stale field, so a NAME lock can never actually prevent a rename.

Steps to replicate: Lock a character custom field 'HP'; rename it to 'Health'. Lock indicator disappears; next character-tracker run overwrites the value; both 'HP' and 'Health' appear.

Code trace: CharacterTrackerCard.tsx:209-219 / FeaturedCharacterTrackerCard.tsx:195-205 updateCustomField (delete nextFields[oldName]; if(trimmedName) nextFields[trimmedName]=nextValue) with no onUpdateFieldLocks call; tracker-field-locks.ts:523-549 mergeCharacterCustomFieldsWithLocks re-adds next['HP']='10' leaving {Health, HP}. Sibling array path mergeCustomTrackerFieldsWithGenericLocks (:454) restores name in place correctly, proving intended semantics.

Bug 7 — Renaming an agent-generated (name-keyed) character drops all its locks (medium)

How it breaks the pipeline: characterLockRef uses name:<name> when characterId is absent (common for agent-emitted rows). The name-edit handler changes the name but does not migrate the characters.name:OLD.* lock prefix, so every lock orphans and the server merge re-derives keys from the NEW name and finds nothing locked.

Steps to replicate: On an agent-produced character without characterId, lock several fields, then edit the character's name. All locks unlock; the next tracker run overwrites all of them.

Code trace: tracker-field-locks.ts:193-200 characterLockRef; CharacterTrackerCard.tsx:255 onSave={(name)=>onUpdate({...character, name: name||'Character'})}; use-tracker-mutations.ts:128-135 updateCharacter patches presentCharacters only, never fieldLocks (unlike removeCharacter:142/removeQuest:212 which migrate). mergeCharactersWithLocks (:558-583) derives keys from the renamed character.

Bug 8 — Lock toggle silently dropped when the targeted snapshot is orphaned (low)

How it breaks the pipeline: When the client PATCHes an explicit (messageId, swipeIndex) target that can no longer be updated (target message deleted / belongs to another chat), all fallback writers are gated behind !hasExplicitTarget, so the fieldLocks write is dropped and a 404 returned while the client already shows the lock optimistically; the catch re-queues the same stale target, looping forever.

Steps to replicate: Delete the assistant message whose snapshot is the current GET fallback, then toggle a lock against that orphaned snapshot. The lock appears set but never persists; next turn the field is overwritten.

Code trace: chats.routes.ts:1489-1551 — hasExplicitTarget true, targetMessage?.chatId guard at :1491 leaves updated null, recovery blocks at :1501/1511/1525 all gated !hasExplicitTarget, returns 404 at :1552; client use-game-state-patcher.ts:413-420 set optimistically, :293 requeues stale target. Orphan reachable because removeMessage does not cascade snapshots (see Storage issue).


Suggested Fix

  • Give stats/inventory/custom-fields/quest-objective locks the same stable id/name ref scheme already used for characters/quests (characterLockRef/questLockRef): derive the ref from a stable name or synthetic id, key locks by that ref on both client renderers and the server merge, so locks follow rows through reorder/insert/drop. (Fixes Bugs 1-4.)
  • When findCurrentNamedIndex resolves via positional fallback (no name/id match), do NOT apply per-field locks; carry the locked original row forward separately rather than stamping its values onto an unrelated new row. (Bug 3.)
  • When cloning a snapshot for a new swipe of an existing message, source fieldLocks from the sibling swipe(s) of the SAME messageId, not from the previous message's base. (Bug 5.)
  • In updateCustomField/updateCharacter rename paths, migrate the lock keys (read live fieldLocks, move <prefix>.<oldName>.<field> -> <prefix>.<newName>.<field>); in mergeCharacterCustomFieldsWithLocks, when a name is locked detect and drop the agent's renamed counterpart instead of duplicating, OR migrate character customFields to an array-of-{name,value}. (Bugs 6-7.)
  • When hasExplicitTarget but the targeted snapshot cannot be updated, create/locate a snapshot for that exact (messageId, swipeIndex) so the lock persists, or surface an error and stop requeuing the same stale target. (Bug 8.)

Template checklist

  • pnpm check passes (TypeScript + ESLint)
  • pnpm db:push run if schema/storage touched
  • Manually verify locking a persona stat, then making the agent reorder stats, keeps the lock on the original stat
  • Manually verify locking a stat the agent later omits keeps it protected across two more turns
  • Manually verify a renamed/new stat does not inherit an unrelated row's locked value
  • Manually verify locking a quest objective survives the agent completing an earlier objective
  • Manually verify a field locked on the visible message survives generating a new swipe/regenerating
  • Manually verify renaming a locked character custom field keeps the lock and does not duplicate the field
  • Manually verify renaming an agent-generated character (no characterId) keeps its locks
  • Manually verify a lock toggle against a deleted-message snapshot either persists or surfaces an error (no silent 404 loop)

Affected files

  • packages/shared/src/utils/tracker-field-locks.ts
  • packages/server/src/routes/generate.routes.ts
  • packages/server/src/routes/generate/retry-agents-route.ts
  • packages/server/src/routes/generate/generate-route-utils.ts
  • packages/server/src/routes/chats.routes.ts
  • packages/client/src/features/tracker-panel/components/character-card/CharacterTrackerCard.tsx
  • packages/client/src/features/tracker-panel/components/character-card/FeaturedCharacterTrackerCard.tsx
  • packages/client/src/features/tracker-panel/hooks/use-tracker-mutations.ts

Audit provenance

Found by a multi-agent static audit of the trackers/widgets subsystem (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified). Severity: HIGH. Line numbers are against the staging working tree.

Note: this issue was AI-drafted from a static read of the code; the validation/test-plan boxes are intentionally left UNCHECKED for a human to verify before close.

Originally created by @kolacheee on GitHub (Jun 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2722 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Field locks are the user's main defense against tracker re-runs overwriting manually-pinned values, but the lock-key identity scheme for the most common collections (persona/character stats, inventory, generic custom fields, quest objectives) is **purely positional**, while the server merge re-associates rows **by name**. The two disagree the moment an agent reorders, inserts, drops, or renames a row — so a pin silently stops protecting the row the user pinned, freezes an unrelated row, or stamps a locked value onto a brand-new row. Several related paths (re-swiping, character/custom-field renames, orphaned-snapshot PATCH) also lose or fail to persist locks. These are the literal source of the recurring "tracker ignored my lock / lost my manually-edited value" reports. --- ### Bug 1 — Positional lock keys drift to the wrong row on agent reorder (high) **How it breaks the pipeline:** Lock-key identity for stats/inventory/custom-fields/quest-objectives is a bare array index (`persona.stats.${index}.value`, `player.inventory.${index}.name`, etc.), but `applyTrackerFieldLocksToGameStatePatch` -> `mergeStatsWithLocks`/`mergeInventoryWithLocks`/`mergeCustomTrackerFieldsWithGenericLocks` matches the row by NAME via `findCurrentNamedIndex` and emits the merged array in the agent's new order. After one reorder the lock key points at a different array slot, so the merge protects the wrong row and the pinned row is freely overwritten on the next turn. **Steps to replicate:** 1. personaStats = `[HP, MP]`; lock `persona.stats.0.value` (HP). 2. Next turn the tracker agent emits reordered `[MP, {HP, value:999}]`. 3. Merge restores HP this turn but persists order `[MP, HP]`; the panel now renders the lock badge on index 0 = MP. 4. Following turn, `persona.stats.0.value` protects MP; HP is unprotected and overwritten. **Code trace:** - `packages/shared/src/utils/tracker-field-locks.ts:177-179` `personaStatTrackerLockKey` -> `persona.stats.${index}.${field}`; `:185-187` inventory; `:306-308` custom; `:278-285` quest objective — all positional. - `:381-407` `mergeNamedRowsWithLocks` maps `nextRows` and keys locks via `keyFor(currentIndex,...)`, output is in agent order. - Client renders lock by new position: `StatList.tsx` `getLockKey=(index)=>personaStatTrackerLockKey(index,...)`, `PersonaTrackerPanel.tsx:387`, `RoleplayHUDPanels.tsx:349-351`. - Index-shift helper `removeIndexedTrackerLocks` (`tracker-field-locks.ts:92-140`) exists but is wired ONLY to manual-delete UI handlers, never to the agent-merge path — proving the maintainers knew positional locks need realignment but only covered user edits. - Contrast: `characterLockRef` (`:193-200`) and `questLockRef` (`:254-261`) use stable id:/name: refs and do NOT drift. ### Bug 2 — Carrying a locked-but-dropped row to the array end breaks its positional key (high) **How it breaks the pipeline:** When the agent omits a locked row, `mergeNamedRowsWithLocks` re-appends it at the END of the merged array, but the lock key still encodes the row's ORIGINAL index, so the next merge cannot find the lock and the carried row becomes overwritable. **Steps to replicate:** 1. current `[HP(idx0,locked), MP(idx1)]`; agent emits only `[MP]`. 2. merged becomes `[MP, HP]` (HP re-pushed to index 1) but its lock key is still `persona.stats.0.value`. 3. Next turn agent emits `[HP, MP]`; HP resolves to currentIndex 1, key `persona.stats.1.value` not locked -> HP value overwritten; MP at index 0 spuriously protected. **Code trace:** `tracker-field-locks.ts:402-406` tail loop pushes unused-but-locked current rows at `merged.length`; `mergeQuestObjectivesWithLocks:482-485` only carries TRAILING dropped objectives, dropping a locked non-trailing objective entirely. Merged array persisted verbatim via `buildLockedPersonaTrackerPatch` (`generate-route-utils.ts:151`) while `fieldLocks` is carried forward independently; no re-key pass exists. ### Bug 3 — Positional fallback stamps a locked value onto an unrelated/renamed row (high) **How it breaks the pipeline:** `findCurrentNamedIndex` falls back to the positional index when the agent's row name matches nothing. Because every row has a (non-matching) name, the merge still resolves to the same slot and applies that slot's lock to the new row, writing the locked value into the wrong field — the lock both fails to protect AND actively corrupts an unrelated field. **Steps to replicate:** 1. current personaStats `[HP (value locked), MP]`. 2. Agent renames/replaces with `[Stamina]` (name matches nothing). 3. `findCurrentNamedIndex(Stamina,...,0)` byName=-1 -> fallbackIndex 0 -> currentRow=HP -> `isTrackerFieldLocked(persona.stats.0.value)` true -> `Stamina.value = HP's locked value`. **Code trace:** `tracker-field-locks.ts:367-379` (fallback), `:409-425`/`:427-444` (mergeStats/Inventory copy currentStat value when locked). Scenario C: inserting a NEW stat at front while keeping HP/MP named both present causes Stamina to consume slot 0 via fallback, blocking HP's legit name match (usedCurrent), silently losing HP's lock AND transplanting it. ### Bug 4 — Quest objectives matched purely by position during locked merge (medium) **How it breaks the pipeline:** Quests match by id/name, but objectives have no id (`game-state.ts:133` `{text;completed}`) and `mergeQuestObjectivesWithLocks` pairs them by raw array index, so any objective reorder/removal mis-pairs the lock. **Steps to replicate:** Lock objective 'Find the key' (index 1, completed). Agent marks an earlier objective done and re-emits the list shifted; the lock now pins a different objective while 'Find the key' is overwritten. **Code trace:** `tracker-field-locks.ts:470-471` `const currentObjective = current[index]` positional pairing; lock key `questObjectiveTrackerLockKey(quest,questIndex,index,...)` positional (`:278-285`); client `QuestRow.tsx:223-224` derives the same positional keys; `quest-state.ts:261` wholesale replaces `objectives` on update. ### Bug 5 — Locks set on a swipe lost when generating additional swipes / regenerating (high) **How it breaks the pipeline:** Locks are stored per (messageId, swipeIndex) row. A new swipe's snapshot is cloned from the PREVIOUS message's snapshot, not from the sibling swipe the user locked, so the just-set lock never enters the new swipe's merge/persist path and disappears from the panel. **Steps to replicate:** 1. On the visible assistant message, lock a tracker field. 2. Swipe to generate an alternate response (or regenerate). 3. New swipe overwrites the locked field; lock badge vanishes from the panel. **Code trace:** `generate.routes.ts:1350-1357` builds `visibleAnchor=resolveRegenerationGameStateAnchor(...)` which slices messages BEFORE the target, resolving the PREVIOUS assistant message; `baseGameStateSnapshot` (`:3967`) = previous message's snapshot. World-state handler creates the new swipe row with `fieldLocks: currentGameStateForLocks?.fieldLocks` (`:7597`) = previous message's locks. `updateByMessage` clone path also sources `fieldLocks` from `baseSnapshot` (`game-state.storage.ts:337`). The locked sibling swipe is never read. ### Bug 6 — Renaming a character custom-field orphans its lock and duplicates the field (medium) **How it breaks the pipeline:** Character custom-field locks are NAME-keyed via `characterCustomFieldTrackerLockKey(...encodeSegment(fieldName))`, but `updateCustomField` deletes the old key and adds the new key without migrating the lock; additionally the server's `mergeCharacterCustomFieldsWithLocks` re-adds the locked old-name key alongside the agent's renamed key, producing a duplicate stale field, so a NAME lock can never actually prevent a rename. **Steps to replicate:** Lock a character custom field 'HP'; rename it to 'Health'. Lock indicator disappears; next character-tracker run overwrites the value; both 'HP' and 'Health' appear. **Code trace:** `CharacterTrackerCard.tsx:209-219` / `FeaturedCharacterTrackerCard.tsx:195-205` `updateCustomField` (`delete nextFields[oldName]; if(trimmedName) nextFields[trimmedName]=nextValue`) with no `onUpdateFieldLocks` call; `tracker-field-locks.ts:523-549` `mergeCharacterCustomFieldsWithLocks` re-adds `next['HP']='10'` leaving `{Health, HP}`. Sibling array path `mergeCustomTrackerFieldsWithGenericLocks` (`:454`) restores name in place correctly, proving intended semantics. ### Bug 7 — Renaming an agent-generated (name-keyed) character drops all its locks (medium) **How it breaks the pipeline:** `characterLockRef` uses `name:<name>` when `characterId` is absent (common for agent-emitted rows). The name-edit handler changes the name but does not migrate the `characters.name:OLD.*` lock prefix, so every lock orphans and the server merge re-derives keys from the NEW name and finds nothing locked. **Steps to replicate:** On an agent-produced character without `characterId`, lock several fields, then edit the character's name. All locks unlock; the next tracker run overwrites all of them. **Code trace:** `tracker-field-locks.ts:193-200` `characterLockRef`; `CharacterTrackerCard.tsx:255` `onSave={(name)=>onUpdate({...character, name: name||'Character'})}`; `use-tracker-mutations.ts:128-135` `updateCharacter` patches `presentCharacters` only, never `fieldLocks` (unlike `removeCharacter:142`/`removeQuest:212` which migrate). `mergeCharactersWithLocks` (`:558-583`) derives keys from the renamed character. ### Bug 8 — Lock toggle silently dropped when the targeted snapshot is orphaned (low) **How it breaks the pipeline:** When the client PATCHes an explicit (messageId, swipeIndex) target that can no longer be updated (target message deleted / belongs to another chat), all fallback writers are gated behind `!hasExplicitTarget`, so the `fieldLocks` write is dropped and a 404 returned while the client already shows the lock optimistically; the catch re-queues the same stale target, looping forever. **Steps to replicate:** Delete the assistant message whose snapshot is the current GET fallback, then toggle a lock against that orphaned snapshot. The lock appears set but never persists; next turn the field is overwritten. **Code trace:** `chats.routes.ts:1489-1551` — `hasExplicitTarget` true, `targetMessage?.chatId` guard at `:1491` leaves `updated` null, recovery blocks at `:1501/1511/1525` all gated `!hasExplicitTarget`, returns 404 at `:1552`; client `use-game-state-patcher.ts:413-420` set optimistically, `:293` requeues stale target. Orphan reachable because `removeMessage` does not cascade snapshots (see Storage issue). --- ## Suggested Fix - Give stats/inventory/custom-fields/quest-objective locks the same stable id/name ref scheme already used for characters/quests (`characterLockRef`/`questLockRef`): derive the ref from a stable name or synthetic id, key locks by that ref on both client renderers and the server merge, so locks follow rows through reorder/insert/drop. (Fixes Bugs 1-4.) - When `findCurrentNamedIndex` resolves via positional fallback (no name/id match), do NOT apply per-field locks; carry the locked original row forward separately rather than stamping its values onto an unrelated new row. (Bug 3.) - When cloning a snapshot for a new swipe of an existing message, source `fieldLocks` from the sibling swipe(s) of the SAME messageId, not from the previous message's base. (Bug 5.) - In `updateCustomField`/`updateCharacter` rename paths, migrate the lock keys (read live `fieldLocks`, move `<prefix>.<oldName>.<field>` -> `<prefix>.<newName>.<field>`); in `mergeCharacterCustomFieldsWithLocks`, when a name is locked detect and drop the agent's renamed counterpart instead of duplicating, OR migrate character `customFields` to an array-of-`{name,value}`. (Bugs 6-7.) - When `hasExplicitTarget` but the targeted snapshot cannot be updated, create/locate a snapshot for that exact (messageId, swipeIndex) so the lock persists, or surface an error and stop requeuing the same stale target. (Bug 8.) --- ## Template checklist - [ ] `pnpm check` passes (TypeScript + ESLint) - [ ] `pnpm db:push` run if schema/storage touched - [ ] Manually verify locking a persona stat, then making the agent reorder stats, keeps the lock on the original stat - [ ] Manually verify locking a stat the agent later omits keeps it protected across two more turns - [ ] Manually verify a renamed/new stat does not inherit an unrelated row's locked value - [ ] Manually verify locking a quest objective survives the agent completing an earlier objective - [ ] Manually verify a field locked on the visible message survives generating a new swipe/regenerating - [ ] Manually verify renaming a locked character custom field keeps the lock and does not duplicate the field - [ ] Manually verify renaming an agent-generated character (no characterId) keeps its locks - [ ] Manually verify a lock toggle against a deleted-message snapshot either persists or surfaces an error (no silent 404 loop) --- ### Affected files - `packages/shared/src/utils/tracker-field-locks.ts` - `packages/server/src/routes/generate.routes.ts` - `packages/server/src/routes/generate/retry-agents-route.ts` - `packages/server/src/routes/generate/generate-route-utils.ts` - `packages/server/src/routes/chats.routes.ts` - `packages/client/src/features/tracker-panel/components/character-card/CharacterTrackerCard.tsx` - `packages/client/src/features/tracker-panel/components/character-card/FeaturedCharacterTrackerCard.tsx` - `packages/client/src/features/tracker-panel/hooks/use-tracker-mutations.ts` ### Audit provenance Found by a multi-agent static audit of the trackers/widgets subsystem (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified). Severity: **HIGH**. Line numbers are against the `staging` working tree. > Note: this issue was AI-drafted from a static read of the code; the validation/test-plan boxes are intentionally left UNCHECKED for a human to verify before close.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 21, 2026):

Fixed in 46b61440. Tracker locks now use stable row refs for stats, inventory, custom fields, and quest objectives; legacy positional locks are migrated from the current snapshot before display/merge/persist; fallback row matches no longer stamp locked values onto unrelated renamed rows; locked omitted rows/objectives are carried forward; rename paths migrate lock prefixes; new swipe tracker snapshots prefer sibling-swipe locks; explicit stale snapshot patches update existing orphan snapshots or stop requeueing permanent 404 targets.

<!-- gh-comment-id:4761765439 --> @SpicyMarinara commented on GitHub (Jun 21, 2026): Fixed in 46b61440. Tracker locks now use stable row refs for stats, inventory, custom fields, and quest objectives; legacy positional locks are migrated from the current snapshot before display/merge/persist; fallback row matches no longer stamp locked values onto unrelated renamed rows; locked omitted rows/objectives are carried forward; rename paths migrate lock prefixes; new swipe tracker snapshots prefer sibling-swipe locks; explicit stale snapshot patches update existing orphan snapshots or stop requeueing permanent 404 targets.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1365
No description provided.