Repository navigation
refactor(crates): extract decdn-config-types leaf crate (#578) - #586
Conversation
The publisher CLI (`decdn`) transitively linked the entire cache stack
(iroh-blobs, AWS S3 SDK, async-compression) via `cli → common → cache`,
defeating the documented binary-split goal in appendix-binaries.md.
Extract the config-vocabulary value types `decdn-common` needs
(RetryPolicy, DecompressMode, OriginUrl, OriginKind, a new panic-free
Hash newtype, PinnedHashes/PinDiff, DEFAULT_USER_AGENT,
DEFAULT_MAX_PROBE_HOLDS) into a new serde+url-only `decdn-config-types`
leaf crate. `decdn-cache` re-exports them so `decdn-node` is unchanged;
`decdn_cache::Hash` still means `iroh_blobs::Hash`, with
`to_store_hash`/`from_store_hash` shims and a single conversion site in
the node `evict` admin handler. The engine keeps its pinned set on the
store hash, converting only on the cold open/SIGHUP path.
`decdn-common` now depends on the leaf instead of `decdn-cache`, so the
production `decdn` binary links none of iroh-blobs / the AWS SDK
(verified via `cargo tree -p decdn-cli -e normal -i ...`). reqwest/iroh
remain via alloy / the direct iroh dep, not the cache.
Realizes the budget-gated remedy appendix-binaries.md already
prescribed; no new ADR. Docs reconciled: appendix-binaries.md,
architecture.md, cli/Cargo.toml, both CLAUDE.md files.
Verification: cargo build/clippy/fmt clean; cargo nextest run
--workspace = 892 passed. Includes a cross-crate wire-compat test
pinning the leaf Hash hex form byte-identical to iroh_blobs::Hash
against the known BLAKE3("") vector, and a RetryPolicy serde
partial-section regression guard.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Extracts a new decdn-config-types leaf crate (deps: serde, url, anyhow) holding the config-vocabulary value types (RetryPolicy, DecompressMode, OriginUrl, OriginKind, a panic-free Hash newtype, PinnedHashes/PinDiff, DEFAULT_USER_AGENT/DEFAULT_MAX_PROBE_HOLDS). decdn-common now depends on this leaf instead of decdn-cache, so the publisher CLI (decdn) no longer links iroh-blobs/AWS SDK/async-compression. decdn-cache re-exports moved types and adds to_store_hash/from_store_hash shims between the leaf Hash and iroh_blobs::Hash; the engine converts at its public boundary (cold paths only).
Changes:
- New leaf crate
crates/config-types/with moved types, tests, and aHashnewtype with hand-rolled hex codec byte-identical toiroh_blobs::Hash. decdn-cacheupdated to import from leaf, re-export for source compat, store pinned set as store-hash internally, and convert at the public boundary;decdn-commonswitches to leaf dep.- Docs updated:
CLAUDE.md,adr/architecture.md,adr/appendix-binaries.md, and inline rustdoc references; nodeevicthandler converts viadecdn_cache::to_store_hash.
Reviewed changes
Copilot reviewed 28 out of 29 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
Cargo.toml, Cargo.lock |
Register new decdn-config-types workspace member and update lockfile. |
crates/config-types/Cargo.toml |
New leaf crate manifest (serde/url/anyhow only). |
crates/config-types/src/{lib,retry,origin_url,origin_kind,decompress,hash,defaults}.rs |
Moved value types with tests; new panic-free Hash newtype + PinnedHashes/PinDiff. |
crates/cache/Cargo.toml |
Adds dep on the new leaf crate. |
crates/cache/src/lib.rs |
Re-exports leaf types; adds to_store_hash/from_store_hash; pins cross-crate hex/round-trip wire-compat. |
crates/cache/src/engine.rs |
Removes moved types; engine pinned set stays on store hash; converts at boundary; recomputes PinDiff over store-hash sets. |
crates/cache/src/retry.rs |
Removes moved RetryPolicy; keeps delay_for (needs rand); tests updated. |
crates/cache/src/origin/{mod,http}.rs |
Re-exports moved types; removes duplicate redact_for_log/OriginUrl/DecompressMode/OriginKind definitions and their tests. |
crates/cache/src/probe_hold.rs |
DEFAULT_MAX_PROBE_HOLDS re-exported from leaf. |
crates/common/Cargo.toml |
Drops decdn-cache dep, adds decdn-config-types. |
crates/common/src/{lib,admin,config/{mod,types,resolved,secret}}.rs |
Replace decdn_cache::* paths with decdn_config_types::*; docs updated. |
crates/node/src/admin.rs |
Converts the leaf hash from parse_hash_arg to the store hash via decdn_cache::to_store_hash at the evict boundary. |
crates/cli/Cargo.toml |
Comment update reflecting the new clean dependency tree (no code change). |
CLAUDE.md, adr/architecture.md, adr/appendix-binaries.md |
Document the new 9-crate workspace, leaf-crate topology, and the realized remedy. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 89.68% (was 89.59%, ▲ +0.08%) — 16110/17964 lines
History
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new leaf crate, decdn-config-types, to house shared configuration value types such as RetryPolicy, OriginUrl, and Hash. This architectural change decouples decdn-common and the CLI from the heavy storage and network dependencies of decdn-cache, significantly reducing the CLI's binary size. The cache engine now includes conversion functions to bridge between the leaf Hash type and the internal iroh_blobs::Hash. Feedback was provided regarding the Display and Debug implementations for the Hash struct, suggesting a more efficient approach that avoids unnecessary string allocations by writing directly to the formatter.
Display/Debug went through to_hex()'s String allocation on every call;
a frequently-logged type shouldn't allocate per format. Write `{:02x}`
straight to the formatter and delegate Debug to Display. Output is
byte-identical (lowercase zero-padded) to to_hex()/the serde form, so
the to_hex() + serde wire path is untouched and the cross-crate
wire-compat test (hash_bridge_tests) still pins it.
Addresses PR #586 review feedback (gemini-code-assist).
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Commit 8d77099 made Display a second, independent hex impl while to_hex() (the serde path) keeps the HEX-table impl. The two must stay byte-identical (admin JSON-RPC uses serde→to_hex; tracing %hash uses Display), but no test pinned that equivalence — hash_bridge_tests only covers to_hex()↔iroh_blobs::Hash, and the prior comment/commit message overstated that coverage. Add display_and_debug_match_to_hex (asserts Display == to_hex() and Debug == to_hex() over zero/0xab/leading-zero+0xff vectors) and correct the Display comment to reference the real pin. Closes the untested drift gap surfaced in PR #586 re-review. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Fixes #578. The
decdnpublisher CLI transitively linked the entirecachecrate (iroh-blobs, AWS S3 SDK, async-compression) throughcli → common → cache, directly defeating the binary-split goal documented inadr/appendix-binaries.md.This extracts the config-vocabulary value types
decdn-commonactually needs into a newdecdn-config-typesleaf crate (deps:serde,url,anyhowonly):RetryPolicy(value type; therand-usingdelay_forbackoff math stays indecdn-cache)DecompressMode,OriginKind,OriginUrl+parse_origin_url/redact_for_logHashnewtype ([u8;32], lowercase-64-hex serde — byte-identical toiroh_blobs::Hash) +PinnedHashes/PinDiffDEFAULT_USER_AGENT/DEFAULT_MAX_PROBE_HOLDSdecdn-cachere-exports every moved type, sodecdn-nodeis essentially untouched;decdn_cache::Hashstill meansiroh_blobs::Hash(the blob-store hash).to_store_hash/from_store_hashshims bridge the two same-shaped 32-byte digests; the only conversion site is the nodeevictadmin handler. The cache engine keeps its internal pinned set on the store hash and converts only on the cold open / SIGHUP path (hotis_pinned/eviction_candidatesstay zero-cost).This realizes the budget-gated remedy
appendix-binaries.mdalready prescribed — no new ADR; existing ADRs and CLAUDE.md files reconciled to the now-true state.Result
The production
decdnbinary (cargo tree -p decdn-cli -e normal) links none ofiroh-blobs,aws-sdk-s3,aws-config,aws-smithy-*,aws-credential-types,async-compression.decdn-commonis clean too.reqwest/irohremain (viaalloy/ the directirohdep — not the cache, as intended). The dev-depdecdn-cacheincliis intentional (integration tests) and never reaches the release binary.Verification
cargo build --workspace/cargo clippy --workspace --all-targets -- -D warnings/cargo fmt --all -- --check— all clean (anti-panic policy satisfied on the hand-rolled hex)cargo nextest run --workspace— 892 passed, 0 skippedengine.rsdiff test has an equivalent in the leaf)Hashhex form byte-identical toiroh_blobs::Hashagainst the known BLAKE3("") vector + lossless store↔leaf round-tripsRetryPolicyserde partial-section regression guard (#[serde(default)]/default_buffered_max_bytes)Review
Ran the multi-agent PR review toolkit (code / comments / tests / silent-failures / type-design). One Critical (missing cross-crate wire-compat test) and four Important doc/test items were found and fixed in this branch; reviewers' consensus is a faithful realization of the approved plan with no remaining blocking issues. A pre-existing
engine.rspoisoned-mutex silent fallback was identified as out of scope (not introduced here) and left as a noted future follow-up.🤖 Generated with Claude Code