Skip to content

bao streaming follow-ups from the #1052 multi-agent review (type design, deferred tests, doc sweep) #1060

Closed

Description

@yigitdot

Deferred items from the multi-agent review of #1052 (ADR 038 bao verified-range streaming). The blockers (reputation inversion, mid-stream corruption misclassification, DecodeError taxonomy, truncated-export guard) were fixed in 80d0c80; these are the agreed follow-ups.

Type design

  • AlignedRange should carry its blob_size and gain wire_len() (replacing free-standing bao_encoded_size(total, ranges) at its 4 call sites). A mismatched (total, ranges) pair silently yields a plausible-but-wrong payment bound with no runtime backstop — the one misuse seam the crypto never sees. Also drop the now-redundant blob_size param from encode_verified_range.
  • Dedicated StreamCommitOutcome::VerifyFailed (or actual: Option<Hash>) instead of the Hash::EMPTY sentinel in HashMismatch — the sentinel is the real hash of the empty blob and renders as 'origin returned blob af1349…' (currently documented in CacheError::HashMismatch::actual).
  • Rename expected → expected_wire_bytes through UpstreamPull / NodeProgressivePull / receive_and_pay — the wire-vs-content unit lives only in comments today (the exact 1,572,864-vs-1,578,944 confusion the test suite hit). A full WireBytes/ContentBytes newtype split was evaluated and recommended AGAINST (the window-budget code intentionally mixes units through the agnostic Bytes).
  • TeeSink takes the content size at open instead of as a magic first 8-byte write — removes an untyped calling convention.

Deferred tests

  • E2e resume with a non-empty proof spine: the only wire-level resume test uses a single-leaf 4 KiB blob (zero parent nodes). Re-point client_byte_offset_returns_suffix (or add a sibling) at a ~200 KiB blob with offset = 70 * 1024 so the production export_bao_range ↔ decode_verified_range pair is exercised with real proof parents.
  • One golden wire-number assertion (e.g. 1.5 MiB blob → 1,578,944 wire bytes): every current expectation is computed with the same helpers production uses, so a bao-tree bump changing the encoding shape would pass all tests while breaking cross-version wire compat (ADR 038 §Risks names this).

Docs / polish

  • Remaining stale 'whole-blob hash' comments in client-pull (HashMismatch docs, fetch_inner guard rationale, UpstreamPull struct doc, receive_and_pay) and node_origin (buffered-path region-accounting comment — bytes.len() is content while the watermark is wire; AcquisitionObserver::on_pull 'delivered length'), plus node_to_node_pull_through.rs narratives ('whole-blob integrity check', stale hash-mismatch close-reason mention).
  • Four comments referencing 'the tee's import_bao' — the tee path is the verifying-decoder + import_and_verify_stream, not import_bao_*.
  • import_and_verify_stream doc: on the tee path pull_through_bytes meters decoded plaintext, slightly under the wire that left the upstream.
  • Deposit pre-flight guard (guard_bytes) uses content size while billing is wire bytes (~0.4% higher) — benign (mid-stream exhaustion is bounded to one window), note or widen.
  • ChannelRecvStream::stop/id inert-by-design comments; recv_bytes zero-length-chunk note.
  • crates/cache/tests/range_pull.rs comment 'strictly more' should be 'at least as much' (single-leaf wire == data).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions