Skip to content

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

Merged
thiras merged 3 commits into
mainfrom
feat/reactive-pull-through-completion
Jul 12, 2026
Merged

thiras merged 3 commits into
mainfrom
feat/reactive-pull-through-completion

Conversation

@thiras

@thiras thiras commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1116. Closes #1117.

Problem

Follow-through on #1124 (reactive origin pull-through), which taught a direct decdn fetch to send the ADR 005 client identity binding but left two gaps:

Change

#1116 — decouple + prefer local origin

  • CacheEngine::populate_local (new): like populate but skips the Peer origin, so it fronts no upstream USDC. Implemented by threading a local_only flag through the shared pull_through chain walk (a peer-only chain is a fast NoOrigin).
  • ClientHandler: new local_populate deadline + attach_local_populate + try_local_populate. The serve-miss path now tries a local-origin fill first (gated on the same pull_authorized proof of channel ownership), before any node→node window/buffered path — so a locally-held whole blob is served from the local origin instead of a paid peer.
  • Runtime wiring arms attach_local_populate whenever [cache.origin] is configured, independent of node_to_node_pull_through_enabled. The node→node window/governor/background/gate paths stay flag-gated. No new config knob.

#1117 — node→node chained binding

  • NodeOriginDeps gains a bind_domain; the runtime threads in the same CapacityBond bind domain the serving side verifies against.
  • node_origin's two requester paths (open_from_candidate, pull_from_candidate) attach an ADR 005 binding — signed over the node's OWN iroh NodeId with the channel's buyer key (ctx.client_signer) — reusing fix(cli): send the ADR 005 client identity binding on decdn fetch (#1115) #1124's sign_client_binding / with_client_binding verbatim. A signing failure drops the candidate rather than sending an unbound request.

Scope / notes

  • Both paths stay gated on pull_authorized (a funded, proven-owned channel), so no change frees any egress. An S3 origin's egress is fronted only for a channel-owning client, and the delivery is billed per-voucher — called out because with the flag ON, a whole-blob request now hits the operator's own S3 before a peer (intended: it's the operator's own authorized origin).
  • Public API additions (CacheEngine::populate_local, ClientHandler::attach_local_populate, NodeOriginDeps.bind_domain) — public-api snapshot regenerated.

Tests

  • crates/cache/tests/pull_through.rs: populate_local skips a Peer origin and fills from local; a peer-only chain is NoOrigin while full populate still pulls the peer.
  • crates/node/tests/client_loopback.rs: cache-only operator serves its own origin with node→node off (bound → origin_fetches == 1, unbound → refused, origin_fetches == 0); local origin preferred over a (dead) peer window path.
  • crates/node/tests/node_origin_pull.rs: two-hop chained reactive pull — B pulls from A, A holds the blob only in its fs origin and serves it only because B's binding authorizes the chained reactive pull (origin_fetches == 1).

Verification

  • cargo build && cargo clippy --all-targets -- -D warnings && cargo fmt -- --check clean.
  • cargo nextest run -p decdn-cache -p decdn-node green (incl. the existing node→node tests, which now send + verify a binding).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added local-only cache population that prioritizes configured local origins and skips peer origins.
    • Cache misses can now reactively retrieve content from local filesystem, HTTP, or S3 origins before attempting peer pulls.
    • Added secure client identity binding for chained node-to-node origin pulls.
  • Bug Fixes

    • Prevented peer fetches when local-only population has no eligible origin.
    • Improved handling of local-origin misses, timeouts, and unavailable content.

…pulate + 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]>
Copilot AI review requested due to automatic review settings July 12, 2026 22:17
@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 25 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: e711c409-9f75-48a5-b4c6-437b26885161

📥 Commits

Reviewing files that changed from the base of the PR and between be72df8 and 18d5fcb.

📒 Files selected for processing (5)
  • crates/node/src/handlers/client.rs
  • crates/node/src/metrics.rs
  • crates/node/src/node_origin.rs
  • crates/node/src/runtime/mod.rs
  • crates/node/tests/client_loopback.rs

Walkthrough

Adds local-only cache population that skips peer origins, wires reactive local fills into client serving, and signs node-origin upstream requests with client bindings for chained reactive pulls. Runtime setup and integration tests cover local-origin precedence, authorization, and bound origin chaining.

Changes

Reactive pull-through

Layer / File(s) Summary
Local-only cache population
crates/cache/src/engine.rs, crates/cache/tests/pull_through.rs
Adds populate_local, filters peer origins, returns NoOrigin when no eligible local origin exists, and tests both local fallback and peer-only behavior.
Reactive local serve fills
crates/node/src/handlers/client.rs, crates/node/src/runtime/mod.rs, crates/node/tests/client_loopback.rs
Adds timeout-configured local population on authorized serve misses, wires it when cache origins exist, and tests local precedence, unbound refusal, and peer-path avoidance.
Bound node-origin pulls
crates/client-pull/src/lib.rs, crates/node/src/node_origin.rs, crates/node/src/runtime/mod.rs
Documents chained client bindings, adds the binding domain to node-origin dependencies, and signs upstream contexts before buffered or progressive pulls.
Reactive origin chaining validation
crates/node/tests/node_origin_pull.rs
Updates node-origin fixtures with binding domains and verifies that a bound downstream pull triggers one reactive filesystem-origin fetch upstream.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ClientHandler
  participant CacheEngine
  participant FilesystemOrigin
  Client->>ClientHandler: request blob
  ClientHandler->>CacheEngine: populate_local(hash)
  CacheEngine->>FilesystemOrigin: fetch(hash)
  FilesystemOrigin-->>CacheEngine: blob
  CacheEngine-->>ClientHandler: local fill result
  ClientHandler-->>Client: serve blob
Loading
sequenceDiagram
  participant NodeOrigin
  participant UpstreamClient
  participant ClientHandler
  participant CacheEngine
  participant FilesystemOrigin
  NodeOrigin->>NodeOrigin: sign upstream client binding
  NodeOrigin->>UpstreamClient: send bound request
  UpstreamClient->>ClientHandler: request blob
  ClientHandler->>CacheEngine: populate_local(hash)
  CacheEngine->>FilesystemOrigin: fetch(hash)
  FilesystemOrigin-->>CacheEngine: blob
  CacheEngine-->>ClientHandler: filled blob
  ClientHandler-->>UpstreamClient: serve 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: 29212341724

@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 reactive local-origin pull-through and chained node-to-node pulls. It introduces populate_local in the cache engine to allow nodes to reactively fill cache misses from their own configured local origins (such as fs, HTTP, or S3) while explicitly skipping paid peer-to-peer origins. Additionally, it wires up client identity bindings to node-to-node requests so that upstream nodes can verify channel ownership and securely chain reactive origin pulls. Comprehensive unit and integration tests have been added to verify these behaviors under various configurations. No review comments were provided, so there is no additional feedback to address.

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.

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

Completes the reactive origin pull-through follow-ups by (1) decoupling local-origin population from the node→node pull-through flag (so cache-only operators can still serve their configured origins) and (2) ensuring node→node pulls carry an ADR-005 client binding so multi-hop chained pull-through can be authorized upstream.

Changes:

  • Add CacheEngine::populate_local to fill only from non-Peer origins (skip paid peer origin) and thread a local_only mode through the pull-through chain walk.
  • Add ClientHandler::attach_local_populate + local-first serve-miss logic to try local-origin fill (authorized) before node→node window/buffered paths.
  • Extend NodeOriginDeps with bind_domain and bind node→node upstream requests using sign_client_binding to enable chained reactive pulls.

Reviewed changes

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

Show a summary per file
File Description
crates/cache/src/engine.rs Adds populate_local/local_only mode so local-origin fills skip OriginKind::Peer during pull-through.
crates/cache/tests/pull_through.rs Adds tests asserting populate_local skips peer origins and returns NoOrigin for peer-only chains.
crates/node/src/handlers/client.rs Adds local_populate wiring and local-first reactive fill on serve miss (authorized) before node→node paths.
crates/node/src/runtime/mod.rs Arms local-origin populate when [cache.origin] is configured, independent of node_to_node_pull_through_enabled.
crates/node/src/node_origin.rs Threads bind_domain into deps and binds upstream node→node pulls to support chained reactive pull-through.
crates/client-pull/src/lib.rs Updates sign_client_binding docs to reflect node→node usage.
crates/node/tests/client_loopback.rs Adds integration tests for cache-only local-origin serving + local-origin preferred over (dead) window path.
crates/node/tests/node_origin_pull.rs Adds a two-hop chained reactive pull test asserting upstream origin fetch occurs only with propagated binding.

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

Comment thread crates/node/src/runtime/mod.rs Resolved
Comment thread crates/node/src/handlers/client.rs Resolved
@github-actions

github-actions Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.23% (was 80.27%, ▼ 0.04%) — 45150/56275 lines

File Coverage Lines Δ
crates/cache/src/engine.rs 89.68% 2329/2597 ▲ +0.07%
crates/client-pull/src/lib.rs 88.77% 759/855 ▼ 0.12%
crates/node/src/handlers/client.rs 77.99% 999/1281 ▼ 0.78%
crates/node/src/metrics.rs 85.31% 1045/1225 ● 0.00%
crates/node/src/node_origin.rs 88.64% 507/572 ▼ 0.33%
crates/node/src/runtime/mod.rs 50.14% 1082/2158 ▼ 0.33%
History
Commit Total Δ vs base
be72df8 80.26% ▼ 0.01%
52ab4af 80.23% ▼ 0.03%
18d5fcb (HEAD) 80.23% ▼ 0.04%

thiras and others added 2 commits July 13, 2026 01:27
…eck (#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]>
…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]>
@thiras
thiras merged commit d73358a into main Jul 12, 2026
23 checks passed
@thiras
thiras deleted the feat/reactive-pull-through-completion branch July 12, 2026 23: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

2 participants