[PR #7288] [MERGED] fix(trackers): use manual Tracker Panel edits as the base for the next generation #7666

Closed
opened 2026-10-24 04:06:19 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7288
Author: @SpicyMarinara
Created: 10/8/2026
Status: ✅ Merged
Merged: 10/8/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/tracker-manual-edit-base


📝 Commits (10+)

  • 2d507c9 fix(trackers): use manual Tracker Panel edits as the base for the next generation
  • 5263dee Merge remote-tracking branch 'origin/staging' into fix/tracker-manual-edit-base
  • 6a81ac3 Merge remote-tracking branch 'origin/staging' into fix/tracker-manual-edit-base
  • 6dfe0b0 fix(trackers): retire a Tracker Panel edit once a tracker changes its value
  • 8a676a3 Merge origin/staging into fix/tracker-manual-edit-base
  • f53053a Merge origin/staging into fix/tracker-manual-edit-base
  • 61b383f fix(trackers): let the newest Tracker Panel edit win across a reply's swipes
  • 0133924 Merge origin/fix/tracker-manual-edit-base into the newest-edit fix
  • 30a4602 fix(trackers): keep agent prompts consistent with Tracker Panel edits
  • e49e4cd Merge origin/staging into fix/tracker-manual-edit-base

📊 Changes

7 files changed (+867 additions, -53 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/roleplay/hud-and-trackers.md (+1 -1)
➕ e2e/tracker-manual-edit-base.e2e.ts (+151 -0)
📝 packages/server/src/routes/generate.routes.ts (+48 -7)
📝 packages/server/src/routes/generate/generate-route-utils.ts (+2 -2)
📝 packages/server/src/services/storage/game-state.storage.ts (+202 -43)
➕ scripts/regressions/tracker-manual-edit-base.regression.ts (+462 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7286

Why this change

Mari fixed a wrong World State location in the Tracker Panel and regenerated the reply. The regeneration ignored her fix and started from the previous reply's trackers, which held the same wrong value she had just corrected.

Her rule: a manual Tracker Panel edit replaces the committed value and becomes the base for the next generation. That includes regenerating or swiping the edited reply, and the next new message. The new generation may then change the value, and its result replaces the edit.

Root cause. A regeneration builds its base from the reply before the regenerated one (resolveRegenerationGameStateAnchor and excludeMessageId in getForGeneration). The Tracker Panel PATCH writes the edit only onto the edited reply's own (message, swipe) row. That is exactly the row the regeneration base excludes, and nothing copied the edit into the base. A new message already worked, because it commits the edited row and starts from it.

What changed

Server only, with no schema or storage-format change. Edits stay on the row the user edited. They are never written into the previous reply's row, so its history, branches made from it, and deletes of the edited reply behave as before.

  • Recording edits (game-state.storage.ts). A manual PATCH now records every tracker value it actually changes, in the existing manualOverrides column:

    • The five scene fields are recorded by value. A cleared field is recorded as "", so clearing also counts.
    • worldCustomFields, presentCharacters and personaStats are recorded as a short sha256 fingerprint, so the record does not copy whole lists into every prompt.
    • playerStats is recorded per key (playerStats.customTrackerFields), so a Custom Tracker edit does not drag Quests or Inventory along.
  • applyManualEdits lays the edits from every swipe of a reply over a base. An edit counts only while its row still holds the edited value. Every write to a row also drops the edits that row no longer holds, so once a tracker run changes a field, that edit is retired for good. It stays retired even if a later run writes the same value again.

  • getForGeneration applies those edits whenever it excludes a regenerated reply. This one change covers:

    • the main prompt's tracker context;
    • the lorebook scan;
    • every tracker agent's current state;
    • Peek Prompt for a regeneration;
    • the retry base when a swipe has no row.

    Re-run trackers anchors the reply's own row, so the edit is not applied a second time there.

  • Leaving a value out. When a tracker leaves a value out on a regeneration, the value comes from the swipe just before the new one. That fallback row now carries the edits too, so the result matches what the trackers were shown. The update_game_state tool base does the same.

  • Regenerated swipes with no tracker run. No tracker may write a regenerated swipe's row, for example in manual-tracker chats or when a run fails. That swipe now gets a row from the edited base, so the panel and the next message keep the edit. Game mode is excluded.

  • Rewriting the same row. When a tracker run rewrites its own row, as a continuation does, it now keeps that row's edit record.

  • CHANGELOG entry, plus one sentence in docs/roleplay/hud-and-trackers.md. Translation follow-up: #7287.

Behaviour for Mari to confirm

  • An edit on any swipe of a reply still counts while that swipe shows it. Regenerating again after a regeneration moved the location still starts from your correction, not from the old wrong value. Each swipe still shows its own values, and new messages still start from the active swipe.
  • If two swipes of one reply edit the same value, the higher swipe wins (ponytail: note; the upgrade path is to record the edit time).
  • A list is taken whole from the edited swipe. For example, editing one character carries that swipe's whole character list (ponytail: note; the upgrade path is a per-row diff).
  • A tracker re-run that changes a value retires that edit, so a later regeneration starts from the previous reply's value for that field again.
  • Clear Trackers still wipes the edit record (unchanged).
  • The capability API getGameState is a separate read path and is unchanged.

Not on this path

  • The Relationship Tracker keeps its own state in Marinara-Agents.
  • Game Mode ruleset, inventory and combat code are unchanged.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Agent-run checks (for the reviewer to confirm, not ticked):

  • pnpm check exited 0.

  • pnpm regression:prompt passed.

  • New scripts/regressions/tracker-manual-edit-base.regression.ts passes. On origin/staging it fails at:

    • the regeneration's Peek Prompt and tracker prompts;
    • the untouched edits after a tracker re-run;
    • a branch that includes the edited reply;
    • the manual-tracker regeneration;
    • the continuation case without the same-row record change.

    The new-message and delete cases already pass on staging, as guard tests. The A → B → A case (a retired edit must not return) fails without the second commit.

  • These related regressions passed:

    • Trackers and agent context: tracker-sections, agent-context-generation, roleplay-swipe-media, advanced-memory-core, open-issues, lazy-chat-units, capability-package-lifecycle, multiplayer-game-persona.
    • Checkpoints and experience state: checkpoint-retention, game-checkpoint-engine-state, experience-state, experience-state-ordinal.
    • Game tools and inventory: game-tool-controls, game-tool-outcomes, game-inventory-bags, game-inventory-turn.
    • Rulesets: game-ruleset-* (6 files).
    • Combat director: combat-director-route, ruleset-combat-director-route.
  • New e2e/tracker-manual-edit-base.e2e.ts passes on desktop-chromium and mobile-webkit. It edits the location through the real Tracker Panel, reloads, regenerates from the message row, and checks the prompt and the new swipe. On staging it fails because the prompt still says Location: Old town.

  • world-tracker-controls, docked-tracker-panel and tracker-window e2e passed on both projects.

  • Full node scripts/run-regressions.mjs (first commit): 537/538 passed. The one failure, termux-sharp, is ERR_PNPM_NO_OFFLINE_TARBALL from its offline pnpm install simulation in this environment, not this change.

  • Local CodeRabbit (coderabbit review --agent --committed --base-commit <merge-base>) on the first commit returned 0 findings. Its outcome was "completed_with_warnings" ("Review completed with unverified findings"), with no finding items in the output.

  • The GitHub CodeRabbit review found one valid issue: a retired edit came back when a tracker later wrote the same value again. It is fixed in the second commit, with a regression case, and the thread is resolved.

Manual verification notes

  • Manually verify in a Roleplay chat with World State on: send a message, change the reply's Location in the Tracker Panel, then regenerate or swipe that reply. Peek Prompt and the agent debug log should show your location, and the new swipe should keep it unless the World State agent moves the scene.
  • Manually verify the same with a Present Characters mood and a Custom Tracker value.
  • Manually verify that regenerating a second time still starts from your correction, and that swiping back to the first swipe shows your edit while the other swipes show their own values.
  • Manually verify that sending a new message from the edited swipe starts from your edit.
  • Manually verify that deleting the edited swipe, or branching from an earlier message, does not bring the edit into the regeneration or the branch.
  • Manually verify a chat with Manual Trackers on (Chat Settings → Agents): after editing and regenerating, the panel still shows your edit on the new swipe and after a reload.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

CHANGELOG [Unreleased] entry added. docs/roleplay/hud-and-trackers.md gained one sentence; translation follow-up is #7287.

UI evidence (if applicable)

No UI change. The fix is on the server.

Summary by CodeRabbit

  • New Features
    • Tracker Panel corrections now provide starting values for subsequent replies, including regenerated and swiped replies. Manually run trackers also use these corrections.
    • Corrections are tracked per swipe; later edits to the same value replace earlier ones, while list-valued trackers are retained as whole values.
  • Bug Fixes
    • Corrected values remain in effect when tracker output leaves them unchanged and are replaced when tracker output changes them. Deleting a reply or swipe removes its associated corrections.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7288 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/8/2026 **Status:** ✅ Merged **Merged:** 10/8/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/tracker-manual-edit-base` --- ### 📝 Commits (10+) - [`2d507c9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2d507c95a66a5f15df581b1ac1208be0a274feb6) fix(trackers): use manual Tracker Panel edits as the base for the next generation - [`5263dee`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5263deed6ad5aba02ff74173c6dc1bcf91a04572) Merge remote-tracking branch 'origin/staging' into fix/tracker-manual-edit-base - [`6a81ac3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6a81ac38123688b76bbc52b8ed65fc40e2c94a8e) Merge remote-tracking branch 'origin/staging' into fix/tracker-manual-edit-base - [`6dfe0b0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6dfe0b0b7c67670a35e0cce175c136a414c0753d) fix(trackers): retire a Tracker Panel edit once a tracker changes its value - [`8a676a3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8a676a3f09d7bf452a694e50071f9da32f0f173b) Merge origin/staging into fix/tracker-manual-edit-base - [`f53053a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f53053a5e668e192b2f62541440af6b513554a0e) Merge origin/staging into fix/tracker-manual-edit-base - [`61b383f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/61b383f27961e7cefe086f929655410ef682e2e4) fix(trackers): let the newest Tracker Panel edit win across a reply's swipes - [`0133924`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0133924e10a3c6a850d27f649fb7f54fe1df0322) Merge origin/fix/tracker-manual-edit-base into the newest-edit fix - [`30a4602`](https://github.com/Pasta-Devs/Marinara-Engine/commit/30a46029f4c12b1b665afcb5a8a2427c6563e6e0) fix(trackers): keep agent prompts consistent with Tracker Panel edits - [`e49e4cd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e49e4cd6515587422c7f3a5ed7ff8ab25a059994) Merge origin/staging into fix/tracker-manual-edit-base ### 📊 Changes **7 files changed** (+867 additions, -53 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/roleplay/hud-and-trackers.md` (+1 -1) ➕ `e2e/tracker-manual-edit-base.e2e.ts` (+151 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+48 -7) 📝 `packages/server/src/routes/generate/generate-route-utils.ts` (+2 -2) 📝 `packages/server/src/services/storage/game-state.storage.ts` (+202 -43) ➕ `scripts/regressions/tracker-manual-edit-base.regression.ts` (+462 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7286 ## Why this change Mari fixed a wrong World State location in the Tracker Panel and regenerated the reply. The regeneration ignored her fix and started from the previous reply's trackers, which held the same wrong value she had just corrected. Her rule: a manual Tracker Panel edit replaces the committed value and becomes the base for the next generation. That includes regenerating or swiping the edited reply, and the next new message. The new generation may then change the value, and its result replaces the edit. **Root cause.** A regeneration builds its base from the reply before the regenerated one (`resolveRegenerationGameStateAnchor` and `excludeMessageId` in `getForGeneration`). The Tracker Panel PATCH writes the edit only onto the edited reply's own (message, swipe) row. That is exactly the row the regeneration base excludes, and nothing copied the edit into the base. A new message already worked, because it commits the edited row and starts from it. ## What changed Server only, with no schema or storage-format change. Edits stay on the row the user edited. They are never written into the previous reply's row, so its history, branches made from it, and deletes of the edited reply behave as before. - **Recording edits** (`game-state.storage.ts`). A manual PATCH now records every tracker value it actually changes, in the existing `manualOverrides` column: - The five scene fields are recorded by value. A cleared field is recorded as `""`, so clearing also counts. - `worldCustomFields`, `presentCharacters` and `personaStats` are recorded as a short sha256 fingerprint, so the record does not copy whole lists into every prompt. - `playerStats` is recorded per key (`playerStats.customTrackerFields`), so a Custom Tracker edit does not drag Quests or Inventory along. - **`applyManualEdits`** lays the edits from every swipe of a reply over a base. An edit counts only while its row still holds the edited value. Every write to a row also drops the edits that row no longer holds, so once a tracker run changes a field, that edit is retired for good. It stays retired even if a later run writes the same value again. - **`getForGeneration`** applies those edits whenever it excludes a regenerated reply. This one change covers: - the main prompt's tracker context; - the lorebook scan; - every tracker agent's current state; - **Peek Prompt** for a regeneration; - the retry base when a swipe has no row. Re-run trackers anchors the reply's own row, so the edit is not applied a second time there. - **Leaving a value out.** When a tracker leaves a value out on a regeneration, the value comes from the swipe just before the new one. That fallback row now carries the edits too, so the result matches what the trackers were shown. The `update_game_state` tool base does the same. - **Regenerated swipes with no tracker run.** No tracker may write a regenerated swipe's row, for example in manual-tracker chats or when a run fails. That swipe now gets a row from the edited base, so the panel and the next message keep the edit. Game mode is excluded. - **Rewriting the same row.** When a tracker run rewrites its own row, as a continuation does, it now keeps that row's edit record. - CHANGELOG entry, plus one sentence in `docs/roleplay/hud-and-trackers.md`. Translation follow-up: #7287. **Behaviour for Mari to confirm** - An edit on any swipe of a reply still counts while that swipe shows it. Regenerating again after a regeneration moved the location still starts from your correction, not from the old wrong value. Each swipe still shows its own values, and new messages still start from the active swipe. - If two swipes of one reply edit the same value, the higher swipe wins (`ponytail:` note; the upgrade path is to record the edit time). - A list is taken whole from the edited swipe. For example, editing one character carries that swipe's whole character list (`ponytail:` note; the upgrade path is a per-row diff). - A tracker re-run that changes a value retires that edit, so a later regeneration starts from the previous reply's value for that field again. - **Clear Trackers** still wipes the edit record (unchanged). - The capability API `getGameState` is a separate read path and is unchanged. **Not on this path** - The Relationship Tracker keeps its own state in Marinara-Agents. - Game Mode ruleset, inventory and combat code are unchanged. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Agent-run checks (for the reviewer to confirm, not ticked): - `pnpm check` exited 0. - `pnpm regression:prompt` passed. - New `scripts/regressions/tracker-manual-edit-base.regression.ts` passes. On `origin/staging` it fails at: - the regeneration's Peek Prompt and tracker prompts; - the untouched edits after a tracker re-run; - a branch that includes the edited reply; - the manual-tracker regeneration; - the continuation case without the same-row record change. The new-message and delete cases already pass on staging, as guard tests. The A → B → A case (a retired edit must not return) fails without the second commit. - These related regressions passed: - Trackers and agent context: `tracker-sections`, `agent-context-generation`, `roleplay-swipe-media`, `advanced-memory-core`, `open-issues`, `lazy-chat-units`, `capability-package-lifecycle`, `multiplayer-game-persona`. - Checkpoints and experience state: `checkpoint-retention`, `game-checkpoint-engine-state`, `experience-state`, `experience-state-ordinal`. - Game tools and inventory: `game-tool-controls`, `game-tool-outcomes`, `game-inventory-bags`, `game-inventory-turn`. - Rulesets: `game-ruleset-*` (6 files). - Combat director: `combat-director-route`, `ruleset-combat-director-route`. - New `e2e/tracker-manual-edit-base.e2e.ts` passes on desktop-chromium and mobile-webkit. It edits the location through the real Tracker Panel, reloads, regenerates from the message row, and checks the prompt and the new swipe. On staging it fails because the prompt still says `Location: Old town`. - `world-tracker-controls`, `docked-tracker-panel` and `tracker-window` e2e passed on both projects. - Full `node scripts/run-regressions.mjs` (first commit): 537/538 passed. The one failure, `termux-sharp`, is `ERR_PNPM_NO_OFFLINE_TARBALL` from its offline pnpm install simulation in this environment, not this change. - Local CodeRabbit (`coderabbit review --agent --committed --base-commit <merge-base>`) on the first commit returned 0 findings. Its outcome was "completed_with_warnings" ("Review completed with unverified findings"), with no finding items in the output. - The GitHub CodeRabbit review found one valid issue: a retired edit came back when a tracker later wrote the same value again. It is fixed in the second commit, with a regression case, and the thread is resolved. ### Manual verification notes - Manually verify in a Roleplay chat with World State on: send a message, change the reply's **Location** in the Tracker Panel, then regenerate or swipe that reply. **Peek Prompt** and the agent debug log should show your location, and the new swipe should keep it unless the World State agent moves the scene. - Manually verify the same with a **Present Characters** mood and a **Custom Tracker** value. - Manually verify that regenerating a second time still starts from your correction, and that swiping back to the first swipe shows your edit while the other swipes show their own values. - Manually verify that sending a new message from the edited swipe starts from your edit. - Manually verify that deleting the edited swipe, or branching from an earlier message, does not bring the edit into the regeneration or the branch. - Manually verify a chat with **Manual Trackers** on (Chat Settings → Agents): after editing and regenerating, the panel still shows your edit on the new swipe and after a reload. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) CHANGELOG `[Unreleased]` entry added. `docs/roleplay/hud-and-trackers.md` gained one sentence; translation follow-up is #7287. ## UI evidence (if applicable) No UI change. The fix is on the server. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Tracker Panel corrections now provide starting values for subsequent replies, including regenerated and swiped replies. Manually run trackers also use these corrections. * Corrections are tracked per swipe; later edits to the same value replace earlier ones, while list-valued trackers are retained as whole values. * **Bug Fixes** * Corrected values remain in effect when tracker output leaves them unchanged and are replaced when tracker output changes them. Deleting a reply or swipe removes its associated corrections. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:06:19 +07:00
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#7666
No description provided.