Skip to content

fix(node): don't tar honest providers' reputation for buyer-side pull failures (#857) - #882

Merged
thiras merged 3 commits into
mainfrom
fix/857-buyer-side-pull-misclassification
Jun 12, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/857-buyer-side-pull-misclassification

Conversation

@thiras

@thiras thiras commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #857. In the node→node cache-miss pull path, pull_from_candidate classified every non-HashMismatch / non-BlobTooLargeClaim stream_fetch error as Outcome::Unreachable, which both folds a hard 0.0 into the local EWMA score and emits a gossiped uptime_observed: Some(false) report. Two of those errors are the buyer's own fault, not the provider's:

So a buyer systematically down-scored and publicly defamed honest providers it had successfully pulled from.

Approach

Mirrors the existing channel-open-failure / BlobTooLargeClaim exoneration pattern (typed sentinel + downcast_ref, skip the candidate without recording a reputation observation):

  • client_requester.rs — replace the two bare-anyhow errors with typed sentinels PullTimeout and UpstreamVoucherRejected. The latter carries the typed Copy VoucherRejectReason (not a lossy format!("{e:?}")), and the ack match is narrowed so only a genuine StreamError::VoucherRejected is exonerated — any other StreamError at the voucher-ack point is an upstream protocol violation and stays provider-attributable.
  • node_origin.rs — downcast_ref both sentinels in pull_from_candidate and return None with a metric + debug log, no reputation recorded. A failure to sign/encode our own voucher still maps to Unreachable by design (catastrophic local fault, not routine provider mis-scoring) — documented at the catch-all arm.
  • metrics.rs — new decdn_node_pull_timeout_total / decdn_node_pull_voucher_rejected_total counters so the now-silent rejections stay visible to operators.

Per the decision on the issue, timeouts are fully exonerated (no local or gossip signal) — accepting that a genuinely stalling provider won't be deprioritized for future pulls.

Tests

  • Flipped node_origin_pull_falls_through_a_stalled_candidate: the timed-out staller now records no observation, and its local score stays neutral (guards a future local/gossip split).
  • New node_origin_voucher_rejection_does_not_tar_upstream: serves correct bytes, rejects the closing voucher → NotFound, empty observation buffer, neutral score, only node_pull_voucher_rejected moves.
  • New node_origin_transport_failure_still_scores_unreachable: over-exoneration regression guard — a real post-probe transport failure must still score Unreachable.
  • New unit buyer_side_sentinels_survive_anyhow_downcast: pins the downcast_ref-after-anyhow contract at the boundary.

Review

This PR incorporates findings from a multi-agent review pass (narrowed the over-broad StreamError match, switched the carried reason to the typed enum, added the over-exoneration + local-score + downcast tests, corrected a doc over-claim).

Verification

```
cargo build -p decdn-node && cargo clippy -p decdn-node --all-targets
cargo nextest run -p decdn-node # 593 passed, 0 skipped
cargo fmt -- --check
```

🤖 Generated with Claude Code

… failures (#857)

The node→node cache-miss pull path classified every non-HashMismatch /
non-BlobTooLargeClaim stream_fetch error as Outcome::Unreachable, which folds a
0.0 sample into the local EWMA score AND emits a gossiped
uptime_observed: Some(false) report. Two of those errors are the buyer's own
fault, not the provider's: a local pull_timeout and an upstream voucher
rejection (our stale nonce / deposit exhaustion). The result was a buyer
systematically down-scoring and publicly defaming providers it had successfully
pulled from.

Mirror the existing channel-open-failure / BlobTooLargeClaim exoneration
pattern:

- client_requester: replace the two bare-anyhow errors with typed sentinels
  PullTimeout and UpstreamVoucherRejected (carrying the typed Copy
  VoucherRejectReason, not a stringified Debug). Narrow the ack match so only a
  genuine StreamError::VoucherRejected is exonerated — any other StreamError at
  the voucher-ack point is an upstream protocol violation and stays
  provider-attributable.
- node_origin: downcast both sentinels in pull_from_candidate and skip the
  candidate without recording a reputation observation. A failure to sign/encode
  our OWN voucher still maps to Unreachable by design (catastrophic local fault,
  not routine provider mis-scoring) — documented at the catch-all arm.
- metrics: add node_pull_timeout / node_pull_voucher_rejected counters so the
  now-silent rejections stay visible to operators.

Tests: flip the stalled-candidate test (the timed-out staller now records no
observation and its local score stays neutral); add a voucher-rejection
exoneration test, an over-exoneration regression guard (a real post-probe
transport failure must STILL score Unreachable), and a unit test pinning the
downcast-after-anyhow contract.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings June 12, 2026 21:07

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request addresses issue #857 by introducing typed sentinel errors (PullTimeout and UpstreamVoucherRejected) to distinguish buyer-side failures (such as local timeouts and payment-side voucher rejections) from actual provider reachability or transport failures. This prevents honest providers from having their reputation unfairly penalized. It also adds corresponding metrics and extensive integration tests to verify this behavior. The review feedback suggests updating the unit tests to use root_cause().downcast_ref() to ensure that context-wrapped errors are also successfully recovered.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread crates/node/src/node_origin.rs Resolved

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.

Pull request overview

This PR fixes provider reputation mis-scoring in the node→node cache-miss pull path by distinguishing buyer-side failures (local pull timeout and upstream voucher rejection) from true provider reachability problems, preventing honest providers from being down-scored locally or via gossiped observations.

Changes:

  • Introduces typed buyer-side error sentinels (PullTimeout, UpstreamVoucherRejected) in the requester and uses downcast_ref in pull_from_candidate to exonerate providers for those cases.
  • Adds new operational counters for the exonerated cases (node_pull_timeout, node_pull_voucher_rejected) to keep these failures observable despite no longer emitting reputation observations.
  • Updates/adds integration tests to assert: no observation/local EWMA penalty for buyer-side timeout/voucher rejection, while real transport failures still score Unreachable.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
crates/node/src/client_requester.rs Adds typed error sentinels for buyer-side timeout and voucher rejection; narrows voucher-ack error matching.
crates/node/src/node_origin.rs Exonerates providers on buyer-side sentinel errors (no local/gossip reputation hit) and adds a unit test to pin anyhow downcasting behavior.
crates/node/src/metrics.rs Adds counters for exonerated pull timeout and upstream voucher rejection for operator visibility.
crates/node/tests/node_origin_pull.rs Extends integration coverage for the new exoneration behavior and adds a transport-failure regression guard.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/node/tests/node_origin_pull.rs Resolved
@github-actions

github-actions Bot commented Jun 12, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 86.12% (was 86.13%, ● 0.00%) — 35001/40640 lines

File Coverage Lines Δ
crates/node/src/client_requester.rs 86.11% 279/324 ▼ 1.19%
crates/node/src/metrics.rs 83.82% 720/859 ▲ +0.11%
crates/node/src/node_origin.rs 90.88% 279/307 ▲ +0.77%
History
Commit Total Δ vs base
122fff4 86.12% ● 0.00%
b8913fc 86.16% ▲ +0.03%
bcff4b9 (HEAD) 86.12% ● 0.00%

thiras and others added 2 commits June 13, 2026 00:14
…(PR #882 review)

- serve_then_reject_voucher: bail with a clear message if the buyer stops
  presenting a closing voucher, instead of silently no-op'ing into a confusing
  timeout/EOF on the buyer side (Copilot).
- buyer_side_sentinels_survive_anyhow_downcast: add a context-wrapped assertion
  using the SAME plain `downcast_ref` the orchestrator uses (verified anyhow
  walks the chain), and correct the doc comment that wrongly implied a context
  layer would break classification. Kept plain `downcast_ref` rather than the
  suggested `root_cause().downcast_ref()` so the test exercises production's
  actual call (Gemini).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ay (PR #882 review round 2)

Low-severity polish from the second review pass (no Critical/Important found):

- node_origin: note the voucher-rejection arm is intentionally reason-agnostic
  and that RetryLater resend is not yet wired (same terminal behavior as
  pre-#857), so the carried typed reason isn't mistaken for active per-reason
  handling.
- client_requester: note that UpstreamVoucherRejected's `{:?}` Display is
  load-bearing for the loopback .contains("RetryLater"/"Expired") assertions.
- node_origin_pull: assert the flipped stalled-candidate test leaves the
  voucher-rejected and corruption counters at 0, for symmetry with the
  voucher/transport tests (guards a timeout double-classification).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@thiras
thiras merged commit 0356a8b into main Jun 12, 2026
38 of 40 checks passed
@thiras
thiras deleted the fix/857-buyer-side-pull-misclassification branch June 12, 2026 21:32
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