Honor positional offsets when HTTP servers return full responses
perfloop-oss/zml · Uncatalogued correctness
https://perfloop.ai/t/oss/case_tgrmwx37sq
Verdict
VERIFIED · settled 2026-11-02 · pull request opened as zml/zml#1008
What happened: The check fails before this change and passes with it.
Hypothesis
HTTP-backed positional reads can silently return bytes from the wrong location when a server ignores the Range header and sends the whole file. A native loopback check reproduces this behavior. The prevalence of affected servers and callers is unmeasured.
HTTP.performRead constructs the requested range and accepts both 200 OK and 206 Partial Content. It discards a prefix only when a parsed Content-Range header supplies a start before the requested offset. An ordinary 200 response has no such header, so the successful response is read from its beginning instead of the caller's offset. This claim concerns nonzero offsets below the cached file size, not the early EOF return.
checkProperty(prop_4wrh35nqzm) at d4b413f5f99f08e7862ea05f250663ea1a4271bb ran `sh vfs/http_property_run.sh 'http property bytes'` with repository-pinned Zig 0.17.0 and exited 1. Its reduced full-response input opens the stable object "01", requests one byte at offset 1, and receives count 1 with byte '0' rather than '1'. The retained `vfs/http_property_replay_full.zon` reproduces this without search. The independent 120-case cached-EOF matrix passed. The runner workaround disables sandbox-incompatible stack-trace capture, not product safety checks or real networking.
The smallest useful Case check is the retained replay followed by the bounded full-response and range-response byte/count matrices. Correct bytes at nonzero offsets, legal short-read counts, and unchanged cached-EOF behavior would confirm the repair. Reject the asserted defect if the same public operation demonstrably returns the requested byte on the accepted baseline without altering the response semantics.
Current open work was refreshed before publication. The implementation in https://github.com/zml/zml/pull/578 adds Xet dispatch and scattering to HF.performRead, not this HTTP reader. https://github.com/zml/zml/pull/800 records loader failures; it does not change successful HTTP positional reads. Neither implements this response-origin correction.
Change to test: Normalize accepted HTTP responses to the requested file window before copying bytes. Preserve full-response support by treating an ordinary 200 response as starting at byte zero and skipping the requested prefix.
Where it lives
perfloop-oss/zml · vfs/http.zig
Evidence
The check fails before this change and passes with it: `For stable loopback objects of 0 through 8 bytes, HTTP positional reads return the requested bytes with legal short-read counts for full 200 and range 206 responses at offsets 0 through size+1 and buffer capacities 1 through 10; cached EOF returns zero without a GET.`
Checks: 3 of 3 passed. Verification: no defect found.