Skip to content

fix(client,cli): name a run's untracked escrows on every end of the command - #2516

Merged
thiras merged 3 commits into
mainfrom
fix/2511-untracked-hold-on-handle
Oct 18, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/2511-untracked-hold-on-handle

Conversation

@thiras

@thiras thiras commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

What

When a run's topUp or openPool mined and its local record failed (EscrowUntracked), the run refused later escrows (#2514). But the hold lived on the per-pass RunFunding, which is dropped with a fetch, a bundle entry, or a pass, and no end of the command read it. A Ctrl-C during the 30 s drain of late lane builds printed "interrupted; run the same command again to resume". The receipt read had already removed the tx from UnconfirmedEscrows, so nothing named it, and a re-run read the uncredited row and escrowed again. A bundle pull whose entry with the escrow was dropped could give up with exit 75 the same way.

  • The handle holds every untracked escrow. UnconfirmedEscrows keeps one entry per tx (UnconfirmedEscrows::untracked, a new UntrackedEscrow { tx, text }). RunFunding::note_untracked writes to it, and refuse_after_untracked reads from it. So the hold outlives a dropped fetch, a dropped bundle entry and a pass, and every later pass on the handle refuses to escrow. It holds every escrow, not only the first: an openPool that passed its check before another escrow went untracked can go untracked too.
  • The CLI names it on every end. decdn get (a blob or a bundle) calls name_held_escrows(result, &handle) on every exit, so a call site cannot forget the hold.
    • A Ctrl-C prints interrupted: <escrow> and exits 130.
    • A give-up exits 1, not 75.
    • A run that otherwise succeeds exits 1.
    • A second Ctrl-C names it too (exit_lines).
    • An untracked escrow whose tx the error's text already names is not repeated. A stop (Interrupted, GaveUp) never counts as naming it by text, because main prints only the stop's own line.
  • BundlePuller: the end of the pull is a pure pull_end. A pull that is not interrupted ends BundleEnd::Stopped while the handle holds an untracked escrow. The escrows are folded oldest first, and the pull's own stop is kept as text. A give-up, a pool replacement or "funding needed" never counts as already naming the escrow, so none of them can invite a rerun. An interrupted pull stays Interrupted. Its caller names the hold from BundlePuller::unconfirmed_escrows, which this PR adds.
  • Smaller API:
    • EscrowUntracked::tx() is new.
    • UntrackedEscrow is #[non_exhaustive].
    • UnconfirmedEscrows::hold_untracked_for_test is new, behind test-util.
  • Renames:
    • PendingEscrows → UnreconciledEscrows (cli)
    • UntrackedEscrowHeld → RefusedAfterUntracked (crate-private)
    • HeldEscrows → Shared (private)

Closes #2511

Reviewer notes

  • Read first:
    • UnconfirmedEscrows and hold_untracked in crates/client/src/buyer_pool.rs
    • name_unconfirmed_escrows and in_flight in crates/cli/src/commands/interrupt.rs
    • pull_end and invites_rerun in crates/client/src/bundle/engine.rs
  • Duplicate check by text. The check for "already names the escrow" looks for the tx in the error text, because LaneBuildFault hides its inner error from a downcast. Every producer prints the full 0x… hash, and sanitize_err_chain leaves it intact.
  • No effect on the node, gateway or pool commands.
    • The node and sponsord do not use RunFunding, UnconfirmedEscrows or BundlePuller.
    • The gateway shares one handle across fetches but is delegated-only, so it never escrows.
    • decdn pool open and decdn pool top-up build no RunFunding, so they hold nothing. Their own error names the tx.
  • fix(client): a bundle pull drops sibling entries mid-drain, losing a late escrow and allowing exit 75 #2509 is not closed. The handle gives it a fallback: a dropped bundle entry's untracked escrow is now named at the end. The real fix, letting sibling entries finish their drain in run_groups and first_open, is still open. fix(client): a fatal lane build drops the rest of its batch, and an escrow in it goes unnamed #2508 and fix(client): the build drain starts a refill after the fetch ended #2513 are unchanged.
  • Out of scope, filed as fix(client,cli): a second Ctrl-C between a receipt read and its record names no escrow #2515: a second Ctrl-C between a receipt read and its record write names no escrow. This existed before this PR.
  • Tests:
    • buyer_pool/tests.rs: the handle holds each tx once, and a clone shares the hold.
    • funding/adoption_tests.rs: the hold outlives its RunFunding and refuses a later pass.
    • bundle/engine/tests.rs: pull_end for every end, including several escrows, a stop that names the tx, and a second pool replacement.
    • cli interrupt/tests.rs: built on a real handle through the test-util hook.
    • Mutation checks: I removed the stop guard, the carried escrow in in_flight, the hold in the CLI and each invites_rerun arm in turn. Each change fails its test.
    • Not covered: pull_end's call site in PullCtx::run, which is a single line, and Interrupt::watch's process::exit. Its lines come from exit_lines, which is tested.

Verification

  • cargo fmt -- --check
  • CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features (run as -- -D warnings)
  • cargo nextest run --workspace: 5117 passed. One retry, origin_range_pull offset_past_the_blob_is_rejected_before_delivery, which this PR does not touch.
  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items
  • decdn-client public-api snapshot regenerated (cargo nextest run -p decdn-client --features public-api-test --test public_api)
  • contracts/ changed: n/a
  • User-visible change: CHANGELOG.md entry added (and the fix(client): a lane build that drains after an untracked escrow can send a second topUp #2506 entry's scope updated)
  • Design change: n/a. No ADR describes the escrow refusals.
  • PR title uses an allowed type with a lowercase subject

🤖 Generated with Claude Code

thiras and others added 3 commits October 18, 2026 09:54
…mmand

The hold on a run's untracked topUp or openPool lived in RunFunding, which
is per pass and is dropped with a fetch or a bundle entry. No end of the
command read it. A Ctrl-C during the late-build drain printed "run the same
command again", and a bundle give-up could exit 75, so a re-run escrowed
again.

The hold now lives on the command's UnconfirmedEscrows handle
(UnconfirmedEscrows::untracked, UntrackedEscrow with its tx).
name_unconfirmed_escrows names it on every end that does not already name
its tx, and so does the second-Ctrl-C exit. A BundlePuller pull that holds
one ends Stopped on the escrow.

Closes #2511

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-up for #2511.

- The handle holds every untracked escrow, one per tx, not only the first:
  an openPool that passed its check before another escrow went untracked
  can go untracked too, and a dropped bundle entry left it unnamed.
- The CLI names the hold through name_held_escrows(result, &handle), so a
  call site cannot forget it. A stop (Interrupted, GaveUp) never counts as
  naming an untracked escrow by its text, and the stop line names a carried
  topUp beside the attached escrows.
- The bundle end is a pure pull_end, tested for every end. A give-up, a pool
  replacement or "funding needed" never stands for the escrow, and a folded
  second replacement no longer asks for a rerun.
- BundlePuller::unconfirmed_escrows exposes the handle; EscrowUntracked::tx
  reads the tx; UntrackedEscrow is non_exhaustive outside test-util.
- Renames: PendingEscrows -> UnreconciledEscrows,
  UntrackedEscrowHeld -> RefusedAfterUntracked, HeldEscrows -> Shared.
- Docs and the CHANGELOG no longer scope the hold to one run, and no longer
  claim the pool commands hold one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Re-review follow-up for #2511.

- pull_end folds every untracked escrow into one error with the oldest as
  its root, and adds "the pull stopped" only when the pull stopped. A
  completed pull that held two escrows read as stopped on the first one.
- Tests cover a "funding needed" and a pool-replaced stop whose text names
  the escrow, which still stop on it.
- The fetch `# Errors` doc states which escrows are not repeated, and
  UntrackedEscrow is plainly non_exhaustive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 18, 2026 07:51
@thiras thiras added kind:bug Something does not behave as documented rust Dependabot: a Cargo update; use area: labels for Rust code otherwise area:payments Pools, vouchers, redeem, reclaim, staking (incentive crate and chain) labels Oct 18, 2026
@thiras thiras self-assigned this Oct 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Shared retention and exit handling are consistent, with focused regression coverage and no unresolved blocking findings.

No open issues 🎉

What changed in this PR

Keeps untracked escrows on the command-wide handle so dropped fetches, bundle entries, and interrupts still report transactions requiring reconciliation.

Changes:

  • Retains every untracked escrow and refuses later funding on the same handle.
  • Reports held escrows on CLI exits and prevents unsafe bundle retry outcomes.
  • Adds regression tests and updates public API documentation.
File Description
crates/​client/​tests/​snapshots/​public_api__public_api.snap Records new public escrow APIs.
crates/​client/​src/​funding/​adoption_tests.rs Tests retention across funding runs.
crates/​client/​src/​funding.rs Moves escrow retention to the shared handle.
crates/​client/​src/​fault.rs Updates refusal-type classification.
crates/​client/​src/​buyer_pool/​tests.rs Tests deduplication and shared retention.
crates/​client/​src/​buyer_pool.rs Stores untracked transactions and exposes their details.
crates/​client/​src/​bundle/​engine/​tests.rs Tests outcomes with held escrows.
crates/​client/​src/​bundle/​engine.rs Incorporates held escrows into pull outcomes.
crates/​client/​src/​bundle.rs Exposes the handle and documents outcomes.
crates/​cli/​src/​commands/​pool.rs Uses the shared reporting helper.
crates/​cli/​src/​commands/​interrupt/​tests.rs Tests escrow messages and exit behavior.
crates/​cli/​src/​commands/​interrupt.rs Reports pending and untracked escrows.
crates/​cli/​src/​commands/​fetch.rs Reports held escrows when fetching ends.
crates/​cli/​src/​commands/​bundle_pull.rs Reports held escrows when bundle pulling ends.
CHANGELOG.md Documents command-wide retention and reporting.

Review effort: Balanced

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 41e5cd5 fix/2511-untracked-h... 7093af5 +/-
76% 76% 0%
View coverage of the 10 most impacted files.
File main 41e5cd5 fix/2511-untracked-h... 7093af5 +/-
crates/node/src/dht/publish.rs 80% 78% -2%
crates/client/src/lib.rs 89% 89% 0%
crates/client/src/scheduler.rs 94% 94% 0%
crates/node/src...gin/pull_leg.rs 85% 85% 0%
crates/client/src/bundle.rs 28% 28% 0%
crates/client/src/funding.rs 82% 82% 0%
crates/client/s...undle/engine.rs 61% 62% +1%
crates/client/s...c/buyer_pool.rs 96% 97% +1%
crates/protocol/src/framing.rs 92% 93% +1%
crates/cli/src/...ds/interrupt.rs 85% 89% +4%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@thiras
thiras merged commit 6d5bbd5 into main Oct 18, 2026
32 checks passed
@thiras
thiras deleted the fix/2511-untracked-hold-on-handle branch October 18, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:payments Pools, vouchers, redeem, reclaim, staking (incentive crate and chain) kind:bug Something does not behave as documented rust Dependabot: a Cargo update; use area: labels for Rust code otherwise

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(client,cli): an interrupted or dropped run does not name the untracked escrow it holds

2 participants