Skip to content

DHT prefetch: live FindValue→probe→pull-through acquisition + OriginAssignment subscription (AC 7 of #650) #820

Closed

Description

@thiras

Context

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 #819 decides 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.

Notes

Acceptance criteria

Activity

  1. added
    rust
    on Jun 5, 2026
  2. github-actions commented on Jun 5, 2026

    @github-actions

    🎯 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) 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

    🔗 Similar issues

    💡 Notes and suggestions

    Sub-task breakdown:

    • 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.

    Generated by Agentic Triage for issue #820 · sonnet46 615.2K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  3. self-assigned this
    on Jun 13, 2026
  4. thiras commented on Jun 14, 2026

    @thiras
    ContributorAuthor

    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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

rust

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions