Skip to content

fix(client,node): heal a chain-seeded lane's BytesRegression by rebasing to the seller's anchor - #2313

Merged
thiras merged 2 commits into
mainfrom
fix/2254-seeded-lane-bytes-regression-heal
Oct 5, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/2254-seeded-lane-bytes-regression-heal

Conversation

@thiras

@thiras thiras commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

What

The investigation answers the three questions in #2254.

1. Why the local lane record is missing: a schema bump, not lost writes. Each reseed wave follows a boot that logged BuyerPoolService bootstrap complete tracked=0 adopted=true fleet-wide:

Both commits renamed the buyer table, so the new binary started with an empty store. Bootstrap then adopted the pool with no lanes, and each lane seeds when it is first used, which can be hours later. The 15:27 restart booted with tracked=1. The boots on 10-01, 10-02 and 10-03 caused no reseeds. Buyer writes are Durability::Immediate. So there is nothing to fix here; only the doc on reseed_lane_from_chain changes.

2. Why the rejection was terminal: a gap in the client heal (fixed).

  • The chain seed sits below the seller's unredeemed anchor. The ledger prices its spans from the lower seed, so its amount passes the anchor while its bytes still trail it.
  • lane.rs then rejects BytesRegression, and the rejection carries the anchor as a watermark bundle.
  • heal_watermark_desync had no heal for that reason, so the drive ended and node-origin suppressed the provider. The payer now rebases to the bundle, which is its own voucher, and resumes.

3. Concurrent double seed (fixed). Two streams that find one lane missing now seed it once.

Closes #2254

Reviewer notes

Read these first:

  • crates/client/src/lib.rs: heal_bytes_regression.
  • crates/client/src/ledger.rs: rebase_ahead_on_bytes / rebase_if. The bytes test runs under the issuance lock beside the generation test, so a sibling voucher that commits past the bundle cannot be overwritten downward.
  • crates/node/src/buyer_channel.rs: per-lane seed_locks, reread_before_seed, and WATERMARK_READ_TIMEOUT.

Behaviour decisions:

  • A BytesRegression bundle that the ledger already covers on both axes is retried, because the rejected voucher trailed the ledger. It is no longer terminal. scopes_to_source now includes BytesRegression, so a healed rejection past the resume budget cools only that source.
  • Payer safety is unchanged. A bundle is admitted only if it carries the payer's own signature, and redemption pays the highest cumulative the node holds.

Unchanged on purpose:

  • The seller's equal-amount divergent arm (voucher.rs, feat(payments): self-describing vouchers to enable concurrent same-lane settlement #1699 rule 4) still rejects BytesRegression with no bundle. If a seeded lane's amount lands exactly on the anchor, that lane still ends there. Each crossing has roughly a 1-in-(per-voucher price step) chance of landing exactly on the anchor. Closing that gap means attaching the bundle on that arm, which reverses a deliberate policy, so it is left for a separate decision.
  • node-origin's BytesRegression → OurDeadLane stays. Only a rejection that no heal took reaches it.

Not covered by tests:

  • The getWatermark timeout, because the mock transport cannot hang.
  • An end-to-end loopback run of the new path. The attempt healed through the existing reseed instead, so the seller half is pinned by a handler test and the buyer half by unit and driver tests.

The decdn-spec-discipline gate passed for the ADR 005 edit. The heal is enforced locally by the payer and adds no wire, chain or config surface.

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run -p decdn-client -p decdn-node -p decdn-incentive: 2438 passed
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • Mutation checks:
    • Dropping the re-read under the seed lock fails concurrent_reseeds_of_one_lane_read_the_chain_once.
    • Dropping proof_generation fails a_bytes_regression_from_an_earlier_generation_is_stale.
  • contracts/ changed: n/a
  • User-visible change: CHANGELOG.md entry added
  • Design change: ADR 005 and ADR 003 updated
  • PR title uses an allowed type with a lowercase subject

🤖 Generated with Claude Code

…ing to the seller's anchor

A buyer-table schema bump starts the node's buyer store empty. Bootstrap
adopts the on-chain pool with no lanes, and each lane seeds from
getWatermark on its first use. That seed counts redeemed vouchers only, so
it sits below any voucher the provider holds unredeemed. The ledger prices
its spans from the lower seed: its amount passes the provider's anchor
while its bytes still trail it, and the provider rejects BytesRegression
with its watermark bundle. heal_watermark_desync took no heal for that
reason, so the drive ended and node-origin suppressed a healthy provider.

Client:
- A BytesRegression whose bundle is at or behind the ledger on amount and
  ahead of it on bytes rebases to the bundle, through the new
  PoolLedger::rebase_ahead_on_bytes. The bytes test runs under the
  issuance lock beside the generation test.
- A bundle the ledger already covers on both axes retries from the ledger.
  A BytesRegression with no bundle stays a single-signer fault.
- scopes_to_source includes BytesRegression, so a healed rejection past
  the resume budget cools only that source.

Node:
- Lane seeds take a per-lane lock and re-read the row under it, so
  concurrent streams seed a lane once. A replaced row seeds the new pool;
  a vanished row refuses the pull.
- The getWatermark read times out after WATERMARK_READ_TIMEOUT (10 s).

ADR 005 documents the BytesRegression rebase, and ADR 003 lists it among
the recoveries.

Closes #2254

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

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

Zero-watermark concurrency repeats serialized RPCs, and the seed-lock registry grows without reclamation.

Review effort: Balanced
Findings: 2 Medium severity · 2 Low severity

Open (4)
What changed in this PR

Adds recovery for chain-seeded lanes rejected with BytesRegression and coordinates concurrent lane seeding.

Changes:

  • Rebases buyer ledgers to authenticated seller anchors.
  • Adds per-lane seed locking and watermark-read timeouts.
  • Updates tests, ADRs, and changelog documentation.
File Description
crates/​node/​src/​handlers/​client/​voucher.rs Tests bundled regression anchors.
crates/​node/​src/​buyer_channel.rs Coordinates lane seeding and bounds RPC reads.
crates/​incentive/​src/​buyer_pool.rs Documents rebase persistence.
crates/​incentive/​src/​buyer_pool_table.rs Tests byte-ahead rebases.
crates/​client/​src/​lib.rs Implements BytesRegression healing.
crates/​client/​src/​ledger.rs Adds conditional byte-ahead rebasing.
crates/​client/​src/​fault.rs Clarifies terminal rejection behavior.
crates/​client/​src/​driver.rs Scopes exhausted healing to its source.
crates/​client/​src/​buyer_pool.rs Updates progress-write semantics.
CHANGELOG.md Records the user-visible fix.
adr/​005-protocol.md Specifies regression recovery.
adr/​003-payments.md Updates payment-rejection guidance.

💡 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/node/src/buyer_channel.rs Resolved
Comment thread adr/003-payments.md Resolved
Comment thread adr/005-protocol.md Resolved
@github-code-quality

github-code-quality Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 4149571 in the fix/2254-seeded-lane... branch remains at 87%, unchanged from commit de1893b in the main branch.

Show a line coverage summary of the most impacted files.
File main de1893b fix/2254-seeded-lane... 4149571 +/-
crates/client/src/sink.rs 97% 96% -1%
crates/node/src...ient/voucher.rs 97% 96% -1%
crates/node/src/dht/publish.rs 92% 92% 0%
crates/client/src/streamer.rs 91% 91% 0%
crates/client/s...c/connection.rs 97% 97% 0%
crates/client/src/lib.rs 92% 92% 0%
crates/client/src/driver.rs 97% 97% 0%
crates/cache/src/engine.rs 94% 94% 0%
crates/incentiv...r_pool_table.rs 98% 98% 0%
crates/node/src...uyer_channel.rs 76% 77% +1%

Updated October 05, 2026 10:48 UTC

…une idle slots

Review follow-ups for #2254 (PR #2313):

- A zero watermark persists nothing, so each stream queued on a lane's
  seed lock re-read the chain in turn. The lane's seed slot now carries
  the first stream's read, and the rest of the queue reuses it.
- The seed-lock map kept one entry per lane ever attempted. A SeedTurn
  guard now removes a lane's slot when the last stream holding it leaves,
  including one cancelled while it waited.
- ADR 003: keep the BytesRegression qualifier on the rebase action, not
  on UnderFold's fold.
- ADR 005: a current-generation BytesRegression rebases again, as an
  Underpaid does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras merged commit fc23654 into main Oct 5, 2026
30 checks passed
@thiras
thiras deleted the fix/2254-seeded-lane-bytes-regression-heal branch October 5, 2026 10:52
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