Repository navigation
refactor: drop two dead knobs — min-reputation floor and trusted-IP rate-limit exemption - #1456
Conversation
…floor
The floor was built ahead of any consumer: the sole production call site
(`node_origin.rs` -> `rank_candidates`) passed `DEFAULT_MIN_REPUTATION = 0.0`,
which short-circuits filtering entirely, and no config, CLI, or client path
ever threaded a non-zero value. Every `_with_floor` entry point was exercised
only by unit tests.
Poor-reputation nodes are still de-prioritized by the two mechanisms that ship
and stay: the `reputation^2` score amplification and the `max(reputation, 0.1)`
denominator clamp (`REPUTATION_FLOOR`), which are unrelated to the rejection
floor despite the shared word.
* selection.rs: drop `DEFAULT_MIN_REPUTATION`, `apply_reputation_floor`,
`rank_candidates_with_floor{,_and_rng}`, `top_n_with_floor`; collapse
`rank_candidates` onto `rank_candidates_with_rng` and `top_n` onto
`rank_candidates` + truncate.
* Drop the 12 floor-specific tests, keeping the distinct `REPUTATION_FLOOR`
clamp tests. The one real coverage delta — that `rank_candidates` keeps a
negative-reputation candidate rather than dropping it — is retained as
`rank_candidates_keeps_negative_reputation_candidate`.
* ADR 001: replace the subsection with a headless paragraph stating reputation
is a graded weight with no veto. Headless on purpose — no anchor means the
dangling-link rot this commit cleans up cannot recur.
* ADRs 037 and 039 both asserted a floor-filtered candidate pool and linked the
removed anchor; drop both clauses. `MD051` is disabled and `check-md-anchors`
does not resolve fragments, so these would have rotted silently.
* discovery.rs: drop the `proxy_warming_order` "Contract not yet enforced" block
documenting the floor precondition ADR 037 no longer states.
* CHANGELOG: delete the entry rather than adding a Removed one — the whole file
is `[Unreleased]` and the entry itself says "no config/env/CLI knob yet".
No behavior change: every production path already ran with the floor disabled.
Closes #1438
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`probe.rate_limit.trusted_ips` and `dht.rate_limit.trusted_ips` let an operator punch a hole in the middle (per-IP) layer of the three-layer token-bucket limiter for a curated IP list. The default is empty and no config in the repo sets it, so this removes surface rather than behavior. The knob was also weakest exactly where it was most likely to be used: on the probe path the always-on `ConnectionLimiter` per-source bucket (`security.per_source_*`, default 100/s) is NOT bypassed, so exempting an IP only moved its effective ceiling from 50/s to 100/s — a number the operator could have set directly. Raising `per_ip_rate_per_sec` / `per_ip_burst` gives the same relief while keeping the layer's invariant that every source IP is bounded, and leaves no standing allow-list to go stale as peer IPs change. * rate_limit.rs: drop the field from `RateLimitConfig` and `ThreeLayerRateLimiter`, both `From<&Resolved*>` impls, the /64 mask-into-set in `new()`, and the per-IP bypass branch in `try_admit_one` — the per-IP layer now always charges when an IP key is present. * Config: drop the key from `Dht`/`ProbeRateLimitConfig` and `ResolvedDht`/ `ResolvedProbe`, and delete the `parse_trusted_ips` resolver helper. * Delete the 4 DHT exemption tests and the 2 resolver tests. On the probe side `trusted_ip_exempts_per_ip_only` is REWRITTEN, not deleted, as `per_ip_rejection_drives_probe_per_ip_counter`: it was the only test pinning `decdn_probe_rate_limit_rejected_per_ip_total`, and the hand-written `ProbeRateLimitMetrics::rejected` match needs that guard against an arm swap. * Drop the two commented rows from the `decdn config init` template and the two ADR paragraphs (005 §Probe rate limiting, 022 §DHT Rate Limiting). BREAKING CHANGE: both config structs use `#[serde(deny_unknown_fields)]`, so a node whose TOML still sets `dht.rate_limit.trusted_ips` or `probe.rate_limit.trusted_ips` now fails to load at startup and under `decdn config validate` rather than ignoring the key. This is deliberate — a silent ignore would leave the operator believing an exemption is still in force. Remove the key and raise `per_ip_rate_per_sec` / `per_ip_burst` if the headroom was actually needed. Closes #1440 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Warning Review limit reached
Next review available in: 41 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 selected for processing (7)
WalkthroughThe change removes minimum-reputation filtering from default node selection and eliminates trusted-IP exemptions from DHT and probe rate limiting. Configuration schemas, resolved settings, limiter logic, tests, runtime notices, ADRs, and generated config templates are updated accordingly. ChangesSelection policy
Rate-limit configuration
Limiter behavior
Protocol and integration alignment
Estimated code review effort: 3 (Moderate) | ~25 minutes 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 removes two unused/dead operator/client “knobs” in the node codebase and reconciles the surrounding docs/tests accordingly: (1) the minimum-reputation rejection floor in node selection, and (2) the trusted-IP exemption that bypassed only the per-IP tier of the probe/DHT three-layer rate limiter. It simplifies selection and rate-limiting surfaces without changing any production behavior that was previously reachable.
Changes:
- Remove the minimum-reputation rejection floor APIs from
crates/node/src/selection.rsand keep only the graded reputation weighting/clamp behavior. - Remove
trusted_ipsfrom probe/DHT rate limit config + limiter engine, including resolver plumbing and tests. - Update ADRs, CLI default config template, and changelog/docs to remove now-invalid references/anchors.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/node/src/selection.rs | Deletes min-reputation floor filtering APIs/tests; keeps ranking + clamp semantics. |
| crates/node/src/rate_limit.rs | Removes trusted-IP bypass field and per-IP exemption branch from the shared limiter engine. |
| crates/common/src/config/types.rs | Drops trusted_ips from config types and removes ADR references to that knob. |
| crates/common/src/config/resolved.rs | Drops resolved trusted_ips sets from ResolvedDht/ResolvedProbe. |
| crates/common/src/config/mod.rs | Removes trusted-IP parsing/validation and wiring into resolved configs + tests. |
| crates/node/src/handlers/probe.rs | Updates probe handler docs to reflect no trusted-IP exemption. |
| crates/node/src/handlers/probe_rate_limit.rs | Updates wrapper docs and rewrites the per-IP rejection metrics guard test without trusted IPs. |
| crates/node/src/dht/rate_limit.rs | Updates wrapper docs and deletes trusted-IP-specific tests/fixtures. |
| crates/node/src/runtime/reload.rs | Updates hot-reload warning text to remove trusted-IP mention for DHT rate-limit sections. |
| crates/client-pull/src/discovery.rs | Removes stale “contract not yet enforced” note tied to the removed reputation floor. |
| crates/cli/src/commands/config.rs | Removes commented trusted_ips lines from the generated default config template. |
| crates/node/tests/self_hosted_discovery.rs | Updates permissive probe rate limiter test config to remove trusted_ips. |
| crates/node/tests/probe_loopback.rs | Updates permissive probe rate limiter test configs to remove trusted_ips. |
| crates/node/tests/probe_0rtt.rs | Updates permissive probe rate limiter test config to remove trusted_ips. |
| crates/node/tests/dht_loopback.rs | Updates permissive DHT rate limiter test configs/comments to remove trusted_ips. |
| crates/node/tests/dht_lookup.rs | Updates permissive DHT rate limiter test config to remove trusted_ips. |
| crates/node/tests/dht_integration.rs | Updates permissive DHT rate limiter test config to remove trusted_ips. |
| crates/node/tests/dht_bootstrap.rs | Updates permissive DHT rate limiter test config to remove trusted_ips. |
| CHANGELOG.md | Removes unreleased changelog entry describing the (now-removed) min-reputation floor APIs. |
| adr/001-network.md | Replaces the min-reputation rejection-floor subsection with a headless paragraph clarifying reputation is not a veto. |
| adr/005-protocol.md | Removes the probe-side trusted-IP exemption paragraph. |
| adr/022-content-discovery.md | Removes the DHT-side trusted-IP exemption paragraph. |
| adr/037-regional-proxy-warming.md | Removes references/link to the removed min-reputation floor anchor. |
| adr/039-multi-source-parallel-fetch.md | Removes references/link to the removed min-reputation floor anchor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 81.07% (was 81.07%, ▼ 0.01%) — 52383/64616 lines
History
|
Five reviewers swept the branch. The mechanical removals verified clean — both "no behavior change" claims were confirmed by hand-tracing, and the `try_admit_one` rewrite turns out to strictly *widen* `maybe_prune_per_ip` (a trusted IP previously skipped the prune, a latent keyspace gap). What they found was survivors: prose the deletion missed because it carried no markdown link for the anchor-driven sweep to catch. * ADR 037 acceptance criterion 2 and ADR 039 lines 57, 102, 117 still required, credited, or gated on the removed reputation floor. AC 2 and ADR 039's AC 1 are normative, so both ADRs mandated a mechanism ADR 001 now explicitly denies. ADR 039's "selection floor" becomes "admissible", matching the term already used in its source-selection paragraph. * `resolve_dht_into`'s doc still promised "trusted IPs are parsed once at resolution; malformed entries fail fast under the bag pattern". The probe twin was fixed; the DHT one was missed — and `resolve_probe_into` says "Mirrors `resolve_dht_into`", pointing readers straight at it. * CHANGELOG: add the `### Changed (BREAKING)` entry for the config-breaking removal, per the file's own convention (line 14) and the `gossip.allowlist` precedent. The prior call to omit it was wrong: the startup failure is operator-visible regardless of whether the key was ever changelogged, and `decdn config init` shipped `# trusted_ips = []` in its template, so anyone who uncommented it has a node that no longer boots. The migration text was in the commit body — i.e. only in git history, not the operator artifact. * `rate_limit.rs`: the "lets the compiler catch a field transposition" claim is false — all eight remaining fields are `f64`/`u32`/`usize`, so any same-typed swap compiles. Corrected to what the literals actually buy (arity), with the real gap tracked in #1457; a `per_peer`/`per_ip` swap in the probe impl would loosen an unauthenticated cap from 5 to 50 req/s. * `ResolvedDht`: restore an invariant sentence covering the validation that survived. The removed trusted-IP clause was the only place the type doc claimed any resolver guarantee. * `selection.rs`: add `score_nan_reputation_clamps_to_floor`. The deleted floor tests were the only NaN-reputation coverage, and `compute_score` silently depends on `f32::max` implementing IEEE `maxNum` (ignores NaN). A "cleanup" to `.clamp()` would propagate NaN, which `total_cmp` sorts last and `tie_group_end` then sweeps into the preceding tie group — a garbage candidate winning a tie-break tier. Mutation-checked: the test fails against `.clamp(REPUTATION_FLOOR, 1.0)` and passes as written. * `top_n`: its doc advised `n = MAX_PROVIDER_ATTEMPTS` for the fetch path, which is what #1165 fixed — that budget is fetch-wide, not per-list, and `node_origin`'s ranker deliberately does not truncate. Follow-ups filed rather than widening a deletion PR: #1457 (From-impl transposition tests), #1458 (reputation has no upper bound; `f32::INFINITY` wins unconditionally), #1459 (`Some(0)` stake outranks `None` at tie-break tier 2, contradicting its own comment). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review pass applied —
|
…hive Rebased onto main after #1456 landed the min-reputation rejection-floor removal (#1438). The code removal, ADR 001's headless "graded weight, not a veto" paragraph, ADR 037's candidate-pool wording, and the CHANGELOG entry are all already on main and are dropped from this branch. What remains is the two stale-reference sites #1456 did not cover. - ADR 039 § Source set and selection: the floor was the only path by which reputation entered multi-source admission, so removing it left the admitted set ranked on RTT and rate alone — contradicting this ADR's own Cross-ADR Impact entry, which states selection uses the same RTT, price, reputation, and diversity inputs as ADR 001. Rank by the ADR 001 unified selection score instead, which carries reputation as the graded weight the removal keeps. #1456 removed the floor clause from this sentence but left "preferring lower RTT and lower rate" in its place. - adr/_history/alternatives-pre-launch.md: two rejected-alternative entries cited "ADR 008's hard floor" / "ADR 008's hard reputation floor" as the thing a collusive-reporting vector would attack. No such floor exists — ADR 008 § Score Decay pins the minimum score at 0.0, with the selection algorithm clamping the denominator at 0.1. Cite the weighting instead. The rejections themselves are unchanged. Co-Authored-By: Claude Opus 5 <[email protected]>
… vector Rebased onto main after #1456 landed the min-reputation rejection-floor removal (#1438). The code removal, ADR 001's "graded weight, not a veto" paragraph, ADR 037's candidate-pool wording, and the CHANGELOG entry are all already on main and are dropped from this branch. What remains are the stale reference sites #1456 did not cover, plus one #1418 left behind. ADR 039 § Source set and selection. The floor was the only path by which reputation entered multi-source admission. #1456 removed the floor clause but left "preferring lower RTT and lower rate" in its place, so the admitted set ranked on RTT and rate alone — contradicting this ADR's own Cross-ADR Impact entry, which states selection uses the same RTT, price, reputation, and diversity inputs as ADR 001. Cite ADR 001's unified selection score instead (its own term, defined at ADR 001 § Node Selection Algorithm), which carries reputation as the graded weight the removal keeps. Citing the formula rather than paraphrasing it also removes a standing rot vector: the old wording was already a lossy restatement that silently dropped reputation, wrong against ADR 001 even before #1456. The collusive-reporting vector no longer exists. Two rejected-alternative entries in adr/_history/alternatives-pre-launch.md and one live paragraph in adr/appendix-blob-cache-eviction.md argued that coupling reputation to eviction "creates a collusive-reporting vector". That vector was a coalition sending negative ReputationReport messages to push a competitor below an eviction threshold — and #1418 deleted ReputationReport, the cdn/reputation/v1 topic, and all cross-node aggregation. Reputation is local-only; no peer can move another node's score, so the premise is gone. #1418 removed the argument from appendix-peer-table-eviction.md but missed its two archive compressions and the parallel claim in appendix-blob-cache-eviction.md, which it never touched. Drop the clause in all three places, leaving the two rationales the live appendix still states (conflates discovery with selection; reputation is noisy in the tail). The rejections themselves are unchanged. Docs only. Not fixed here: "admissible" at ADR 039 §§ 25/55/116 lost its definition when #1456 removed the floor it referred to, and the archive's bare section refs (§1, §3, §4, §6-§11) predate #610 dropping ADR section numbering — both pre-existing and wider than this change. Co-Authored-By: Claude Opus 5 <[email protected]>
… vector (#1452) Rebased onto main after #1456 landed the min-reputation rejection-floor removal (#1438). The code removal, ADR 001's "graded weight, not a veto" paragraph, ADR 037's candidate-pool wording, and the CHANGELOG entry are all already on main and are dropped from this branch. What remains are the stale reference sites #1456 did not cover, plus one #1418 left behind. ADR 039 § Source set and selection. The floor was the only path by which reputation entered multi-source admission. #1456 removed the floor clause but left "preferring lower RTT and lower rate" in its place, so the admitted set ranked on RTT and rate alone — contradicting this ADR's own Cross-ADR Impact entry, which states selection uses the same RTT, price, reputation, and diversity inputs as ADR 001. Cite ADR 001's unified selection score instead (its own term, defined at ADR 001 § Node Selection Algorithm), which carries reputation as the graded weight the removal keeps. Citing the formula rather than paraphrasing it also removes a standing rot vector: the old wording was already a lossy restatement that silently dropped reputation, wrong against ADR 001 even before #1456. The collusive-reporting vector no longer exists. Two rejected-alternative entries in adr/_history/alternatives-pre-launch.md and one live paragraph in adr/appendix-blob-cache-eviction.md argued that coupling reputation to eviction "creates a collusive-reporting vector". That vector was a coalition sending negative ReputationReport messages to push a competitor below an eviction threshold — and #1418 deleted ReputationReport, the cdn/reputation/v1 topic, and all cross-node aggregation. Reputation is local-only; no peer can move another node's score, so the premise is gone. #1418 removed the argument from appendix-peer-table-eviction.md but missed its two archive compressions and the parallel claim in appendix-blob-cache-eviction.md, which it never touched. Drop the clause in all three places, leaving the two rationales the live appendix still states (conflates discovery with selection; reputation is noisy in the tail). The rejections themselves are unchanged. Docs only. Not fixed here: "admissible" at ADR 039 §§ 25/55/116 lost its definition when #1456 removed the floor it referred to, and the archive's bare section refs (§1, §3, §4, §6-§11) predate #610 dropping ADR section numbering — both pre-existing and wider than this change. Co-authored-by: Claude Opus 5 <[email protected]>
Two removals from the Protocol simplifications milestone, batched because both are pure dead-knob deletions on the node side: no contract surface, no gas snapshot, no
decdn-protocolpublic-API snapshot regen.Net: 24 files, +55 / −518.
refactor(selection)!— remove the minimum-reputation rejection floor (#1438)The floor was built ahead of its consumer. The sole production call site (
node_origin.rs→rank_candidates) passedDEFAULT_MIN_REPUTATION = 0.0, which short-circuits filtering entirely, and nothing ever threaded a non-zero value from config, CLI, or the client fetch path — every_with_floorentry point was reached only from unit tests.Poor-reputation nodes are still de-prioritized by the two mechanisms that ship and stay: the
reputation²score amplification and themax(reputation, 0.1)denominator clamp (REPUTATION_FLOOR). Those are a different thing from the rejection floor despite sharing the word, and their tests are untouched.selection.rs: dropDEFAULT_MIN_REPUTATION,apply_reputation_floor,rank_candidates_with_floor{,_and_rng},top_n_with_floor; collapserank_candidatesontorank_candidates_with_rngandtop_nontorank_candidates+ truncate.MD051is disabled andmake -C adr check-md-anchorsonly checks that a cross-link carries an anchor, never that it resolves, so both would have rotted silently.client-pull/src/discovery.rs: drop theproxy_warming_order"Contract not yet enforced" block documenting the floor precondition ADR 037 no longer states.Removedone — the whole file is[Unreleased]and the entry itself says "no config/env/CLI knob yet", so nothing published and nothing adoptable.Test coverage: the 12 floor tests go; the
REPUTATION_FLOORclamp tests and the fourtop_n_*tests stay. One genuine delta — thatrank_candidateskeeps a negative-reputation candidate rather than dropping it — is retained asrank_candidates_keeps_negative_reputation_candidate.No behavior change: every production path already ran with the floor disabled.
refactor(config)!— remove the trusted-IP rate-limit exemption (#1440)probe.rate_limit.trusted_ips/dht.rate_limit.trusted_ipslet an operator punch a hole in the middle (per-IP) layer of the three-layer limiter for a curated IP list. Default empty; no config in the repo sets it.It was weakest exactly where it was most likely to be used: on the probe path the always-on
ConnectionLimiterper-source bucket (security.per_source_*, default 100/s) is not bypassed, so exempting an IP only moved its effective ceiling from 50/s to 100/s — a number the operator could have set directly. Raisingper_ip_rate_per_sec/per_ip_burstgives the same relief, keeps the layer's invariant that every source IP is bounded, and leaves no standing allow-list to go stale as peer IPs change.rate_limit.rs: field gone fromRateLimitConfig+ThreeLayerRateLimiter, bothFrom<&Resolved*>impls, the /64 mask-into-set innew(), and the per-IP bypass branch intry_admit_one.Dht/ProbeRateLimitConfigandResolvedDht/ResolvedProbe;parse_trusted_ipsdeleted.trusted_ip_exempts_per_ip_onlywas the only test pinningdecdn_probe_rate_limit_rejected_per_ip_total, and the hand-writtenProbeRateLimitMetrics::rejectedmatch needs that guard against an arm swap. It survives asper_ip_rejection_drives_probe_per_ip_counterwith the trusted half dropped. The 4 DHT exemption tests are safe to delete —per_ip_layer_masks_ipv6_to_slash_64independently coverssource_key/64 masking.Both structs use
#[serde(deny_unknown_fields)], so a node whose TOML still sets either key now fails to load at startup and underdecdn config validaterather than ignoring it. Deliberate: a silent ignore would leave the operator believing an exemption is still in force. Verified:Remove the key and raise
per_ip_rate_per_sec/per_ip_burstif the headroom was actually needed. No CHANGELOG entry — the key never shipped in a tagged release.Verification
All green locally:
cargo fmt --all --checkcargo clippy --workspace --all-targets(clean;--all-targetswas needed to catch three now-unused#[cfg(test)]-gatedHashSetimports)RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-itemscargo nextest run --workspace— 2552 passed, 0 failedcargo test --doc --workspacemake -C adr check-book-list check-bare-refs check-md-anchors check-no-section-numbersgrep -rn "minimum-reputation-rejection-floor" adr/→ empty (the anchor check above cannot catch this)pre-commit run --all-filesvia the commit hookstrusted_ipskey rejects as shown above;decdn config initoutput still parses with both[*.rate_limit]sections intact.Not run, and not needed: contracts / anvil-e2e (no
contracts/**change) and thepublic-apisnapshot job (decdn-protocoluntouched).Notes for review
decdn-nodehas noCounterVec; theiroh_metricsbackend realizes{reason=}splits as sibling plain counters by written convention (crates/gossip/src/metrics.rs:17-27). Detail posted on the issue.adr/039-multi-source-parallel-fetch.md:25sits one line outside that PR's first hunk (@@ -18,7). Happy to land after it merges.Closes #1438
Closes #1440
🤖 Generated with Claude Code
Summary by CodeRabbit