open-standards/wai/http-conformance/falsify/left-len.patch
Transaction Science 1cddbdad19 wai: http-conformance falsification patches and their runner
Twelve patches, each breaking one function (the content hash's domain, the
root flag, the left-subtree rule, the chunk counter, the component digest
check, the Content-Range and content-coding checks, the union, the trailing-
byte rule, the missing-digest plan, the class merge, the selection digest
test), each naming the cases that must fail. run.sh applies each to a fresh
worktree, requires the build, and requires verify to fail naming them; then
the Python mutations and the differential.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-05 07:52:43 -04:00

15 lines
658 B
Diff

# must fail: head_proof_ok_O3
# the left subtree is half the length, rounded down to a chunk (head_proof::left_len)
diff --git a/wai/wai-rs/src/http_binding/head_proof.rs b/wai/wai-rs/src/http_binding/head_proof.rs
index 40b6f1fa..ea665c22 100644
--- a/wai/wai-rs/src/http_binding/head_proof.rs
+++ b/wai/wai-rs/src/http_binding/head_proof.rs
@@ -35,7 +35,7 @@ pub struct HeadProof {
/// leaves at least one byte to the right.
fn left_len(n: u64) -> u64 {
let q = (n - 1) / CHUNK;
- CHUNK << (63 - q.leading_zeros())
+ ((n / 2) / CHUNK).max(1) * CHUNK
}
/// The root of a tree from its two children: BLAKE3's parent node with the ROOT flag.