Skip to content

refactor(adr-001): trim probe machinery (cache evidence retention, outbound rate-limit, two-phase early-exit) - #1200

Merged
alpergundogdu merged 2 commits into
mainfrom
cut/adr-001-probe-trim
Jul 15, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
cut/adr-001-probe-trim

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Trims three over-specified pieces from ADR 001's probe section: the probe cache no longer needs to hoard signed ProbeResponse bytes for slashing evidence (a client challenges within the 15s TTL and the evidence lands on-chain), the redundant outbound 3-batches/sec clause is gone (the inbound three-layer limiter already bounds probe cost), and the two-phase rolling-median early-exit collection window collapses to a flat concurrent probe cut off at 500ms. The one paired code change drops the node-origin per-candidate probe timeout from 5s to 500ms; since candidates are probed concurrently, that const already bounds the whole collection phase. Dangling cross-references in ADR 005 and ADR 015 are fixed to match.

Closes #1157
Closes #1159
Closes #1160

Net: 17 insertions, 20 deletions (-3).

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 15, 2026 12:37
@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@alpergundogdu, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 011320f0-88f6-4a18-9dda-19c4170ef1dc

📥 Commits

Reviewing files that changed from the base of the PR and between 9e79076 and b83c02d.

📒 Files selected for processing (4)
  • adr/001-network.md
  • adr/005-protocol.md
  • adr/015-zero-rtt.md
  • crates/node/src/node_origin.rs

Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands.

@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 simplifies the probe response collection mechanism by removing the complex two-phase wait and adaptive early-exit logic. Instead, candidates are probed concurrently with a single, unified timeout of 500ms, which is reflected in both the architecture decision records (ADRs) and the node implementation (where PROBE_TIMEOUT is reduced from 5 seconds to 500 milliseconds). Additionally, the probe cache structure is optimized by removing the full ProbeResponse from the cached entries, reducing its memory footprint. There are no review comments to address, and we have no further feedback to provide.

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.

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 88.71% (2452/2764 lines)
▲ +0.00pp vs base (88.71% → 88.71%)
Run: 29416508576

@alpergundogdu alpergundogdu changed the title cut(adr-001): trim probe machinery — cache evidence retention, outbound rate-limit, two-phase early-exit refactor(adr-001): trim probe machinery (cache evidence retention, outbound rate-limit, two-phase early-exit) Jul 15, 2026
@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

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

Updates the probe-related design documentation (ADR 001 and cross-references) to remove over-specified probe machinery and align the implementation with a simplified “flat concurrent probe with ~500ms cutoff” model in the node origin selection path.

Changes:

  • Simplifies ADR 001’s probe cache and probe collection specs (drops evidence-retention + outbound probe rate-limit + two-phase early-exit).
  • Updates ADR 005 and ADR 015 text to match the new single 500ms concurrent probe collection window.
  • Reduces the node-origin per-candidate probe timeout from 5s to 500ms.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
crates/node/src/node_origin.rs Lowers per-candidate probe timeout to 500ms to bound concurrent probe collection time.
adr/001-network.md Trims probe cache/evidence language, removes outbound rate-limit clause, and collapses collection to a single 500ms timeout.
adr/005-protocol.md Updates discovery/probing flow description to match concurrent probing with a 500ms collection timeout.
adr/015-zero-rtt.md Adjusts narrative references to the probe collection window to remove outdated parameter names and align with the 500ms cutoff.

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

