Skip to content

id(currency_poc): InMemoryLedger forgets failed transfer IDs — a failed transfer resubmits and posts after funding, real TigerBeetle refuses it forever (IdAlreadyFailed) #6150

Closed

Description

@dezren39

Summary

pkgs/id/src/currency_poc/ledger.rs — InMemoryLedger never remembers failed transfer IDs, so it can never return TransferError::IdAlreadyFailed — while real TigerBeetle remembers a failed transfer's ID permanently and refuses every resubmission of it. A transfer (or linked chain) that fails in the in-memory backend can be resubmitted later — after the blocker clears, e.g. the debit account is funded — and it posts. On a real cluster the same recovery resubmission is refused id_already_failed and the conversion can never post with those IDs.

  • The variant exists and is documented for exactly this: TransferError::IdAlreadyFailed (ledger.rs:97–103) — "TigerBeetle remembers failed transfer IDs and refuses their resubmission (id_already_failed). A recovery resubmission meeting this is a rejected resubmission, not a posting."
  • The real backend maps it: tb_ledger.rs:223 — Status::IdAlreadyFailed => Err(TransferError::IdAlreadyFailed).
  • The in-memory backend never produces it: an exhaustive grep of pkgs/id/src/currency_poc/ finds IdAlreadyFailed only at its definition (ledger.rs:101–103) and the TB mapper (tb_ledger.rs:223) — the only other mention of the concept is the snake_case status name in the live-test comment (tests.rs:1491). InMemoryLedger records only posted transfers (transfers / transfer_order, ledger.rs:152–156); a chain that fails in create_transfers (ledger.rs:270ff) stages nothing and records nothing about the failed IDs, so a later resubmission is validated from scratch as if the first attempt never happened.
  • The pinned behaviour exists only as a live-cluster test: live_failed_conversion_recovery_reports_resubmission_rejected (tests.rs:1478ff, #[cfg(feature = "currency-poc-tb")], #[ignore] — requires the pinned TigerBeetle binary) asserts that after a failed conversion, recovery resubmission is refused (id_already_failed, comment at tests.rs:1491) and surfaces as ResubmissionRejected. There is no in-memory counterpart — and with the current backend there cannot be one that passes: in-memory, once liquidity is restored, recovery::reconcile (recovery.rs:110–125) resubmits the legs, they post, and the record is marked Posted instead of ResubmissionRejected.

Evidence (verified this run, laptop probe against the real id crate)

Probe: ~/git/fleet/probe-failed-id on the laptop (path dependency on the real pkgs/id crate), at laptop primary HEAD 266875e1e02f8312d63baec10cdf03f917687578 (line citations re-verified at this HEAD):

PROBE create_accounts: [Ok(()), Ok(()), Ok(())]
PROBE t42 first submit (unfunded): [Err(DebitsMustNotExceedCredits)]
PROBE t42 identical resubmit (still unfunded): [Err(DebitsMustNotExceedCredits)]
PROBE fund USER id=1: [Ok(())]
PROBE USER balance after funding: Some(AccountBalance { debits_posted: 0, credits_posted: 1000 })
PROBE t42 resubmit after funding: [Ok(())]
PROBE lookup_transfer(42): Some((42, 500))
PROBE LP balance: Some(AccountBalance { debits_posted: 0, credits_posted: 500 })
PROBE t43 amount=0 submit: [Err(AmountMustNotBeZero)]
PROBE t43 fixed-amount resubmit (different fields): [Ok(())]
PROBE chain 50/51 first submit: [Err(DebitsMustNotExceedCredits), Err(LinkedEventFailed)]
PROBE fund USER id=2: [Ok(())]
PROBE chain 50/51 identical resubmit after funding: [Ok(()), Ok(())]
PROBE lookup_transfer(50): Some((50, 600))
PROBE USER balance final: Some(AccountBalance { debits_posted: 1100, credits_posted: 2600 })

No resubmission ever returns IdAlreadyFailed: the failed transfer 42 posts once funded, the validation-failed ID 43 posts with corrected fields, and the failed linked chain 50/51 posts byte-identical after funding.

Controls in the same run: account creation and the funding transfers post normally; the first submission of each failing shape returns the expected original error (the failure itself is modelled — only the memory of the failure is missing).

On the real backend each resubmission above returns IdAlreadyFailed (tb_ledger.rs:223) and nothing ever posts with those IDs — the exact behaviour the live test at tests.rs:1478 pins for the recovery path.

Why it matters

InMemoryLedger is the executor's test oracle (see #6135 / #6108 for the sibling divergences): every non-live scenario test, including the whole recovery suite, runs against it. The recovery scanner's central promise is "absent from the ledger ⇒ the submission never landed, so the same IDs may be safely resubmitted" (recovery.rs module docs; intent.rs:9) — but on TigerBeetle "absent" has two different meanings: never submitted (resubmittable) and submitted and failed (poisoned forever). The in-memory backend collapses them into one, so the in-memory recovery tests certify a resubmission path that, against a real cluster, strands the intent as ResubmissionRejected — and, worse, a scenario in which a failed conversion later posts after re-funding passes in-memory while being impossible in production. The one test that pins the real behaviour is #[ignore]d and needs a live cluster, so CI never runs it.

Acceptance criteria

  • InMemoryLedger records the IDs of transfers that failed for their own reason (validation / balance-invariant failures, including the failing leg of a linked chain), and any later submission of a recorded ID returns Err(TransferError::IdAlreadyFailed) — regardless of whether the resubmitted fields match or differ, and regardless of whether the original blocker has cleared
  • The treatment of LinkedEventFailed legs (siblings of the failing leg) is decided explicitly and pinned by a test, consistent with what the TB binding observes on resubmission of a failed chain (the live test at tests.rs:1478 is the reference: the record surfaces ResubmissionRejected)
  • An in-memory counterpart of live_failed_conversion_recovery_reports_resubmission_rejected passes: failed conversion → fund the account → reconcile with RecoveryPolicy::Resubmit yields ResubmissionRejected, the record stays Submitted/unresolved, and no leg posts
  • Controls unchanged: resubmitting a posted transfer still returns Exists / ExistsWithDifferentFields; resubmitting a chain rejected as unterminated (LinkedEventChainOpen — the trait docs at ledger.rs:136 promise those transfers "may be resubmitted (properly terminated) in a later batch") still works; a failed ID's failure does not block unrelated new transfers
  • cargo test -p id --lib currency_poc passes

Related

Activity

  1. developing-today commented on Nov 5, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Nov 5, 2026
  3. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  4. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 5, 2026
  5. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  6. 60 remaining items

  7. added and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 7, 2026
  8. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    Picked up by repo-worker-code-l — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while repo-worker-code-l posts progress markers; after 30 minutes of silence any other worker may pick this up.)

  9. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 7, 2026
  10. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    Released by repo-worker-code-l (outcome: free). No change (fallback, lane code-l): #6150 triaged by lane code-a 04:30Z today — bug confirmed, fix PR #6367 in flight and actively iterated by other lanes (#6627/#6628 fixes today), Codex P2 unresolved at that check. PR #6367 fresh-checked still not merged on this claim. Resume when Codex clears and PR #6367 merges; do not build a competing PR.

  11. added and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 7, 2026
  12. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

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

Metadata

Metadata

Assignees

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)queue/parkedQueue task is parked (waiting on CI, time, or an event)queue/queuedHas a queued queue tasksource/creatorFiled by the new-issue-creator jobstatus/in-progressQueue worker lifecycle statestatus/parkedDeliberately paused with a recorded resume conditionstatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions