You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DHT prefetch: live FindValue→probe→pull-through acquisition + OriginAssignment subscription (AC 7 of #650) #820
Follow-up to #650 / PR #819, which landed the core slice of DHT speculative prefetch: the FIND_VALUE popularity oracle (PopularityTracker), the decision engine (PrefetchPolicy with enabled/throttle/authorized-origin/budget gates), config, and metrics — all behind prefetch.enabled = false. PR #819decides and meters but does not yet act: it satisfies AC 8 (demand derives from FIND_VALUE traffic) but leaves AC 7 (a node actually initiates a prefetch) open.
Scope
Wire the real acquisition and close the remaining gates' data sources (ADR 022 §Prefetch Decision):
Acquisition path — on a PrefetchDecision::Acquire, run DHT FindValue → cdn/probe/v1 → cdn/client/v1 pull-through for the hash, reusing the existing iterative-lookup (crate::dht::lookup), probe, and cache pull-through machinery. Respect the off-by-default flag and the budget/throttle gates already enforced by PrefetchPolicy::decide.
OriginAssignment event subscription — replace the empty ConfigOriginDirectory wired in the runtime with a live, fail-closed origin-directory cache kept current via AssignmentActivated / AssignmentRevoked / DefaultOpenAllowlistUpdated events (ADR 022 §Recommended configuration; same pattern as blacklist polling / channel-state queries). On RPC unavailability the gate fails closed (no prefetch).
Ledger feedback — call the already-implemented, unit-tested PrefetchPolicy::record_acquisition (spend + acquired bytes) and record_served (served bytes) from the live acquisition + serving paths so the rolling-1h budget and demand-quality auto-throttle have real data and decdn_prefetch_spend_usdc_total becomes non-zero.
AC 7 (Implement content discovery via cdn/dht/v1 Kademlia DHT #320) — a node with prefetch.enabled = true observing a prefetch trigger for hash H initiates a prefetch, subject to the origin gate, budget ceiling, and demand-quality auto-throttle.
This is a well-scoped follow-up to #650 / PR #819: the decision engine (PrefetchPolicy), popularity oracle, config, and metrics are already merged — this issue wires the missing act phase. Specifically: (1) the FindValue → probe → pull-through acquisition path, (2) replacing the stub ConfigOriginDirectory with a live, fail-closed subscription to OriginAssignment events, and (3) hooking record_acquisition/record_served into the live paths so the budget and auto-throttle actually track real spend. All three sub-tasks have existing machinery to build on and a clear acceptance criterion (AC 7 of #320).
📊 Assessment
Dimension
Value
Reasoning
Type
Feature
Set to match parent #650; this completes a feature slice already designed and partially implemented
Labels
technical, rust, prod-blocking (existing)
Labels are already correct — prod-blocking is appropriate since this closes the final AC of the prefetch feature; no changes needed
Coding agent
Suitable
Requirements are clear and complete, all dependencies exist (PR #819 landed the decision engine), three discrete wiring tasks, single AC as success criterion
Acquisition path — on PrefetchDecision::Acquire, spawn an async task calling crate::dht::lookup(hash), then cdn/probe/v1, then cdn/client/v1 pull-through. Plumb through the with_prefetch seam already present in the node wiring.
OriginAssignment subscription — replace ConfigOriginDirectory stub in runtime with a live cache subscribed to AssignmentActivated / AssignmentRevoked / DefaultOpenAllowlistUpdated events. Follow the same pattern as blacklist polling and channel-state queries. Fail-closed on RPC unavailability.
Ledger feedback — call PrefetchPolicy::record_acquisition(spend, acquired_bytes) after a successful pull-through, and record_served(bytes) from the serving path, so decdn_prefetch_spend_usdc_total becomes non-zero and the rolling-1h budget auto-throttle has real data.
Key constraints to keep in mind:
prefetch.enabled defaults to false; no production impact until operator opts in — this simplifies integration testing.
record_acquisition and record_served are already unit-tested, so ledger feedback can be verified without end-to-end infra.
Per ADR 037, local cache-miss frequency is observability-only and intentionally excluded from this scope.
The origin gate must fail closed (no prefetch) if the OriginAssignment RPC is unavailable, to avoid the demand-supply Sybil attack described in ADR 022 §Threat Model.
Testing approach: Integration test with prefetch.enabled = true and a mock OriginDirectory returning an authorized origin; assert that a synthetic FIND_VALUE trigger causes a pull-through and that record_acquisition is called with non-zero spend/bytes.
Done — shipped in PR #899 (squash-merged to main).
AC 7 is closed: a node with prefetch.enabled = true now initiates a live acquisition on a prefetch trigger (DHT discovery → probe → paid pull-through via cache.populate), subject to the authorized-origin gate, the rolling-1h budget, and the demand-quality auto-throttle. Spend and served bytes feed back into the policy ledgers (decdn_prefetch_spend_usdc_total is now non-zero).
Scope note: the "OriginAssignment subscription" task in this issue's title was already delivered by #830 (ChainOriginDirectory) and was wired into the prefetch engine before this work, so #899 covered the remaining acquisition + ledger-feedback tasks.
Non-blocking test follow-up tracked in #900 (record_served through the live serve loop).
Activity
github-actions commentedon Jun 5, 2026
🎯 Triage report
This is a well-scoped follow-up to #650 / PR #819: the decision engine (
PrefetchPolicy), popularity oracle, config, and metrics are already merged — this issue wires the missing act phase. Specifically: (1) theFindValue → probe → pull-throughacquisition path, (2) replacing the stubConfigOriginDirectorywith a live, fail-closed subscription toOriginAssignmentevents, and (3) hookingrecord_acquisition/record_servedinto the live paths so the budget and auto-throttle actually track real spend. All three sub-tasks have existing machinery to build on and a clear acceptance criterion (AC 7 of #320).📊 Assessment
technical,rust,prod-blocking(existing)prod-blockingis appropriate since this closes the final AC of the prefetch feature; no changes needed🔗 Similar issues
crate::dht::lookup, the probe machinery, and the ACs this issue closes)💡 Notes and suggestions
Sub-task breakdown:
PrefetchDecision::Acquire, spawn an async task callingcrate::dht::lookup(hash), thencdn/probe/v1, thencdn/client/v1pull-through. Plumb through thewith_prefetchseam already present in the node wiring.ConfigOriginDirectorystub in runtime with a live cache subscribed toAssignmentActivated/AssignmentRevoked/DefaultOpenAllowlistUpdatedevents. Follow the same pattern as blacklist polling and channel-state queries. Fail-closed on RPC unavailability.PrefetchPolicy::record_acquisition(spend, acquired_bytes)after a successful pull-through, andrecord_served(bytes)from the serving path, sodecdn_prefetch_spend_usdc_totalbecomes non-zero and the rolling-1h budget auto-throttle has real data.Key constraints to keep in mind:
prefetch.enableddefaults tofalse; no production impact until operator opts in — this simplifies integration testing.record_acquisitionandrecord_servedare already unit-tested, so ledger feedback can be verified without end-to-end infra.OriginAssignmentRPC is unavailable, to avoid the demand-supply Sybil attack described in ADR 022 §Threat Model.Testing approach: Integration test with
prefetch.enabled = trueand a mockOriginDirectoryreturning an authorized origin; assert that a synthetic FIND_VALUE trigger causes a pull-through and thatrecord_acquisitionis called with non-zero spend/bytes.Add this agentic workflows to your repo
To install this agentic workflow, run
fix(node): address PR #819 review — edge-trigger, hot-path, lock scope (
feat(node): add DHT prefetch popularity signal + decision engine (#650)…
feat(node): chain-backed origin directory + OriginAssignment/Publishe…
fix(node): address PR review on prefetch acquisition (#820)
feat(node): wire live DHT prefetch acquisition + ledger feedback (#820)…
thiras commentedon Jun 14, 2026
Done — shipped in PR #899 (squash-merged to
main).AC 7 is closed: a node with
prefetch.enabled = truenow initiates a live acquisition on a prefetch trigger (DHT discovery → probe → paid pull-through viacache.populate), subject to the authorized-origin gate, the rolling-1h budget, and the demand-quality auto-throttle. Spend and served bytes feed back into the policy ledgers (decdn_prefetch_spend_usdc_totalis now non-zero).Scope note: the "OriginAssignment subscription" task in this issue's title was already delivered by #830 (
ChainOriginDirectory) and was wired into the prefetch engine before this work, so #899 covered the remaining acquisition + ledger-feedback tasks.Non-blocking test follow-up tracked in #900 (
record_servedthrough the live serve loop).Merge origin/main into fix/856-window-paced-pull-through
fix(node): address PR #893 review round 3 (#856)
feat(node): window-paced pull-through for regional proxy warming (#856)…