[PR #5149] [MERGED] Capability API 1.12: spatial transition events for the game-owning Experience #6650

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5149
Author: @kolacheee
Created: 8/16/2026
Status: ✅ Merged
Merged: 8/16/2026
Merged by: @kolacheee

Base: staging ← Head: feat/5143-experience-spatial-events


📝 Commits (3)

  • 919c320 feat(capability): address spatial transition events to the game-owning Experience (capability API 1.12)
  • 89b9ff9 fix(client): streamEvents carries the parsed error body on its ApiError
  • 22f9e86 fix(capability): synthesize spatial rejects only on definitive evidence (review round)

📊 Changes

9 files changed (+209 additions, -29 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/development/optional-agent-packages.md (+24 -0)
📝 packages/client/src/hooks/use-generate.ts (+41 -9)
📝 packages/client/src/hooks/use-spatial-context.ts (+62 -6)
📝 packages/client/src/lib/api-client.ts (+13 -4)
📝 packages/client/src/lib/capability-client-events.ts (+21 -0)
📝 packages/shared/src/schemas/capability-package.schema.ts (+4 -1)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+5 -5)
📝 scripts/regressions/roleplay-streaming.regression.ts (+37 -4)

📄 Description

Linked issue

Closes #5143

Why this change

  • An Experience that sends a travel command (sendMessage's pendingSpatialTransition argument) never learns whether the move committed or was rejected — the spatial capability events are addressed to hierarchical-maps only. The reference Experience (Pixelforge) ships a two-turn stale-count heuristic as a stand-in, and every future Experience would need the same hack. During implementation a second, pre-existing gap surfaced that affects World Maps itself: on the game/roleplay owner-turn path the commit runs before the SSE stream opens, so a rejected transition surfaces only as an HTTP error and no reject event exists at all.

What changed

  • dispatchSpatialCapabilityEvent (new, in capability-client-events.ts) dual-dispatches every spatial event: once to hierarchical-maps, once to the chat's gameExperienceId package when present. Addressing stays filter-by-own-id — an addressed second dispatch, never a broadcast.
  • All six existing dispatch sites converted (SSE committed / SSE rejected / recovery in use-generate.ts, the finally-block spatial_context_refresh, and the REST commit success + onError-recovery paths in use-spatial-context.ts), with the owning package id resolved lazily from the cached chat row.
  • Silent-reject gap closed for both audiences: the generation catch path and the REST-commit onError branch now synthesize spatial_transition_rejected (with the error code in the payload) when a transition lands in needs_review. streamEvents now carries the parsed error body on its ApiError so that code is actually reachable.
  • supportedCapabilityApi → 1.12 (soft seam per the 1.11 precedent: delivered regardless of declared capabilityApi; a package declares 1.12 only to require the events). No manifest vocabulary changes.
  • Docs: a 1.12 section in docs/development/optional-agent-packages.md (includes the step_by_step/complete: false keep-pending rule). CHANGELOG entry added.
  • Regressions: the roleplay-streaming dispatch-shape pins updated, plus two new pins on the dual-dispatch contract and the reject synthesis.
  • Consumer follow-up: Pixelforge 0.4.1 consumes this in Marinara-Agents PR #384 (keeps its stale-count fallback for older engines); merge this PR first.

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

Performed by the submitting agent (boxes above intentionally left for the human reviewer):

  • pnpm check green; node scripts/run-regressions.mjs --filter roleplay-streaming passes with the updated and added pins.
  • Live end-to-end on this branch's build with hierarchical-maps 1.3.6 active and a real map, driving the Pixelforge 0.4.1 consumer: a committed travel delivered spatial_transition_committed addressed to pixelforge with the matching commandId (pending journey resolved the moment the turn settled); a deliberately stale map revision delivered the synthesized spatial_transition_rejected with code: "spatial_transition_stale_definition" and the journey cleared immediately. World Maps behavior unchanged throughout (its own events still arrive as before).
  • Still worth a human pass: a normal World Maps travel round-trip through the real UI in both roleplay and game modes.

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)

For the reviewer: this PR updates CHANGELOG.md and docs/development/optional-agent-packages.md, and [docs-i18n] follow-up issue #5150 is already open for the language-pack mirror. No version bump.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Spatial transition events are now delivered to both the Maps client and the game-owning Experience package.
    • Added committed, rejected, recovery, and context-refresh events with spatial details.
    • Added rejection events for definitive failures occurring before streaming begins.
    • Capability API support is updated to version 1.12.
  • Bug Fixes

    • Improved error handling preserves API response details for clearer transition failures.
    • Inconclusive failures now trigger a context refresh.
    • Incomplete travel steps remain pending until a completion event is received.

🔄 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/5149 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/16/2026 **Status:** ✅ Merged **Merged:** 8/16/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/5143-experience-spatial-events` --- ### 📝 Commits (3) - [`919c320`](https://github.com/Pasta-Devs/Marinara-Engine/commit/919c32049ee81d9025ca96f449d4ebcdc098aef4) feat(capability): address spatial transition events to the game-owning Experience (capability API 1.12) - [`89b9ff9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/89b9ff9bebf0ba927a3784e62af38f7459944911) fix(client): streamEvents carries the parsed error body on its ApiError - [`22f9e86`](https://github.com/Pasta-Devs/Marinara-Engine/commit/22f9e8683449bdfcb6a17cb9bfac74f331ae8786) fix(capability): synthesize spatial rejects only on definitive evidence (review round) ### 📊 Changes **9 files changed** (+209 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/development/optional-agent-packages.md` (+24 -0) 📝 `packages/client/src/hooks/use-generate.ts` (+41 -9) 📝 `packages/client/src/hooks/use-spatial-context.ts` (+62 -6) 📝 `packages/client/src/lib/api-client.ts` (+13 -4) 📝 `packages/client/src/lib/capability-client-events.ts` (+21 -0) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+4 -1) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+5 -5) 📝 `scripts/regressions/roleplay-streaming.regression.ts` (+37 -4) </details> ### 📄 Description ## Linked issue Closes #5143 ## Why this change - An Experience that sends a travel command (`sendMessage`'s `pendingSpatialTransition` argument) never learns whether the move committed or was rejected — the spatial capability events are addressed to `hierarchical-maps` only. The reference Experience (Pixelforge) ships a two-turn stale-count heuristic as a stand-in, and every future Experience would need the same hack. During implementation a second, pre-existing gap surfaced that affects World Maps itself: on the game/roleplay owner-turn path the commit runs *before* the SSE stream opens, so a rejected transition surfaces only as an HTTP error and no reject event exists at all. ## What changed - `dispatchSpatialCapabilityEvent` (new, in `capability-client-events.ts`) dual-dispatches every spatial event: once to `hierarchical-maps`, once to the chat's `gameExperienceId` package when present. Addressing stays filter-by-own-id — an addressed second dispatch, never a broadcast. - All six existing dispatch sites converted (SSE committed / SSE rejected / recovery in `use-generate.ts`, the finally-block `spatial_context_refresh`, and the REST commit success + onError-recovery paths in `use-spatial-context.ts`), with the owning package id resolved lazily from the cached chat row. - Silent-reject gap closed for both audiences: the generation catch path and the REST-commit onError branch now synthesize `spatial_transition_rejected` (with the error `code` in the payload) when a transition lands in `needs_review`. `streamEvents` now carries the parsed error body on its `ApiError` so that code is actually reachable. - `supportedCapabilityApi` → 1.12 (soft seam per the 1.11 precedent: delivered regardless of declared `capabilityApi`; a package declares 1.12 only to *require* the events). No manifest vocabulary changes. - Docs: a 1.12 section in `docs/development/optional-agent-packages.md` (includes the `step_by_step`/`complete: false` keep-pending rule). CHANGELOG entry added. - Regressions: the `roleplay-streaming` dispatch-shape pins updated, plus two new pins on the dual-dispatch contract and the reject synthesis. - Consumer follow-up: Pixelforge 0.4.1 consumes this in Marinara-Agents PR #384 (keeps its stale-count fallback for older engines); merge this PR first. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Performed by the submitting agent (boxes above intentionally left for the human reviewer): - `pnpm check` green; `node scripts/run-regressions.mjs --filter roleplay-streaming` passes with the updated and added pins. - Live end-to-end on this branch's build with hierarchical-maps 1.3.6 active and a real map, driving the Pixelforge 0.4.1 consumer: a committed travel delivered `spatial_transition_committed` addressed to `pixelforge` with the matching commandId (pending journey resolved the moment the turn settled); a deliberately stale map revision delivered the synthesized `spatial_transition_rejected` with `code: "spatial_transition_stale_definition"` and the journey cleared immediately. World Maps behavior unchanged throughout (its own events still arrive as before). - Still worth a human pass: a normal World Maps travel round-trip through the real UI in both roleplay and game modes. ## Docs and release impact - [ ] No docs changes needed - [x] 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) For the reviewer: this PR updates `CHANGELOG.md` and `docs/development/optional-agent-packages.md`, and `[docs-i18n]` follow-up issue #5150 is already open for the language-pack mirror. No version bump. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Spatial transition events are now delivered to both the Maps client and the game-owning Experience package. - Added committed, rejected, recovery, and context-refresh events with spatial details. - Added rejection events for definitive failures occurring before streaming begins. - Capability API support is updated to version 1.12. - **Bug Fixes** - Improved error handling preserves API response details for clearer transition failures. - Inconclusive failures now trigger a context refresh. - Incomplete travel steps remain pending until a completion event is received. <!-- 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-23 04:12:25 +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#6650
No description provided.