Skip to content

feat: unify platform game flow contracts - #38

Merged
imjlk merged 15 commits into
mainfrom
codex/platform-game-flow-contracts
Jul 11, 2026
Merged

imjlk merged 15 commits into
mainfrom
codex/platform-game-flow-contracts

Conversation

@imjlk

@imjlk imjlk commented Jul 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add shared identity-session, launch/presentation, share, inbound-share, and notification contracts across browser, Apps in Toss, Capacitor, Devvit, and native bridge hosts.
  • Model integration readiness independently from feature flags so each target can expose configured, supported, approval-required, configuration-required, disabled, or unsupported states safely.
  • Add bounded and server-verified guest-progress reconciliation plus durable, fenced, idempotent notification-delivery contracts.
  • Wire identity sessions and launch intents into the example and generated Phaser starters, with conservative Devvit declarations and a platform game-flow guide.
  • Keep the private AIT host self-contained for actual ait packaging, and prevent ttsx/graph checks from emitting files into package source trees.

Trust boundaries

  • Client share and launch payloads remain untrusted inputs.
  • Progress linking requires issued handoff verification, server-owned progress verification, bounded payloads, and atomic deduplication.
  • Notification delivery requires a durable claim ledger, fenced completion/release operations, and an idempotent provider.
  • The AIT host preserves the official Toss game-user hash resolver from main: strict getPlayer errors remain intact, while a verified hash maps to a platform-anonymous, platform-asserted session and failures fall back to guest/local.

Per-commit Open Code Review

  • ecd7a9c: no High/Medium findings; 2 Low maintainability suggestions.
  • 3b7a57f: 1 Medium tautological-smoke finding fixed by 8202216; 4 Low suggestions.
  • 3742ee6: 3 Medium validation/store-boundary findings fixed or explicitly documented by 318092a; 2 Low suggestions.
  • cc83af6, e15576b, 1643885: no findings after final review.
  • 44a4451: 1 Medium suggestion to restore the package alias was intentionally not applied because the AIT packager fails on that workspace runtime dependency; the source-only type import is erased and the full ait artifact build passes.
  • 318092a, 8202216: follow-up reviews completed with no findings.

Validation

  • pnpm test
  • pnpm check
  • pnpm pack:packages
  • pnpm validate:catalog
  • pnpm validate:ads
  • pnpm validate:target-config
  • pnpm validate:effective-config
  • pnpm validate:targets
  • pnpm graph:preflight
  • pnpm build:web
  • pnpm build:microsoft-store
  • pnpm build:ait, including mpgd-kit.ait creation
  • pnpm build:devvit
  • pnpm build:android, including release AAB and manifest
  • pnpm build:ios, including Capacitor sync and release manifest
  • Sampo release dry-run with all four changesets

Deferred game-specific work

  • Game modes, difficulty rules, and daily-content scheduling remain game-owned.
  • Reddit inline preview/client transition, referrals, app mentions, and realtime wiring remain follow-up platform integrations.

Summary by CodeRabbit

  • New Features
    • Added shared platform game-flow contracts for identity sessions/upgrades, launch intents, presentation controls, sharing (inbound + outbound), and notification subscriptions across supported adapters.
    • Introduced durable, idempotent notification delivery and secure guest-progress reconciliation (progress links).
    • Browser gateway now supports Web Share with clipboard fallback and inbound-link parsing, with runtime capability detection.
  • Documentation
    • Added “Shared Platform Game Flow” guidance and updated starter/kit checklists and README for the new integration model.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@imjlk, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 23 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c29cbdad-1d89-484f-8162-31bf76b7f28d

📥 Commits

Reviewing files that changed from the base of the PR and between a63f57e and e83ed78.

📒 Files selected for processing (7)
  • apps/target-ait/src/aitBridge.test.ts
  • apps/target-ait/src/aitBridge.ts
  • apps/target-ait/vite.config.ts
  • packages/bridge/src/cloudflare-pages.test.ts
  • packages/bridge/src/cloudflare-pages.ts
  • packages/target-config/src/runtime.ts
  • packages/target-config/test/target-config-smoke.ts
📝 Walkthrough

Walkthrough

Adds shared identity, launch, presentation, sharing, and notification contracts; target integration readiness snapshots; Phaser starter bootstrap fallbacks; bounded progress reconciliation; and durable, idempotent notification delivery.

Changes

Game services

Layer / File(s) Summary
Progress reconciliation
packages/game-services/src/progress-link.ts, packages/game-services/src/progress-link.test.ts
Adds verified, bounded guest-progress reconciliation with deterministic merging and idempotency.
Notification delivery
packages/game-services/src/notification-delivery.ts, packages/game-services/src/notification-delivery.test.ts
Adds validated notification delivery with provider routing, ledger claims, leases, retries, and completion reconciliation.
Package exports
packages/game-services/package.json, packages/game-services/src/index.ts, packages/game-services/src/server.ts
Publishes the new modules and runs their tests.

Platform flow adapters

Layer / File(s) Summary
Platform and bridge contracts
packages/platform/src/index.ts, packages/bridge/src/*
Adds typed identity, presentation, sharing, notification, and bridge-method contracts.
Adapter implementations
adapters/*, apps/target-ait/*, apps/target-devvit/*, native-plugins/*
Implements or stubs the new flows across browser, AIT, Capacitor, Devvit, and native bridges.
Browser sharing and launch behavior
adapters/browser/src/*
Adds URL launch parsing, inbound-share parsing, Web Share support, and clipboard fallback.

Target readiness

Layer / File(s) Summary
Integration configuration and runtime
packages/target-config/src/*, packages/target-config/targets.json
Adds per-target integration states, presentation modes, runtime availability computation, and conditional gateway adapters.
Runtime validation
packages/target-config/test/*, tools/smoke/*
Validates normalized configuration, adapter support, runtime clamping, and delegated calls.

Starter flow and documentation

Layer / File(s) Summary
Starter bootstrap
examples/phaser-starter/src/*, packages/cli/templates/phaser-game/src/*
Resolves identity sessions and launch intents before Phaser scene creation, with guest and home fallbacks.
Guidance and release metadata
docs/PLATFORM_GAME_FLOW.md, README.md, examples/phaser-starter/agent/*, packages/cli/templates/phaser-game/agent/*, .sampo/changesets/*
Documents platform flow boundaries, acceptance requirements, generated-starter wiring, and release notes.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

  • imjlk/mpgd-kit#1: Shares Phaser starter agent workflow artifacts and platform-flow guidance.
  • imjlk/mpgd-kit#2: Overlaps on Devvit bridge handling for identity, presentation, sharing, and notifications.
  • imjlk/mpgd-kit#21: Overlaps on Cloudflare Pages bridge handlers and platform-flow fallback responses.

Poem

A rabbit hops through flows so bright,
Guest sessions tucked in right.
Shares go out, links come in,
Ledgers guard each tiny win.
Progress merges, safe and neat—
Platform paths are now complete! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: unifying platform game flow contracts across the repo.
Description check ✅ Passed The description covers Summary, Validation, and Notes content, and is mostly complete despite using custom headings instead of the template’s exact Notes section.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/platform-game-flow-contracts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 820221677f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread adapters/browser/src/index.ts Resolved
Comment thread packages/bridge/src/index.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/target-ait/src/aitBridge.ts`:
- Around line 328-358: Update shareIntent to handle AbortError separately from
other failures: when getTossShareLink or share rejects with an AbortError,
return the ShareResult-compatible cancelled status; retain unavailable for
validation failures and all other errors, including the existing warning
behavior. Ensure the function’s return type includes cancelled and identify
AbortError robustly.

In `@packages/game-services/src/notification-delivery.ts`:
- Around line 513-519: Update normalizeTemplateData to enforce the 128-property
limit before calling Object.entries or otherwise materializing all values. After
assertRecord, incrementally count own enumerable properties and throw once the
count exceeds 128, then build the entries only after validation.

In `@packages/game-services/src/progress-link.ts`:
- Around line 468-470: In the metric-map handling logic around assertRecord,
avoid calling Object.entries before enforcing the entry limit; first count the
input’s own enumerable properties using a bounded approach, call
assertCollectionLimit with that count, then materialize Object.entries only
after validation and continue processing the entries.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 667f8e60-5f39-4c1f-bfc6-830aba7a744f

📥 Commits

Reviewing files that changed from the base of the PR and between d318b06 and 8202216.

📒 Files selected for processing (47)
  • .sampo/changesets/game-services-platform-flow.md
  • .sampo/changesets/platform-game-flow-adapters.md
  • .sampo/changesets/starter-platform-flow.md
  • .sampo/changesets/target-integration-readiness.md
  • README.md
  • adapters/ait/src/index.test.ts
  • adapters/ait/src/index.ts
  • adapters/browser/src/index.test.ts
  • adapters/browser/src/index.ts
  • adapters/capacitor/src/index.test.ts
  • adapters/capacitor/src/index.ts
  • adapters/devvit/src/index.test.ts
  • adapters/devvit/src/index.ts
  • apps/target-ait/src/aitBridge.ts
  • apps/target-devvit/src/server/index.ts
  • docs/PLATFORM_GAME_FLOW.md
  • examples/phaser-starter/agent/acceptance.md
  • examples/phaser-starter/agent/brief.template.md
  • examples/phaser-starter/agent/game.manifest.json
  • examples/phaser-starter/src/main.ts
  • examples/phaser-starter/src/runtime/starterContext.ts
  • native-plugins/capacitor-game-services/android/src/main/java/dev/mpgd/capacitor/CapacitorGameServicesPlugin.java
  • native-plugins/capacitor-game-services/ios/Sources/CapacitorGameServices/CapacitorGameServicesPlugin.swift
  • packages/bridge/src/bridge-protocol.test.ts
  • packages/bridge/src/fixtures.ts
  • packages/bridge/src/index.ts
  • packages/cli/templates/phaser-game/agent/acceptance.md
  • packages/cli/templates/phaser-game/agent/game-manifest.json
  • packages/cli/templates/phaser-game/apps/target-devvit/src/server/index.ts
  • packages/cli/templates/phaser-game/src/main.ts
  • packages/cli/templates/phaser-game/src/runtime/gameContext.ts
  • packages/game-services/package.json
  • packages/game-services/src/index.ts
  • packages/game-services/src/notification-delivery.test.ts
  • packages/game-services/src/notification-delivery.ts
  • packages/game-services/src/progress-link.test.ts
  • packages/game-services/src/progress-link.ts
  • packages/game-services/src/server.ts
  • packages/platform/src/index.ts
  • packages/target-config/src/effective.ts
  • packages/target-config/src/runtime.ts
  • packages/target-config/targets.json
  • packages/target-config/test/target-config-smoke.ts
  • tools/smoke/effective-target-config.ts
  • tools/smoke/target-config-runtime.ts
  • tsconfig.graph.json
  • tsconfig.tools.json

Comment thread apps/target-ait/src/aitBridge.ts Resolved
@imjlk

imjlk commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@imjlk

imjlk commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Addressed all five unresolved review threads in 646ff51, 1cda2a9, and a63f57e. All thread replies include validation details; please re-review the latest head.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a63f57ecbb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/bridge/src/cloudflare-pages.ts Resolved
Comment thread packages/target-config/src/runtime.ts Resolved
Comment thread apps/target-ait/src/aitBridge.ts Resolved
@imjlk

imjlk commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Second feedback round addressed in bdad794, 850f5e8, and e83ed78. All three new P2 threads are replied to and resolved; please re-review the latest head.

@imjlk

imjlk commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: e83ed78c2b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@imjlk
imjlk merged commit 77a1d1b into main Jul 11, 2026
5 checks passed
@imjlk
imjlk deleted the codex/platform-game-flow-contracts branch July 15, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant