Repository navigation
fix: buyer-side rate integrity & slash evidence on the paid-pull path (#1375, #1377, #1382) - #1420
Conversation
|
Warning Review limit reached
Next review available in: 32 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (23)
WalkthroughThe change adds buyer-side per-MB rate ceilings, threads them through configuration and pull APIs, rejects over-ceiling quotes before payment, refactors upstream refusal access, and adds typed rate-floor voucher rejection handling with node-origin classification and tests. ChangesRate Ceiling and Refusal Handling
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant NodeOrigin
participant Upstream
participant VoucherHandler
Client->>NodeOrigin: request paid pull with max_rate_per_mb
NodeOrigin->>Upstream: probe candidate and open stream
Upstream-->>NodeOrigin: signed StreamResponse quote
NodeOrigin->>NodeOrigin: compute effective rate ceiling
alt quote exceeds ceiling
NodeOrigin-->>Client: RateAboveCeiling with signed evidence
else quote accepted
NodeOrigin->>VoucherHandler: submit voucher
VoucherHandler-->>NodeOrigin: VoucherAck or RateFloorRaised
NodeOrigin-->>Client: pull result or retryable re-quote outcome
end
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
Pull request overview
This PR hardens the paid-pull buyer path by (1) making slash-evidence invariants unforgeable in types, (2) enforcing a buyer-side rate ceiling with retained signed over-quote evidence, and (3) adding an explicit wire-level re-quote signal when the live delivery floor rises mid-stream.
Changes:
- Introduce
UpstreamRefusedencapsulation so “signed evidence present ⇒ open-stage, verified” is enforced by construction, and adjust all call sites to use accessors. - Add buyer-side rate ceiling enforcement (
RateAboveCeiling+effective_rate_ceiling) and plumb a newcache.max_rate_per_mbknob through node + CLI paths, including metrics and tests. - Append
VoucherRejectReason::RateFloorRaisedto the protocol and use it server-side to signal a floor-raise-induced re-quote instead of an opaque transport error.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/protocol/tests/snapshots/public_api__public_api.snap | Public API snapshot update for the appended RateFloorRaised variant. |
| crates/protocol/src/client.rs | Adds VoucherRejectReason::RateFloorRaised with ordering freeze + documentation. |
| crates/node/tests/sighup_signal.rs | Extends resolved cache config seed with max_rate_per_mb. |
| crates/node/tests/node_origin_pull.rs | Plumbs max_rate_per_mb into origin configs and adds an integration test for probe-relative rate ceiling behavior + metric + reputation neutrality. |
| crates/node/tests/client_loopback.rs | Adds loopback tests for buyer rate ceiling refusal/accept boundary and evidence retention; updates call signatures. |
| crates/node/src/runtime/reload.rs | Seeds + restart-required detection includes cache.max_rate_per_mb. |
| crates/node/src/runtime/mod.rs | Threads resolved cache.max_rate_per_mb into NodeOriginConfig. |
| crates/node/src/node_origin.rs | Applies effective_rate_ceiling, classifies RateAboveCeiling as PullVerdict::RateCeiling, adds metric + suppression behavior, and handles RateFloorRaised as retryable-with-channel-kept. |
| crates/node/src/metrics.rs | Adds node_pull_rate_above_ceiling counter and recorder hook. |
| crates/node/src/handlers/client/voucher.rs | Emits RateFloorRaised on live-floor rejection instead of bail!, aiming for a graceful re-quote signal. |
| crates/e2e/tests/g_node_08_revocation.rs | Migrates UpstreamRefused usage to accessor-based API. |
| crates/e2e/tests/g_node_08_authorized_origin.rs | Migrates UpstreamRefused usage to accessor-based API. |
| crates/e2e/src/client.rs | Migrates to UpstreamRefused::{error(), evidence()} and updates buyer call signatures for the new ceiling parameter. |
| crates/common/src/config/types.rs | Adds cache.max_rate_per_mb to config types with documentation. |
| crates/common/src/config/resolved.rs | Adds resolved max_rate_per_mb with documented semantics (0 = unlimited). |
| crates/common/src/config/mod.rs | Resolves max_rate_per_mb from CLI/env/file and wires env var name. |
| crates/common/src/cli/run.rs | Adds --max-rate-per-mb to node run CLI args (and env support). |
| crates/common/src/cli/fetch.rs | Adds --max-rate-per-mb to CLI fetch args, documented as an opt-in ceiling on the client path. |
| crates/client-pull/src/lib.rs | Adds RateAboveCeiling, effective_rate_ceiling, rate ceiling checks in open stage, and encapsulates UpstreamRefused evidence invariants. |
| crates/cli/tests/config_validate.rs | Updates sample resolved config with max_rate_per_mb. |
| crates/cli/src/commands/fetch.rs | Threads max_rate_per_mb through CLI fetch/bundle pull plumbing; updates UpstreamRefused handling. |
| crates/cli/src/commands/config.rs | Prints max_rate_per_mb in validate summary and documents it in the default config template. |
| crates/cli/src/commands/bundle_pull.rs | Threads max_rate_per_mb into per-entry pulls and updates UpstreamRefused usage in tests/logic. |
| adr/005-protocol.md | Updates ADR protocol documentation to include RateFloorRaised semantics and retry behavior table. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…#1375, #1377, #1382) Batch of three tightly-coupled fixes on the paid-pull buyer path, all surfaced in the G-GOV e2e review series. #1377 — express UpstreamRefused's evidence invariants in the type. Convert the two-pub-field struct to a newtype over a private inner enum (Open{error,response} / MidStream{error}). Enum variant fields cannot be private in Rust, so the newtype is what makes "present response ⇒ open-stage, verified" unforgeable. Crate-private open() derives error from the response (and now also rejects ok==true); pub mid_stream() is provably evidence-free; error()/evidence() accessors; slash_sig-eliding Debug. All consumers migrated (.error→.error(), .response→.evidence()), incl. the e2e on-chain-challenge feeder which can no longer receive an unverified response. #1375 — buyer-side rate ceiling + retained slash evidence. Refuse a stream quote above effective_rate_ceiling(candidate probe rate, config max_rate_per_mb) BEFORE paying, via a typed RateAboveCeiling that carries the operator's own signed over-quote as replayable evidence (single crate-private constructor derives the quoted rate from the response). Classified as reputation-neutral PullVerdict::RateCeiling: metered (node_pull_rate_above_ceiling) and suppressed, never tarring the peer. New cache.max_rate_per_mb knob wired through all surfacing sites and both the node-to-node and CLI buyer paths. #1382 — graceful re-quote signal on a live-floor voucher rejection. Emit the new VoucherRejectReason::RateFloorRaised (appended wire variant) instead of an opaque anyhow::bail! when a governance floor raise strands an honest buyer's quote; the buyer classifies it retry-with-re-quote (channel kept). Scope per merged #1388, which correctly kept the live-floor read. ADR 005 updated (SoT) with the new reason plus the two handler-direct variants its listing had drifted from. Adds unit, loopback, and node-origin integration coverage (probe-relative bound, exact-ceiling accept, evidence signature recovery, RateCeiling verdict) and extends the wire-order freeze test. Verified: fmt, clippy --all-targets, protocol/client-pull/node suites, public-api snapshot, and e2e (anvil-e2e) build. Closes #1375 Closes #1377 Closes #1382 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
3d7cde7 to
ce52c9b
Compare
Coverage reportTotal: 81.00% (was 81.01%, ▼ 0.01%) — 51929/64109 lines
History
|
…rot again (#1473) `crates/node/tests/anvil_bringup_shutdown_e2e.rs` has not compiled since 2026-07-23. `ResolvedConfig` gained a `content` field in #1380 and `ResolvedCache` gained `max_rate_per_mb` in #1420; neither threaded the new field into this builder. Adding the two initializers is the whole fix — the test then passes on the first run, so nothing about the behaviour it asserts had actually regressed. The interesting part is why nobody noticed for three days. The `anvil e2e (settlement)` job ran `--test anvil_settlement_e2e`, a single-target filter, so this file was never built by any job in CI. It was even edited in its broken state by #1465 the day before this fix, because touching a file that no job compiles produces no signal. `cargo build --workspace --all-targets` does not catch it either: the target is behind the off-by-default `anvil-e2e` feature. So the job now names both anvil targets explicitly rather than filtering to one. A bare `-p decdn-node --features anvil-e2e` would have been shorter but drags the full unit suite in behind the feature flag and duplicates the `test` job; the explicit list keeps the job scoped while making a missing target a build failure instead of silence. The added target needs only `anvil` + `forge`, both already on PATH in that job, and drives `runtime::run` in-process, so it fits the "no daemon binary on disk" property the split relies on. Adds ~25s. Both targets pass together locally: 5 tests across 2 binaries. Incidental, found while auditing the metric registry for #1443: `decdn_probe_holds_disabled_total` was documented twice in `adr/appendix-observability.md` — once under § Slash-Safety Metrics and again under § Probe Metrics — and the two copies had already drifted in wording. The § Slash-Safety Metrics row is canonical (that section's preamble states the probe-hold capacity metrics are grouped there deliberately), so the § Probe Metrics copy is removed and replaced with a pointer naming all five probe-hold metrics and why they live elsewhere. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Batch of three tightly-coupled fixes on the paid-pull buyer path, all surfaced in the G-GOV e2e review series and reviewed by the multi-agent PR toolkit before opening.
#1377 — express
UpstreamRefused's evidence invariants in the typeUpstreamRefusedbecomes a newtype over a private inner enum (Open{error,response}/MidStream{error}). Enum variant fields can't be private in Rust, so the newtype is what makes "present response ⇒ open-stage, verified" unforgeable rather than doc-comment convention. Crate-privateopen()deriveserrorfrom the response (and rejectsok == true);pub mid_stream()is provably evidence-free;error()/evidence()accessors; aslash_sig-elidingDebug. All consumers migrated (.error→.error(),.response→.evidence()) — including the e2e on-chain-challenge feeder, which can no longer be handed an unverified response.#1375 — buyer-side rate ceiling + retained slash evidence
The buyer refuses a stream quote above
effective_rate_ceiling(candidate probe rate, config max_rate_per_mb)before paying any voucher, via a typedRateAboveCeilingthat carries the operator's own signed over-quote as replayable rate-manipulation evidence (a single crate-private constructor derives the quoted rate from the response, so it can't desync). Classified as reputation-neutralPullVerdict::RateCeiling: metered (node_pull_rate_above_ceiling) and suppressed, never tarring the peer. Newcache.max_rate_per_mbknob wired through every surfacing site and both the node-to-node and CLI buyer paths.#1382 — graceful re-quote signal on a live-floor voucher rejection
Emits the new
VoucherRejectReason::RateFloorRaised(appended wire variant) instead of an opaqueanyhow::bail!when a governance floor raise strands an honest buyer's quote; the buyer classifies it retry-with-re-quote (channel kept). Scope per merged #1388, which correctly kept the live-floor read as the node's on-chain-mirrored self-protection.Notes
RateAboveCeilingevidence is retained on the error for a caller; the daemon does not yet auto-submit a challenge (auto-slashing deferred, same footing asUpstreamRefusedevidence today).Tests
Unit (
effective_rate_ceiling,UpstreamRefusedencapsulation,open()ok==true rejection, wire-order freeze incl.RateFloorRaised), loopback (over-ceiling refusal with evidence signature recovery, exact-ceiling accept), and a node-origin integration test pinning the probe-relative bound +RateCeilingverdict + metric + reputation neutrality.Verified:
fmt --check,clippy --workspace --all-targets, protocol/client-pull/node suites, public-api snapshot, and theanvil-e2ebuild.Closes #1375
Closes #1377
Closes #1382
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes