[GH-ISSUE #6180] An Experience-owned Game narrates its opening turn before the Experience has built its world #3442

Closed
opened 2026-10-21 06:03:09 +07:00 by bsakaguchi · 3 comments
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

When a Game chat is owned by an Experience package such as Pixelforge, the Engine shows its own Start Game screen and streams the Game Master's opening turn before the Experience surface has mounted at all. The surface, and with it the package's world-building call, only starts after the player presses Continue on the intro. So the Game Master narrates an opening about a settlement, its people and its places, and the tile world that is supposed to be that settlement is designed afterwards by a separate call that never sees the opening it has to live up to.

How to reproduce (try it yourself)

  1. Install Pixelforge (any 0.16.x) and create a new Game chat with the Pixelforge experience turned on. Fill in a Setting and let the wizard finish.
  2. Watch what appears after creation. You get the Engine's Start Game screen over the world overview, not the Pixelforge loading screen.
  3. Press Start Game. The Game Master's first turn streams and the typewriter intro plays. It names people and places.
  4. Press Continue.
  5. Now the Pixelforge surface mounts and its loading gate appears while the package's own world design call runs. That call commonly takes a minute or more.
  6. When the world compiles, walk around and compare the settlement's name, its buildings and its villagers with what the opening narration said.

What you'll see: The opening narration comes first and the world comes second, with a long wait between them. The two were produced by two different model calls with two different inputs, so the names and places in the narration and the names and places in the world can disagree, and a player who reads the intro then walks into a village that does not match it has no way to know which one the game means. It only happens on a chat's first visit; a returning player never sees the intro again.

What should happen: For a chat an Experience owns, the Experience's world should exist before the Game Master narrates it, or the Engine should let the Experience decide when the game starts.

Where it is

packages/client/src/components/game/GameSurface.tsx at staging f2219d815. The intro early return is lines 10920 to 10926:

if (
  (sessionStatus === "ready" && !introPresented) ||
  startGame.isPending ||
  startGameRequested ||
  awaitingFirstTurn ||
  initialTurnFailed
) {

None of those terms consults experienceOwnsGame, which is defined at line 2332 and first used at line 12111. The Experience surface mounts at line 11513, gated on experienceSurfaceActive (line 2324), far below the early return, so nothing from the package renders until the return stops firing. introPresented has four sources at lines 3296 to 3300; on a brand new chat all four are false, and the only one this flow sets is the gameIntroPresented: true PATCH sent from the Continue handler at line 10992.

On the server side, /game/setup writes gameSessionStatus: "ready" at packages/server/src/routes/game.routes.ts:6050, and /game/start writes "active" at lines 7063 and 7082 while streaming the first Game Master turn.

On the package side, Pixelforge arms its loading gate and starts its world design call from the surface element's mount at packages/pixelforge/src/90-element.js:211 (in Marinara-Agents), which is exactly the code path the early return keeps unmounted. The package never reads the Engine's blueprint: gameWorldOverview, gameStoryArc, gamePlotTwists and gameStartingNpcs appear nowhere in packages/pixelforge/src/. Its world call is fed the Setting, tone, difficulty, rating and the chat's lorebook entries (60-save.js:2188-2196).

What's happening

The real order for a brand new Pixelforge chat is: create, /game/setup writes ready, the Start Game screen, /game/start writes active and streams the first Game Master turn from the Engine's narrative blueprint, the typewriter runs, the player presses Continue, gameIntroPresented is PATCHed, and only then does the surface mount, arm its gate and start the world design call. The Game Master is told about startingNpcs and a worldOverview the Experience never reads, and the Experience builds a settlement the Game Master has not been told about yet. Both halves are working as designed on their own; the ordering between them was never decided, because the intro screen predates Experience packages and the Experience mount point was placed below it.

Suggested fix

Two workable shapes, and they are not exclusive.

  1. When experienceOwnsGame is true, mount the Experience surface at ready instead of the Start Game screen, and hold the Engine's Start Game / intro flow until the Experience says its world is ready. That needs one small Capability API addition: a way for a game-surface package to report "ready to start" to the host (a host event or a metadata flag the host watches), since today the host has no signal for it. With that, the first Game Master turn can be given the world that exists, either through the package's existing GM prompt contribution or by the host passing the sealed world summary into the start call.
  2. As a cheaper interim, let a game-surface package declare in its manifest that it owns the start flow, and when it does, skip the Engine intro screen entirely for that chat: mount the surface at ready, and let the package call /game/start itself once its gate lifts. This changes what the first turn knows only if the package also contributes the world to the prompt, which Pixelforge already does for later turns.

Either way, please keep the current behaviour for classic Game Mode chats. The early return is correct for them.

Context

This came out of planning the Pixelforge 0.16.7 setup seam (Engine setup wizard hosting the Experience toggle and seed). The seam does not cause this and does not fix it; the planned work will keep the current order. Recorded in the plan as risk R1 so it is not rediscovered later. The concurrency note next to it is worth a glance too: registerSequentialGameTasks covers /setup and /:chatId/experience-generation only when metadata.gameSequentialAgents === true (packages/server/src/services/game/sequential-tasks.ts:29-35), so without that flag the Engine blueprint pass and the package's world call could in principle run concurrently on the same connection; today the ordering above means they never actually do.

Found by an AI-assisted review and re-verified against staging f2219d815 on 2026-09-13. Please verify before fixing.

Originally created by @kolacheee on GitHub (Sep 14, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6180 Originally assigned to: @SpicyMarinara on GitHub. When a Game chat is owned by an Experience package such as Pixelforge, the Engine shows its own Start Game screen and streams the Game Master's opening turn before the Experience surface has mounted at all. The surface, and with it the package's world-building call, only starts after the player presses Continue on the intro. So the Game Master narrates an opening about a settlement, its people and its places, and the tile world that is supposed to be that settlement is designed afterwards by a separate call that never sees the opening it has to live up to. ## How to reproduce (try it yourself) 1. Install Pixelforge (any 0.16.x) and create a new Game chat with the Pixelforge experience turned on. Fill in a Setting and let the wizard finish. 2. Watch what appears after creation. You get the Engine's Start Game screen over the world overview, not the Pixelforge loading screen. 3. Press Start Game. The Game Master's first turn streams and the typewriter intro plays. It names people and places. 4. Press Continue. 5. Now the Pixelforge surface mounts and its loading gate appears while the package's own world design call runs. That call commonly takes a minute or more. 6. When the world compiles, walk around and compare the settlement's name, its buildings and its villagers with what the opening narration said. **What you'll see:** The opening narration comes first and the world comes second, with a long wait between them. The two were produced by two different model calls with two different inputs, so the names and places in the narration and the names and places in the world can disagree, and a player who reads the intro then walks into a village that does not match it has no way to know which one the game means. It only happens on a chat's first visit; a returning player never sees the intro again. **What should happen:** For a chat an Experience owns, the Experience's world should exist before the Game Master narrates it, or the Engine should let the Experience decide when the game starts. ## Where it is `packages/client/src/components/game/GameSurface.tsx` at staging f2219d815. The intro early return is lines 10920 to 10926: ```ts if ( (sessionStatus === "ready" && !introPresented) || startGame.isPending || startGameRequested || awaitingFirstTurn || initialTurnFailed ) { ``` None of those terms consults `experienceOwnsGame`, which is defined at line 2332 and first used at line 12111. The Experience surface mounts at line 11513, gated on `experienceSurfaceActive` (line 2324), far below the early return, so nothing from the package renders until the return stops firing. `introPresented` has four sources at lines 3296 to 3300; on a brand new chat all four are false, and the only one this flow sets is the `gameIntroPresented: true` PATCH sent from the Continue handler at line 10992. On the server side, `/game/setup` writes `gameSessionStatus: "ready"` at `packages/server/src/routes/game.routes.ts:6050`, and `/game/start` writes `"active"` at lines 7063 and 7082 while streaming the first Game Master turn. On the package side, Pixelforge arms its loading gate and starts its world design call from the surface element's mount at `packages/pixelforge/src/90-element.js:211` (in Marinara-Agents), which is exactly the code path the early return keeps unmounted. The package never reads the Engine's blueprint: `gameWorldOverview`, `gameStoryArc`, `gamePlotTwists` and `gameStartingNpcs` appear nowhere in `packages/pixelforge/src/`. Its world call is fed the Setting, tone, difficulty, rating and the chat's lorebook entries (`60-save.js:2188-2196`). ## What's happening The real order for a brand new Pixelforge chat is: create, `/game/setup` writes ready, the Start Game screen, `/game/start` writes active and streams the first Game Master turn from the Engine's narrative blueprint, the typewriter runs, the player presses Continue, `gameIntroPresented` is PATCHed, and only then does the surface mount, arm its gate and start the world design call. The Game Master is told about `startingNpcs` and a `worldOverview` the Experience never reads, and the Experience builds a settlement the Game Master has not been told about yet. Both halves are working as designed on their own; the ordering between them was never decided, because the intro screen predates Experience packages and the Experience mount point was placed below it. ## Suggested fix Two workable shapes, and they are not exclusive. 1. When `experienceOwnsGame` is true, mount the Experience surface at `ready` instead of the Start Game screen, and hold the Engine's Start Game / intro flow until the Experience says its world is ready. That needs one small Capability API addition: a way for a game-surface package to report "ready to start" to the host (a host event or a metadata flag the host watches), since today the host has no signal for it. With that, the first Game Master turn can be given the world that exists, either through the package's existing GM prompt contribution or by the host passing the sealed world summary into the start call. 2. As a cheaper interim, let a game-surface package declare in its manifest that it owns the start flow, and when it does, skip the Engine intro screen entirely for that chat: mount the surface at `ready`, and let the package call `/game/start` itself once its gate lifts. This changes what the first turn knows only if the package also contributes the world to the prompt, which Pixelforge already does for later turns. Either way, please keep the current behaviour for classic Game Mode chats. The early return is correct for them. ## Context This came out of planning the Pixelforge 0.16.7 setup seam (Engine setup wizard hosting the Experience toggle and seed). The seam does not cause this and does not fix it; the planned work will keep the current order. Recorded in the plan as risk R1 so it is not rediscovered later. The concurrency note next to it is worth a glance too: `registerSequentialGameTasks` covers `/setup` and `/:chatId/experience-generation` only when `metadata.gameSequentialAgents === true` (`packages/server/src/services/game/sequential-tasks.ts:29-35`), so without that flag the Engine blueprint pass and the package's world call could in principle run concurrently on the same connection; today the ordering above means they never actually do. Found by an AI-assisted review and re-verified against staging f2219d815 on 2026-09-13. Please verify before fixing.
bsakaguchi 2026-10-21 06:03:09 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Sep 14, 2026):

Codex is handling this assigned issue on behalf of @SpicyMarinara in the staging sweep branch fix/assigned-sweep-6180-6186. No existing issue-linked branch, open PR, or project item was found. I will verify the affected flow and reuse the existing implementation where possible.

<!-- gh-comment-id:5661077114 --> @SpicyMarinara commented on GitHub (Sep 14, 2026): Codex is handling this assigned issue on behalf of @SpicyMarinara in the staging sweep branch fix/assigned-sweep-6180-6186. No existing issue-linked branch, open PR, or project item was found. I will verify the affected flow and reuse the existing implementation where possible.
Author
Owner

@SpicyMarinara commented on GitHub (Sep 14, 2026):

Confirmed the startup ordering: Engine currently mounts the Experience only after opening narration. #6188 adds an optional package declaration to mount during preparation and wait for the existing package world-generation/retry flow before Start or first-turn retry can proceed. The package supplies bounded starting-world context to the existing opening-generation guide; Classic Game and packages without the declaration keep their current flow. Pixelforge changes stay in companion Pasta-Devs/Marinara-Agents#849, separate from its setup-wizard work in Pasta-Devs/Marinara-Agents#847.

<!-- gh-comment-id:5661284058 --> @SpicyMarinara commented on GitHub (Sep 14, 2026): Confirmed the startup ordering: Engine currently mounts the Experience only after opening narration. #6188 adds an optional package declaration to mount during preparation and wait for the existing package world-generation/retry flow before Start or first-turn retry can proceed. The package supplies bounded starting-world context to the existing opening-generation guide; Classic Game and packages without the declaration keep their current flow. Pixelforge changes stay in companion Pasta-Devs/Marinara-Agents#849, separate from its setup-wizard work in Pasta-Devs/Marinara-Agents#847.
Author
Owner

@SpicyMarinara commented on GitHub (Sep 14, 2026):

Fixed on staging by #6188 and Pasta-Devs/Marinara-Agents#849. Opted-in Experiences prepare their saved world before Start Game, and the opening receives that world context. Classic Game startup remains supported; Pixelforge uses the new Capability API 1.17 startup contract.

<!-- gh-comment-id:5662432400 --> @SpicyMarinara commented on GitHub (Sep 14, 2026): Fixed on staging by #6188 and Pasta-Devs/Marinara-Agents#849. Opted-in Experiences prepare their saved world before Start Game, and the opening receives that world context. Classic Game startup remains supported; Pixelforge uses the new Capability API 1.17 startup contract.
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#3442
No description provided.