Skip to content

docs(design): document zlib codec invariants and basis-window contract - #5627

Merged
oferchen merged 1 commit into
masterfrom
docs/uts-18-k-zlib-codec-invariants
Jun 10, 2026
Merged

oferchen merged 1 commit into
masterfrom
docs/uts-18-k-zlib-codec-invariants

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

Changes

  • `docs/design/zlib-codec-invariants.md` (new) - wire-byte invariants (INSERT / COPY / END token contracts), runtime invariants per code path, failure-mode -> regression-test table, and fuzz target rationale.
  • `fuzz/fuzz_targets/zlib_token_decode.rs` (new) - libfuzzer harness using only existing crate APIs (`CountingZlibDecoder::new`, `Read::read`, `Read::read_to_end`, `bytes_read`). Asserts panic-freedom across COPY/INSERT/MAP_END token combinations, monotonic byte-counter, and the same 100x expansion ceiling as `decompressor_zlib`.
  • `fuzz/Cargo.toml` - registers the new `[[bin]]` entry.
  • `.github/workflows/fuzz-coverage-report.yml` - adds the new target to the nightly coverage matrix.
  • `docs/design/fuzz-coverage-matrix.md` - lists the new target under codec category.
  • `crates/compress/src/zlib/tests.rs` - two regression tests:
    • `malformed_deflate_header_returns_err` - malformed stored-block header (LEN / NLEN ones-complement mismatch) must surface as typed `Err`, never a panic. Mirrors the "INSERT past basis-window edge" failure mode.
    • `read_beyond_decoded_payload_returns_eof_not_panic` - reading past the end of a valid decompressed payload must return `Ok(0)` cleanly without advancing the byte counter. Mirrors the "COPY token offset beyond `window_start + window_len`" failure mode.

Test plan

  • CI: fmt + clippy
  • CI: nextest (stable) - new tests `malformed_deflate_header_returns_err` and `read_beyond_decoded_payload_returns_eof_not_panic` execute under `compress` crate
  • CI: Windows / macOS / Linux musl matrices stay green
  • Nightly fuzz-coverage workflow auto-discovers and runs `zlib_token_decode` for 5 minutes (`max_total_time=300`); coverage lcov uploads as a new matrix artifact.

@oferchen
oferchen force-pushed the docs/uts-18-k-zlib-codec-invariants branch from 0a9e8a5 to f55183d Compare June 10, 2026 19:55
Records the wire-byte and runtime invariants that govern the delta-transfer
codec stack: the upstream-compatible zlib token decoder, the BufferedMap
basis-window mapper, and the streaming raw-deflate primitives in the
compress crate. Closes the documentation gap left open by the UTS-18 series
(BufferedMap fail-loud bounds, window_len clamp, never-shrink) and PR #5535
(URV-1 zlib obuf overflow on matched-block inserts).

- New design doc at docs/design/zlib-codec-invariants.md catalogues wire
  invariants (INSERT / COPY / END token contracts), runtime invariants
  per code path, the failure-mode -> regression-test table, and fuzz
  target rationale.
- New complementary fuzz target fuzz/fuzz_targets/zlib_token_decode.rs
  drives CountingZlibDecoder through arbitrary byte sequences under
  streaming read semantics. Asserts panic-freedom, monotonic byte-counter,
  and 100x expansion ceiling. Uses only existing crate APIs.
- Two new unit tests in crates/compress/src/zlib/tests.rs pin the
  malformed-INSERT and COPY-past-EOF panic-freedom guarantees at the
  streaming decoder layer (malformed stored-block NLEN check, post-EOF
  Ok(0) tail reads).
- Wires zlib_token_decode into the nightly fuzz-coverage matrix workflow
  and the FCV-20.c coverage tracking table.
@oferchen
oferchen force-pushed the docs/uts-18-k-zlib-codec-invariants branch from f55183d to 430e3a1 Compare June 10, 2026 20:03
@oferchen
oferchen merged commit 9c0c583 into master Jun 10, 2026
17 checks passed
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jun 10, 2026
@oferchen
oferchen deleted the docs/uts-18-k-zlib-codec-invariants branch June 11, 2026 03:11
oferchen added a commit that referenced this pull request Aug 24, 2026
…iants

docs(design): document zlib codec invariants and basis-window contract
oferchen added a commit that referenced this pull request Aug 24, 2026
UTS-18.j: extend URV-1 attestation with the basis-window panic chain
discovered after the original codec-only audit cleared the file.
Document the three follow-on regressions (window_len overstatement,
buffer.resize overlap-shrink, bare slice index on misaligned chunk
requests) and the remediation PRs (#5566, #5569, #5588, #5590, #5627).

UTS-18.i: keep `compress-zlib-insert` out of the upstream-testsuite
known-failures list so the workflow's wildcard run surfaces any
regression as an UNEXPECTED FAIL. The cell already iterates
`$suitedir/*.test`, so explicit wiring is the explanatory comment in
`tools/ci/upstream_testsuite_known_failures.conf` plus the
attestation-doc cross-reference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant