Skip to content

feat(catalog): support generic resource grants - #88

Merged
imjlk merged 4 commits into
mainfrom
codex/catalog-resource-grants
Jul 16, 2026
Merged

imjlk merged 4 commits into
mainfrom
codex/catalog-resource-grants

Conversation

@imjlk

@imjlk imjlk commented Jul 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add generic consumable resource grants to @mpgd/catalog
  • validate and preserve resource grants through the authoritative @mpgd/game-services ledger
  • keep the Verse8 adapter fail-closed until a resource wallet implementation is available

Why

Consumable game resources such as hints are neither currency nor durable entitlements. A dedicated grant type lets platform fulfillment award them through the existing catalog and ledger boundaries without leaking game-specific concepts into the kit.

Validation

  • pnpm graph:game-services
  • pnpm --filter @mpgd/catalog check
  • pnpm --filter @mpgd/catalog test
  • pnpm --filter @mpgd/game-services check
  • pnpm --filter @mpgd/game-services test
  • pnpm --filter @mpgd/adapter-verse8 check
  • pnpm --filter @mpgd/adapter-verse8 exec vitest run src/agent8.test.ts
  • pnpm validate:catalog
  • SAMPO_RELEASE_BRANCH=main pnpm sampo:release:dry-run

Summary by CodeRabbit

  • New Features

    • Added support for consumable, resource-based product grants (named resources with positive quantities).
    • Resource grants are now validated end-to-end and recorded during authoritative ledger transactions.
  • Bug Fixes

    • Adapter Verse8 now fails closed with a clear error for resource-based grants.
    • Verse8 product exposure is stricter: products missing a platform ID or using resource grants are omitted.
  • Tests

    • Expanded catalog, game-services, adapter, and entitlement-ledger test coverage for valid/invalid resource grants.

@coderabbitai

coderabbitai Bot commented Jul 16, 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: 33 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: 1b64db56-b078-47ee-b525-95b0d1c0dfd6

📥 Commits

Reviewing files that changed from the base of the PR and between 605f4c6 and e6631ef.

📒 Files selected for processing (4)
  • .sampo/changesets/catalog-resource-grants.md
  • packages/catalog/src/index.test.ts
  • packages/target-config/src/effective.ts
  • packages/target-config/test/target-config-smoke.ts
📝 Walkthrough

Walkthrough

Adds resource-based product grants to the catalog and game-services validation paths, preserves them in purchase ledger transactions, and makes Verse8 reject unsupported resource grants explicitly.

Changes

Resource Grant Support

Layer / File(s) Summary
Catalog resource grant contract
packages/catalog/src/index.ts, packages/catalog/src/index.test.ts, packages/catalog/package.json
ProductGrant now supports resource grants with string resources and numeric amounts; validation tests cover valid and invalid shapes.
Game-services validation and ledger flow
packages/game-services/src/types.ts, packages/game-services/src/types.test.ts, packages/game-services/src/server.test.ts, backend/entitlement-ledger/src/index.ts, backend/entitlement-ledger/src/index.test.ts, packages/game-services/package.json
Resource grants require non-empty resources and finite positive amounts, and verified purchases preserve the grant in ledger transactions.
Verse8 unsupported-grant guard
adapters/verse8/src/index.ts, adapters/verse8/src/index.test.ts, adapters/verse8/src/agent8.ts, adapters/verse8/src/agent8.test.ts, .sampo/changesets/catalog-resource-grants.md
Verse8 excludes resource products from commerce mappings and rejects resource grants with an explicit error, with coverage and release metadata.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AndroidPurchase
  participant GameServicesServer
  participant ProductCatalog
  participant LedgerStore
  AndroidPurchase->>GameServicesServer: verify HINT_PACK_5 purchase
  GameServicesServer->>ProductCatalog: resolve resource grant
  ProductCatalog-->>GameServicesServer: return hint amount 5
  GameServicesServer->>LedgerStore: write grant transaction
  LedgerStore-->>GameServicesServer: persist transaction
Loading
sequenceDiagram
  participant Verse8Purchase
  participant Agent8
  participant applyGrant
  Verse8Purchase->>Agent8: purchase hint-pack-5
  Agent8->>applyGrant: apply resource grant
  applyGrant-->>Agent8: throw unsupported resource error
  Agent8-->>Verse8Purchase: reject purchase
Loading

Possibly related PRs

  • imjlk/mpgd-kit#85: Implements the Agent8 grant-consumption path touched by this adapter guard.

Poem

A bunny found a grant of five,
And watched it safely ledger-live.
Verse8 said, “Not here, dear hare!”
The catalog checks with careful care.
Hop hop—the resource rules arrive!

🚥 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 is concise and accurately describes the main change: adding generic resource grants to catalog.
Description check ✅ Passed Summary and Validation sections are present and relevant; the optional Notes section is missing, but the description is otherwise complete.
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/catalog-resource-grants

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: bd52b6d350

ℹ️ 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/verse8/src/agent8.ts Resolved
Comment thread packages/catalog/src/index.ts Resolved
Comment thread packages/catalog/src/index.ts Resolved
@imjlk

imjlk commented Jul 16, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 4b63f06daf

ℹ️ 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 force-pushed the codex/catalog-resource-grants branch from 4b63f06 to 605f4c6 Compare July 16, 2026 10:55
@imjlk

imjlk commented Jul 16, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@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: 1

🤖 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 `@packages/catalog/src/index.test.ts`:
- Around line 9-13: Remove the assertEqual wrapper around assertProductGrant in
the generic resource grant test, invoking the assertion function directly so
successful validation does not compare its void return value with resourceGrant.
Preserve the existing test description and valid-case behavior.
🪄 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: 665f181f-9a00-4657-8970-0bc0dfd1ca17

📥 Commits

Reviewing files that changed from the base of the PR and between bd52b6d and 605f4c6.

📒 Files selected for processing (14)
  • .sampo/changesets/catalog-resource-grants.md
  • adapters/verse8/src/agent8.test.ts
  • adapters/verse8/src/agent8.ts
  • adapters/verse8/src/index.test.ts
  • adapters/verse8/src/index.ts
  • backend/entitlement-ledger/src/index.test.ts
  • backend/entitlement-ledger/src/index.ts
  • packages/catalog/package.json
  • packages/catalog/src/index.test.ts
  • packages/catalog/src/index.ts
  • packages/game-services/package.json
  • packages/game-services/src/server.test.ts
  • packages/game-services/src/types.test.ts
  • packages/game-services/src/types.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • .sampo/changesets/catalog-resource-grants.md
  • packages/game-services/src/types.ts
  • packages/catalog/src/index.ts
  • packages/game-services/src/server.test.ts

Comment thread packages/catalog/src/index.test.ts Resolved
@imjlk

imjlk commented Jul 16, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@imjlk

imjlk commented Jul 16, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai

coderabbitai Bot commented Jul 16, 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: bdcf753391

ℹ️ 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/verse8/src/index.ts Resolved
@imjlk

imjlk commented Jul 16, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@imjlk

imjlk commented Jul 16, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai

coderabbitai Bot commented Jul 16, 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. More of your lovely PRs please.

Reviewed commit: e6631efbb0

ℹ️ 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 4307985 into main Jul 16, 2026
6 checks passed
@imjlk
imjlk deleted the codex/catalog-resource-grants branch October 27, 2026 11:26
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