Skip to content

feat(id): grant service core — record, store, pending-ledger seam, register/vest/void/partial-refund (#2294) - #11196

Merged
dezren39 merged 1 commit into
mainfrom
queue/19739-2294-grant-service
Nov 17, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/19739-2294-grant-service

Conversation

@dezren39

@dezren39 dezren39 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

First build slice for #2294 (refundable grants / pending transfers), implementing the merged design in doc/2026-10-29T12-10-00Z_design_refundable_grants_pending_transfers/.

What lands

New grants module in id-currency-registry:

  • Grant record + GrantState (pending/posted/voided/expired/clawback_pending/clawback_settled/debt) per design §2.3, plus correction_of from §4.
  • GrantStore trait + in-memory implementation. Duplicate-key rule: a voided grant's steam_key_hash may recur only via its own correction (partial unique index in the migration matches).
  • PendingLedger trait + StubLedger enforcing TigerBeetle two-phase semantics (at-most-once resolution; credits_pending/credits_posted balances as the test oracle). GRANT_TRANSFER_CODE = 0xF000, the reserved PendingHoldRedemption range start.
  • GrantService: idempotent register on steam_key_hash (sha256; the key itself is never stored), vest/void with double-resolution returning the API 409 outcome and syncing the row to the ledger's truth, refund_partial as void-and-reissue keeping the original vesting window. Vesting window comes from config (14 days per id: decide: grant refund window length and whether pending tokens are spendable #2296, never hard-coded); pending-transfer timeout = window + 72h slack (§6.3).
  • Migration 0002_grants (up/down): grant_record table, u128 ids as text, amount numeric(39,0), unix-second times.

Tests

tests/grants_acceptance.rs: 9 acceptance tests (register→vest, register→void, double-resolution 409, partial refund leaves no posted credit, register idempotency, refund bounds, expiry sync, unknown grant, sha256 vector). Full crate suite green: 11 lib + 6 factory + 9 grants. Clippy clean for the new module (the two remaining crate warnings are pre-existing in factory.rs / factory_acceptance.rs).

Not in this slice

Gateway HTTP endpoints (§2.4), the Postgres GrantStore implementation, the real TigerBeetle PendingLedger, and dev-cluster acceptance (gated by #2292). Queue task 19739 remains the build vehicle for the follow-on slices.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 17, 2026 09:59
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-17T09:59:05.114206Z
We couldn’t complete this review. Comment @codex review to try again.
0757153 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 02574c15-d3dc-4c81-9ba8-83904ad71fef
Commits

Reviewing files that changed from the base of the PR and between 3b20b9d and 0757153.

Files ignored due to path filters: 1

  • pkgs/id/Cargo.lock is excluded by !**/*.lock
Files selected for processing: 6

  • pkgs/id/crates/id-currency-registry/Cargo.toml
  • pkgs/id/crates/id-currency-registry/migrations/0002_grants.down.sql
  • pkgs/id/crates/id-currency-registry/migrations/0002_grants.up.sql
  • pkgs/id/crates/id-currency-registry/src/grants.rs
  • pkgs/id/crates/id-currency-registry/src/lib.rs
  • pkgs/id/crates/id-currency-registry/tests/grants_acceptance.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@dezren39
dezren39 merged commit 87cccd6 into main Nov 17, 2026
1 check passed
@dezren39
dezren39 deleted the queue/19739-2294-grant-service branch November 17, 2026 09:59
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