[PR #4085] [CLOSED] fix(game): sync map after location tool updates #6228

Closed
opened 2026-10-23 04:08:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4085
Author: @Romuromylus
Created: 7/25/2026
Status: ❌ Closed

Base: staging ← Head: fix/4084-game-map-tool-location-sync


📝 Commits (9)

  • c2a03ad fix(game): sync map after location tool updates
  • cbcbacd fix(game): preserve manual map state during sync
  • 909df34 fix(game): compare normalized map locations
  • 53a1b2e fix(game): normalize location apostrophes
  • 78ea386 fix(game): compare resolved map positions
  • c6d52c9 fix(game): update map on existing-node arrivals
  • 379780d fix(game): harden narrated map updates
  • a33af13 fix(game): preserve map update authority
  • 1ae6b59 fix(game): gate map tags on fresh metadata

📊 Changes

5 files changed (+280 additions, -51 deletions)

View changed files

📝 package.json (+1 -1)
📝 packages/server/src/routes/generate.routes.ts (+102 -40)
📝 packages/server/src/services/game/gm-prompts.ts (+5 -2)
📝 packages/server/src/services/game/map-position.service.ts (+60 -8)
➕ scripts/regressions/game-map-location-sync.regression.ts (+112 -0)

📄 Description

Linked issue

Closes #4084

Why this change

  • In Game Mode, the regular node map could remain on an old location after narration moved the party elsewhere.
  • The live reproduction showed a chat with only Music DJ active and no Function Calling tools. Opus moved the story from Grieve Farm to Market Row, but the GM contract allowed [map_update:] only for entirely new nodes. No command or game-state snapshot was produced, so later prompts kept injecting stale <map_state> data and the marker stayed at the farm.
  • Function Calling had a separate gap: when Opus did emit update_game_state(location_change), that path updated the tracker but did not synchronize regular map metadata or emit game_map_update.

What changed

  • Require the Game Mode GM to emit [map_update:] for every real node-map arrival, including existing nodes, and to repair stale map state when story continuity disagrees with <map_state>.
  • Suppress that command contract when Hierarchical Maps owns Game Mode location, and continue excluding grid/mapless chats.
  • Apply location locks before narrator tags can move the marker; a locked tracker location remains authoritative.
  • Persist narrator-tag map metadata through the queued fresh-metadata patch path, preventing concurrent metadata writes from being lost.
  • Anchor the exact generated message/swipe snapshot even when Function Calling or another path already positioned the map.
  • Synchronize regular map metadata and emit game_map_update after accepted update_game_state(location_change) tool calls.
  • Preserve manual marker moves for locked/no-op updates and label/ID aliases that resolve to the same canonical map position.
  • Add focused regression coverage for existing/new nodes, stale-state prompt repair, grid/mapless and Hierarchical negative controls, tracker lock ordering, queued metadata updates, aliases, and message/swipe anchoring.

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

Manual verification notes

  • Live trace confirmed the original failure: final narration was in Market Row, persisted map and latest tracker snapshot remained at Northeastern Farmlands — Grieve Farm, activeToolIds was empty, and no world-state agent was active.
  • pnpm --filter @marinara-engine/server exec tsx ../../scripts/regressions/game-map-location-sync.regression.ts passes on final commit 1ae6b5930.
  • pnpm regression:prompt passes on final commit 1ae6b5930.
  • GitHub pnpm-validate and container-build-test pass on final commit 1ae6b5930.
  • Final maintainer-style review found no code findings; final state/data-loss and cross-mode/authority adversarial passes were dry.
  • Final commit is deployed to the private test instance; container is running and the auth-gated endpoint is healthy.
  • Manually generate the next Opus Game Mode turn while the story is still in Market Row and the saved marker is stale at Grieve Farm. The stale-state instruction should emit the existing-node map command and move the marker to Market Row.
  • Manually move to another existing node and verify the regular map marker and tracker update together.
  • Manually verify Hierarchical Maps remains authoritative and does not move from narrator tags or update_game_state.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

  • The reported screenshot shows narration at Market Row while the regular node-map marker remains on Northeastern Farmlands — Grieve Farm. Final after-fix evidence is pending the live retest above.

🔄 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/4085 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 7/25/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `fix/4084-game-map-tool-location-sync` --- ### 📝 Commits (9) - [`c2a03ad`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c2a03ad5df2cb26d1d6b44e5d392e4a47b2c1953) fix(game): sync map after location tool updates - [`cbcbacd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cbcbacdc9bbcd7f3cba4f3dc753e4b1c99dc636e) fix(game): preserve manual map state during sync - [`909df34`](https://github.com/Pasta-Devs/Marinara-Engine/commit/909df348f671d15ea18599926915d76a9403ca2e) fix(game): compare normalized map locations - [`53a1b2e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/53a1b2e3eb9b997c59a1da95999c67cef9ff803b) fix(game): normalize location apostrophes - [`78ea386`](https://github.com/Pasta-Devs/Marinara-Engine/commit/78ea386fda77563c7abe824f7ebb1a602552f1a9) fix(game): compare resolved map positions - [`c6d52c9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c6d52c92a356664e87389065da7487e5299f443b) fix(game): update map on existing-node arrivals - [`379780d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/379780dc5a32deaf35f816e765bef42814c013f9) fix(game): harden narrated map updates - [`a33af13`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a33af13bf46c3e19dcade8e1c384e37f7d4e4524) fix(game): preserve map update authority - [`1ae6b59`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1ae6b59304b39005519fd17746e90d6bdd111cf2) fix(game): gate map tags on fresh metadata ### 📊 Changes **5 files changed** (+280 additions, -51 deletions) <details> <summary>View changed files</summary> 📝 `package.json` (+1 -1) 📝 `packages/server/src/routes/generate.routes.ts` (+102 -40) 📝 `packages/server/src/services/game/gm-prompts.ts` (+5 -2) 📝 `packages/server/src/services/game/map-position.service.ts` (+60 -8) ➕ `scripts/regressions/game-map-location-sync.regression.ts` (+112 -0) </details> ### 📄 Description ## Linked issue Closes #4084 ## Why this change - In Game Mode, the regular node map could remain on an old location after narration moved the party elsewhere. - The live reproduction showed a chat with only Music DJ active and no Function Calling tools. Opus moved the story from Grieve Farm to Market Row, but the GM contract allowed `[map_update:]` only for entirely new nodes. No command or game-state snapshot was produced, so later prompts kept injecting stale `<map_state>` data and the marker stayed at the farm. - Function Calling had a separate gap: when Opus did emit `update_game_state(location_change)`, that path updated the tracker but did not synchronize regular map metadata or emit `game_map_update`. ## What changed - Require the Game Mode GM to emit `[map_update:]` for every real node-map arrival, including existing nodes, and to repair stale map state when story continuity disagrees with `<map_state>`. - Suppress that command contract when Hierarchical Maps owns Game Mode location, and continue excluding grid/mapless chats. - Apply location locks before narrator tags can move the marker; a locked tracker location remains authoritative. - Persist narrator-tag map metadata through the queued fresh-metadata patch path, preventing concurrent metadata writes from being lost. - Anchor the exact generated message/swipe snapshot even when Function Calling or another path already positioned the map. - Synchronize regular map metadata and emit `game_map_update` after accepted `update_game_state(location_change)` tool calls. - Preserve manual marker moves for locked/no-op updates and label/ID aliases that resolve to the same canonical map position. - Add focused regression coverage for existing/new nodes, stale-state prompt repair, grid/mapless and Hierarchical negative controls, tracker lock ordering, queued metadata updates, aliases, and message/swipe anchoring. ## 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` ### Manual verification notes - Live trace confirmed the original failure: final narration was in Market Row, persisted map and latest tracker snapshot remained at Northeastern Farmlands — Grieve Farm, `activeToolIds` was empty, and no world-state agent was active. - `pnpm --filter @marinara-engine/server exec tsx ../../scripts/regressions/game-map-location-sync.regression.ts` passes on final commit `1ae6b5930`. - `pnpm regression:prompt` passes on final commit `1ae6b5930`. - GitHub `pnpm-validate` and `container-build-test` pass on final commit `1ae6b5930`. - Final maintainer-style review found no code findings; final state/data-loss and cross-mode/authority adversarial passes were dry. - Final commit is deployed to the private test instance; container is running and the auth-gated endpoint is healthy. - Manually generate the next Opus Game Mode turn while the story is still in Market Row and the saved marker is stale at Grieve Farm. The stale-state instruction should emit the existing-node map command and move the marker to Market Row. - Manually move to another existing node and verify the regular map marker and tracker update together. - Manually verify Hierarchical Maps remains authoritative and does not move from narrator tags or `update_game_state`. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) - The reported screenshot shows narration at Market Row while the regular node-map marker remains on Northeastern Farmlands — Grieve Farm. Final after-fix evidence is pending the live retest above. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:08:23 +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#6228
No description provided.