Skip to content

test(node): cover prefetch record_served through the live cdn/client/v1 serve loop #900

Closed

Description

@thiras

Context

Follow-up to #820 / PR #899 (live DHT prefetch acquisition). The demand-quality auto-throttle's served-bytes numerator is fed by PrefetchEngine::note_served_if_prefetched, called from the client serve path (crates/node/src/handlers/client.rs, in the accepted-voucher branch of collect_voucher).

Both halves of the credit contract are currently tested independently:

  • tag-on-acquire — the e2e prefetch_acquire_pulls_and_records_spend asserts engine.acquired().contains(...) after a prefetch pull;
  • tag → credit — the unit test note_served_credits_only_prefetched_hashes proves a tagged hash credits record_served and an untagged one does not.

What is not covered: an actual cdn/client/v1 serve of a prefetch-acquired blob driving note_served_if_prefetched from the live serve handler — i.e. the wiring through the real serve loop.

Scope

Add a test that, after a node prefetch-acquires a blob, performs a real paid client pull of that blob from the node and asserts the demand-quality ratio moved (i.e. record_served fired via the serve path). The node_origin_pull.rs / client_loopback.rs harnesses already have the paid-delivery machinery to build on.

Notes

  • Impact of the current gap is bounded to the demand-quality analytics input (throttle bias on a miss is the safe direction — toward more throttling), not payment or delivery correctness — hence it was deemed a non-blocking follow-up during the PR feat(node): wire live DHT prefetch acquisition + ledger feedback (#820) #899 review rather than a merge blocker.
  • Lower-priority adjacent coverage that could ride along: semaphore-saturation (prefetch_acquire_dropped_saturated), throttle/budget gate blocking a live acquisition, and the reused-channel per-pull spend delta value.

🤖 Generated with Claude Code

Activity

  1. self-assigned this
    on Jun 14, 2026
  2. added
    rust
    on Jun 14, 2026
  3. removed their assignment
    on Jun 14, 2026
  4. added
    prio:low
    kind:test
    on Jun 14, 2026
  5. github-actions commented on Jun 14, 2026

    @github-actions

    🎯 Triage report

    Follow-up to the now-closed #820 / PR #899, this task asks for an integration test that closes the untested wiring between the live cdn/client/v1 serve path and PrefetchEngine::note_served_if_prefetched. The two halves of the credit contract (tag-on-acquire and tag→credit) are unit-tested in isolation; what's missing is a test that drives the full loop end-to-end with real paid delivery. Scope is deliberately narrow and the impact of the gap is bounded to demand-quality analytics (throttle biases toward more throttling on miss, which is the safe direction).

    📊 Assessment

    Dimension Value Reasoning
    Type Task Adding integration test coverage — not a bug or new feature
    Labels testing, low added (kept existing technical, rust) Test coverage task; explicitly marked non-blocking and lower priority in issue
    Coding agent Suitable Clear requirements, well-scoped, references existing harnesses (node_origin_pull.rs, client_loopback.rs) with paid-delivery machinery already in place; success criterion is concrete (demand-quality ratio moves after a paid pull of a prefetch-acquired blob)

    🔗 Similar issues

    💡 Notes and suggestions

    Recommended approach:

    1. Build on the existing client_loopback.rs or node_origin_pull.rs test harness — both already have the paid-delivery setup needed.
    2. Sequence: (a) start node, (b) trigger prefetch acquisition for a known blob (ensuring engine.acquired().contains(hash)), (c) perform a real cdn/client/v1 paid pull of that blob, (d) assert demand_quality_ratio or served-bytes counter incremented via PrefetchEngine public API.
    3. The note_served_if_prefetched call is inside the accepted-voucher branch of collect_voucher in crates/node/src/handlers/client.rs — the test must go through the voucher acceptance path, not a bypass.

    Optional adjacent coverage (noted in issue) that could ride along:

    • prefetch_acquire_dropped_saturated — semaphore saturation drop
    • Throttle/budget gate blocking a live acquisition
    • Reused-channel per-pull spend delta value

    Key invariant to verify: if note_served_if_prefetched is never called (e.g., due to a future refactor moving the call site), the test should fail — so assert a concrete counter/ratio value rather than just "no panic".

    Generated by Agentic Triage for issue #900 · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  6. self-assigned this
    on Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:testprio:lowrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions