Skip to content

feat(client): parse and print decdn: URIs - #2455

Merged
alpergundogdu merged 1 commit into
mainfrom
feat/decdn-uri
Oct 14, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
feat/decdn-uri

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The parser half of #2449: decdn_client::uri::DecdnUri names a blob, a whole bundle, or one bundle entry, with an optional namespace hint.

decdn:<hash>[/<path>][?ns=<id>]
URI target
decdn:<hash> UriTarget::Blob
decdn:<hash>/ UriTarget::Bundle
decdn:<hash>/a/b.txt UriTarget::BundleEntry("a/b.txt")
any of the above ?ns=42 same, namespace: Some(42)
  • FromStr parses; Display writes the canonical form (lowercase hex, entry segments percent-encoded as RFC 3986 pchar), which round-trips.
  • Rejects b3:/0x prefixes, wrong length or non-hex, a // authority, ns=0 or non-decimal ns, unknown or duplicate query keys, and entry paths with ./.., empty segments, encoded /, NUL, raw non-pchar characters, bad escapes, or non-UTF-8 once decoded.
  • Typed UriError (hand-rolled, no new dependency). public_api snapshot updated: the diff is the new uri module only.

decdn get (replacing fetch and bundle pull) stays its own piece of #2449. The first user of this parser is decdn gateway (#2456), which is stacked on this branch: merge this first.

Checks

  • cargo nextest run -p decdn-client uri::: 11 tests
  • cargo clippy -p decdn-client --all-targets --all-features -D warnings
  • cargo doc -p decdn-client with -D warnings
  • public API snapshot regenerated

Part of #2449.

🤖 Generated with Claude Code

`decdn_client::uri::DecdnUri` names a blob (`decdn:<hash>`), a whole
bundle (`decdn:<hash>/`) or one bundle entry (`decdn:<hash>/a/b.txt`),
with an optional `?ns=<id>` namespace hint. Entry paths are percent-
encoded per RFC 3986 pchar and held to the manifest path rules; the
canonical `Display` form round-trips. This is the parser half of #2449;
`decdn get` builds on it separately.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Copilot AI 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.

🟢 Approval recommended

The change is an isolated, pure-logic parser module with exhaustive tests and correct edge-case handling that follows established workspace conventions, and no defects were found.

0 open findings

What changed in this PR

This PR adds the parser half of #2449: a new decdn_client::uri module that parses and canonically prints decdn:<hash>[/<path>][?ns=<id>] URIs, which name a blob, a whole bundle, or a single bundle entry with an optional namespace routing hint. The URI is client-side syntax only — it resolves to the BLAKE3 hash and namespace_id the wire already carries — so no node or protocol changes are involved. It is self-contained (no CLI wiring yet); the decdn get command and decdn gateway consumer land in stacked PRs.

Changes:

  • Introduce DecdnUri with FromStr (hand-rolled parsing, no new dependency) and a canonical Display that round-trips, plus UriTarget, a typed UriError, and a SCHEME constant.
  • Validate hashes (64 bare hex, no b3:/0x), entry paths (per-segment pchar percent-decoding; reject ./.., empty, encoded /, NUL, non-pchar, bad escapes, non-UTF-8), and ns (decimal, non-zero, single).
  • Export the module from lib.rs and regenerate the public_api snapshot.
File Description
crates/​client/​src/​uri.rs New decdn: URI module: DecdnUri/UriTarget/UriError, FromStr, canonical Display, and private hash/path/query validators.
crates/​client/​src/​uri/​tests.rs 11 unit tests covering every target kind, namespace hint, round-trip, uppercase hex, percent-encoding, and all rejection paths.
crates/​client/​src/​lib.rs Exports pub mod uri; with a doc-comment-placement note mirroring the existing sink pattern.
crates/​client/​tests/​snapshots/​public_api__public_api.snap Records the new uri public surface in the API snapshot.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit b0e83b8 in the feat/decdn-uri branch remains at 75%, unchanged from commit 0dfc706 in the main branch.

Show a line coverage summary of the most impacted files.
File main 0dfc706 feat/decdn-uri b0e83b8 +/-
crates/client/src/lib.rs 88% 88% 0%
crates/client/src/scheduler.rs 94% 94% 0%
crates/protocol/src/framing.rs 93% 93% 0%
crates/client/src/uri.rs 0% 91% +91%

@alpergundogdu
alpergundogdu merged commit c50a62e into main Oct 14, 2026
32 checks passed
@alpergundogdu
alpergundogdu deleted the feat/decdn-uri branch October 14, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants