Repository navigation
feat(cli,bao-range): decdn origin import — seed a cache origin (sharded blob + .obao4) (#1904) - #1905
Conversation
…#1904) Operators running a serving node with a filesystem pull-through origin had no supported way to populate it: the sharded data object is a plain `cp`, but the sibling `{hex}.obao4` outboard must be a `bao-tree` pre-order outboard at `IROH_BLOCK_SIZE` (16 KiB chunk groups) — a stock `bao encode --outboard` produces a file the daemon rejects. Add an offline, config-free `decdn origin import -i <path> --to <target>`: - Single file: stream once to compute the BLAKE3 root and the outboard, write the sharded data object + `.obao4` sibling atomically. `--move` renames the source (copy+unlink across filesystems); idempotent on a content-addressed path; `--force` overwrites. - Directory: walk (reusing `bundle create`'s containment / `--exclude` / `--follow-symlinks` rules), import every file, emit the canonical bundle manifest (byte-identical to `bundle create`), and import the manifest blob itself so the whole tree is retrievable by one bundle hash. - `--json` status line, mirroring `bundle create`. `--to fs:<dir>` is implemented; the hash + outboard prep is backend-independent, so an `s3://` writer is an additive follow-up (the target parser already rejects `s3://` and `http(s)://` with actionable errors). The outboard encoder and the `.obao4` layout contract (`OBAO4_SUFFIX`, shard prefix) move into the iroh-blobs-free `bao-range` leaf crate, shared by the cache reader (`origin::fs` / `origin::s3`) and the new writer, so a blob written by `origin import` is one the daemon reads back verbatim — an integration test proves it by range-serving through the real `FilesystemOrigin`. The CLI stays iroh-blobs / AWS-SDK free (#578). Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
origin import --move can delete source data without verifying an already-present target object/outboard matches the expected bytes, risking silent data loss and leaving stale .obao4 files in place.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a new offline CLI workflow (decdn origin import) to seed a cache origin store from local files/trees by writing both the sharded data object and its daemon-compatible {hex}.obao4 pre-order outboard, reusing shared manifest-walk/serialization logic so directory imports produce bundle manifests byte-identical to decdn bundle create.
Changes:
- Introduces
decdn origin importCLI args + dispatch and implements an fs-backed origin writer (with--move,--force,--exclude,--follow-symlinks,--bundle,--json). - Extracts bundle-manifest walk + canonical JSON serialization into a shared
commands::manifestmodule used by bothbundle createandorigin import. - Moves the
.obao4layout contract and outboard encoder into thebao-rangeleaf crate and wires the cache fs origin to use the sharedOBAO4_SUFFIX.
File summaries
| File | Description |
|---|---|
| crates/common/src/cli/origin.rs | Defines clap args for the new decdn origin import command. |
| crates/common/src/cli/mod.rs | Plumbs Origin into the shared CLI command enum and exports args types. |
| crates/cli/src/main.rs | Adds runtime dispatch for Command::Origin without threading config. |
| crates/cli/src/commands/mod.rs | Registers new manifest + origin command modules. |
| crates/cli/src/commands/manifest.rs | Shared directory walk, exclude semantics, and canonical manifest serialization/writes. |
| crates/cli/src/commands/bundle.rs | Refactors bundle create to use shared manifest machinery. |
| crates/cli/src/commands/origin.rs | Implements origin import (fs target), including report output and atomic writes. |
| crates/cli/tests/origin_import.rs | Integration coverage proving daemon-compat .obao4 via real FilesystemOrigin reads + bundle byte-identity. |
| crates/cli/Cargo.toml | Adds decdn-bao-range dependency for the outboard/layout contract used by import. |
| crates/cache/src/origin/fs.rs | Re-exports .obao4 suffix from decdn_bao_range to keep layout contract shared. |
| crates/bao-range/src/origin_seed.rs | New shared outboard encoder + shard prefix + .obao4 naming contract. |
| crates/bao-range/src/lib.rs | Exposes the new origin-seeding helpers from bao-range. |
| CLAUDE.md | Updates crate/binary capability overview to include origin import. |
| Cargo.lock | Updates lockfile for new dependency edge(s). |
Review details
Suppressed comments (1)
crates/cli/src/commands/origin.rs:359
- If a
{hex}.obao4sibling already exists, this treats it as valid and skips writing without checking that it matches the expected outboard bytes. That can leave a stale/foreign outboard in place, defeating the main goal oforigin import(daemon-compatible range serving) while still reporting success.
let present = std::fs::metadata(obao4_path).is_ok();
if present && !force {
return Ok(());
}
- Files reviewed: 13/14 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 82.64% (was 82.66%, ▼ 0.02%) — 71608/86648 lines
History
|
Copilot review: `origin import --move` decided a target object was already present using a length-only check, then deleted the source — so a same-size but corrupt/foreign object at the content-addressed path could silently discard the only correct copy of the data. - `--move` now re-hashes an already-present object and refuses to delete the source unless it verifies (`--force` still overwrites from the source). - Replace the length-only `.obao4` check with a content check (`ensure_obao4`): a stale/foreign sibling from a partial prior import is overwritten instead of left in place (the node rejects a mismatching `.obao4` and drops to whole-blob serving). A byte-identical sibling is still a no-op. Adds regression tests: move-refuses-on-corrupt-present, move-consumes-on- verified-present, stale-obao4-replaced. Co-Authored-By: Claude Opus 4.8 <[email protected]>
What
Adds
decdn origin import— an offline, config-free command that seeds a cacheorigin store with local content, writing each blob's sharded data object
{base}/{hex[0..2]}/{hex}and its sibling pre-order bao outboard{hex}.obao4in the exact layout the daemon reads (ADR 037 §Origin-tierpull-through).
Closes #1904.
Why
Operators running a serving node with a filesystem pull-through origin had no
supported way to populate it. The data object is a plain
cp, but the.obao4must be abao-treepre-order outboard atIROH_BLOCK_SIZE(16 KiBchunk groups) — a stock
bao encode --outboarduses a different chunk groupsize and produces a file the daemon rejects. The only reference implementation
was a
#[cfg(test)]helper.Behavior
the data object and
.obao4atomically (temp + rename into the shard).--moverenames the source (copy+unlink across filesystems). Idempotent on acontent-addressed path; a size mismatch is refused unless
--force.bundle create's exact containment /--follow-symlinks/--excluderules, imports every file, emits thecanonical bundle manifest (byte-identical to
bundle create), and importsthe manifest blob itself so the whole tree is retrievable by one bundle hash.
--jsonstatus line mirroringbundle create.Design
are identical across the fs and s3 backends; only the final write differs. The
--to <target>parser selects the writer.fs:<dir>is implemented;s3://is an additive follow-up (the parser already rejects
s3://andhttp(s)://with actionable errors).
(
encode_outboard) and the.obao4layout (OBAO4_SUFFIX, shard prefix) nowlive in the
bao-rangeleaf crate, consumed by both the cache reader(
origin::fs/origin::s3) and the new writer — so a blob written here isone the daemon reads back verbatim. The CLI stays free of iroh-blobs / the AWS
SDK (CLI binary-split regression: publisher links cache crate (iroh-blobs/AWS SDK) #578); verified with
cargo tree -p decdn-cli -e normal -i iroh-blobs.bundle createwalk + canonical serializer were extracted into a sharedcommands::manifestmodule so both commands emit identical manifest bytes byconstruction rather than by two copies staying in sync.
Testing
crates/cli/tests/origin_import.rsproves the written outboard isdaemon-compatible by range-serving through the real
decdn-cacheFilesystemOrigin(whole-blob fetch + a chunk-group-aligned verified range),plus idempotent re-import,
--movesource consumption, and directory importmatching
bundle createbyte-for-byte with the manifest blob present.bao-rangeunit test pinsencode_outboardbyte-identical to the in-memoryPreOrderMemOutboard::createthe cache seeds with.cargo build,cargo clippy --workspace --all-targets --all-features -- -D warnings,cargo nextest run(871 tests),cargo fmt --check, doc gate,cargo deny.🤖 Generated with Claude Code