Skip to content

fix(cli): keep TERMS.md byte-exact on Windows checkouts - #2448

Merged
alpergundogdu merged 3 commits into
mainfrom
ccr-8b19213d-19cto3
Oct 12, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
ccr-8b19213d-19cto3

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

What

An operator reports that the Windows decdn.exe fails decdn node register with an operator terms hash mismatch:

  • network currentTermsHash: 0x7da33feb…5ec37f4b (keccak of the LF bytes of TERMS.md)
  • Windows binary: 0x1ee6719d…5d27323c (keccak of the same file with CRLF line endings)

Root cause: the repo has no .gitattributes. The windows-latest runners set core.autocrlf=true, so actions/checkout writes crates/cli/TERMS.md with CRLF, and include_str! embeds those bytes. Windows CI only runs clippy and a smoke test, so the hash-lock unit test never runs on Windows.

The fix:

  • .gitattributes: crates/cli/TERMS.md -text, so every checkout writes the committed bytes unchanged.
  • terms.rs: a const assertion fails the build when TERMS_TEXT contains \r. A CRLF checkout on any platform now fails at compile time and cannot produce a binary that silently mismatches. The Windows CI clippy job compiles it, which covers the release targets.

Reviewer notes

  • I left crates/cli/deployments/421614.json (also include_str!'d) alone on purpose: it is parsed as JSON, so CRLF does not change its meaning.
  • Crates.io .crate tarballs come from Linux packaging and were never affected. Only binaries built from a Windows git checkout are.
  • The affected Windows release assets (v0.0.1–v0.0.3) need a rebuild/re-release after this merges.

Verification

  • cargo fmt -- --check
  • cargo clippy -p decdn-cli --all-targets: clean
  • cargo test -p decdn-cli --lib terms: 9 passed, including the hash lock (nextest is not installed in this environment)
  • Converted TERMS.md to CRLF locally: cargo check -p decdn-cli fails with TERMS.md has CRLF line endings; check it out byte-exact (see .gitattributes)
  • git ls-files --eol crates/cli/TERMS.md → attr/-text
  • User-visible change: CHANGELOG.md entry added

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xqsrm6fyKyUKySQTsbnM36


Generated by Claude Code

The Windows release runner checks the repo out with core.autocrlf, so
include_str! embedded CRLF terms and the binary's terms hash never matched
the network's currentTermsHash. Mark TERMS.md -text, and fail the build
when the embedded terms contain a carriage return.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xqsrm6fyKyUKySQTsbnM36
Copilot AI balanced review requested due to automatic review settings October 12, 2026 19:01

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.

🟡 Changes recommended

The core fix is sound and idiomatic, but the compile-time guard protects only the crates/cli copy of TERMS.md while .gitattributes is the sole safeguard for the crates/e2e include of the same file, which is a human-review judgment call worth confirming before approval.

0 open findings

What changed in this PR

This PR fixes a byte-exactness bug where Windows checkouts converted crates/cli/TERMS.md to CRLF line endings. Because the operator terms' keccak256 is the exact preimage of the on-chain currentTermsHash, a CRLF-embedded binary (decdn.exe) hashed different bytes and decdn node register failed with a terms mismatch. The fix pins the file to byte-exact checkout via .gitattributes and adds a compile-time guard so a CRLF checkout fails the build instead of silently shipping a mismatched binary. This is a low-risk, additive safety change with no runtime logic change.

Changes:

  • Add .gitattributes with crates/cli/TERMS.md -text so every checkout writes the committed bytes unchanged.
  • Add a compile-time const assertion plus a const fn contains_cr helper in terms.rs that fails the build if the embedded terms contain a carriage return.
  • Add a CHANGELOG.md entry under ### Fixed documenting the user-visible fix.
File Description
.gitattributes New file pinning crates/cli/TERMS.md to byte-exact (-text) so line-ending normalization cannot alter the hash preimage.
crates/​cli/​src/​commands/​terms.rs Adds a compile-time CR-reject assertion and a const fn helper, matching the repo's established const _: () = assert!(...) guard pattern.
CHANGELOG.md Documents the Windows terms-hash fix under the Fixed section.

🧠 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

github-code-quality Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 21968ae in the ccr-8b19213d-19cto3 branch remains at 75%, unchanged from commit d898a53 in the main branch.

Show a line coverage summary of the most impacted files.
File main d898a53 ccr-8b19213d-19cto3 21968ae +/-
crates/node/src...s/client/mod.rs 90% 89% -1%
crates/protocol/src/framing.rs 93% 93% 0%
crates/cli/src/...mmands/terms.rs 65% 69% +4%

Updated October 12, 2026 19:24 UTC

@alpergundogdu
alpergundogdu merged commit 5a920d9 into main Oct 12, 2026
31 checks passed
@alpergundogdu
alpergundogdu deleted the ccr-8b19213d-19cto3 branch October 12, 2026 20:22
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.

3 participants