Skip to content

decdn bundle subcommand: pull and create directory bundles #391

Closed

Description

@alpergundogdu

Summary

Add a bundle subcommand namespace to decdn with two operations:

  • decdn bundle pull — fetch a directory tree from a bundle (local file or content-addressed hash)
  • decdn bundle create -i <dir>/ -o bundle.json — walk a local tree, hash each file, emit a bundle file

Pure client-side; no protocol or ADR changes. Bundle files are the durable, shareable artifact that origins publish alongside (or instead of) raw hashes.

Motivation

ADR 002 keeps multi-file as an application concern, so bundles live above the protocol. But hand-authoring path → hash JSON is error-prone and a non-starter for any non-trivial origin. Pairing pull with create from day one means origins never have to hand-write bundles, and the format gets validated by its own generator.

A bundle file is just bytes, so it gets its own BLAKE3 hash like any other blob. That means origins can publish a single bundle hash and clients fetch the bundle blob first, then everything it references — no out-of-band file distribution, no separate channel for handing out the JSON. The deterministic-emit requirement (see Implementation notes) is what makes this work: same input dir → same bundle bytes → same hash, cacheable and dedupable across origins.

Bundle format (committed: JSON v1)

{
  "version": 1,
  "entries": [
    { "path": "index.html",    "hash": "b3:abc…", "size": 4096 },
    { "path": "assets/app.js", "hash": "b3:def…", "size": 51234 },
    { "path": "img/logo.png",  "hash": "b3:123…" }
  ]
}
  • path: relative POSIX path; .., absolute paths, and symlink escapes rejected on both create and pull
  • hash: BLAKE3 hex; transparently resolves to a raw blob or an ADR-012 chunked manifest (the DECDNMAN magic lives inside the blob)
  • size: optional on the wire format, but bundle create always emits it (used for pull progress / pre-flight)

Future formats (YAML/TOML) can be added without breaking v1; sniff by extension if/when that happens.

CLI shape

decdn bundle create -i ./site/ -o ./site.bundle.json [--follow-symlinks] [--exclude <glob>]

decdn bundle pull -i ./site.bundle.json   -o ./out/   [flags]   # local bundle file
decdn bundle pull --hash b3:abc…          -o ./out/   [flags]   # fetch bundle blob, then pull contents

# pull flags: [--jobs N] [--verify] [--overwrite|--skip-existing] [--dry-run]

-i and --hash are mutually exclusive; exactly one is required. The --hash form is the same code path as -i plus one extra fetch up front (bundle blob → deserialize → continue).

bundle create is hash-only in v1 — it does not push blobs to an origin/cache. Publishing is a separate concern (cache backend selection, auth, etc.) and will get its own issue once the fetch/push primitives land.

Implementation notes

  • Crate placement: new crates/node/src/cli/bundle/ module (mod.rs, pull.rs, create.rs). Spinning out a crates/client is premature with two subcommands; revisit if the surface grows past ~4–5 commands or non-CLI consumers appear.
  • Atomicity (pull): write each file to <path>.partial, BLAKE3-verify, then rename. Leave partials on failure so re-runs can resume. Verify default-on (--verify is the toggle off, not on).
  • Determinism (create): sort entries by path (byte-wise) and emit canonical JSON (no trailing whitespace, fixed key order per entry) so byte-identical inputs produce byte-identical bundles. This is what makes --hash distribution viable — same dir always hashes the same.
  • Fetch primitive: depends on a future "client fetch" helper (no client-side fetch path exists today — crates/node only has probe). Both --hash and per-entry fetches use the same primitive; --hash is not extra work beyond -i once the primitive exists.

Documentation

  • New adr/appendix-bundles.md (short, ~1 page): JSON schema, path-safety rules, determinism requirement, the bundle-as-blob property (origins publish a hash, not a file), and the explicit non-relationship to ADR 012's chunk manifest. No new numbered ADR — bundles are a client-side convenience above the protocol, not a design decision the network depends on.
  • The appendix is the source of truth; CLI --help text and any future SDK helpers reference it.

Non-goals (v1)

  • No publishing/pushing in bundle create
  • No bundle-of-bundles / nested bundles
  • No signing, encryption, or access control on bundle files
  • No relationship to ADR 012's chunk manifest (intra-file vs. inter-file — orthogonal layers)

Checklist

  • adr/appendix-bundles.md — format spec, path-safety rules, determinism, bundle-as-blob
  • decdn bundle create — directory walk, BLAKE3 hashing, sorted canonical JSON emit (unblocked)
  • decdn bundle pull -i <file> — depends on a client-side fetch primitive (separate issue/PR)
  • decdn bundle pull --hash <b3> — same primitive, one extra fetch up front

Activity

  1. added
    kind:feature
    area:cli
    on May 4, 2026
  2. added
    status:blocked
    on May 6, 2026
  3. thiras commented on May 6, 2026

    @thiras
    Contributor

    Blocked by #421 — decdn bundle … subcommands need to land on the client binary, which doesn't exist yet. Either land #421 first, or fold the binary split into the same PR as the first bundle command.

  4. removed
    status:blocked
    on May 6, 2026
  5. thiras commented on May 6, 2026

    @thiras
    Contributor

    Unblocked by #421 (merged in #425, commit ea01130). The user CLI now lives in crates/cli/; decdn bundle pull / decdn bundle create land on decdn directly. See adr/appendix-binaries.md for the binary layout.

  6. self-assigned this
    on May 7, 2026
  7. removed their assignment
    on May 15, 2026
  8. added
    status:blocked
    on May 21, 2026
  9. thiras commented on Jun 2, 2026

    @thiras
    Contributor

    Label/status note (issue-labeling audit): bundle create has since shipped — crates/cli/src/commands/bundle.rs (directory walk, BLAKE3 hashing, sorted canonical JSON emit) with coverage in crates/cli/tests/bundle_create.rs. The first two checklist items (appendix-bundles.md + bundle create) are effectively done.

    The blocked label is retained because the remaining work — bundle pull -i and bundle pull --hash — is still gated on a client-side fetch primitive that doesn't exist yet. Once that primitive lands, the pull half can proceed and the label can drop.

  10. thiras commented on Jun 3, 2026

    @thiras
    Contributor

    Status update (labeling audit): bundle create has shipped — crates/cli/src/commands/bundle.rs, crates/common/src/cli/bundle.rs, the Bundle(BundleArgs) CLI dispatch, crates/cli/tests/bundle_create.rs, and adr/appendix-bundles.md are all in main. That covers the first two checklist items (the appendix and bundle create).

    The remaining scope — bundle pull -i and bundle pull --hash — is still blocked on the client-side fetch primitive (no client fetch path exists in crates/cli today; see the Pull deferral note in crates/cli/src/commands/bundle.rs:24). The blocked label now applies only to that remaining pull work.

  11. assigned and unassigned on Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:clikind:featureprio:mediumstatus:blocked

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions