Skip to content

fix(cli,incentive,node): count resumed bundle bytes apart, tag buyer rows with the chain id, flag unmatched filters - #2244

Merged
thiras merged 6 commits into
mainfrom
fix/cli-batch-2236-2198-2190
Sep 30, 2026
Merged

thiras merged 6 commits into
mainfrom
fix/cli-batch-2236-2198-2190

Conversation

@thiras

@thiras thiras commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Batch of three CLI-labelled fixes, one commit each.

#2236 — a resumed .partial prefix is not "downloaded"

  • pull_entry_untimed reads the resume record's present spans (new ClientRangedStore::present_byte_ranges) before any drive.
  • Whole-blob path: paid = len − resumed.
  • Range-dedup path: DedupOutcome.resumed_bytes = resumed spans minus spliced spans (spliced wins on overlap, so spliced_bytes is unchanged), set on every return including early finalize and self-heal.
  • Entry line: X downloaded at R, Y resumed, Z spliced from disk. The rate uses paid bytes only.
  • PullReport.resumed_bytes plus a resumed N from earlier partials summary line. The "counts again" carve-out is gone from the docs, and the drift in adr/appendix-bundles.md is fixed.

#2190 — bundle pull UX

  • A filter glob that matches no entry prints a stderr warning, with a **/ hint when that form would match. This covers -i, --hash and --dry-run.
  • PullReport.excluded counts entries dropped by the glob filter and by --select.
  • BREAKING (--json): deduped is renamed to reused, which pairs with reused_bytes. The counts line is now (… fetched, … linked, … skipped, … reused, … excluded, … failed).
  • At run end, one stderr line lists the staging files in .decdn-partial/ that belong to entries this run did not select, with their size. Nothing is deleted.

#2198 — buyer pool rows carry (chainId, payment_pool)

  • Deployment moves to decdn-incentive (still re-exported from channel_store). BuyerPoolState now carries it, and is_on compares both halves.
  • BREAKING (storage): the buyer tables move to _v5 with record schema 3, and chain_id is written before payment_pool. Existing rows are not read, so node and client re-adopt the live pool from chain.
  • The node (bootstrap, pull hot path, reconcile/adopt/drop), decdn fetch reuse/adopt/delegated paths and open_pool all take the Deployment. The voucher domain is derived from it, so there is one source.
  • WARNs keep their text and fields and add foreign_chain_id/configured_chain_id. pool list --json and admin_v1_pools gain chain_id.

Not in scope, and still untagged as before: the run_open re-check, reclaim_once, the delegated lane read in fetch.rs, and pool top-up/close/reclaim.

Test plan

  • Per commit: cargo clippy --workspace --all-targets -D warnings, cargo doc -D warnings, cargo fmt --check, the public-api snapshot, and nextest for incentive/client/cli/node/common
  • cargo clippy -p decdn-e2e --all-targets --features anvil-e2e -D warnings
  • anvil e2e: cli_bundle_pull_range_dedup 8/8 on the combined branch; node_pull_pool_redeploy + cli_fetch_topup 6/6
  • Testnet: interrupt a bundle pull, re-run with -v and a missing --exclude, check the resumed split, the glob warning and the leftover-partial line

Closes #2236
Closes #2198
Closes #2190

🤖 Generated with Claude Code

thiras and others added 3 commits September 30, 2026 07:04
…ed bytes

A bundle pull that resumes a `.partial` left by an interrupted run counted
the prefix again as downloaded: the whole-blob path took the file length
as paid, and the range-dedup path took the blob less its spliced bytes.
The entry line's rate, the summary's `downloaded` and `--json` all
overstated what the run moved. On the testnet a re-pull that resumed a
1.46 GB prefix reported 9.7 GB for about 8.3 GB moved.

Each entry now reads its resume record before it drives anything. The
ranged store marks only fetched bytes present, never spliced donor
bytes, so the record's present set is exactly what earlier runs paid
for. `decdn-client` exposes it as `ClientRangedStore::present_byte_ranges`.
The whole-blob path pays for the blob less that prefix. The range-dedup
path reports the prefix less the bytes it spliced, so a byte both
resumed and spliced counts once, as spliced; that holds on every return
of the reassembly, including a first drive that finalizes the blob and
the self-heal re-drive.

The resumed bytes travel beside the paid bytes to the entry line
(`X downloaded at R, Y resumed, Z spliced from disk`), the summary
(`resumed N from earlier partials`) and a new `resumed_bytes` field in
`--json`. The docs drop the carve-out that said a resumed prefix counts
again, and the bundles appendix now states that range-dedup savings and
the resumed prefix are both outside `downloaded`.

Closes #2236

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ount excluded entries

Three gaps from one testnet pull left the operator guessing. An
`--exclude 'metal/*'` matched nothing, because every pattern matches the
whole path from the bundle root and the entry sat at
`openai-gpt-oss-20b/metal/model.bin`, and the pull went ahead at 22.9 GiB
instead of 13.8 GiB with no word. A 1.5 GB partial of that entry, left by
an earlier interrupted pull, stayed in `.decdn-partial/` unseen. And the
summary read `0 deduped` beside `range-dedup: spliced 12.7 GB`, while the
excluded entry appeared in no count at all.

The entry filter now tracks each pattern's hits over the whole manifest
and prints one stderr warning per pattern that matched nothing, at every
site that filters: a local `-i` manifest, a `--hash` manifest, and
`--dry-run`. When the pattern's `**/` form would match an entry, the
warning names it. At run end, staging files for blobs the run did not
select (neither a kept entry nor the manifest blob) print one warning with
their count and size; the pull keeps them, since they are the resume
prefix of a later run that selects the entry again.

The summary and `--json` gain `excluded`, the entries that the filter
dropped or `--select` deselected, and rename `deduped` to `reused` so the
count pairs with `reused_bytes` and no longer reads as covering range
dedup. The rename breaks `--json` readers of `deduped`; the anvil e2e
that asserted it reads `reused`.

Closes #2190

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ymentPool address

poolId = keccak256(owner, ownerPoolNonce) names neither the chain nor the
contract, and a redeploy restarts the nonce. Buyer rows carried only the
PaymentPool address as their deployment tag, but the same deployer nonce
gives the same address on every chain. A node or client repointed at
another chain with its data dir intact therefore treated a row from the
other chain as its own: it resumed lane progress the live pool never
redeemed against and reused a deposit figure the live pool may not hold.

Move the seller store's Deployment (chain id + PaymentPool) into
decdn-incentive (re-exported from channel_store) and make it the buyer row
tag. BuyerPoolState carries a Deployment and is_on compares both halves.
The record codec inserts chain_id (8 bytes, big-endian) before
payment_pool under schema 3, and both buyer tables move to _v5, so rows
written by an earlier binary are not read; node and client re-adopt the
live pool from chain.

Thread the deployment through every reader that checks the tag: node
bootstrap (reconcile_owned_pool, adoption_applies, AdoptionCheck::Foreign,
drop_foreign_row), the node pull path (reuse_or_report), and decdn fetch
(cached_pool_token, pool_to_reuse, adopt_owned_pool, open_or_reuse_pool,
build_delegated_pool_ctx). BuyerPoolService::bootstrap takes the
Deployment in place of the PaymentPool address and the voucher domain.
decdn_client::buyer_pool::open_pool takes the Deployment in place of the
voucher EIP-712 domain, derives the domain from it, and refuses a
deployment whose address is not the contract's. The foreign-row WARNs keep
their text and payment_pool fields and add foreign_chain_id and
configured_chain_id. admin_v1_pools and decdn pool list --json gain
chain_id.

Tests: same-address-other-chain siblings for the node foreign-row drop,
standalone drop, adoption check and pull-path filter; a CLI pool_to_reuse
test for address and chain mismatch; cached_pool_token covers both; the
golden record and schema-skew tests move to schema 3. The decdn-client
public API snapshot is regenerated.

Closes #2198

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings September 30, 2026 04:15
@thiras thiras self-assigned this Sep 30, 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.

Copilot review overview

🟡 Changes recommended

Resume retry accounting, foreign-row opening, and leftover-partial reporting contain correctness gaps.

Review effort: Balanced
Findings: 1 High severity · 4 Medium severity

Open (5)
What changed in this PR

Separates resumed bundle bytes from new downloads, improves bundle-filter reporting, and scopes buyer pools to chain plus contract.

Changes:

  • Adds resumed-byte, excluded-entry, and reused-file reporting.
  • Warns about unmatched filters and leftover partials.
  • Adds chain-aware buyer-pool persistence and APIs.
File Description
docs/​runbook.md Documents buyer deployment tags.
crates/​node/​src/​runtime/​mod.rs Wires deployment into buyer bootstrap.
crates/​node/​src/​channel_store.rs Reuses shared Deployment.
crates/​node/​src/​buyer_channel.rs Applies deployment-aware buyer logic.
crates/​node/​src/​admin.rs Exposes buyer chain IDs.
crates/​incentive/​src/​lib.rs Exports Deployment.
crates/​incentive/​src/​deployment.rs Defines deployment encoding and domains.
crates/​incentive/​src/​buyer_pool.rs Tags buyer state by deployment.
crates/​incentive/​src/​buyer_pool_table.rs Introduces v5 storage schema.
crates/​incentive/​src/​buyer_pool_redb.rs Updates storage tests.
crates/​e2e/​tests/​pool_floor_ceiling_aggregate.rs Updates deployment fixtures.
crates/​e2e/​tests/​node_pull_pool_redeploy.rs Documents deployment-aware behavior.
crates/​e2e/​tests/​cli_fetch_topup.rs Uses deployment-based pool opening.
crates/​e2e/​tests/​cli_bundle_pull_range_dedup.rs Verifies renamed JSON field.
crates/​e2e/​src/​client.rs Centralizes fixture deployment construction.
crates/​common/​src/​admin.rs Adds chain ID to pool snapshots.
crates/​client/​tests/​snapshots/​public_api__public_api.snap Updates public API snapshot.
crates/​client/​src/​ranged_store.rs Exposes present byte ranges.
crates/​client/​src/​buyer_pool.rs Derives voucher domains from deployments.
crates/​client/​examples/​common/​mod.rs Updates example pool reuse.
crates/​cli/​tests/​pool_list.rs Tests chain-aware pool listing.
crates/​cli/​tests/​admin_rpc.rs Tests chain ID round-tripping.
crates/​cli/​src/​commands/​pool.rs Emits chain IDs in JSON.
crates/​cli/​src/​commands/​fetch.rs Validates deployment during reuse.
crates/​cli/​src/​commands/​bundle_pull.rs Implements reporting and warning changes.
CHANGELOG.md Records breaking and user-visible changes.
adr/​appendix-bundles.md Clarifies bundle byte accounting.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/node/src/buyer_channel.rs Resolved
Comment thread crates/cli/src/commands/bundle_pull.rs Resolved
Comment thread crates/cli/src/commands/bundle_pull.rs Resolved
Comment thread crates/cli/src/commands/bundle_pull.rs Resolved
Comment thread crates/cli/src/commands/bundle_pull.rs Resolved
@github-code-quality

github-code-quality Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 9542d17 in the fix/cli-batch-2236-2... branch remains at 87%, unchanged from commit e90f1e3 in the main branch.

Show a line coverage summary of the most impacted files.
File main e90f1e3 fix/cli-batch-2236-2... 9542d17 +/-
crates/node/src/dht/publish.rs 92% 92% 0%
crates/client/src/lib.rs 92% 92% 0%
crates/node/src/runtime/mod.rs 53% 53% 0%
crates/cli/src/...ommands/pool.rs 68% 68% 0%
crates/cli/src/.../bundle_pull.rs 80% 81% +1%
crates/cli/src/...mmands/fetch.rs 70% 71% +1%
crates/client/s...ranged_store.rs 94% 95% +1%
crates/node/src...uyer_channel.rs 71% 74% +3%
crates/client/s...c/buyer_pool.rs 70% 74% +4%
crates/incentiv...c/deployment.rs 0% 98% +98%

Updated September 30, 2026 05:53 UTC

thiras and others added 3 commits September 30, 2026 08:15
… settlement e2e

The anvil-e2e settlement test still passed the bare PaymentPool address
and the voucher domain. It builds only under --features anvil-e2e, so the
local clippy run missed it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The re-check under the open slot treated any row for the owner as the
live pool. A foreign row that bootstrap could not drop already reads as
no row on the pull path, so every pull spawned an open that stopped at
the re-check and found no pool again. The re-check now counts only a row
on this deployment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…overs by disk use

- A finalize whose hash fails drops every byte the store held and
  fetches the blob again, including a resumed prefix and spliced bytes.
  Downloader::refetched_targets reports that pass, and bundle pull then
  counts the whole blob as downloaded.
- The leftover-partial scan also runs when the filter or --select
  empties the run, which is where every retained partial is unused.
- It totals allocated space, not length: a range-dedup .partial is sized
  to the whole blob before its bytes land.
- The warning says "did not use" rather than "did not select", since a
  partial another bundle left in the same output dir counts too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras merged commit c040691 into main Sep 30, 2026
30 checks passed
@thiras
thiras deleted the fix/cli-batch-2236-2198-2190 branch September 30, 2026 06:37
thiras added a commit that referenced this pull request Oct 7, 2026
…ed manifest (#2360)

`bundle pull --hash <H> --dry-run` never read the manifest, so an
`--include`/`--exclude` pattern that matches no entry went unreported:
the repro in #2327. The live-run warning already exists (#2244).

The dry run now reads the manifest from the output root's
`.decdn-bundles/` cache when an earlier pull stored it. The read is
local, unpaid, and verified against the hash, so it happens even under
`--overwrite`. It then prints the filtered plan and the unmatched-pattern
warnings, as `-i --dry-run` does. With no cached manifest it prints the
bundle and output root, with `count`/`entries` null under `--json`. A
malformed `--hash` fails the dry run, as it fails a real pull, and a
cached manifest that does not parse names its cache file.

Closes #2327

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants