Repository navigation
fix(id/currency_poc): map every reachable TigerBeetle status to a typed error (#6108) - #8670
Conversation
|
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 30 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. |
9b72220 to
c15948e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c15948e784
ℹ️ 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".
| if transfer.id == 0 { | ||
| return Err(TransferError::IdMustNotBeZero); | ||
| } | ||
| if transfer.id == u128::MAX { | ||
| return Err(TransferError::IdMustNotBeIntMax); |
There was a problem hiding this comment.
Validate reserved transfer IDs before consulting failed IDs
When an unlinked transfer with ID 0 or u128::MAX is submitted twice, the first call returns the new ID-validation error, but create_transfers caches that failure in failed_transfers, so the second call returns IdAlreadyFailed before reaching these checks. This contradicts the intended backend parity: TigerBeetle 0.17.9 validates these reserved IDs before its existing/failed-transfer lookup and therefore consistently returns the ID-validation error. Move these checks ahead of the failed-ID lookup so retries produce the same typed outcome on both backends.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 09526854d0 — thank you, the ordering divergence was real. The reserved transfer-ID checks (IdMustNotBeZero / IdMustNotBeIntMax) now sit at the top of InMemoryLedger::validate_and_stage, ahead of the failed-ID lookup, matching TigerBeetle 0.17.9's validation order. The account-ID checks already preceded every lookup in create_accounts (account failures are not cached in this backend), so no change was needed there.
Also added the missing regression coverage: in_memory_rejects_the_reserved_id_shapes_like_tigerbeetle submits each reserved transfer ID twice and asserts the ID error both times (previously the second submission returned IdAlreadyFailed), plus the reserved account-ID and debit/credit-ID shapes. Correction to the PR description: it originally cited this parity test as if it already existed — it did not; it exists as of this commit. The full currency_poc suite is re-running against this head.
c15948e to
0952685
Compare
Summary
Implements #6108: the TigerBeetle status mappers in
pkgs/id/src/currency_poc/tb_ledger.rsno longer fall through to a catch-all for reachable statuses.map_account_status/map_transfer_statusare now exhaustive matches with no wildcard arm — a future tigerbeetle crate bump that adds a status fails to compile here instead of surprising production.ledger.rsfor the reachable families the issue enumerates: zero/int-max transfer and account IDs (IdMustNotBeZero,IdMustNotBeIntMax,DebitAccountIdMustNotBeZero/IntMax,CreditAccountIdMustNotBeZero/IntMax), closed accounts (DebitAccountAlreadyClosed,CreditAccountAlreadyClosed), mutually exclusive flags, non-zero initial balances (InitialBalanceMustBeZero), linked-batch failures on the account side (LinkedEventFailed,LinkedEventChainOpen),CodeMustNotBeZero, andOverflowsTimeout.UnmodelledStatus, each with a comment saying why it is unreachable.InMemoryLedgernow rejects the same zero/int-max ID shapes with the same typed errors, so scenario tests mean the same thing on both backends. (Before, it accepted account/transfer ID 0 that a real cluster refuses.)tb_ledger.rslist everyCreateAccountStatus/CreateTransferStatusvariant of the pinned crate (=0.17.9) with its expected mapping and assert no variant panics (oracle: issue id(currency_poc/tb_ledger): status mappers panic on unmodelled-but-ordinary TigerBeetle statuses (zero/int-max IDs, closed accounts) the in-memory backend accepts #6108's acceptance criteria).Verification status
Local
cargo test --features currency-poc-tb --lib currency_pocis still queued behind the fleet build lock on the laptop (load >50 from concurrent lane builds; detached job3b57d88af21b, log at~/git/fleet/9922-6108/test.login the task worktree). This PR is opened per the queue runbook's outcome-early rule; task 9922 parks as a CI wait and resumes on checks. Do not merge until the currency_poc suite is green (CI or the detached local run) and any Codex findings are dispositioned.Closes #6108 once merged.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.