Skip to content

fix(cli): send the ADR 005 client identity binding on decdn fetch (#1115) - #1124

Merged
thiras merged 3 commits into
mainfrom
fix/1115-fetch-client-binding
Jul 12, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/1115-fetch-client-binding

Conversation

@yigitdot

@yigitdot yigitdot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1115.

Problem

A direct decdn fetch never sent an ADR 005 client identity binding, so the node's pull_authorized gate always failed for client fetches. A cache miss for a blob present only in the node's configured cache.origin (fs/http/s3) was refused as NotFound and the origin was never read — the "operator hand-curates an origin, clients fetch on demand" flow was non-functional.

The node side was already fully wired to verify and require the binding (handlers/client.rs pull_authorized / verify_binding); only the client failed to send one — both request-building sites in client-pull hard-coded the request ext to None.

Change

The client now signs an ephemeral BindNodeId(nodeId, nonce = 0) attestation over its own iroh NodeId with the buyer key, under the CapacityBond EIP-712 domain, and attaches it to every cdn/client/v1 request's ext. The serving node recovers the buyer address, confirms it owns the named channel, and reactively populates from its origin.

  • client-pull: new sign_client_binding helper + ChannelContext::with_client_binding and a client_binding: Option<ClientBinding> field; fetch_inner and open_progressive_pull attach the binding when present. Absent ⇒ byte-for-byte the pre-fetch: stream_fetch omits the ADR 005 client identity binding, so reactive origin pull-through never fires for a direct client fetch #1115 wire, so unbound node→node pulls are unchanged.
  • cli/fetch: sign + attach the binding when capacity_bond_address is set; warn and fall back to prior behavior (already-cached content only) when it is not.
  • tests: loopback proof that a bound fetch of an origin-only blob populates from the fs origin and serves, with an unbound control that is refused.
  • docs: refresh the serve-path + e2e comments that still said stream_fetch sends no binding.

Scope / follow-ups

The reusable helpers are shaped for #1117 (node→node chained binding — the node_origin requester still omits it). Decoupling local-origin populate from node_to_node_pull_through_enabled (the whole-blob window path shadowing the fs read) remains #1116.

Verification

  • cargo build, cargo clippy --all-targets -- -D warnings, cargo fmt --check clean.
  • New loopback tests pass (bound_client_fetch_triggers_reactive_origin_pull_through, unbound_client_fetch_is_refused_on_origin_only_blob) alongside the existing binding tests.
  • Full decdn-client-pull + decdn-incentive suites: 250/250 passed.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added client identity binding for paid content fetches when a capacity bond is configured.
    • Bound requests can access origin content on cache misses while preserving content verification.
    • Supports identity binding for both buffered and progressive downloads.
  • Bug Fixes

    • Unbound requests are prevented from using protected origin pull-through.
    • A warning is shown when client identity binding is unavailable, with previous behavior retained.

yigitdot and others added 2 commits July 12, 2026 21:17
)

A direct `decdn fetch` never sent an ADR 005 client identity binding, so the
node's `pull_authorized` gate always failed for client fetches: a cache miss
for a blob present only in the node's configured `cache.origin` was refused as
`NotFound`, and the origin was never read. The "operator hand-curates an
fs/http/s3 origin, clients fetch on demand" flow was non-functional.

The client now signs an ephemeral `BindNodeId(nodeId, nonce=0)` attestation
over its OWN iroh NodeId with the buyer key, under the `CapacityBond` domain,
and attaches it to every `cdn/client/v1` request's `ext`. The serving node
recovers the buyer address, confirms it owns the named channel, and reactively
populates from its origin.