Comment on lines +77 to +83
/// Per-candidate probe timeout. Because candidates are probed concurrently, this
/// also bounds the whole probe-collection phase. Short relative to the pull
/// timeout — a probe is a single unpaid round trip, so a slow candidate is
/// dropped quickly rather than burning the caller's miss-latency budget on it.
/// The 500ms ceiling accommodates inter-continental RTTs (London↔Sydney
/// ~250–300ms).
const PROBE_TIMEOUT: Duration = Duration::from_millis(500);
Comment thread adr/001-network.md Outdated
A short-lived LRU cache holds `hash → Vec<(NodeId, rate_per_mb, rtt)>` entries, TTL 15 seconds, max 1024 entries. Each hash entry retains at most 10 responses (top 10 by selection score). Approximate memory: 1,024 × 10 × ~100 bytes ≈ 1 MB. On a cache miss the requester checks the probe cache first; if a valid entry exists, it skips DHT lookup and goes straight to selection. On probe cache hit, if the selected provider no longer has the blob (evicted — rare with eviction holds), try the next-best cached provider; if all fail, run a fresh DHT lookup + probe. **Observability:** track `EvictedSinceProbe` response rate; sustained >1% may indicate eviction hold failures ([ADR 005](005-protocol.md#probe-triggered-eviction-hold)).

**Probe cache TTL is 15 seconds** — half the 30-second slashing evidence window from [ADR 005](005-protocol.md#adr-005-wire-protocol). Probe cache TTL (15s) < `probe_hold_duration` (35s), so any cached probe response used for a stream is within both the slashing window and the eviction hold period.
**Probe cache TTL is 15 seconds** — half the 30-second slashing evidence window from [ADR 005](005-protocol.md#adr-005-wire-protocol). Probe cache TTL (15s) < `probe_hold_duration` (35s), so any stream opened from a cached entry falls within both the slashing window and the eviction hold period.
@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.30% (was 80.30%, ● 0.00%) — 45267/56372 lines

File Coverage Lines Δ
crates/node/src/node_origin.rs 89.55% 523/584 ● 0.00%
History
Commit Total Δ vs base
6bc6cd2 80.30% ● 0.00%
b83c02d (HEAD) 80.30% ● 0.00%

Drop the probe-cache slashing-evidence retention clause (the positive
and negative caches stay), remove the outbound probe rate-limit clause
(the inbound three-layer limiter already bounds probe cost), and replace
the two-phase early-exit collection window with a flat concurrent probe
cut off at a 500ms timeout. The node-origin probe timeout drops from 5s
to 500ms to match.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu
alpergundogdu force-pushed the cut/adr-001-probe-trim branch from 6bc6cd2 to e4abb54 Compare July 15, 2026 12:43
Frame the probe-cache TTL around keeping cache-driven streams inside the
slashable window rather than around evidence storage, and describe the
probe timeout budget as connection setup plus one round trip, noting that
warm/0-RTT connections fit the 500ms ceiling.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@altanoruc

Copy link
Copy Markdown
Contributor

Review

Overview. Trims three over-specified pieces from ADR 001's probe section (cache no longer retains signed ProbeResponse bytes for evidence; the redundant outbound 3-batches/sec limiter is dropped; the two-phase rolling-median early-exit collection collapses to a flat concurrent probe with a 500ms cutoff) and drops the paired PROBE_TIMEOUT const from 5s → 500ms. Cross-refs in ADR 005/015 are updated to match. Clean, well-scoped simplification.

Verified

  • Concurrency claim holds. probe_and_rank fans out via futures_util::future::join_all (node_origin.rs:687), so all probes run concurrently and a single PROBE_TIMEOUT bounds the whole collection phase — the const change from 5s to 500ms lowers worst-case collection latency without changing the fanout-vs-sum semantics. The code matches the new ADR narrative.
  • No dangling references. probe_min_wait, probe_max_wait, min_probe_responses, early_exit_score_threshold, rolling_median, and the outbound "3 probe batches/sec" clause no longer appear in ADR 001/005/015 on this branch. ADR 022 (still the cross-ref target for "the full discovery flow") never described the two-phase/early-exit machinery or an outbound batch limit, so nothing there goes stale.

One substantive risk — cold inter-continental first probe vs. the 500ms ceiling. The 500ms budget covers connection setup plus the probe round trip. A cold connection to a distant, previously-uncontacted peer costs a 1-RTT QUIC/TLS handshake (~275ms London↔Sydney) followed by the probe request/response (~another ~275ms) ≈ ~550ms, which exceeds PROBE_TIMEOUT. The ADR 015 0-RTT/warm-ticket mitigation only kicks in on the second+ probe to a peer, so it doesn't cover first contact. And a timeout here isn't neutral: the Err arm records Outcome::Unreachable (node_origin.rs:734) and drops the candidate — so a legitimate far provider takes a reputation ding on first contact purely from handshake+probe overrunning 500ms. The old 5s comfortably absorbed this.

This may well be acceptable-by-design (the ADR explicitly accepts dropping slow candidates, and the same node will usually have other, closer candidates), but worth confirming: is it intended that the first probe to a cold distant peer can time out and be scored Unreachable? If not, options are a slightly higher ceiling (e.g. 600–750ms) or not scoring a timeout as Unreachable when the connection was cold.

Minor. The PR body says "17 insertions, 20 deletions"; GitHub reports 18/21 (same net −3). Cosmetic.

Overall LGTM as a docs+const trim — the only thing I'd want a maintainer's read on is the cold-first-probe timeout behavior above.

@alpergundogdu
alpergundogdu merged commit 1c8a846 into main Jul 15, 2026
43 of 45 checks passed
@alpergundogdu
alpergundogdu deleted the cut/adr-001-probe-trim branch July 15, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants