Repository navigation
feat(id): currency status transitions (freeze/sunset) in the registry and gateway service (#13342) - #13547
Conversation
… and gateway service (#13342) Registry (id-currency-registry): - Store::set_currency_status is the status-transition write (InMemoryStore implements it against the currency row). - Registry::freeze_currency / sunset_currency share one issuer-only set_status with a documented transition table: Active -> Frozen, Active -> Sunset, Frozen -> Sunset (sunset stays reachable from frozen); sunset is terminal (InvalidTransition); repeats are idempotent successes. - RegistryError::InvalidTransition names the from/to statuses. Gateway service (pkgs/id): - handle() executes Freeze/Sunset through the registry write and records each as a posted intent (posted_simple, like registration and grants); the transition's idempotence is the write-ahead answer for a retry whose intent finalize was lost. - open() replays posted freeze/sunset intents over the rebuilt registry records (freezes before sunsets; the transitions are monotone), so a status survives restart. - F3 authorize(): lifecycle ops are authorized on existence plus issuer only (they are how a currency leaves Active); value ops keep requiring Active, and RegistryView already maps the registry status onto the view's active flag, so issue/transfer on a frozen or sunset currency refuse with InactiveCurrency. Layering documented in the module docs. Tests: 5 new registry acceptance tests (happy paths, non-issuer refusal, idempotent repeats, unknown currency, sunset terminal); a gateway authorize test pinning lifecycle authorization on an inactive currency; 3 new gateway-service tests (execute + value ops refuse, issuer- only + retry/repeat answers, restart replay). The old unsupported_ops_refuse_by_name test now pins a balance read instead of freeze/sunset.
|
Warning Review limit reachedYou'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 31 minutes. View limit details
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. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a435fa68be
ℹ️ 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".
| #[test] | ||
| fn issuer_can_freeze_then_sunset_and_sunset_is_terminal() { |
There was a problem hiding this comment.
Add generated coverage for the currency lifecycle model
The new lifecycle is a specified state machine with terminal-state, authorization, and idempotence invariants, but its coverage consists solely of hand-written examples. AGENTS.md requires property tests for invariants and model-based tests where a specification exists; the existing gateway property tests do not exercise lifecycle transitions. Add generated issuer/non-issuer freeze/sunset sequences against a three-state reference model, checking terminal-state monotonicity, idempotence, unchanged state after rejection, and equivalence after restart replay.
AGENTS.md reference: AGENTS.md:L37-L39
Useful? React with 👍 / 👎.
| /// currency's issuer may move its status — the same | ||
| /// issuer-only rule as `grant_minter` (design section 4.2). | ||
| /// | ||
| /// The transition table, decided here: |
There was a problem hiding this comment.
Record lifecycle decisions in the required dated design document
This adds public lifecycle APIs and decides terminal-sunset, repeat-idempotence, and restart-replay semantics, but records those decisions only in Rust comments. The earlier control-plane design defines the status flags and signed writes, not these transition/recovery choices; a repository-wide documentation search found no corresponding dated record. Add the dated design document required by pkgs/id/AGENTS.md, explaining the transition table and retry/replay rationale, so this behavioral/API change has the required architecture history.
AGENTS.md reference: pkgs/id/AGENTS.md:L159-L168
Useful? React with 👍 / 👎.
Implements #13342: the F1 registry gains a status-transition write and the production gateway service executes
freeze/sunsetthrough it.What changed
Registry (
pkgs/id/crates/id-currency-registry)Store::set_currency_status— the transition write on the store seam;InMemoryStoreimplements it against the currency row (UnknownLedgerwhen no currency row exists for the ledger).Registry::freeze_currency/Registry::sunset_currencyover one issuer-onlyset_status, with the transition table decided and documented in the method docs:Active → Frozen,Active → Sunset,Frozen → Sunset(sunset stays reachable from frozen, so freeze is never a trap short of the terminal state);Sunset → Frozenrefuses with the new typedRegistryError::InvalidTransition { from, to };RegistryError::NotIssuernow covers issuer-only writes generally (grant + transitions); its display text is neutral accordingly.Gateway service (
pkgs/id/src/currency/gateway_service.rs)handle()executes Freeze/Sunset (newset_statuspath) and records each as a posted intent via the sameposted_simpleshape as registration/grants — no ledger transfer exists to write ahead of; the transition's idempotence is the crash answer.GatewayService::open()replays posted freeze/sunset intents over the rebuilt registry records (all freezes before all sunsets; transitions are monotone), so a status survives restart.Unsupportedarms for freeze/sunset are gone (remainingUnsupportedfallback covers reads/convert as before).F3 authorization (
pkgs/id/src/currency/gateway.rs)active_currency, andRegistryViewalready maps the registry record's status onto the view'sactiveflag — so once a transition lands in the registry,issue/transferon that currency refuse withInactiveCurrency. Which layer refuses what is documented in the service module docs.Verification (laptop run, private target dir, sccache disabled)
cargo test -p id-currency-registry— 16 acceptance (5 new: happy paths incl. sunset-from-frozen, non-issuer refusal, idempotent repeats, unknown currency, sunset terminal) + 6 factory + 17 grants, all green.cargo test -p id --lib currency— 152 passed, 0 failed (incl. new gateway authorize test and 3 new service tests: execute + value ops refuse; issuer-only + exact-retry replay + fresh-id repeat; restart replay over the durable store).cargo test -p id --lib(full) — 572 passed, 4 failed; the 4 failures are the pre-existinghosted_exportfailures documented on id: 4 hosted_export tests fail on main (BlobCitationMismatch/MissingBlob) #13444 (BlobCitationMismatch/MissingBlobon main, flag-held), untouched by this change.cargo clippyon both crates — no warnings in the touched files (one pedantic or-pattern warning in the new match was found and fixed; remaining registry warnings are pre-existing in untouched files).Closes #13342
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.