Skip to content

docs: client parallelism, download resume, and file manifests (ADR 012 amendment) - #209

Merged
alpergundogdu merged 5 commits into
mainfrom
adr/024-026-client-improvements
Apr 11, 2026
Merged

alpergundogdu merged 5 commits into
mainfrom
adr/024-026-client-improvements

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Summary

Adds three client-side features as new sections in ADR 012 (012-client.md) rather than separate ADR files — these are implementation details of the client, not independent architectural decisions.

Multi-Node Parallel Download

  • --max-channels N CLI flag; default 1 (sequential, existing behaviour)
  • One payment channel per node; N equal byte ranges assigned by latency rank
  • Economic breakeven ~10 GiB at N=4 ($0.23/channel overhead vs. $0.01/GB rate)
  • Minimum range 256 MiB; falls back to single-node if fewer candidates available
  • Incompatible with streaming/piped output (--streaming flag forces sequential)
  • PoC: --max-channels capped at 1

Download Resume and Crash Recovery

  • Atomic state.json (write-to-temp + rename) under ~/.decdn/downloads/<hash>/
  • 64 MiB flush cadence; worst-case re-download per crash: 64 MiB
  • Voucher nonce persisted on every voucher send (nonces must never be reused)
  • Channel reuse on reconnect (avoids $0.23 lifecycle overhead if still open)
  • decdn downloads list/clean subcommands; 30-day abandonment threshold
  • PoC: single-channel only; 256 MiB cadence; no decdn downloads subcommands

File Manifests and Reconstruction

  • 256 MiB canonical chunk size at ingest
  • Postcard-encoded Manifest struct (version, total_bytes, mime_type, chunks)
  • Manifest BLAKE3 hash = canonical file identifier distributed out-of-band
  • Two-phase download: fetch manifest first, then chunks in order
  • Per-chunk BLAKE3 verification; blob retention for re-serving (opt-out: --no-keep-blobs)
  • Per-chunk encryption via ADR 006 epoch key scheme; K_blob excluded from manifest
  • Backward-compatible: raw single-blob downloads unchanged
  • PoC: single-chunk manifests only

Closes #206, #207, #208

alpergundogdu and others added 4 commits April 10, 2026 11:44
Defines BitTorrent-style parallel blob download across N nodes via
--max-channels flag. Covers economic analysis (breakeven ~9 GiB at N=4),
range assignment strategy, separate payment channel per node, reassembly
from range-N.part files, node failure handling, and streaming incompatibility.

PoC caps --max-channels at 1. Updates architecture.md with ADR 024 summary.

Closes #206

Co-authored-by: Copilot <[email protected]>
Defines on-disk layout (~/.decdn/downloads/<hash>/), atomic state.json
(write-to-temp + rename), 64 MiB flush cadence, voucher nonce persistence,
channel reuse on resume, and decdn downloads subcommands for stale cleanup.

Updates architecture.md with ADR 025 summary.

Closes #207

Co-authored-by: Copilot <[email protected]>
Defines 256 MiB canonical chunk size, postcard-encoded manifest format
(Manifest + ChunkEntry + ChunkEncryption structs), two-phase client download
(manifest fetch then chunks), per-chunk BLAKE3 verification, blob retention
for re-serving, and backward compatibility with raw single-blob downloads.

Encrypted files use per-chunk K_blob via ADR 006 epoch key scheme;
K_blob excluded from manifest. PoC supports single-chunk manifests only.
Updates architecture.md with ADR 026 summary.

Closes #208

Co-authored-by: Copilot <[email protected]>
Folds three client improvement topics into ADR 012 (012-client.md)
as new sections rather than separate ADRs:

- Multi-Node Parallel Download: --max-channels N CLI flag, one channel per
  node, 256 MiB minimum range, economic breakeven ~10 GiB at N=4, streaming
  incompatibility, node failure handling. PoC capped at 1.

- Download Resume and Crash Recovery: atomic state.json (write-to-temp +
  rename) under ~/.decdn/downloads/<hash>/, 64 MiB flush cadence, voucher
  nonce persisted on every send, channel reuse on reconnect, decdn downloads
  subcommands for stale cleanup.

- File Manifests and Reconstruction: 256 MiB chunks, postcard-encoded
  Manifest struct, two-phase download (manifest then chunks), per-chunk
  BLAKE3 verification, blob retention for re-serving, per-chunk encryption
  via ADR 006 epoch keys, backward-compatible with raw blob downloads.
  PoC: single-chunk manifests only.

Removes separate draft ADR 024/025/026 files (content consolidated here).
Updates architecture.md ADR 012 summary paragraph.

Closes #206, #207, #208

Co-authored-by: Copilot <[email protected]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates ADR 012 to include specifications for multi-node parallel downloads, crash recovery with persistent state, and a chunked file manifest system. The review feedback suggests clarifying the cost-benefit of parallelism, ensuring download ranges align with chunk boundaries for efficiency, and fixing a potential off-by-one error in the resume logic. Additionally, it is recommended to add a magic header to the manifest format to prevent resource exhaustion and improve the reliability of manifest detection.

Comment thread adr/012-client.md Resolved
Comment thread adr/012-client.md Resolved
Comment thread adr/012-client.md Resolved
Comment thread adr/012-client.md Resolved
Comment thread adr/012-client.md Resolved
- Economic threshold: replace misleading "economical" with accurate framing
  — parallelism trades cost for latency; recommended for >10 GiB to amortize
  the fixed per-channel overhead
- Range assignment: align ranges to 256 MiB chunk boundaries instead of
  equal division, so chunks are not split across multiple nodes
- state.json verified_offset: change semantics to "next byte to fetch"
  (0 = start of range) to avoid off-by-one when used as StreamRequest
  byte_offset; remove the -1 sentinel
- Manifest struct: add magic: [u8; 8] = b"DECDNMAN" as first field so
  the client can safely detect manifests without deserialising arbitrary
  blobs (prevents resource exhaustion from malformed Vec lengths)
- Backward compatibility: replace deserialization-failure heuristic with
  explicit DECDNMAN magic header check

Co-authored-by: Copilot <[email protected]>
@alpergundogdu
alpergundogdu merged commit a7793fe into main Apr 11, 2026
13 of 14 checks passed
@alpergundogdu
alpergundogdu deleted the adr/024-026-client-improvements branch May 7, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant