Repository navigation
docs(protocol): MAX_MESSAGE_SIZE derivation + compile-time guards (#240) - #287
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates several dependencies in Cargo.lock, including a version bump for windows-sys and rustls-webpki, and introduces detailed documentation and compile-time assertions for MAX_MESSAGE_SIZE in the protocol framing logic. Review feedback identifies a potential issue where forcing windows-sys to version 0.59.0 in the lockfile may violate semver constraints of dependent crates. Furthermore, it is recommended to change the range-based assertions for MAX_MESSAGE_SIZE to an exact equality check to strictly enforce the 16 MiB limit defined in ADR 013.
| dependencies = [ | ||
| "libc", | ||
| "windows-sys 0.52.0", | ||
| "windows-sys 0.59.0", |
There was a problem hiding this comment.
The update of windows-sys from 0.52.0 to 0.59.0 for several crates (e.g., errno, quinn-udp, rustix) appears to be an incorrect lockfile modification. These crates are locked to the 0.52 series in their respective Cargo.toml files. Forcing them to 0.59.0 in Cargo.lock without updating the crates themselves is a semver violation for 0.x versions and will likely cause cargo to error out or re-resolve the lockfile during the next build. If a unification of windows-sys versions was intended, it should be achieved by updating the dependent crates to versions that officially support 0.59.0.
Per review on #287: ADR 013 §Wire Framing pins the value at 16 MiB, not a range. A shrink is equally a protocol-wide change (breaks peers whose messages fit the old cap), so the guard should catch any edit in either direction. Collapse the floor+ceiling pair into one equality assert and note in the doc that per-deployment tightening is a runtime-config concern, not a constant edit. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Addressed the two review comments: Medium — High — |
#240) ADR 013 pins the 16 MiB ceiling (pre-allocation DoS bound vs. documented per-ALPN message upper bounds), but the doc comment didn't say so and nothing caught accidental edits. Expand the comment to cite the derivation and add two `const _: () = assert!(...)` guardrails so a shrink below 64 KiB or a bump above 16 MiB fails the build with a pointer back to the ADR. Closes #240. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Per review on #287: ADR 013 §Wire Framing pins the value at 16 MiB, not a range. A shrink is equally a protocol-wide change (breaks peers whose messages fit the old cap), so the guard should catch any edit in either direction. Collapse the floor+ceiling pair into one equality assert and note in the doc that per-deployment tightening is a runtime-config concern, not a constant edit. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
fff3235 to
0e90ca0
Compare
Summary
MAX_MESSAGE_SIZEto cite ADR 013's derivation (pre-allocation DoS bound, documented per-ALPN message upper bounds, QUICMAX_STREAMSinteraction).const _: () = assert!(...)guardrails: floor at 64 KiB, ceiling at 16 MiB. An accidental edit to the constant fails the build with a message pointing back to ADR 013.crates/protocol/src/framing.rs. ~25 LOC, no behavior change.Closes #240.
Why
ADR 013 §Wire Framing pins this constant at 16 MiB but the previous two-line doc didn't record the rationale, and nothing in the tree caught accidental edits. A compile-time assertion is the cheapest durable guard — no runtime cost, no test framework, fires at build time with a message that tells the changer what to read.
Base branch
Based on top of
chore/bump-rustls-webpki-rustsec-2026-0104(PR #286) socargo deny check advisoriespasses locally and in CI. Will rebase ontomainonce #286 merges; merge order is #286 → this.Test plan
cargo clippy -p decdn-protocol --all-targets -- -D warnings→ cleancargo test -p decdn-protocol→ 22 passedcargo fmt -- --check crates/protocol/src/framing.rs→ cleanMAX_MESSAGE_SIZEto 32 KiB locally; build failed with the floor message, as designed. Reverted.🤖 Generated with Claude Code