Skip to content

id: build: grant service — pending-transfer grants (register/vest/void) with control-plane grant records #2294

Open

Description

@dezren39

Follow-up from the #2065 design (doc/2026-10-29T12-10-00Z_design_refundable_grants_pending_transfers/, PR #2293). Buildable once the control-plane/gateway shape in #2062 is settled.

Scope

  • Control-plane grant table exactly as §2.3 of the design: id, steam_key_hash, user_id, ledger, amount, state, pending_transfer_id, resolution_transfer_id, window_started_at/ends_at, attempt counters.
  • Endpoints (§2.4): POST /grants (idempotent on steam_key_hash), POST /grants/{id}/vest, POST /grants/{id}/void, GET /grants/{id}, GET /users/{id}/grants.
  • TigerBeetle side: one flags.pending transfer per key from issuer.grant_pool to the holder account, dedicated grant code range, user_data_128 = grant id, user_data_64 = key hash; vest via post_pending_transfer + pending_id; refund via void_pending_transfer.
  • Partial refunds: void-and-reissue (§4) — TigerBeetle's void is all-or-nothing, so a partial refund voids the hold and issues a new pending transfer for the remainder, linked by correction_of.
  • Treat pending_transfer_already_posted / _voided / _expired as idempotent outcomes (409 at the API, success internally).

Not in scope

Vesting automation and drift detection — that is the reconciler issue. The refund-window value comes from the decision issue; use it as a config, never hard-coded.

Done when

Register → vest and register → void both work against a dev TigerBeetle cluster with targeted tests, double-resolution returns 409, and a partial refund leaves no posted credit behind.

Acceptance criteria

  • Grant table matches design §2.3 exactly (fields incl. pending/resolution transfer ids, window bounds, attempt counters)
  • Endpoints live: POST /grants (idempotent on steam_key_hash), vest, void, GET one, GET per-user
  • Register → vest and register → void both pass against a dev TigerBeetle cluster with targeted tests
  • Double-resolution returns 409; already-posted/voided/expired treated as idempotent outcomes internally
  • Partial refund via void-and-reissue leaves no posted credit behind; refund-window value comes from config, never hard-coded

