Repository navigation
Description
Summary
pkgs/id/src/currency_poc/ledger.rs — InMemoryLedger, the in-memory LedgerBackend the conversion-executor scenarios run against in CI and the module's stated reference for a real client binding — accepts and posts account and transfer IDs that real TigerBeetle refuses outright: 0 and u128::MAX (TigerBeetle reserves both: IdMustNotBeZero / IdMustNotBeIntMax in the pinned tigerbeetle = "=0.17.9" crate, the statuses #6108 catalogues). The pure batch builder accepts the same shapes, so a conversion that "posts" in every in-memory scenario can never post on a real cluster.
create_accounts(ledger.rs,impl LedgerBackend for InMemoryLedger): the only validation isledger == 0→LedgerMustNotBeZero. There is no check onaccount.id(grep: zero occurrences ofid == 0in the file).validate_and_stage(ledger.rs): checksamount == 0, same-account, and ledger mismatch — but nevertransfer.id,debit_account_id, orcredit_account_idagainst0/u128::MAX.- The error enums have no variant for it:
AccountError(ledger.rs:84–92) andTransferError(ledger.rs:97–126) model zero ledger and zero amount, but no zero/int-max ID. build_conversion_batch(pkgs/id/src/conversion.rs:430ff): transfer IDs are checked for count and duplicates only — an explicit0(oru128::MAX) leg ID builds fine, as do account IDs of0in any of the five account fields. (The sibling ledger-0 builder gap is id(conversion): build_conversion_batch accepts ledger 0 — builds a batch that can never post, with no typed pre-ledger rejection #6102.)
Evidence (verified this run, laptop probe against the real id crate)
Probe: ~/git/fleet/probe-inmem-zero-id on the laptop (path dependency on pkgs/id, built and run on the laptop; the two source files are unchanged on current main — last touch ecf15d3 / be67273):
create_accounts(&[Account { id: 0, ledger: 100, .. }])→[Ok(())];lookup_account(0)→Some(0)create_accounts(&[Account { id: u128::MAX, ledger: 100, .. }])→[Ok(())]- Transfer
id: 0between two normal accounts →[Ok(())]; it posts (credit balance 500) andlookup_transfer(0)→Some((0, 500)) - Transfer
id: u128::MAX→[Ok(())];lookup_transfer(u128::MAX)→Some(5) build_conversion_batchwithtransfer_ids: [0, 1002]→Ok, leg IDs[0, 1002], and the in-memory backend posts both legs[Ok(()), Ok(())]; withcaller_source: 0→Ok, leg 0 debit account0- Controls — the zero checks that DO exist all fire: account
ledger: 0→Err(LedgerMustNotBeZero); transferamount: 0→Err(AmountMustNotBeZero); transferledger: 0→Err(LedgerMismatch)
On the real backend these same inputs return IdMustNotBeZero (account status 6 / transfer status 5) and IdMustNotBeIntMax (transfer status 6, plus the debit/credit account-ID variants 8–11) — today those statuses hit the panic catch-all in tb_ledger.rs (#6108); after #6108 they will be typed errors the in-memory backend still never produces.
Why it matters
InMemoryLedger is the test oracle for the executor: the #2063 §4 scenario coverage (posted conversion findable by user_data_128, atomic failure, crash recovery, pre-flight) runs against it. An oracle that accepts strictly more than the real system proves scenarios the real system rejects — ID-generation bugs (a default/unset ID of 0, an int-max sentinel leaking through) pass every in-memory test and only fail against a live cluster, the most expensive place to discover them. The module doc presents this backend as "implementing the TigerBeetle semantics the PoC depends on" and "usable as a reference for a real client binding" — ID validity is one of those semantics.
Acceptance criteria
-
InMemoryLedger::create_accountsrefusesid == 0andid == u128::MAXwith typedAccountErrorvariants (e.g.IdMustNotBeZero/IdMustNotBeIntMax), mirroring TigerBeetle's verdicts -
InMemoryLedger::create_transfersrefuses transferid == 0/u128::MAXand debit/credit account IDs of0/u128::MAXwith typedTransferErrorvariants, before any staging; a linked chain containing such a leg fails atomically like any other validation failure -
build_conversion_batchrejects0/u128::MAXintransfer_idsand in any account field with a typedConvertError, in its documented deterministic validation order (consistent with the direction of id(conversion): build_conversion_batch accepts ledger 0 — builds a batch that can never post, with no typed pre-ledger rejection #6102) - Pinning tests cover every refused shape on both backends' shared types, plus controls: ordinary IDs still post, and the existing ledger-0 / amount-0 refusals are unchanged
-
cargo test -p id --lib currency_pocand the conversion tests pass
Related
- 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 — the real-backend side: the same shapes return statuses the
tb_ledger.rsmappers currently panic on. After both issues, one input gets the same typed verdict on both backends. - id(conversion): build_conversion_batch accepts ledger 0 — builds a batch that can never post, with no typed pre-ledger rejection #6102 — sibling builder gap in the same function (ledger 0 accepted by
build_conversion_batch). - id(currency): RateAuthorisation::validate accepts internally inconsistent bodies — min>max, empty/inverted window, fee_bps>10000, empty/same ledgers #4071 / id: implement ID conversion engine - linked transfer pairs and rate authorisation (design #2063) #5536 — the wider conversion validation surface.
Activity
developing-today commentedon Nov 5, 2026
CODE-1774
dezren39 commentedon Nov 5, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 5, 2026
Enqueue note: the triage packet for issue #6135 was submitted to the repo-health-code-pilot queue twice during filing bookkeeping (the first call's output was truncated before its task id was visible); the second call returned task 9934. If the dedupe key did not collapse the two submissions, a duplicate triage task for this issue may exist — the second claimant/monitor should supersede it. Confirmed task: task 9934, dedupe key repo-health:v1:triage:developing-today/code:issue:6135.
dezren39 commentedon Nov 5, 2026
🤖 Agent note · handed off
10 remaining items
dezren39 commentedon Nov 5, 2026
🤖 Agent note · blocked
dezren39 commentedon Nov 9, 2026
Dropped-thread catcher — blocked-claim validation (2026-11-09T23:40Z)
Claim checked: queue task 9934 blocked this issue as a packet defect on 2026-11-05 — the packet said
kind=triage, but the issue's acceptance requires implementing typed ID validation inInMemoryLedgerandbuild_conversion_batchplus regression tests (agent note, 2026-11-05T09:04Z). Nothing has moved on the issue since that note.Live evidence: the issue is fully specified with file:line evidence (issue body):
create_accountsvalidates onlyledger == 0;validate_and_stagenever checkstransfer.id/debit_account_id/credit_account_idagainst0/u128::MAX;AccountError(ledger.rs:84–92) andTransferError(ledger.rs:97–126) model no zero/int-max ID variant. No external blocker, no missing decision, no Drew act — only the packet kind was wrong. Same packet-defect class already validated on opencode#1977 and opencode#2206.Action: the blocked state is stale. A fix-kind packet for this issue (implementation scope: ID validation in
create_accounts,validate_and_stage, andbuild_conversion_batch, with regression tests) was prepared by the catcher (packet-6135-fix.json, deduperepo-health:v1:fix:developing-today/code:issue:6135); the direct repo-queue enqueue currently routes code-pilot packets to the shadow queue, so this issue is instead being routed through the pilot feeder:status/blocked+queue/blockedremoved,queue/queuedadded. Task 9934's blocker explicitly requested this fix-kind re-enqueue.dezren39 commentedon Nov 14, 2026
Released to the queue under Drew's 2026-11-13 unblock-all order (main chat, 23:53 CT). Task(s) 15203 moved from blocked/parked to queued in the fleet unblock-all pass (worker
main-unblock-all-2026-11-13). Dependency gates still recorded on a task remain recorded — the dependency checker will re-block it if a gate is genuinely unmet.dezren39 commentedon Nov 14, 2026
🤖 Agent note · done (already_done)
Verdict — already done at current main; every acceptance item verified
Fresh verification this shift at origin/main (verify worktree at 1f6abda, code reads at e19c1a2):
InMemoryLedger::create_accountsrefuses reserved IDs:pkgs/id/src/currency_poc/ledger.rschecksaccount.id == 0→AccountError::IdMustNotBeZeroandaccount.id == u128::MAX→AccountError::IdMustNotBeIntMax(typed variants added with the 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 status mapping, commit 0952685).create_transfers/validate_and_stagerefuses them before staging: transferid,debit_account_id, andcredit_account_idare each checked against0andu128::MAXwith typedTransferErrorvariants (IdMustNotBeZero,IdMustNotBeIntMax,DebitAccountIdMustNotBeZero/IntMax,CreditAccountIdMustNotBeZero/IntMax) — ledger.rs lines 321–375.build_conversion_batchrejects reserved IDs:pkgs/id/src/conversion.rsvalidates every transfer ID and account ID (id == 0 || id == u128::MAX, typedConvertError), landed in commit 9015bfa (for 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) alongside the id(conversion): build_conversion_batch accepts ledger 0 — builds a batch that can never post, with no typed pre-ledger rejection #6102 ledger-0 rejection (fb5bb62). The executor preflight also rejects reserved transfer IDs (PR fix(id): reject reserved transfer IDs in currency_poc executor preflight (#6194) #8674, merged 2026-11-11, for id(currency_poc): executor preflight never checks transfer ID values — 0 / int-max IDs pass prepare, persist an intent, and post (in-memory) or strand as a poison Submitted record (real TigerBeetle) #6194;executor.rscites this issue's finding).in_memory_rejects_the_reserved_id_shapes_like_tigerbeetleandreserved_transfer_ids_fail_preflight_before_persisting_intent(currency_poc/tests.rs),rejects_reserved_transfer_ids_in_every_leg_positionandrejects_reserved_account_ids_in_every_role(conversion.rs). On the verify worktree (pkgs/id, via fleet-build-lock):cargo test --lib reserved— 10 passed, 0 failed;cargo test --lib conversion— 25 passed, 0 failed;cargo test --lib in_memory— 2 passed, 0 failed.Issue #6135 therefore closes as already-done: the in-memory backend and the batch builder now return the same typed verdicts as the real backend for every reserved-ID shape the issue lists. Task 15203 completes with outcome
already_done.dezren39 commentedon Nov 14, 2026
Agent note · done (already_done)