Repository navigation
Description
Summary
pkgs/id/src/conversion.rs — the production pure conversion layer (Phase E of #2063, landed under #5536) — builds a linked conversion batch for transfer IDs and account IDs of 0 or u128::MAX without any rejection. Both values are reserved in TigerBeetle: an ID of 0 is never a valid account/transfer ID (id must not be zero) and u128::MAX is the reserved int-max sentinel, so every leg built with one is refused outright at submission. The builder mirrors the ledger's other hard rules as typed pre-ledger ConvertErrors — ZeroAmount, SameAccount, duplicate transfer IDs — but has no ID-validity variant at all, so the failure surfaces only at ledger submission time instead of as a typed pre-ledger rejection.
Evidence (verified this run, laptop primary @2f470e0e65; conversion.rs unchanged at current main @97cd55c865)
build_conversion_batch(pkgs/id/src/conversion.rs:430) validates, in order: zero amount (:433), min/max bounds, rate/scale/fee terms (viaconvert_amount/fee_amount), same-account for the source/destination/fee legs, fee-account presence, and transfer-ID count + duplicates. A module-wide grep foru128::MAX/ ID zero checks finds none for IDs: the only== 0checks areamount_in,rate_den, and the computedamount_out. Transfer IDs are only counted and deduped; account IDs are only compared for equality between roles.- Probe (laptop,
~/git/fleet/probe-conversion-ids, realidcrate): with an otherwise-sane request (ledgers 100/200, amount 1000, rate 3/2, min 10 / max 10_000), each of these returnedOkand built a full batch:transfer_ids = [0, 22]— source leg built withid=0transfer_ids = [11, 0]— destination leg built withid=0transfer_ids = [u128::MAX, 22]— source leg built withid=u128::MAXcaller_source = 0,lp_source = u128::MAX,caller_dest = 0,lp_dest = u128::MAX— legs built debiting/crediting the reserved IDs- fee leg shapes:
fee_account = Some(0)withfee_bps = 100(fee 10 > 0) andtransfer_ids = [11, 0, 33]— fee leg built withid=0/ crediting account0 - Control (all IDs ordinary) builds the expected 2-leg batch (
amount_out 1500).
- Real TigerBeetle refuses these IDs at submission: id(currency_poc): InMemoryLedger accepts and posts zero / int-max account and transfer IDs real TigerBeetle refuses — the reference backend is a broken oracle for ID validity #6135 established (with a probe of the in-memory backend) that TB rejects zero / int-max account and transfer IDs (
IdMustNotBeZero/ int-max class) while accepting ordinary IDs. The Phase F executor persists the intent first and submits exactly the batch built here, so a reserved ID becomes a persisted, submitted, refused conversion instead of a build-time rejection.
Why it matters
The module's own contract is that rejections happen before any ledger write, with typed reasons: "ConvertError — Why a conversion quote or batch cannot be built. Every variant is a rejection before any ledger write, per the failure table in #2063 §2.4." The builder already mirrors the ledger's hard rules — SameAccount mirrors AccountsMustBeDifferent, ZeroAmount mirrors AmountMustNotBeZero — and #6102 covers the one ledger-value mirror it also misses (ledger 0). ID validity is the remaining unmirrored hard rule: transfer IDs are caller-generated and persisted before submission (write-ahead discipline), so a generator or persistence bug that yields 0/MAX is exactly the class of error this layer exists to catch early; today nothing catches it until the ledger refuses the whole linked chain.
Related but distinct: #6102 covers source_ledger/dest_ledger == 0 in this same function (a ledger value, not an ID); #6135 covers InMemoryLedger accepting zero/int-max IDs (the backend oracle, not the builder); #6108 covers the tb_ledger status mappers panicking on the resulting TB statuses. Fixing any of those does not add an ID check here.
Acceptance criteria
build_conversion_batchrejects any transfer ID equal to0oru128::MAX, and any account ID (caller_source,lp_source,lp_dest,caller_dest, and a suppliedfee_account) equal to0oru128::MAX, with a new typedConvertErrorvariant (e.g.InvalidTransferId { id }/InvalidAccountId { id }or equivalent), before any leg is built.- The rejection order stays deterministic and is documented alongside the existing validation-order note in
build_conversion_batch's docs. - Pinning tests in
pkgs/id/src/conversion.rscover: zero and int-max in each transfer-ID position (source, fee, destination), zero and int-max in each account role, and the existing sane-ID requests still building identical batches. cargo test -p id --lib conversionpasses.
Scope notes
- Filed-only from the creator lane; not self-solved (the variant shape and its position in the validation order are the Phase F author's call, as with id(conversion): build_conversion_batch accepts ledger 0 — builds a batch that can never post, with no typed pre-ledger rejection #6102).
- Out of scope:
InMemoryLedgerID acceptance (id(currency_poc): InMemoryLedger accepts and posts zero / int-max account and transfer IDs real TigerBeetle refuses — the reference backend is a broken oracle for ID validity #6135),tb_ledgerunmodelled-status panics (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), ledger-zero (id(conversion): build_conversion_batch accepts ledger 0 — builds a batch that can never post, with no typed pre-ledger rejection #6102),RateAuthorisation::validate(id(currency): RateAuthorisation::validate accepts internally inconsistent bodies — min>max, empty/inverted window, fee_bps>10000, empty/same ledgers #4071).
Activity
developing-today commentedon Nov 5, 2026
CODE-1801
dezren39 commentedon Nov 5, 2026
🤖 Agent note · filed
idcrate):build_conversion_batchreturns Ok for transfer IDs 0 and u128::MAX in the source, fee, and destination positions, and for account IDs 0 / u128::MAX in every role (caller_source, lp_source, lp_dest, caller_dest, fee_account); the sane-ID control builds the expected batch (amount_out 1500). No ID-validity check exists anywhere in pkgs/id/src/conversion.rs (transfer IDs are only counted/deduped; account IDs only equality-compared). Distinct from id(conversion): build_conversion_batch accepts ledger 0 — builds a batch that can never post, with no typed pre-ledger rejection #6102 (ledger 0 in the same function), id(currency_poc): InMemoryLedger accepts and posts zero / int-max account and transfer IDs real TigerBeetle refuses — the reference backend is a broken oracle for ID validity #6135 (InMemoryLedger accepting the same IDs), and 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 (tb_ledger mapper panics). Enqueued as a repo-task/v1 triage packet on repo-health-code-pilot.dezren39 commentedon Nov 5, 2026
🤖 Agent note · picked up
292 remaining items
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off to opencode claimant — Agent: queue worker (repo-worker-code), lane code-n — Session/ID: task 9988, repo-queue-worker-shift-n 2026-11-09 run. Task 9988 (small_fix) for issue #6189: add typed ID-validity rejection to build_conversion_batch; attempts 3/8 on this claim. Fresh check: issue #6189 OPEN, no held/user/owned/do-not-merge/do-not-auto-edit labels, no status/needs-triage (labels also carry a stale status:in-review alongside status/parked — pre-existing divergence, left for the fleet monitor). Execution lane row 2576 = opencode (repeat handoff). Checkpointed handed_off with handoff_reason "scheduled shift is time-bounded; claimant is the persistent execution session" (#8097 Rule 4); parking task 9988 for 20 minutes for the claimant window.
dezren39 commentedon Nov 10, 2026
state: picked_up
task: 13508
lane: code-f
issue: #6189
pr: #7200
Lane code-f claimed task 13508 direct (#8187) to shepherd PR #7200. Fresh state: PR open, no hard-stop labels, Codex review has no unresolved findings; the old head's three failing checks (scripts-test, shellcheck, world snapshot) are in areas the PR diff does not touch. The PR is one commit on pkgs/id/src/conversion.rs. This shift rebases it onto current main (conflicts were additive — main's ZeroLedger checks/test plus this PR's account-ID validation/tests — resolved keeping both), runs the conversion tests, pushes, and parks as a CI wait or merges if checks go green inside the polling window.
id(conversion): add typed ID-validity rejection to build_conversion_b…
dezren39 commentedon Nov 10, 2026
state: parked
task: 13508
lane: code-f
issue: #6189
pr: #7200
Parked as a CI wait on PR #7200. This shift rebased the PR (one commit, pkgs/id/src/conversion.rs) onto current origin/main; the three conflicts were additive and were resolved keeping both sides — main's ZeroLedger checks and ledger test, plus this PR's account-ID validation and reserved-ID tests — with the validation-order doc updated to match. Verification:
cargo test --lib conversionin pkgs/id — 25 passed, 0 failed, including rejects_reserved_account_ids_in_every_role, rejects_reserved_transfer_ids_in_every_leg_position, and batch_rejects_zero_ledgers_but_builds_for_sane_ledgers; rustfmt check passes; new head 5006e58 pushed with force-with-lease; Codex review has no unresolved findings. The old head's failing checks (scripts-test, shellcheck, world snapshot) are outside this PR's diff. Resume condition: PR #7200 checks complete — merge if green under the standing criteria.id(conversion): add typed ID-validity rejection to build_conversion_b…
Merge pull request #7200 from developing-today/queue/9988-6189-conver…
dezren39 commentedon Nov 11, 2026
Agent note — done (already_done)
cargo test --lib conversion25/25 including the reserved-ID pinning tests. Issue id(conversion): build_conversion_batch accepts zero / int-max transfer and account IDs — builds a batch real TigerBeetle refuses outright, with no typed pre-ledger rejection #6189 is CLOSED.