Repository navigation
fix(cli): keep TERMS.md byte-exact on Windows checkouts - #2448
Conversation
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
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xqsrm6fyKyUKySQTsbnM36
There was a problem hiding this comment.
🟡 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
.gitattributeswithcrates/cli/TERMS.md -textso every checkout writes the committed bytes unchanged. - Add a compile-time
constassertion plus aconst fn contains_crhelper interms.rsthat fails the build if the embedded terms contain a carriage return. - Add a
CHANGELOG.mdentry under### Fixeddocumenting 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.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit 21968ae in the Show a line coverage summary of the most impacted files.
Updated |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xqsrm6fyKyUKySQTsbnM36
What
An operator reports that the Windows
decdn.exefailsdecdn node registerwith an operator terms hash mismatch:currentTermsHash:0x7da33feb…5ec37f4b(keccak of the LF bytes ofTERMS.md)0x1ee6719d…5d27323c(keccak of the same file with CRLF line endings)Root cause: the repo has no
.gitattributes. Thewindows-latestrunners setcore.autocrlf=true, soactions/checkoutwritescrates/cli/TERMS.mdwith CRLF, andinclude_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: aconstassertion fails the build whenTERMS_TEXTcontains\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
crates/cli/deployments/421614.json(alsoinclude_str!'d) alone on purpose: it is parsed as JSON, so CRLF does not change its meaning..cratetarballs come from Linux packaging and were never affected. Only binaries built from a Windows git checkout are.Verification
cargo fmt -- --checkcargo clippy -p decdn-cli --all-targets: cleancargo test -p decdn-cli --lib terms: 9 passed, including the hash lock (nextest is not installed in this environment)TERMS.mdto CRLF locally:cargo check -p decdn-clifails withTERMS.md has CRLF line endings; check it out byte-exact (see .gitattributes)git ls-files --eol crates/cli/TERMS.md→attr/-textCHANGELOG.mdentry added🤖 Generated with Claude Code
https://claude.ai/code/session_01Xqsrm6fyKyUKySQTsbnM36
Generated by Claude Code