- client-pull: add `sign_client_binding` + `ChannelContext::with_client_binding`
  and a `client_binding: Option<ClientBinding>` field; `fetch_inner` and
  `open_progressive_pull` attach the binding when present (absent => byte-for-byte
  the pre-#1115 wire, so unbound node->node pulls are unchanged pending #1117).
- cli/fetch: sign + attach the binding when `capacity_bond_address` is set;
  warn and fall back to prior behavior when it is not.
- tests: loopback proof that a bound fetch of an origin-only blob populates from
  the fs origin and serves, with an unbound control that is refused.

The reusable helpers are shaped for #1117 (node->node chained binding). Local
origin / node->node flag decoupling remains #1116.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The serve-path note and the e2e pre-warm comment still said `stream_fetch`
sends no ownership binding. After #1115 the direct-client `decdn fetch` does;
the remaining gap is the node→node requester (`node_origin`, #1117). The e2e
`ClientFixture` sends none by choice (`client_binding: None`).

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

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 35 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: 8d87a296-ce62-4260-be19-776588e8d632

📥 Commits

Reviewing files that changed from the base of the PR and between 7fc01dc and 9fdd766.

📒 Files selected for processing (4)
  • crates/cli/src/commands/fetch.rs
  • crates/client-pull/src/lib.rs
  • crates/e2e/src/node.rs
  • crates/node/tests/client_loopback.rs

Walkthrough

Changes

The pull client now carries optional ADR 005 client bindings, signs them for configured capacity-bond chains, and conditionally encodes them in buffered and progressive requests. Tests cover bound and unbound origin pull-through, while existing contexts and documentation are updated for the new field.

Client identity binding

Layer / File(s) Summary
Binding contract and request transport
crates/client-pull/src/lib.rs
ChannelContext carries optional bindings, signing helpers create attestations, and stream requests conditionally include binding extensions.
CLI binding integration
crates/cli/src/commands/fetch.rs
fetch signs and applies bindings when capacity-bond data is available, otherwise warning and retaining unbound behavior.
Pull-through validation and context updates
crates/node/tests/client_loopback.rs, crates/node/tests/*, crates/e2e/src/*, crates/node/src/handlers/client.rs
Loopback tests cover bound and unbound cache-miss pull-through, and existing contexts and comments reflect optional binding state.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI as CLI fetch
  participant Pull as client-pull
  participant Node as serve_stream
  participant Origin as filesystem origin
  CLI->>Pull: provide signed ClientBinding in ChannelContext
  Pull->>Node: send StreamRequest with binding extension
  Node->>Origin: request blob on cache miss
  Origin-->>Node: return blob
  Node-->>Pull: deliver verified blob
Loading

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.

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Contracts coverage

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

@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 implements the ADR 005 client identity binding for the direct-client fetch command, allowing clients to prove channel ownership to serving nodes. This is achieved by signing the client's own Iroh NodeId with the buyer key using EIP-712. The signed binding is attached to stream requests, enabling reactive origin pull-through on cache misses. Unbound requests are safely refused. The changes also include comprehensive integration tests verifying this behavior. There are no review comments, and I have no additional 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 12, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.36% (was 80.34%, ▲ +0.02%) — 44900/55876 lines

File Coverage Lines Δ
crates/cli/src/commands/fetch.rs 39.34% 216/549 ▲ +4.61%
crates/client-pull/src/lib.rs 88.77% 759/855 ▲ +0.55%
crates/e2e/src/client.rs 0.00% 0/129 ● 0.00%
crates/e2e/src/node.rs 0.00% 0/199 ● 0.00%
crates/node/src/handlers/client.rs 78.76% 979/1243 ● 0.00%
History
Commit Total Δ vs base
7fc01dc 80.34% ● 0.00%
9fdd766 (HEAD) 80.36% ▲ +0.02%

…ssertions)

Applies the review feedback on the #1115 client-binding change:

- fetch: drop the always-on `capacity_bond_address` unset warning (it fired
  on every successful cached fetch too, a false positive that trains users to
  ignore it). Instead, when an UNBOUND request is refused with NotFound, attach
  an actionable hint at the point of failure via `annotate_unbound_cache_miss`,
  reconnecting the opaque `delivery refused: NotFound` to its cause. Unit-tested
  (unbound+NotFound → hint; bound → untouched; non-NotFound → untouched).
- tests: wire `CacheMetrics` into `empty_cache_with_fs_origin` and assert
  `origin_fetches == 1` on the bound path and `== 0` on the unbound path — the
  negative control now proves the gate short-circuits BEFORE any origin egress
  (the anti-griefing guarantee), not just that it refused.
- client-pull: add a `client_binding_ext` unit test locking the shared
  bound/unbound → ext mapping both request sites depend on.
- docs: steer `with_client_binding` callers to `sign_client_binding`; soften the
  `sign_client_binding` #1117 "reusable" claim to "once wired, not yet a caller";
  tighten the e2e pre-warm comment ("reactive pull-through is not attached by
  default" vs the narrower "node-to-node").

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@thiras
thiras merged commit cbe9664 into main Jul 12, 2026
23 checks passed
@thiras
thiras deleted the fix/1115-fetch-client-binding branch July 12, 2026 21:37
thiras added a commit that referenced this pull request Jul 12, 2026
…pulate + node→node chained binding (#1116, #1117) (#1128)

* feat(node): complete reactive origin pull-through — decouple local populate + node→node chained binding (#1116, #1117)

Follow-through on #1124. Two gaps remained after the direct-client fetch
learned to send the ADR 005 client identity binding:

#1116 — reactive local-origin populate was gated behind
cache.node_to_node_pull_through_enabled, so a cache-only operator (flag off)
got a silent NotFound for content in its own fs/http/s3 origin, and with the
flag on a whole-blob request preferred the paid peer window path over the
node's own local origin.

- CacheEngine::populate_local: like populate but skips the Peer origin (via a
  local_only flag threaded through the shared pull_through chain walk); a
  peer-only chain is a fast NoOrigin.
- ClientHandler gains local_populate + attach_local_populate + try_local_populate;
  the serve-miss path tries a local-origin fill FIRST (gated on the same
  pull_authorized proof of channel ownership) before any node→node path.
- Runtime arms attach_local_populate whenever [cache.origin] is configured,
  independent of the node→node flag. No new config knob.

#1117 — node_origin omitted the binding, so multi-hop node→node chained
warming stopped at the first hop that already held the blob.

- NodeOriginDeps gains bind_domain; the runtime threads in the same CapacityBond
  bind domain the serving side verifies against.
- Both node_origin requester paths attach a binding signed over the node's own
  iroh NodeId with the channel buyer key, reusing #1124's sign_client_binding /
  with_client_binding.

Both paths stay gated on pull_authorized, so no change frees egress.

Tests: engine populate_local (skips peer / peer-only NoOrigin); loopback
cache-only-operator serve + local-preferred-over-window; two-hop chained
reactive pull proving the binding propagates across a node→node hop.

Closes #1116. Closes #1117.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(node): address review — local-populate deadline + timeout race check (#1116)

- Arm attach_local_populate with the per-attempt node_pull_timeout_sec, not
  outer_pull_deadline (which budgets MAX_PROVIDER_ATTEMPTS × for the sequential
  node→node fan-out); a single local origin-chain walk shouldn't block ~3×
  longer before falling through to the node→node paths.
- try_local_populate now does a post-deadline cache.has race check (extracted to
  on_local_populate_timeout) and meters the timeout, so a concurrent fill that
  lands at the deadline is served — not reported as CacheMiss with node→node OFF
  — and operators get a timeout signal. No background warm is spawned (local-only).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(node): address PR review — displaced doc/attr, timeout metering, docs, test (#1116, #1117)

Multi-agent review of PR #1128:

- node_origin.rs: bind_upstream_ctx was inserted between pull_from_candidate's
  doc comment + #[allow(cognitive_complexity, too_many_lines)] and the function,
  so both bound to the wrong item (bind_upstream_ctx got pull_from_candidate's
  rustdoc; pull_from_candidate lost its doc and lint allow). Move bind_upstream_ctx
  above so the doc/attr sit on pull_from_candidate again.
- client.rs on_local_populate_timeout: a store-lookup error at the deadline was
  metered as node_pull_through_error AND then also as node_pull_through_timeout
  with a misleading "timed out" log. Return after the error meter so a store fault
  isn't double-counted / mislabeled as a timeout.
- metrics.rs: document that node_pull_through_{errors,timeouts} now cover BOTH
  reactive tiers (node→node #831 and local-origin populate #1116), so they aren't
  read as node→node-only health signals.
- runtime/mod.rs: correct the deadline comment — outer_pull_deadline adds a fixed
  PULL_THROUGH_OUTER_SLACK on top of MAX_PROVIDER_ATTEMPTS×, so the overshoot is
  >3× (more at small budgets), not ~3×.
- test: add local_populate_miss_is_clean_cache_miss — a blob absent from the local
  origin terminates as a clean delivery refusal after the origin is consulted once
  (node→node off), guarding the local-first miss path.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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.

fetch: stream_fetch omits the ADR 005 client identity binding, so reactive origin pull-through never fires for a direct client fetch

2 participants