Skip to content

fix(node): attribute every reputation outcome to its peer (#1987) - #2001

Merged
thiras merged 3 commits into
mainfrom
fix/1987-reputation-attribution
Sep 14, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/1987-reputation-attribution

Conversation

@thiras

@thiras thiras commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Summary

A failed probe or pull lowers a peer's local reputation score, but nothing recorded which peer took the hit. This PR adds that record.

  • One event for every score change. record_outcome is the single choke point for reputation writes. It now calls fold_outcome, which emits debug!(target: "decdn::reputation", peer, ?outcome, score). score is the post-fold value that LocalReputation::record already returned; the caller used to discard it.
  • Probe-failure line (probe_candidate): now carries peer and the operator address when it resolves (provider_addr is an Option).
  • The other scoring lines (degraded refusal, corruption, pull Unreachable): gain peer as a join key.
  • Runbook: a short "Attribute" note under Delivery hash mismatch. It names the filter RUST_LOG=info,decdn::reputation=debug.

debug!, not info!: a dead peer gets re-probed on every cache miss, so an info! per penalty would flood the default log. To investigate, watch the counter rise, then turn on that one log target.

Deliberately not done

Test plan

  • New unit test a_reputation_penalty_names_the_peer_and_its_new_score: captures the tracing output and checks the target, peer=, the outcome, and that the logged score matches the stored score. It also checks the aggregate counter.
  • cargo nextest run -p decdn-node node_origin: 79 passed
  • cargo nextest run -p decdn-node --test node_origin_pull: 66 passed
  • clippy -D warnings, fmt, rustdoc -D warnings, pre-commit hooks

Closes #1987

🤖 Generated with Claude Code

https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j

`record_outcome` is the single choke point for local reputation writes.
It now emits a `decdn::reputation` debug event carrying the peer, the
outcome, and the post-fold score that `LocalReputation::record` already
returned and the caller discarded. The probe-failure `Unreachable` line
gains the peer id and the resolvable operator address, and the other
scoring lines gain `peer` as a join key.

The `node_pull_*` counters stay unlabeled: a peer-id label is unbounded
cardinality and breaks the sibling-counter convention (#1475). The
runbook names the `RUST_LOG=info,decdn::reputation=debug` filter that
attributes a counter rise instead.

Closes #1987

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j
Copilot AI lite review requested due to automatic review settings September 14, 2026 07:36
@thiras thiras self-assigned this Sep 14, 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.

🟡 Changes recommended

RegionLatencyMismatch still records reputation directly, bypassing the required attribution event.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This pull request adds per-peer debug attribution for node-origin reputation changes and documents the corresponding log filter.

Changes:

  • Logs peer, outcome, and post-fold score details.
  • Adds peer context to probe and pull failure handling.
  • Documents the reputation logging filter and adds test coverage.
  • A RegionLatencyMismatch update still bypasses the attribution path.
File summaries
File Summary
docs/runbook.md Documents per-peer reputation attribution.
crates/node/src/node_origin/mod.rs Adds attribution logging, failure context, and tests; retains one direct reputation update that needs routing through record_outcome.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

Comment thread crates/node/src/node_origin/mod.rs Resolved
thiras and others added 2 commits September 14, 2026 10:42
…tcome

`probe_candidate` folded `RegionLatencyMismatch` into the local score
directly, so that penalty skipped the `decdn::reputation` attribution
event. It now goes through `record_outcome` like every other outcome.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j
A reload rebuilds the tracing filter from `observability.log_level` and
drops any `RUST_LOG` per-target setting, so the runbook and the
`REPUTATION_LOG_TARGET` doc now say to restart with `RUST_LOG` set. The
wording narrows "every score change" to "every recorded outcome", since
idle decay moves scores without an event, and `probe_candidate` lists the
ADR 030 region penalty among its side effects. The test pins the target
string the runbook quotes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j
@github-actions

Copy link
Copy Markdown

Coverage report

Total: 82.74% (was 82.86%, ▼ 0.12%) — 76995/93054 lines

File Coverage Lines Δ
crates/node/src/node_origin/mod.rs 92.02% 1084/1178 ▼ 0.89%
History
Commit Total Δ vs base
5562953 (HEAD) 82.74% ▼ 0.12%

@thiras
thiras merged commit bb53bc7 into main Sep 14, 2026
25 checks passed
@thiras
thiras deleted the fix/1987-reputation-attribution branch September 14, 2026 07:58
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.

node: probe-failure reputation penalty is applied with no peer identifier, no labeled metric, and no score surface

2 participants