Activity

  1. added
    status/needs-triage
    app/id
    on Oct 29, 2026
  2. developing-today commented on Oct 29, 2026

    @developing-today
    Contributor
  3. added
    priority/normal
    effort/l
    meta/enriched
    on Oct 29, 2026
  4. dezren39 commented on Oct 29, 2026

    @dezren39
    MemberAuthor

    Intake review

    Related: #2065 design (PR #2293, §2.3/§2.4/§4), #2062 (control-plane shape — buildable once settled), the refund-window decision issue #2296, epic #2056

    Notes: Foundational build for the refundable-grants family; #2295 (reconciler) depends on this table.

    Risks: TigerBeetle void is all-or-nothing — partial-refund correctness lives entirely in the void-and-reissue path; test it hardest.

    Suggested approach: Settle #2062 shape first, then table + endpoints, then the partial-refund tests.

    🤖 Agent note · filed

    • Agent: fleet monitor (repo-fleet-monitor)
    • Session / ID: repo-fleet-monitor run 2026-10-29T12:12Z (07:12 CDT)
    • Found via: monitor reconciliation
    • Task: Duty 2 intake enrichment — acceptance criteria appended (original body preserved verbatim above it), labels normalized, meta/enriched applied. Still-live check this pass: no merged PR or fix commit explicitly resolving this issue was found; where a queue triage task owns verification, it is named in the notes.
    • Expectation: see the effort label; done = the appended acceptance criteria are met.
    • Links: this issue
  5. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done — triage verdict: CONFIRMED, ORDERED (buildable design; two sibling dependencies + one Drew decision ahead of it)

    Verified fresh (2026-11-03)

    Blockers / ordering (recorded per the acceptance)

    1. id: build: TigerBeetle cluster provisioning — RTT mesh gate, 6-replica format, dead-replica runbook + rehearsal #2292 — TigerBeetle cluster provisioning (open, sibling): this issue's acceptance requires register → vest and register → void to pass against a dev TigerBeetle cluster. id: build: TigerBeetle cluster provisioning — RTT mesh gate, 6-replica format, dead-replica runbook + rehearsal #2292 is the sibling that provisions that cluster (RTT mesh gate, 6-replica format, rehearsal). Order: id: build: TigerBeetle cluster provisioning — RTT mesh gate, 6-replica format, dead-replica runbook + rehearsal #2292 first, or the build must stand up its own throwaway dev cluster and say so.
    2. id: decide: grant refund window length and whether pending tokens are spendable #2296 — refund-window decision (open, user/review, priority/high, Drew's): the window length (design recommends 14 days, Steam's window) and whether pending tokens are spendable are deliberately NOT to be defaulted in code — id: decide: grant refund window length and whether pending tokens are spendable #2296 was filed "so it is decided deliberately rather than defaulted in code". The build can plumb the value as config without the decision, but it must not ship a hard-coded or silently-chosen default; the decision gates calling this done.
    3. id: build: grant vesting reconciler and control-plane↔ledger drift alarm #2295 — vesting reconciler (open, sibling): explicitly out of scope here (per the body), listed only to fix the set order: id: build: TigerBeetle cluster provisioning — RTT mesh gate, 6-replica format, dead-replica runbook + rehearsal #2292 → id: build: grant service — pending-transfer grants (register/vest/void) with control-plane grant records #2294 → id: build: grant vesting reconciler and control-plane↔ledger drift alarm #2295, with id: decide: grant refund window length and whether pending tokens are spendable #2296 decided before id: build: grant service — pending-transfer grants (register/vest/void) with control-plane grant records #2294 is called done.

    Verdict

    Still live, correctly scoped, not yet startable as a clean single build until #2292 lands (or a dev-cluster substitute is declared) and #2296 is decided. No packet defect; routing stays a build task at effort/l once the ordering clears.

  6. added
    queue/queued
    source/creator
    task/triage
    and removed
    status/needs-triage
    on Nov 3, 2026
  7. developing-today commented on Nov 3, 2026

    @developing-today
    Contributor

    agent-note:v1
    state: triaged (coverage pass)
    Coverage pass 2026-11-03: reviewed in the fleet-wide per-issue pass (drift / overlap / already-handled / stale / blockers / ordering). Verdict: still live; queued in repo-health-code-pilot as triage at priority 40 (priority/normal). If this is already handled at current main, the triage closes it with evidence; if it needs splitting, the triage files the split.
    Found via: coverage pass 2026-11-03

  8. 79 remaining items

  9. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    Agent note (lane code-b, queue task 19739): first build slice landed.

    Merged: PR #11196 (merge commit 87cccd6) — new grants module in id-currency-registry:

    • Grant record + GrantState per design §2.3, plus correction_of (§4); GrantStore trait + in-memory impl with the duplicate-key rule (a voided grant's steam_key_hash may recur only via its own correction).
    • PendingLedger trait + StubLedger with TigerBeetle two-phase semantics (at-most-once resolution; pending/posted balances as the test oracle); grant transfers use code 0xF000 (reserved PendingHoldRedemption range).
    • GrantService: idempotent register on the sha256 key hash (key itself never stored), vest/void with double-resolution returning the 409 outcome and syncing the row to the ledger's truth, partial refund as void-and-reissue keeping the original vesting window. Window from config (14 days, id: decide: grant refund window length and whether pending tokens are spendable #2296 — never hard-coded); pending timeout = window + 72h (§6.3).
    • Migration 0002_grants (up/down) for the grant_record table.
    • Tests: 9 new acceptance tests; full crate suite green (11 lib + 6 factory + 9 grants); new module clippy-clean.

    Remaining for the full build (task 19739 stays the build vehicle, parked resumable): gateway HTTP endpoints (§2.4), Postgres GrantStore implementation, real TigerBeetle PendingLedger, and dev-cluster acceptance — the last gated by #2292, the build itself is not.

  10. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    Agent note (openchamber scheduled lane any-o, queue task 19739): triage verdict.

    Fresh state checked 2026-11-17: #2294 is OPEN. Slice 1 is MERGED as PR #11196 (merge 87cccd6): grants module, migration 0002, 9 acceptance tests, in-memory GrantStore and StubLedger seam.

    Verdict: not resolved and not closeable. Remaining slices, in the order the issue already records: gateway HTTP endpoints (design 2.4), Postgres GrantStore impl, real TigerBeetle PendingLedger. Dev-cluster acceptance is gated by #2292.

    No new follow-on packet is enqueued in this pass. The next slice is a build, so it should be packetized by the build owner when it starts, with this comment as the reference. Triaged; no status change on the issue.

  11. removed
    work/assigned
    on Nov 17, 2026
  12. removed their assignment
    on Nov 20, 2026
  13. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Merged work, still open. Every pull request that references this issue has merged (#11196) and none is open, but the issue kept status:in-review. Tasks that name it as a blocker have been waiting on it.

    status:in-review is removed. Whoever takes this next: run the issue's done check against main. Close the issue if it passes; if not, list what is left here and carry on with it (AGENTS.md, "Finishing work").

    By: Claude, 2026-11-22 flow review.


    Generated by Claude Code

  14. dezren39 commented on Nov 24, 2026

    @dezren39
    MemberAuthor

    Agent note (openchamber scheduled lane oc-code-01, queue task 21791, second-pass verify-and-route).

    Fresh state checked 2026-11-24: #2294 is OPEN. PR #11196 (grant service core) is MERGED and no PR referencing #2294 is open. The grant module, migration 0002 and in-memory GrantStore/StubLedger seam are on main.

    Verdict: not resolved, not closeable. Remaining work, in the issue's order: gateway HTTP endpoints (design 2.4), Postgres GrantStore impl, real TigerBeetle PendingLedger. Dev-cluster acceptance remains gated by #2292.

    No code changed in this pass. The follow-on build stays on this issue's remaining slices; no new packet enqueued here.

  15. developing-today-fleet commented on Nov 26, 2026

    @developing-today-fleet
    Contributor

    Agent note — triage (lane oc-code-02, task 24904)

    State: triaged — reconciliation pass; prior verdicts (any-o/19739, oc-code-01/21791) confirmed still correct.

    Fresh evidence (checked 2026-11-26T23:58Z via fleet gh):

    Triage verdict: not resolved, not closeable. No new packet from triage — the next slice is a build for the build owner to packetize, and the dev-cluster acceptance resumes when #2292 closes. Task 24904 completes as triaged.

  16. dezren39 commented on Nov 29, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · census 2026-11-29 (lane CEN-C03)

    Gate lifted: the body's precondition — 'buildable once the control-plane/gateway shape in #2062 is settled' — now holds: #2062 is CLOSED. One pre-build check remains from the body: take the refund-window value from the decision issue as config (never hard-coded). Scope and acceptance are complete. Priority: normal (unchanged).

  17. removed
    status/parked
    queue/parked
    on Nov 29, 2026
  18. developing-today-fleet commented on Nov 29, 2026

    @developing-today-fleet
    Contributor

    Census 2026-11-29 (Felix): full re-read (body, labels, all comments, native edges) in the CODE-6 recovery pass.

    STRENGTHS: complete design (four-surface state model, explicit gate condition); thorough triage history.
    GAPS: the park was stale — the recorded gate (park until #2062's subscription decision) has already lifted.
    FIXES I APPLIED: removed status/parked and queue/parked. Verified firsthand today: #2062 is CLOSED, so the park condition recorded on this thread no longer holds; status/triaged (already present) is now the operative state.
    REMAINS: the state-model implementation itself; no Drewry decision needed.

  19. removed
    status/triaged
    on Nov 29, 2026
  20. developing-today-fleet commented on Nov 29, 2026

    @developing-today-fleet
    Contributor

    Issue census — 2026-11-29

    Wave-2 census pass (group code-01409-03205): rechecked live state, body, labels and recent comments firsthand via fleet gh immediately before editing.

    Strengths: detailed body (2141 chars) with context a picker-up can start from; acceptance criteria present in the body; single taxonomy priority band (priority/normal) — verified against live labels; kind label present (kind/enhancement).

    Gaps found: none material.

    Actions taken this pass: labels: +[] -['status/triaged'].

    Priority: priority/normal — checked against content, unchanged (no reprioritization). No closing keywords used; issue left open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/ideffort/lepic/id-programkind/enhancementmeta/enrichedpriority/normalsource/creatortask/triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions