Skip to content

fix(node): attribute every inbound stream failure to one reason counter - #2166

Merged
thiras merged 1 commit into
mainfrom
fix/2073-attribute-inbound-stream-failures
Sep 26, 2026
Merged

thiras merged 1 commit into
mainfrom
fix/2073-attribute-inbound-stream-failures

Conversation

@thiras

@thiras thiras commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Closes #2073

Summary

decdn_streams_failed_total{direction="inbound"} ran ~297/day above the sum of its reason siblings, so the Unattributed stream failures panel (#2071) had an unreadable baseline. This PR makes every failed inbound stream count on exactly one reason counter, so the residual is 0 and any positive rate is a bug.

The residual was: stream-cap resets, unreadable requests, cache-hit voucher rejects, and every peer-attributable end (declined quotes, header handshakes, mid-stream drops). Requesters close with code 0, so the node cannot see why a peer left — but it can see whether any voucher credited bytes, which cleanly splits declined from abandoned with no wire change.

New counters

  • decdn_serve_stream_rejected_stream_cap_full_total
  • decdn_serve_stream_request_unreadable_total
  • decdn_serve_stream_voucher_rejected_total
  • decdn_serve_stream_client_declined_total — left before any voucher credited a byte (incl. the unadopted header handshake)
  • decdn_serve_stream_client_abandoned_total — left after paying

Mechanics

  • ServeEnd::meter + ErrEnd (outcome.rs) count every end in one exhaustive place in the dispatch sink, reason before the failed count (panics included), replacing 14 per-site bumps.
  • deliver/serve_leg become thin wrappers owning paid; a post-payment error carries a PaidProgress marker.
  • write_reject and respond_error tolerate a departed peer, so a refusal/reject/stop keeps its reason; a sign failure counts only as a node fault; a framed write after this node's own close is a node fault (downcast of the wrapped WriteError).
  • Proof-budget exhaustion → ServeStop::ProofBudgetExhausted; request-read failure → ResetCause::RequestUnreadable; both keep their detail on the span error field.
  • INBOUND_FAILURE_REASONS drives both Unattributed panels; the delivery dashboard gains the new series.

ADR appendix-observability.md rows and CHANGELOG updated.

Test plan

  • Unit: every ServeEnd/ErrEnd meters exactly one listed counter and together they cover the list; every exported decdn_serve_stream_* counter is listed; both panels subtract exactly the list; ClosedStream framed-write classification; tag_paid_progress; tolerant write.
  • Loopback/miss-path: declined, abandoned (hit and miss — mutation-checked), unreadable request, stream cap, proof budget, bad-signature and zero-byte vouchers, underpaid miss voucher, hash-denied refusal, mid-stream pool drain, three takedown tests — each asserts the residual is zero via assert_inbound_failures_attributed.
  • cargo clippy --workspace --all-targets -D warnings, rustdoc -D warnings, cargo nextest run -p decdn-node (1379 passed ×2; one retry of the known silent_upstreams_do_not_starve_the_candidate_loop outbound timing flake), pre-commit.
  • After testnet deploy: Unattributed panel ≈ 0 over 24h; declined + abandoned absorb the old ~297/day.

🤖 Generated with Claude Code

About 91% of decdn_streams_failed_total{direction="inbound"} had no reason
counter, so the Unattributed stream failures panel showed a baseline no
operator could read (#2073).

- Five new sibling counters: rejected_stream_cap_full, request_unreadable,
  voucher_rejected, client_declined (the peer left before a voucher credited
  a byte, which includes the unadopted header handshake) and
  client_abandoned (the peer left after paying).
- ServeEnd::meter and ErrEnd count every end in one exhaustive place in the
  dispatch sink, reason before the failed count, so each inbound failure
  counts on exactly one reason and a new variant cannot compile unmetered.
- The deliver/serve_leg wrappers own the paid-byte count and tag a
  post-payment error PaidProgress, which splits declined from abandoned.
- A refusal, voucher reject or mid-stream stop whose frame a departed peer
  never reads keeps its own reason. A sign failure counts only as a node
  fault. A framed write after this node's own close is a node fault.
- A spent proof budget and an unreadable request end as Stopped/Reset and
  keep their detail on the span's error field.
- INBOUND_FAILURE_REASONS drives both Unattributed panels; tests hold the
  list to the panels, to every exported serve_stream counter, and to the
  metering of every end. Loopback and miss-path tests assert the residual
  is zero.

Closes #2073

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

🔵 Needs a closer look

The broad runtime, metrics, dashboard, and integration changes warrant final human review.

Review effort: Lite
Findings: None

What changed in this PR

This PR centralizes inbound stream-failure attribution so every failure maps to one reason counter, with updated dashboards, tests, and documentation.

Changes:

  • Adds five failure-reason counters and exhaustive outcome metering.
  • Expands attribution coverage across stream, voucher, and write-error paths.
  • Updates dashboards, metrics documentation, changelog, and integration tests.
File Reviewed changes
monitoring/​grafana-dashboard.json Updates failure residual panel.
monitoring/​dashboard-delivery.json Adds outcome series and residual panel updates.
crates/​node/​tests/​support/​mod.rs Adds attribution polling support.
crates/​node/​tests/​node_origin_pull.rs Adds pull-through attribution coverage.
crates/​node/​tests/​client_loopback.rs Adds loopback attribution scenarios.
crates/​node/​src/​metrics.rs Defines counters and attribution validation.
crates/​node/​src/​handlers/​client/​wire.rs Classifies peer and node write failures.
crates/​node/​src/​handlers/​client/​voucher.rs Updates proof-budget outcomes.
crates/​node/​src/​handlers/​client/​serve_leg.rs Tracks paid miss-leg progress.
crates/​node/​src/​handlers/​client/​outcome.rs Centralizes exhaustive outcome metering.
crates/​node/​src/​handlers/​client/​mod.rs Routes stop outcomes through centralized metering.
crates/​node/​src/​handlers/​client/​dispatch.rs Applies attribution at stream completion.
crates/​node/​src/​handlers/​client/​delivery.rs Tracks paid progress and stop outcomes.
CHANGELOG.md Documents the observability fix.
adr/​appendix-observability.md Updates metric definitions and semantics.

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

@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit d514549 in the fix/2073-attribute-i... branch remains at 86%, unchanged from commit dd30114 in the main branch.

Show a line coverage summary of the most impacted files.
File main dd30114 fix/2073-attribute-i... d514549 +/-
crates/node/src...ent/dispatch.rs 82% 82% 0%
crates/node/src/metrics.rs 96% 96% 0%
crates/node/src...ent/delivery.rs 94% 94% 0%
crates/node/src...ient/voucher.rs 94% 95% +1%
crates/node/src...nt/serve_leg.rs 89% 90% +1%
crates/node/src...s/client/mod.rs 95% 96% +1%
crates/node/src...ient/outcome.rs 95% 98% +3%
crates/node/src.../client/wire.rs 92% 96% +4%

@thiras
thiras merged commit 74b13a5 into main Sep 26, 2026
31 checks passed
@thiras
thiras deleted the fix/2073-attribute-inbound-stream-failures branch September 26, 2026 20:01
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.

~91% of seller-leg stream failures have no reason counter

2 participants