Skip to content

decdn origin import: support s3:// write target (or document aws s3 sync path) #2090

Closed

Description

@alpergundogdu

Summary

decdn origin import only implements the fs:<dir> target. parse_target in
crates/cli/src/commands/origin.rs accepts s3://… only to return a
"not yet implemented" error, and the arg docs in
crates/common/src/cli/origin.rs promise it as "an additive follow-up… only the
writer differs." This issue scopes that follow-up and — importantly — asks
whether a native S3 writer is worth building at all, given aws s3 sync
already covers it.

What already exists (the easy 90%)

The import path is designed so that only the final write is backend-specific:

  • Hash + outboard are backend-independent and already CLI-side. encode_outboard
    and the layout contract (OBAO4_SUFFIX, two-char shard) live in bao-range, a
    leaf the CLI already links. The importer streams each source once, computes the
    content address and pre-order bao outboard, and today writes them to
    {base}/{hex[0..2]}/{hex} + {hex}.obao4.
  • A full S3 read backend already ships. crates/cache/src/origin/s3.rs
    (S3Origin) fetches from {prefix}{hex[0..2]}/{hex} (+ .obao4) over the AWS
    SDK, with static-key / default-chain / STS credentials, R2/B2/MinIO endpoint +
    path-style knobs, and redacting Debug. Its config resolution
    (S3OriginConfig / ResolvedS3Config / resolve_origin) lives in
    decdn-common.
  • The two layouts are byte-identical by design. key_for in the read
    backend mirrors FilesystemOrigin::path_for precisely so operators can
    aws s3 sync between an fs origin and an S3 origin without renaming objects.

So the missing piece is narrow: PUT the already-computed data object and .obao4
to S3 keys, with the same idempotency/--force/--move semantics the fs writer
has.

The blocker: decdn-cli is deliberately AWS-SDK-free

This is the whole design cost, and why it isn't a five-line change.

.github/scripts/check_crate_edges.py enforces (as part of #578) that
decdn-cli's transitive closure links no aws-sdk-*, aws-config,
aws-smithy-*, aws-sigv4, aws-runtime, aws-types, aws-credential-types
(and no iroh-blobs). cargo install decdn-cli must stay a small, S3-SDK-free
publisher binary. The check runs with --all-features, so a feature-gated
aws-sdk-s3 dependency on the CLI would still trip it.

origin import is also, by explicit design, offline / config-free / no running
daemon
— it lives in its own decdn origin group precisely because it does not
talk to a node. So the obvious "route it through the node's admin RPC" answer
(the node does link the S3 SDK via cache) conflicts with that posture.

Design options

Option 0 — Do nothing native; document aws s3 sync (recommended default).
Because the fs and S3 layouts are identical, this already works end to end today:

decdn origin import -i ./site --to fs:/tmp/origin --bundle bundle.json
aws s3 sync /tmp/origin s3://my-bucket/prefix/

The .obao4 siblings and shard dirs sync verbatim; the read backend serves them
unchanged. Cost: a temp staging dir and a second tool. This may be sufficient —
we should not add an SDK to the publisher CLI to save one aws s3 sync.
If we pick this, close the loop by turning the s3:// "not yet implemented"
error into an actionable hint pointing at exactly this two-step recipe, and say
so in the --to docs.

Option A — Native writer in the CLI behind a relaxed edge rule.
Add an aws-sdk-s3 writer to the CLI (feature-gated), and carve S3 out of
CLI_MUST_NOT_LINK. Rejected unless there's strong demand: it defeats the
stated #578 goal (a lean, SDK-free cargo install decdn-cli) even for users who
never touch S3, since the closure check is --all-features. A per-feature
exception to the edge check is possible but is a real erosion of the invariant.

Option B — Native writer in a shared, SDK-bearing crate, used by a separate
binary or the daemon.
Factor an OriginStoreWriter trait (fs + s3 impls) into
a crate that may link the SDK (e.g. alongside/into cache), reusing
S3OriginConfig + resolve_origin from common. decdn origin import in the
lean CLI keeps fs: only; native S3 import ships as either (a) a decdn node origin import admin-RPC command executed by the daemon, or (b) a distinct
S3-capable tool. Cleanest separation, most code/UX churn, and it splits "import"
across two commands.

Option C — Minimal SigV4 PUT without the SDK. Hand-roll S3 REST PUTs with a
small SigV4 signer so the CLI stays SDK-free. Rejected: re-implements signing,
credential chains, R2/B2/MinIO quirks, and retries that the read backend already
gets from the SDK — high risk, high maintenance, for a writer that must exactly
match the read backend's behavior.

Recommendation

Lead with Option 0: verify + document the aws s3 sync recipe and upgrade
the s3:// rejection message to hand the operator that exact recipe. Only if
real demand appears for a single-command native import, prefer Option B
(shared writer crate + daemon/admin path) over relaxing the CLI's AWS-free
invariant (Option A). Reuse S3OriginConfig / resolve_origin — do not invent a
second S3 config surface.

Acceptance criteria

  • Decide native-vs-aws s3 sync and record the rationale (an ADR note if it
    changes the origin import contract).
  • Regardless of outcome: the s3:// path no longer dead-ends on a bare
    "not yet implemented" — it either works or points at the documented
    aws s3 sync recipe, and crates/common/src/cli/origin.rs --to docs
    match reality.
  • If native (Option B): S3 writer reuses S3OriginConfig + resolve_origin;
    decdn-cli still passes check_crate_edges.py (no aws-sdk-* in its
    closure); --force / --move / idempotent-skip semantics and the .obao4
    sibling match the fs writer; round-trip test writes via the new path and
    reads back through S3Origin (MinIO or aws_smithy_mocks).

Pointers

  • crates/cli/src/commands/origin.rs — parse_target (the s3:// stub),
    import_one_file / import_bytes (fs writer to generalize).
  • crates/common/src/cli/origin.rs — --to arg docs.
  • crates/cache/src/origin/s3.rs — the existing S3 read backend + key_for
    layout to mirror.
  • crates/common/src/config/{resolved,types}.rs — S3OriginConfig /
    resolve_origin.
  • .github/scripts/check_crate_edges.py — the CLI AWS-free invariant (CLI binary-split regression: publisher links cache crate (iroh-blobs/AWS SDK) #578).

Activity

  1. added
    kind:feature
    area:cli
    on Sep 21, 2026
  2. moved this from Backlog to In progress in deCDNon Sep 21, 2026
  3. added a commit that references this issue on Sep 21, 2026
    dcf8245
  4. moved this from In progress to Done in deCDNon Sep 21, 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:feature

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions