Skip to content

feat: range-minimized fetch — unified RangedStore (node+client) + gap-driven pull #1621

Closed

Description

@alpergundogdu

Problem

A node and a client re-pay for bytes they already hold. has() is Complete-only, so any partial hold — interior, prefix, or disjoint — is treated as an empty cache, and every upstream pull threads a single contiguous byte_offset/byte_len. missing_ranges (the disjoint-gap oracle, shipped #1609) is unused. Clients are worse off: with only a .partial length they can't even represent disjoint held ranges, so BitTorrent-style partial state is impossible.

Verified against the code today: holding [K,L) and serving [0,X) re-pulls the whole blob; a prefix [0,K) re-pulls from 0; disjoint holds can't be expressed. All three re-pay for held bytes.

Intent

Satisfy "range R of blob H" by fetching only what you don't already hold+verify — the same stack for node and client — shaped so multi-source parallel (#1164) drops in later.

1. One source-agnostic RangedStore (trait in bao-range)

present_ranges / missing_ranges / admit(range) / read(range) / finalize. Two backends:

Resume: trust records, verify once. admit only writes bao-verified data and records the range; resume trusts the record (O(1), no re-hash); one valid_ranges sweep at materialization is the wrap-up + safety net, and the stored outboard makes recovery surgical (re-fetch only the bad chunk groups).

2. Gap-driven range-minimized pull (A)

gaps = missing_ranges(H,R) → one contiguous pull per gap (interior→2, prefix→1, disjoint→N), verify in transit, admit. No wire change — disjoint gaps stay a local scheduling concern. Cheapest-first is automatic (the store is the free source). Subsumes today's single-byte_offset resume as the degenerate "one gap" case.

Node is a paced middleman; client is an endpoint. Node serve-miss = window-paced forward walk (draw upstream ≤ pull_ahead_bytes ahead of downstream cleared payment, ADR 037; held segments served free from cache); client = order-free, bounded by its own deposit. Pacing is a third injected axis, alongside sink and presence.

Interfaces / crate placement

RangedStore trait → bao-range (shared leaf). Node backend → cache. Client backend + gap-driven driver (A) → client-pull (reachable from node + cli). The driver takes three pluggable axes: RangedStore, Source (the #1608 BlobSource), Pacer. Mirrors the settled BlobSource placement (#578-clean).

Relationship to existing issues

Phasing

P1 RangedStore trait + node backend · P2 client backend (.partial+outboard, conformance-tested against the same suite as the node) · P3 gap-driven driver (A) + Pacer (client first, then node) · P4 extend to bundle pull.

Design worked out 2026-08-05.

Activity

  1. added
    kind:feature
    prio:high
    rust
    on Aug 5, 2026
  2. self-assigned this
    on Aug 5, 2026
  3. alpergundogdu commented on Aug 13, 2026

    @alpergundogdu
    ContributorAuthor

    Complete. All four phases merged:

    Multi-source parallel (B) stays as the follow-on #1164 / ADR 039. Closing as done.

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

Metadata

Metadata

Assignees

Labels

kind:featureprio:highrust

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions