Skip to content

docs(adr)!: the payer fronts credit - #2877

Merged
alpergundogdu merged 29 commits into
mainfrom
claude/payer-fronted-credit
Nov 17, 2026
Merged

alpergundogdu merged 29 commits into
mainfrom
claude/payer-fronted-credit

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Implements #2876: the payer fronts credit. A node sends a frame only when the payment on that stream covers it, and the payer pays ahead within a per-node window that is payer policy. Trust moves one way. #2873 is merged and this branch is merged with it.

The ADR text (adr/003-payments.md § Credit Window, Pool solvency, Attack Vectors; adr/005-protocol.md; adr/037, adr/038) is the spec. Verified blob size is a separate change (#2879).

Credit belongs to the stream

A lane's proofs are cumulative, so the proofs of sibling streams fold into each other: a later reveal on one stream folds an earlier reveal a sibling has in flight. Each proof therefore states its share of the lane's payment for the stream that carries it:

  • a ChunkPreimage pays one chunk to its stream;
  • a Voucher carries a new unsigned field, stream_bytes: the residual on a closing voucher, 0 on anchor and rollover vouchers.

The node credits the stream min(share, lane paid − lane claimed), with claimed held in memory per lane. Out-of-order sibling reveals still pay the stream they were meant for. A replayed or overstated share can only move the payer's own payment between its streams, never past what the lane paid. Credit never carries from one stream to another, and a stream that ends strands its unused credit (at most one window). A lane loaded from disk starts with every paid byte claimed.

Write-offs

The payer books each stream's end once. When the node failed the delivery (a read fault, a stall, a short delivery, a mid-stream refusal, a rejected proof, or bytes the decoder rejects), it writes off paid − verified for that stream; the node's account of why does not count. When the payer chose to stop or drop the stream, nothing is written off. loss_weight shrinks the node's window by the loss.

Changes per crate

decdn-protocol: Voucher.stream_bytes (unsigned, last field).

decdn-node

  • handlers/client/credit.rs: acquire_credit waits until the stream's paid − delivered covers the frame, reading one proof at a time while it falls short. The takedown check runs before every frame; the pool and signer re-checks run on a wall-clock cadence and stop in-band with PoolExhausted or SignerCapExhausted.
  • LaneDeliveryState::claim grants each proof's share out of the lane's unclaimed payment.
  • A stream that spends its proof budget while its credit cannot cover its next frame ends with an in-band AmountRegression reject carrying the lane's watermark bundle, so a restarted payer reseeds and resumes.
  • Serve loops (hit, miss, window pull-through) send only against the stream's credit. The miss path paces its upstream pull with CreditPacer, so a never-paying client costs the node nothing.
  • Node upstream ledgers attach the operator's shared trust record, so the per-node cap and window ramp span its pools at one operator.
  • Floor reservation, floor debt, per-signer floor isolation and the ramp carry are removed.

decdn-client

  • payer_window: PayAheadPolicy, NodeTrust (per operator address) and PayerWindows. The window is min(pay_ahead_cap, max(floor, (verified − loss_weight × lost) / pay_ahead_divisor)), with the floor clamping last.
  • Each stream pays ahead from zero up to min(window, bytes it still needs); the per-node cap bounds all of the payer's streams at one node. A stream holding less than one chunk group may take one chunk past the cap, so other streams' credit cannot starve it.
  • UpstreamPull keeps paid per stream and settles the write-off at its end; decode failures reach it through StashedFault::note_failed_delivery.
  • The payer's verified_bytes/lost_bytes persist per operator address in the peer store as required fields. Saves add each process's own progress to the stored counts, so concurrent fetches never overwrite each other.
  • PULL_AHEAD_BYTES (48 KiB slack) pairs with the node's frame_target room floor, pinned by a cross-crate test.

decdn-common, decdn-cli: pay-ahead knobs are client CLI flags (--pay-ahead-cap, --pay-ahead-divisor, --loss-weight). The floor-debt and per-IP keys that #2873 removed stay removed. The public gateway's drop penalty is capped by the dropped request's span.

decdn-e2e: fixtures follow the node's credit rules. pool_floor_ceiling_aggregate.rs is deleted (it tested floor accumulation, which no longer exists).

Docs: ADRs 003, 005, 022, 037, 038, 039 and architecture.md describe per-stream credit.

Decisions taken

  • Credit per stream, claimed by share. No lane balance, no persisted delivered count, no sibling wakes, no backfill. Lane-level credit needed a payer-side counter of the node's credit, which drifts after any lost frame and needed reconciliation machinery (silent-stall write-off, sibling-spend sizing, run budget). Per-stream credit makes that drift and the cross-stream spend unrepresentable.
  • Not taking the node's word. Any failed delivery is a node failure for the write-off; a refusal reason is not trusted. The payer leaving is the payer's choice and costs the node nothing.
  • No run-wide write-off budget. Windows are per node and start at the floor, and each node identity needs a bond, so a run budget guarded nothing and let a requester pin a long-lived gateway to the floor.
  • One extra round trip per new stream. A stream sends nothing until its own first proof, which the payer sends after the StreamResponse. Pipelining that proof behind the request is out of scope here (see Replace cdn/probe/v1 with a voucher-less stream-open; retire rate-manipulation slashing #2901's "Not in this issue").
  • Slack. PULL_AHEAD_BYTES (48 KiB) matches the room floor of frame_target. Changing one without the other parks the serve leg; a cross-crate test pins them together.

Known gaps

Compatibility

Wire-breaking: Voucher gains a field, and an old client and a new node deadlock by design (the old client waits for bytes before it pays). The network is pre-mainnet, so there is no shim.

Checks

Run locally:

  • cargo fmt -- --check, cargo clippy --workspace --all-targets --all-features -- -D warnings, CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items, python3 .github/scripts/check_crate_edges.py: pass.
  • cargo nextest run --workspace: 6304 tests pass, including the claim suite (out-of-order sibling claims, replay and overstated shares, loaded lanes), below-frontier reveals claiming their own chunk, a sibling that never paid drawing nothing, the aggregate-voucher split across two streams, and the write-off rules (zero-byte and partial early StreamEnd written off, payer drop and disconnect not).
  • cargo test --no-run -p decdn-e2e --features anvil-e2e: compiles.
  • Public API snapshots for decdn-protocol and decdn-client: regenerated and pass.

Not run locally: the anvil e2e tests themselves, gateway_sdk and gateway_sdk_python (sdk-e2e), and the Solidity gates (no contract change). The gateway HTTP contract (paths, headers) is unchanged, so no SDK pin moves are expected. CI runs these.

🤖 Generated with Claude Code

alpergundogdu and others added 5 commits November 11, 2026 17:37
Floor debt charged an abandoned stream's unpaid floor to the capability
signer. Signer keys are free, so a cheater rotates and starts clean,
while an honest client that drops stalled lanes fills its cap and is
locked out of the node until a restart. The per-stream credit window
already bounds what one stream can take, and the pool ceiling and the
per-signer live cap bound concurrent floor.

The default redeem threshold drops from 1 USDC to 0.05 USDC, which caps
the value a lane can leave unredeemed at capability expiry near the gas
of one first-time redemption lane.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A relay-routed connection carries no client address, so an attacker that
dials through a relay skips a source-address layer for free, while
honest peers behind one NAT share one bucket. The rate limiters key on
the NodeId and a global bucket; the connection limiter is the global
concurrency cap.

Removed config keys: security.per_source_rate_per_sec,
security.per_source_burst, security.max_tracked_sources, and
{dht,probe,serve}.rate_limit.{per_ip_rate_per_sec,per_ip_burst,
max_tracked_per_ip}.

Closes #2505

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A node sends a frame only when the lane's confirmed payment covers it.
The payer pays ahead within a credit window that is payer policy: a cap
in USDC for each node, a ramp on verified delivery, and a write-off
weight for credit that a node keeps. Credit belongs to the lane and
carries across streams and a node restart. On a cache miss a node pays
its upstream only up to the credit that its downstream lane holds.

ADR 003 loses the node-side credit window, the floor-credit accumulator
and per-signer floor isolation. Voucher withholding is closed by
construction, and data withholding states the payer's bound.

ADR 005 adds a size proof to StreamResponse and ProbeResponse, so
total_bytes is verified against the content hash.

Refs #2876

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The size proof is proposed in #2879 and does not depend on the credit
direction.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@alpergundogdu alpergundogdu changed the title docs(adr)!: the payer fronts credit and a node proves the blob size docs(adr)!: the payer fronts credit Nov 11, 2026
The node counts a frame as delivered when it sends it, so a frame that a
dropped connection never carried is still counted, and the payer would
pay twice for it on resume. A resume that follows a stream with no clean
close gets the gap back as lane credit, within an allowance of the
lane's paid bytes over a divisor, capped at a small window. The
allowance comes from the lane's own payments, so a fresh signer key has
none, and the node enforces it without a wire field.

Refs #2876

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@alpergundogdu
alpergundogdu marked this pull request as ready for review November 13, 2026 13:32
@alpergundogdu
alpergundogdu marked this pull request as draft November 13, 2026 13:32
alpergundogdu and others added 5 commits November 13, 2026 13:35
WIP: node side of the payer-fronted credit design (#2876). The node debits a
lane-wide credit before each frame and reads proofs while credit falls short.
The lane persists its delivered count, a backfill returns the gap of an
unfinished stream within an allowance, and the miss pull draws only what the
downstream lane has paid for. The node-fronted floor, ramp and per-signer
machinery and their config keys are removed. Not built or tested yet: the
integration suites (client_loopback, node_origin_pull) still target the old
direction.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The client pays ahead of delivery up to a payer-local window,
min(pay_ahead_cap, max(chunk + chunk group, (verified - loss_weight * lost)
/ pay_ahead_divisor)), keyed per node operator address and capped across
every signer of the process. A lane's held credit is a ledger counter that
payment grows and every received byte spends. Completion and resume follow
the verified frontier, so the delivered-but-unpaid span machinery is gone.
A node that ends a stream without delivering against held credit, or sends
provably corrupt bytes, has the credit written off at reconciliation; a
disconnect is not a write-off. A rebase never moves below price times the
bytes the lane verified. PullConfig is non_exhaustive and gains the window
knobs, the CLI gains --pay-ahead-cap, --pay-ahead-divisor, --loss-weight and
--write-off-budget, and the peer store persists each operator's counts.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Gateway test allowances cover the larger drop penalty. Node unit tests no
longer reference the removed floor and ramp machinery. The client_loopback
and node_origin_pull integration suites still target the old direction.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Base automatically changed from fix/payments-lower-redeem-floor-drop-floor-debt to main November 13, 2026 15:47
@alpergundogdu
alpergundogdu marked this pull request as ready for review November 13, 2026 19:31
Copilot AI balanced review requested due to automatic review settings November 13, 2026 19:31

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.

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟡 Changes recommended

The change still has an unresolved moderate issue where PullConfig::apply_pay_ahead() is invoked within Streamer::open_range, potentially causing process-global payer window policy to be silently overwritten across concurrent pulls, along with minor documentation nits.

3 open issues
What changed in this PR

Implements the payer-fronted credit model: nodes only send frames when confirmed lane credit covers them, while clients pay ahead within a per-node, payer-controlled window; removes the legacy floor/ramp machinery and updates configuration, tests, and docs/specs accordingly.

Changes:

  • Switch serving/payment gating to lane credit computed as paid minus delivered, with delivered bytes persisted so credit survives restarts.
  • Add client pay-ahead window policy (including per-operator trust) plus pacing, reconciliation, and write-off semantics across streams.
  • Simplify rate limiting from per-peer+per-IP+global to per-peer+global and update handlers/metrics/tests/ADRs to match.
File Description
docs/​runbook.md Updates operational guidance for the new payer-fronted credit behavior and the simplified rate-limiting model.
crates/​protocol/​src/​lib.rs Refines protocol documentation around error/close semantics (notably RATE_LIMITED).
crates/​node/​tests/​support/​mod.rs Adjusts shared node test support utilities and config fixtures to the updated limiter/config shapes.
crates/​node/​tests/​sighup_signal.rs Updates SIGHUP/reload tests to reflect the revised runtime configuration surface.
crates/​node/​tests/​probe_warm_reconnect.rs Updates probe warm-reconnect test expectations/config for the simplified limiter layering.
crates/​node/​tests/​node_origin_pull.rs Updates node-origin pull integration tests to align with the new credit-gated serving rules and removed mechanisms.
crates/​node/​tests/​dht_loopback.rs Updates DHT loopback tests/fixtures for the revised per-peer/global rate limiting.
crates/​node/​tests/​dht_lookup.rs Updates DHT lookup tests/fixtures to match the new limiter and handler behavior.
crates/​node/​tests/​dht_integration.rs Updates DHT integration tests to the simplified limiter model and updated request admission behavior.
crates/​node/​tests/​dht_bootstrap.rs Updates DHT bootstrap tests/fixtures for the new limiter configuration and behavior.
crates/​node/​tests/​anvil_bringup_shutdown_e2e.rs Updates Anvil bringup/shutdown E2E test setup for the changed resolved config fields and payment semantics.
crates/​node/​src/​runtime/​tests.rs Updates runtime tests and fixtures for the revised resolved configuration structure and reload behavior.
crates/​node/​src/​runtime/​reload/​tests.rs Updates reload tests to reflect which fields are reloadable and the new config layout.
crates/​node/​src/​runtime/​reload.rs Adjusts reload logic and messaging to match removed/renamed configuration keys and updated restart requirements.
crates/​node/​src/​prune_guard.rs Updates prune-guard implementation/docs to align with the post-refactor runtime/limiter behavior.
crates/​node/​src/​pool_store/​tests.rs Adds/updates persistence tests for lane state needed by the paid-minus-delivered credit model.
crates/​node/​src/​pool_store.rs Updates pool storage to persist the delivered-bytes lane counter required for restart-safe credit.
crates/​node/​src/​payment_settlement.rs Updates settlement logic to remove references to deleted floor/ramp accounting and align with the new credit model.
crates/​node/​src/​node_origin/​ranged_pull.rs Updates ranged pull documentation/behavior to match the new credit and backpressure terminology.
crates/​node/​src/​node_origin/​pull_leg/​local_pull_leg_tests.rs Updates local pull-leg tests/fixtures to reflect credit pacing and new pull behavior.
crates/​node/​src/​node_origin/​mod.rs Updates node-origin module documentation and behavior descriptions for the updated pull/credit flow.
crates/​node/​src/​metrics/​tests.rs Updates metrics tests to reflect removed metrics/series and the revised limiter/credit instrumentation.
crates/​node/​src/​lib.rs Updates crate-level documentation/exports to match the refactored limiter and credit architecture.
crates/​node/​src/​handlers/​serve_rate_limit.rs Refactors the serve-path rate limiter wrapper to the simplified layered model and updated metrics labeling.
crates/​node/​src/​handlers/​probe.rs Updates the probe handler to use the simplified limiter layering and revised close behavior semantics.
crates/​node/​src/​handlers/​probe_rate_limit/​tests.rs Updates probe rate-limit tests to match the new two-layer limiter behavior and labels.
crates/​node/​src/​handlers/​probe_rate_limit.rs Refactors probe rate limiting to the simplified layering and updated metrics/error reporting.
crates/​node/​src/​handlers/​dht.rs Updates DHT handler admission/rate-limit wiring to remove per-IP tracking and match the new limiter model.
crates/​node/​src/​handlers/​client/​ramp/​tests.rs Removes or updates ramp-related handler tests now obsolete under the payer-fronted credit design.
crates/​node/​src/​handlers/​client/​ramp.rs Removes the legacy ramp/floor machinery from the node client handler implementation.
crates/​node/​src/​handlers/​client/​outcome/​tests.rs Updates outcome classification tests to reflect removed refusal paths and updated close reason semantics.
crates/​node/​src/​handlers/​client/​outcome.rs Updates client outcome mapping/metrics to remove floor/ramp paths and align with the new credit/limiter behavior.
crates/​node/​src/​dht/​rate_limit.rs Refactors DHT rate limiting implementation to the simplified per-peer+global model.
crates/​node/​src/​dht/​bucket_refresh.rs Updates bucket refresh behavior/docs to align with per-peer (not per-IP) limiter semantics.
crates/​node/​src/​admin/​tests.rs Updates admin RPC/tests to match the revised configuration fields and limiter model.
crates/​incentive/​src/​rate/​tests.rs Updates incentive rate tests for the removal of legacy floor/ramp mechanisms.
crates/​incentive/​src/​rate.rs Updates incentive rate logic by removing obsolete helpers tied to the previous credit model.
crates/​incentive/​src/​lib.rs Updates module exports/docs to reflect the new lane credit/delivered accounting structure.
crates/​incentive/​src/​lane/​tests.rs Adds/updates lane tests covering delivered-bytes persistence and credit/debit behavior.
crates/​incentive/​src/​lane.rs Implements lane delivered-bytes tracking and exposes credit/debit/refund operations needed by the new model.
crates/​incentive/​src/​credit/​tests.rs Removes/updates credit-window tests that were specific to the deprecated ramped-window design.
crates/​incentive/​src/​credit.rs Removes the deprecated ramped credit-window implementation in favor of the delivered-based credit approach.
crates/​e2e/​src/​node/​tests.rs Updates E2E node tests to reflect removed knobs and the new credit/rate-limit behavior.
crates/​e2e/​src/​node.rs Updates E2E node harness/fixtures to match the revised config and removed legacy fields.
crates/​common/​src/​config/​resolved.rs Updates resolved config types/defaults to add pay-ahead/backfill knobs and remove obsolete floor/per-IP settings.
crates/​common/​src/​config/​errors/​tests.rs Updates configuration error/notice tests for the new/renamed fields and validation messages.
crates/​common/​src/​config/​errors.rs Updates configuration error/notice documentation and examples for the new fields.
crates/​common/​src/​cli/​fetch.rs Wires new client pay-ahead policy options into the common fetch CLI configuration surface.
crates/​client/​tests/​snapshots/​public_api__public_api.snap Updates the client public API snapshot to reflect the new pay-ahead window and config surface.
crates/​client/​src/​streamer.rs Integrates pay-ahead policy application into the streaming/open-range flow and related pull behavior.
crates/​client/​src/​source_set.rs Updates source-set documentation/behavior to match revised terminology and credit/backpressure semantics.
crates/​client/​src/​rate_limited/​tests.rs Updates client rate-limited close-label tests to match revised semantics and labels.
crates/​client/​src/​rate_limited.rs Updates client-side rate-limited handling and associated close reason labeling/docs.
crates/​client/​src/​peer_store/​tests.rs Adds/updates tests for persisting pay-ahead trust/window state across runs.
crates/​client/​src/​peer_store.rs Persists per-operator trust stats and payer window state used to size/pay ahead per node.
crates/​client/​src/​payer_window/​tests.rs Adds unit/property tests for payer window sizing, clamping, and trust-driven adjustments.
crates/​client/​src/​pacer.rs Implements credit-based pacing logic for pulls (including miss-path pacing) under the pay-ahead model.
crates/​client/​src/​ledger/​tests.rs Adds/updates ledger tests for prepaid credit accounting, claims/clamps, and write-off semantics.
crates/​client/​src/​lanes.rs Updates lane ledger structures to incorporate per-operator trust and shared lane credit accounting.
crates/​client/​src/​driver.rs Updates the client driver to use the new credit/write-off model and revised completion/resume behavior.
crates/​client/​src/​credential/​tests.rs Updates credential-related tests to match pay-ahead cap/divisor behavior and funding projection changes.
crates/​client/​src/​credential.rs Updates credential funding/projection logic to account for pay-ahead window sizing constraints.
crates/​client/​src/​config/​tests.rs Adds/updates client config tests for new pay-ahead settings and defaults.
crates/​client/​src/​config.rs Extends client configuration with pay-ahead policy knobs and related builder/apply behavior.
crates/​client/​Cargo.toml Updates client crate dependencies/dev-dependencies to support the new payer-window test suite.
crates/​cli/​tests/​doctor_cli.rs Updates doctor CLI tests to validate notices/output for new config keys and removed fields.
crates/​cli/​tests/​config_validate.rs Updates CLI config validation tests for renamed/removed keys and new pay-ahead/backfill settings.
crates/​cli/​tests/​admin_rpc.rs Updates admin RPC CLI tests to reflect new config shapes and removed legacy knobs.
crates/​cli/​src/​commands/​gateway/​tests.rs Updates gateway command tests to reflect changed allowance/exposure behavior under pay-ahead.
crates/​cli/​src/​commands/​gateway.rs Updates gateway command logic to account for pay-ahead credit exposure in its computations.
crates/​cli/​src/​commands/​fetch/​tests.rs Updates fetch command tests to include/validate new pay-ahead policy flags and wiring.
crates/​cli/​src/​commands/​fetch.rs Wires fetch CLI pay-ahead flags into PullConfig and persists policy/trust through the peer store.
crates/​cli/​src/​commands/​doctor/​config/​tests.rs Updates doctor config subcommand tests for revised findings/notices around new keys.
crates/​cli/​src/​commands/​config/​tests.rs Updates config command tests for template/output changes and new/removed keys.
crates/​cli/​src/​commands/​config.rs Updates config command output/templates to include pay-ahead/backfill settings and remove obsolete fields.
Cargo.toml Updates workspace configuration/metadata to reflect the refactor and dependency changes.
Cargo.lock Updates lockfile to include dependency graph changes introduced by the client/test updates.
adr/​architecture.md Updates architecture documentation to reflect the payer-fronted credit model and limiter changes.
adr/​039-multi-source-parallel-fetch.md Updates ADR text to align multi-source/parallel fetch behavior with the new credit semantics.
adr/​038-bao-verified-range-streaming.md Updates ADR guidance around verified range streaming to reflect pay-ahead credit behavior and constraints.
adr/​022-content-discovery.md Updates content discovery ADR text for the simplified DHT rate limiting model.
adr/​013-schema-evolution.md Updates schema evolution ADR text for revised RATE_LIMITED semantics and related protocol behavior.
.claude/​skills/​decdn-spec-discipline/​references/​decdn-precedents.md Updates internal precedent notes to reflect the new payer-fronted credit approach and removed legacy mechanisms.

Review effort: Balanced

Comment thread crates/client/src/streamer.rs Resolved
Comment thread crates/incentive/src/lib.rs Resolved
Comment thread docs/runbook.md Resolved
…credit

Brings in #2879 (the size proof is the only statement of a blob size),
#2900 and the squash of #2873, whose code this branch already carries.

Conflict resolutions:
- node window.rs: main's new unproven-size and out-of-bounds refusals
  release a floor reservation; this branch has none, so those calls go.
- node dispatch.rs, window.rs imports: drop both the floor types and
  StreamResponseBody.
- cli fetch.rs: keep the PayerTrust guard; drop prove_size, which main
  removes.
- client streamer.rs: apply the pay-ahead policy, then read the proven
  size.
- client public_api snapshot regenerated.
- e2e pool_floor_ceiling_aggregate.rs stays deleted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Kpvr4Hsh3j4uw3sPiHpYkv
… links

Drop the removed ramp knobs from the client_loopback harness and the
ramp-only tests, bound the non-paying leaf in node_origin_pull by the
leaf's payment, remove two unused imports, and fix the decdn-client
intra-doc links that clippy and cargo doc reject.
…ee serve gaps

Node fixes:
- serve_leg: wait for lane credit only while wire remains, so a payer that
  paid exactly for the range is not left waiting after the last frame.
- dispatch: run the stateless pre-spend pool gate at the top of the miss
  path again, before any fill tier reads the origin (#1519).

Client fix: refuse a stream whose proven wire runs past the received-byte
cap at the open, before paying for bytes the cap would refuse.

Tests: client_loopback and node_origin_pull pay ahead of delivery. Tests
whose property was the removed floor reservation, committed-floor ledger
or per-stream ramp are deleted.
…de tests

Node:
- A stale sealed voucher on a lane with no credit, or a stale reveal on a
  stream anchored below the lane's signed watermark, is rejected
  AmountRegression with the watermark bundle at once, so a restarted payer
  reseeds instead of waiting out the proof timeout.

Client:
- An AmountRegression heal retires the chain the node did not adopt, as an
  UnderFold heal does.
- Every VoucherRejected forgets the lane's prepaid credit: a gate stop leaves
  the proofs in flight unread, so the node may not hold that credit.

Tests: origin_range_pull, partial_serve and node_to_node_pull_through pay
ahead of delivery; client_loopback's remaining payer, heal and split tests
follow the credit model. Deleted: the closing-voucher send-stop race tests
(a payer's last proof now precedes the node's last frame) and the last
floor-reservation race test.
@github-code-quality

github-code-quality Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 36b02fa claude/payer-fronted... 62400a5 +/-
77% 77% 0%
View coverage of the 10 most impacted files.
File main 36b02fa claude/payer-fronted... 62400a5 +/-
crates/client/src/config.rs 100% 78% -22%
crates/client/s...c/peer_store.rs 92% 90% -2%
crates/e2e/src/node.rs 23% 22% -1%
crates/client/src/lib.rs 89% 89% 0%
crates/cli/src/...mmands/fetch.rs 47% 48% +1%
crates/node/src...s/client/mod.rs 92% 93% +1%
crates/node/src...nt/serve_leg.rs 92% 94% +2%
crates/node/src...ent/delivery.rs 95% 99% +4%
crates/node/src...lient/credit.rs 0% 96% +96%
crates/client/s...payer_window.rs 0% 97% +97%

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


Updated November 17, 2026 16:48 UTC

Node:
- Each lane carries a credit watch that ticks when a proof credits it or a
  backfill returns credit. A stream waiting for credit races its own proof
  read against it, once its payer has paid on it, so a sibling's proof wakes
  it instead of leaving it to the proof timeout. A wake refunds the proof
  attempt.
- The stale sealed-voucher reject applies only to a stream no proof has
  credited, on a connection other than the one that last credited the lane:
  a restarted payer, not a sibling whose late voucher crossed a deeper one.

Client: a stream counts lane credit only once it has paid on itself, so a
lane's second stream pays its own first window and the node can wake it.
Node: after a clean StreamEnd, read and credit the proofs the payer sent
past the last frame before draining to FIN. The node reads a proof only
while credit falls short, so a stream that finished on a sibling's credit
left its own proofs unread while the payer counted them as lane credit.

Client:
- A stream blocked on a read pays again when the lane's prepaid credit
  falls (a sibling received bytes, or credit was dropped), without dropping
  the pinned read.
- After such a sibling spend, a shortfall below one chunk pays one chunk, or
  a closing residual for exactly the rest: the node sends a frame it cut to
  earlier credit whole or not at all.
@yigitdot

Copy link
Copy Markdown
Contributor

CI fix: what the last five commits change, and why

CI is green on 8ff61fe. Locally: 6302/6302 workspace tests, 139/139 anvil e2e journeys (the CI command), and fmt, clippy and doc are clean.

The first CI run failed on clippy, cargo doc, test and anvil e2e (journeys). The lint and doc failures were small. The test failures were not: the node integration tests had never been ported to payer-fronted credit, so they did not compile. Once they compiled, about 120 of them failed. Porting them turned up several places where the code did not do what this PR's description says it does. Those are real behaviour fixes, listed per commit below.

dfea871: compile the node integration tests, fix doc links

  • Removed an unused import that clippy rejected.
  • Fixed two doc errors: a link to ended_frontiers, which this PR deletes, and the payer_window module docs, which resolved in the wrong scope.
  • client_loopback.rs and node_origin_pull.rs still used the removed ramp knobs (credit_max, credit_ramp_divisor, ramped_credit_window). They now compile. I deleted the five ramp-only tests.

ea57a75: port the tests to lane credit, fix three serve gaps

Most tests read the old unpaid floor first and paid afterwards. They now pay ahead. Tests whose whole property was a removed mechanism are deleted: the floor reservation, the committed-floor ledger, and per-stream ramp or credit isolation.

Behaviour fixes:

  • Node, cache-miss serve. After sending the last frame, the loop waited for more credit before it noticed nothing was left to send. A payer that paid exactly for the range hung until the 10 s proof timeout.
  • Node, underfunded pool. The PR removed the check that refuses a pool whose remaining deposit cannot cover one chunk before any cache-miss fill runs. Without it, an underfunded pool made the node contact its origin, which reopens serve: hoist a pre-spend deposit check above the buffered/range/local fill tiers #1519. I restored it as a simple per-request check at the top of the miss path.
  • Client, over-cap blob. Since proposal: a node proves the blob size, so total_bytes is verified #2879 the blob size is proven when the stream opens. A stream whose wire runs past the received-byte cap is now refused before the client pays anything. Before, the client pre-paid for bytes its own cap would refuse.

aeb6688: restore the stale-proof heal, port the remaining node tests

  • Ported origin_range_pull, partial_serve, node_to_node_pull_through and the rest of client_loopback.
  • Restarted payer heal. A restarted payer that re-signs a watermark it lost now gets an immediate AmountRegression with the watermark bundle, and reseeds. Before, it waited out the proof timeout. The PR description claims this heal, but the code did not do it.
    • The node rejects a stale closing voucher on a lane with no credit.
    • It rejects a stale reveal only on a stream whose anchor voucher was signed below the lane's watermark, so an honest sibling's reordered reveal is not rejected.
  • Client retires the unadopted chain. The PR description says an AmountRegression heal retires the chain the node never adopted, as an UnderFold heal does. The code only did it for UnderFold. Without it, a payer that had paid ahead under a fresh chain retried under the same chain until it gave up.
  • Client forgets credit on every rejection. After a mid-stream PoolExhausted, the client still counted unread proofs as credit the node held, so it never paid again. A gate stop leaves proofs in flight unread, so the client's view of the node's credit is unknown there too.
  • One test fixture said a hydrated lane had delivered nothing, so its whole old claim counted as free credit. Fixed in the fixture.
  • Deleted three tests of a race where the client's last voucher loses to the node closing the stream. With pay-ahead, the client's last payment always reaches the node before the node's last frame, so that race cannot happen.

8b6df67: wake a paid stream on a sibling's credit

This is the anvil cli_bundle_pull_* failure: extra opens, 16 KiB over-billing, and ~10 s stalls.

  • Node. The PR description promises a wake when a sibling stream pays, but the code had none. Each lane now has a watch that ticks whenever a proof or a backfill adds credit. A stream waiting for credit races its own (cancel-safe) proof read against that tick.
    • A stream wakes only once its own payer has paid on it, per the PR's own rule. Without that limit, a stream held open without paying took credit its siblings had paid for.
    • A wake does not count against the proof budget.
  • Client. A stream ignores the lane's shared credit until it has paid on itself once. Before, a lane's second stream counted the first stream's prepaid credit as its own and never paid.
  • Node, narrower restart rejection. The stale closing-voucher rejection now applies only to a stream no proof has credited, on a connection other than the one that last credited the lane. That keeps it for a restarted payer (always a new connection) and stops it misfiring on an honest stream whose late voucher arrives after another stream's newer one.

8ff61fe: keep concurrent same-lane streams paying

This fixes two_concurrent_pulls_to_one_provider_share_the_lane_ledger and cli_bundle_pull_concurrent_same_lane_streams_bill_correctly, the over-billing listed under Known gaps.

  • Node, trailing proofs. After a clean StreamEnd, the node now reads and credits the proofs the payer sent after the last frame before closing. The node reads proofs only while it is short of credit. A stream that finished on credit another stream paid used to close with its own proofs unread, and the node discarded them while the client counted them as credit. Another stream on the lane then waited for a payment that never came.
  • Client, re-pay while waiting. A stream blocked on a read now pays again when the lane's credit drops: another stream received bytes, or credit was forgotten. It does this without dropping the frame it is reading. Before, a stream that decided not to pay while the lane still held another stream's credit never re-checked after that credit was used up.
  • Client, small shortfalls. The client pays in whole 1 MiB chunks except at a stream's end. The node cuts a frame to the credit it saw and sends all of it or none. When a sibling has taken credit in between, a shortfall under one chunk now pays one chunk, or the exact remainder near the end, instead of nothing. This applies only in that case: applying it everywhere over-paid early and drained small working deposits.

Not part of this PR

cargo deny reports two advisories in the pre-commit hook: crypto-bigint (RUSTSEC-2026-0387) and the unmaintained pin-utils. They come from dependencies, not this change, and they do not block the hook or CI.

…licy

The payer window policy is process-wide. open_range applied the config it
was given, so the CLI's streamed fetch, which builds a default PullConfig,
reset the user's --pay-ahead-* and loss flags to the defaults for every
pull in the process. The CLI already applies the user's policy at its entry
point (discovery_options), so open_range no longer applies one.

Also restore the space after a comma in the incentive crate-root doc table.
… refusal entry

The signer floor-cap refusal and its decdn_serve_stream_rejected_signer_floor_at_cap_total
counter no longer exist, and neither does blockchain.pool_floor_signer_live_windows.
The admission gate prices one chunk against the pool's remaining deposit less M.
ADR 037 still described the removed ramped credit window (credit_max,
credit_ramp_divisor, RampPacer) and the per-signer floor refusal. It now
states what the code does: the pull leg's CreditPacer draws only what the
downstream lane has paid for, plus PULL_AHEAD_BYTES, so a request that pays
nothing makes the node pull nothing. The deposit gate prices one chunk, the
parameters table names backfill_window and backfill_divisor, and the
pipelined look-ahead deferral is gone because the payer pays ahead.

The same stale wording goes from ADR 005, 022, 038, 039, the architecture
overview and the observability appendix.
A mid-stream PoolExhausted, PoolClosed or SignerCapExhausted stop left the
proofs the payer had already sent unread, and the client forgot its prepaid
credit on every rejection. When the node had credited those proofs, the
next stream paid the same chunk again: cli_fetch_topup settled about one
chunk over the whole-blob wire cost.

The node now reads and credits the proofs still in flight before it closes
a stream on a pool or signer stop, as it does after a clean StreamEnd. The
client forgets its prepaid credit only when the node refused a proof, so
the credit it counts after a gate stop is the credit the lane holds.
@yigitdot

Copy link
Copy Markdown
Contributor

Multi-agent review summary

Five review passes (code, tests, silent failures, type design, comments/ADRs) over the full diff; every critical claim below was verified by reading the code at the PR head (236a8dd). Overall: the core accounting is disciplined — saturations all money-safe, atomic debit sound, no lost wakeup in credit_wake, lints clean — but there are three confirmed bugs in the credit-liveness layer, the PR description misstates what shipped, and ADR 005 still specs the old model. The flaky tests are partly fixture infidelity, but two of the bugs below reproduce their exact symptom.

Critical — should block merge

1. Superseded sibling proofs kill a healthy concurrent stream with ProofBudgetExhausted.
A reveal at/below the lane frontier returns Continue { credited_bytes: 0 } (crates/node/src/handlers/client/voucher.rs:618); in acquire_credit only Woken refunds a proof attempt (crates/node/src/handlers/client/credit.rs:259). The node reads a stream's proofs only while that stream is short, so reveals buffer unread on a well-funded stream; one sibling reveal at a higher index supersedes them all. When credit later runs short, the stream reads 8 stale proofs in microseconds and dies at credit.rs:206-218. Hits concurrent same-lane streams (bundles, gateway, node miss pulls) once the window reaches ~9 chunks — tests start at the floor window and miss it. Fix: do not count a zero-credit proof that a sibling's fold already covered, or drain buffered proofs after each frame.

2. The payer never deducts in-flight loss, so its credit view drifts above the lane's and stalls it.
prepaid falls only on received bytes, write-off, or rejection (crates/client/src/ledger.rs:688-699; callers driver.rs:1426, lib.rs:3573, lib.rs:4554) — no stop/abort/drop path touches it, while the node debits at send time. After any unclean end, held exceeds the lane's real credit by the in-flight bytes; due() then under-pays and both sides wait (crates/client/src/payer_window.rs:123-138). Backfill heals only paid/backfill_divisor, same hash + same lane. This matches the flaky-test symptom verbatim ("the fixture lane and the payer disagree about the credit the lane holds"), and in a long-running gateway NodeTrust.outstanding ratchets up until cap_room_bytes hits zero. Fix: resync the payer's count on an unclean end, or have the node state lane credit in StreamResponse (wire change — fine pre-mainnet). The primed-unread-leg known gap shares this root cause.

3. Proof-budget exhaustion sends no AmountRegression and no watermark bundle — a restarted payer wedges forever.
The PR body's decision says a spent proof budget ends the stream with AmountRegression and the watermark bundle so the payer reseeds. The code does not: credit.rs:206-218 just stops, and the reveal-reject path is gated on credit_bytes() == 0 (voucher.rs:609). A lane holding 0 < credit < one chunk group leaves a restarted payer retrying the same stale chain indefinitely. Fix: reject with the bundle when anchor.trailing and the budget is spent, or gate on credit < len.

4. The PR description misstates the implementation (all three verified).
PoolLedger::claim_credit does not exist anywhere; BuyerLaneProgress is unchanged — nothing persists the payer's paid-not-delivered counter, so the known gap understates it (there is no persistence to restore); and the pay-ahead knobs are CLI flags only (crates/common/src/cli/fetch.rs:233-257) — no [client] TOML keys, no decdn config output. The description doubles as the design record; fix the text or the code to match.

Important

  • Backfill has zero tests at any level — take_backfill/apply_backfill/note_unclean_end (crates/node/src/handlers/client/mod.rs:207-238) decide unpaid-byte grants a client triggers at will by aborting; none of the bounds (divisor, window cap, fresh-signer zero, allowance farming) is pinned. credit.rs also has no unit-test file of its own.
  • Write-off budget exhaustion is invisible: once spent, every node's window silently pins to the floor for the run — no log or metric anywhere in payer_window.rs. The symptom is an unexplained throughput collapse. --write-off-budget 0 pins from byte zero (>= at payer_window.rs:296), undocumented; and the knob appears in no ADR, although ADR 003:255 enumerates exactly three payer knobs and the ADR is the spec.
  • ADR 005 still specs the node-fronts-credit model: :289 (per-stream window / ramp pool), :469 ("node pauses when unproved bytes exceed its credit window"), :361 (admission prices a window; code prices one chunk), :340 + ADR 003:429 (deleted floor accumulator / per-signer cap described as current) — direct contradictions of ADR 005:213. Same disease in code comments: an orphaned doc now mis-documents serve_stream_rejected_pull_loop_guard (crates/node/src/metrics.rs:3536-3538), inverted payment-direction docs (crates/client/src/pacer.rs:61-68, driver.rs:1069-1089), deleted-machinery docs at driver.rs:1411-1420, crates/cache/src/fill_session.rs:607-627, crates/node/src/handlers/client/window.rs:369, crates/client/src/endpoint.rs:24-33, plus stale metric docs (metrics.rs:1654-1685, 2490-2493, 3638-3643).
  • Gateway: one dropped response now charges ~66.5 MiB against the shared 1 GiB/day allowance (DROP_PENALTY_BYTES bakes the full 64 MiB cap, crates/cli/src/commands/gateway.rs:288-307) — ~15 aborted browser requests exhaust a public gateway. Cap at min(span, window). It also duplicates DEFAULT_RATE_PER_MB = 10 from a private common constant with no cross-pin.
  • Steal/cancel over-fronting: nothing lowers the pay-ahead target between a steal and the reader reaching the split (crates/client/src/driver.rs:1291-1317), so up to one window strands as lane credit per steal — ADR 003 says the payer stops paying ahead first. Bounded, not lost, but spec-violating.
  • Silent paths: a sibling-spend repay failure is dropped with no log and misattributed to the node (crates/client/src/lib.rs:3656-3673; a LocalPullFault provably never surfaces through the read); the HashMismatch write-off logs nothing while reconcile_empty warns (driver.rs:1426); the trailing-proof drain conflates faults and the timeout with a clean FIN (credit.rs:274-313); the 65th unclean end clear()s all 64 remembered gaps, contradicting its own doc ("forgets the older ones", mod.rs:178-214).
  • Test gaps: reconcile_empty trigger (the bounded-loss guarantee) never exercised; restart-then-serve never integrated; the AmountRegression retire-chain arm untested (lib.rs:2748-2755; the only retire loopback test uses UnderFold); no exact single-cover payment assertion under concurrency (the failing e2e billing test is the only one); negative credit_wake (an unpaid sibling must not wake) unpinned.
  • LaneState::delivered_bytes is a pub field with a pub refund whose real bound is re-derived by its caller (crates/incentive/src/lane.rs:120-129, mod.rs:231-234) — make the field private and have refund return the applied amount.
  • #[serde(default)] on peer_store's new verified_bytes/lost_bytes (crates/client/src/peer_store.rs:106-112) is a dual-format reader under the pre-mainnet rule — contrast StoredLaneState, which correctly made delivered_bytes required.

The three judgment calls

  • Flaky tests: ScriptedLane genuinely diverges from the real node (no fungible below-frontier reveal credit, no backfill), so fix the fixture — but bugs 1 and 2 are the same disagreement in production code. Both are true; fix both rather than retry-looping the tests.
  • Deleting pool_floor_ceiling_aggregate.rs: justified — its one property (floor-reservation aggregation) no longer exists and every neighboring property has surviving loopback coverage.
  • Tail billing (+576 bytes): do not loosen to a percentage. An acceptable interim is a two-sided bound with slack derived from the tail rule and a TODO(#2879); if the 576 cannot be derived, treat it as a possible billing bug rather than an assertion problem.

Strengths

acquire_credit's doc/atomicity contract is exemplary; every money subtraction saturates in the safe direction; the window formula is single-sourced; the PULL_AHEAD_BYTES ↔ frame_target coupling is documented at both sites and pinned by a cross-crate test; stream-end outcomes are exhaustively metered; money-bound assertions ("wire ≤ paid") are behavioral, not structural.

Suggested order: fix 1–3 (all in the credit-liveness layer; 2 together with the primed-leg gap), correct the PR body (4), add the backfill test suite, sweep ADR 005 + the stale comment list, then the gateway drop penalty and the observability warns.

…write off silent stalls

Three credit-liveness fixes from the PR 2877 review:

The serve loop reads, without waiting, the proofs the payer already
delivered on a stream before each frame (credit_buffered_proofs), so a
funded stream's proofs are committed near arrival instead of waiting
unread until a sibling's higher proof supersedes them and they spend the
proof budget crediting nothing. Each drained proof spends the frame's
proof budget, so a payer that slivers a frame across many proofs is cut
at the same bound as before.

A stream that spends its proof budget while the lane's credit does not
cover its next frame now ends with an AmountRegression reject carrying
the lane's watermark bundle, so a restarted payer whose ledger trails
the node's reseeds and resumes instead of retrying a superseded chain
forever.

The payer reconciles in-flight loss: a live stream that reads nothing
for a full floor window while the books hold lane credit writes that
credit off (ADR 003's first write-off case, observed), which books the
loss, shrinks the node's window, and unsticks the lane. A retired
ledger releases its counted credit from the operator's outstanding
total on drop, so stranded credit no longer ratchets the per-node cap
shut. The two previously flaky node_origin_pull tests pass 10/10 with
these fixes.
Code:
- The public gateway's drop penalty is capped by the dropped request's
  span, so aborted range requests no longer charge the flat pay-ahead
  bound against the shared daily allowance; a test pins the locally
  priced pay-ahead constant to the documented 64 MiB default.
- The unclean-ends map evicts one remembered end at its bound instead
  of clearing all 64, and its doc says so.
- Crossing the run's write-off budget logs a warning naming the
  consequence; the zero-budget boundary is documented. The HashMismatch
  write-off and a failed sibling-spend repayment are logged; the
  post-end proof drain tells a fault and its timeout apart from a FIN.
- LaneState.delivered_bytes is private: refund clamps to the bytes sent
  and returns the applied amount (take_backfill drops its re-derived
  clamp), and the on-disk decoder restores the count through a named
  setter.
- The peer store's verified/lost counts are required fields: a record
  without them fails to decode instead of silently resetting an
  operator's track record (pre-mainnet, no dual-format readers).

Tests:
- A backfill unit suite (allowance, window, fresh-signer, divisor-off,
  refund clamp, eviction), the negative credit-wake test, the zero-byte
  StreamEnd write-off pair, the AmountRegression heal and retire-chain
  tests, a single-cover payment bound on the concurrent same-lane test,
  the write-off-budget boundary tests, and a disconnect-leaves-trust
  assertion.
- The tail-billing e2e test passes with exact billing (3/3): the
  576-byte over-bill is gone with the proof-drain fix, so its assertion
  stays exact.

Docs:
- ADR 003/005/039, architecture, appendix-observability and every code
  comment that still described the node-fronts-credit model (ramped
  windows, floor reservation, per-signer floor caps, RampPacer,
  delivered-but-unpaid re-billing) now state the payer-fronts-credit
  design; write_off_budget is in ADR 003 § Credit Window with the other
  payer knobs.

The steal pay-ahead clamp is deferred to #2902.
@yigitdot

Copy link
Copy Markdown
Contributor

Review findings addressed in eef70e2 and a9dbead:

  • Critical 1 (proof-budget kill): fixed — credit_buffered_proofs drains delivered proofs before each frame, sharing the 8-proof budget (sliver bound unchanged; a funded stream is never stopped for drained proofs). Regression tests: buffered_stale_reveals_do_not_spend_a_later_frames_proof_budget, updated sliver tests.
  • Critical 2 (payer in-flight desync): fixed payer-side per the trustless axiom (no wire field) — a live stream that reads nothing for a full floor window against counted credit writes it off (write_off_silent_stall), and PoolLedger releases outstanding on drop. The two flaky node_origin_pull tests now pass 10/10, and the tail-billing e2e passes with exact billing 3/3 — the 576-byte over-bill is gone, so that assertion stays exact.
  • Critical 3 (reseed wedge): fixed — a spent proof budget rejects AmountRegression with the watermark bundle (the PR body's stated decision, now implemented).
  • Critical 4: PR body rewritten to match the code.
  • Importants: gateway drop penalty span-capped + 64 MiB cross-pin test; unclean-ends evicts one, not all; write-off-budget crossing warn + knob added to ADR 003; HashMismatch/sibling-spend/trailing-drain observability; backfill unit suite + negative credit-wake + reconcile_empty pair + retire-chain + single-cover + budget-boundary tests; LaneState.delivered_bytes private with clamping refund; peer-store counts required (no serde default); ADR 005/039/architecture/appendix + ~40 stale code comments swept to the new model.
  • Deferred: the steal pay-ahead clamp → Payer keeps paying ahead past a steal split until the reader reaches it #2902 (needs stop_at plumbed into UpstreamPull, public-API change).

yigitdot and others added 5 commits November 15, 2026 14:38
The ledger releases its counted credit from the operator's outstanding
total when it retires; the Drop impl is part of the public surface.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… drain and backfill

- The one-chunk exemption from the per-node pay-ahead cap reads the lane's
  credit and applies below one chunk group (`payer_window::lane_room`), so a
  lane holding a sliver no frame can use is never starved, and a lane that
  opens many streams takes the exemption once.
- `PeerStore::save_windows` adds the progress a process has not saved to the
  stored track record, so concurrent fetches no longer overwrite each other's
  verified and lost counts.
- The node's upstream buyer ledgers attach the operator's shared trust record,
  so the per-node cap and window ramp span its pools at one operator.
- The pre-frame proof drain ends the stream on a frame the reader consumed and
  could not use (`UnusableProofFrame`), as the waiting read does.
- Only a stream that ends on a fault leaves an unclean end for backfill; an
  in-band stop closes cleanly and grants none (ADR 003 § Credit Window).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aim on each proof

A node sends a frame only when the payment on that stream covers it. Each
proof states the share of the lane's payment it assigns to its stream: a
ChunkPreimage pays one chunk to its stream, and Voucher carries a new
unsigned `stream_bytes` field (the residual on a closing voucher, 0 on
anchor and rollover vouchers). The node credits min(share, lane paid -
lane claimed), with `claimed` held in memory per lane, so out-of-order
sibling reveals still pay the stream they were meant for and a replayed or
overstated share can only move the payer's own payment between its streams.
A lane loaded from disk starts with every paid byte claimed.

Removed with it: lane-level credit and its persisted delivered count, the
per-frame lane record, sibling credit wakes, the pre-frame proof drain and
the trailing settle, backfill and its [payment] keys, the payer's lane
prepaid counter, silent-stall write-off, reconcile_empty, sibling-spend
payment sizing and the per-run write-off budget (--write-off-budget).

The payer books each stream's end once: a delivery the node failed (a read
fault, stall, short delivery, refusal, rejected proof, or bytes the decoder
rejects) writes off paid - verified for that stream; a stream the payer
chose to stop or drop books no loss. Wire-breaking: the Voucher encoding
gains a field.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	crates/cli/src/commands/fetch.rs
#	crates/cli/src/commands/gateway/tests.rs
#	crates/client/src/sink.rs
#	crates/client/tests/snapshots/public_api__public_api.snap
#	crates/node/src/node_origin/admit_store.rs
#	crates/node/src/node_origin/pull_leg.rs
@alpergundogdu
alpergundogdu merged commit 95da7ad into main Nov 17, 2026
39 checks passed
@alpergundogdu
alpergundogdu deleted the claude/payer-fronted-credit branch November 17, 2026 16:59
alpergundogdu added a commit that referenced this pull request Nov 17, 2026
Takes main's pay-ahead credit design (#2877): the node-side floor
accumulator, per-signer live cap and credit ramp are gone, along with
pool_floor_signer_live_windows. The branch's per-pool routing stays:
lanes are keyed by LaneId (contract + LaneKey), redeem hints and lane
stores go through PoolRoute, and the voucher domain is the lane's pool
route.

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

Development

Successfully merging this pull request may close these issues.

4 participants