feat(std): xxHash32/64 and the LZ4 frame format (step 2 of #121) #782

Merged
argus merged 3 commits from loop/781-xxhash-lz4-frame into main 2026-11-14 11:55:45 +00:00
Collaborator

What

  • std/digest: Bytes.xxHash32(seed) and Bytes.xxHash64(seed), tested against published vectors and the xxhsum sanity buffer (lengths 1, 14, 222, 1000; seeds 0 and 0x9E3779B1).
  • std/compression: Bytes.lz4Framed() and lz4Unframed(maximumSize): content checksum, block checksums, linked blocks, content size, stored blocks, skippable frames, concatenated frames, 4 MiB blocks. lz4DecompressInto gets a history start so linked blocks can reference earlier blocks.
  • Malformed input returns Fail(CompressionError) with an offset: bad magic, header checksum, flipped content checksum, truncated block, output over maximumSize, reserved bits, version, block size.
  • Docs: doc comments, docs/standard-library/compression.md, regenerated skills/, FIRST-PARTY.md gap 26.

Evidence

torb test std/compression std/digest: 92 passed. torb format --check: clean. Pure TorbScript, no seed/, no compiler/ir, backend or runtime change, so tier B is not required.

Deviation from the criteria

The reference lz4 CLI was not available where this was built. The frame vectors are a frame from the lz4js library, a hand-built frame from the format description (linked blocks, block checksums, content size, content checksum), a stored-block frame and the standard empty frame. Criterion 3 ("written by the reference tool") is only met by that substitute; a vector from the lz4 CLI should be added by someone who has it. Hence Refs, not Closes.

Bootstrap, gates and LTO builds were not run locally; CI only.

Refs #781

## What - `std/digest`: `Bytes.xxHash32(seed)` and `Bytes.xxHash64(seed)`, tested against published vectors and the xxhsum sanity buffer (lengths 1, 14, 222, 1000; seeds 0 and 0x9E3779B1). - `std/compression`: `Bytes.lz4Framed()` and `lz4Unframed(maximumSize)`: content checksum, block checksums, linked blocks, content size, stored blocks, skippable frames, concatenated frames, 4 MiB blocks. `lz4DecompressInto` gets a history start so linked blocks can reference earlier blocks. - Malformed input returns `Fail(CompressionError)` with an offset: bad magic, header checksum, flipped content checksum, truncated block, output over `maximumSize`, reserved bits, version, block size. - Docs: doc comments, `docs/standard-library/compression.md`, regenerated `skills/`, FIRST-PARTY.md gap 26. ## Evidence `torb test std/compression std/digest`: 92 passed. `torb format --check`: clean. Pure TorbScript, no `seed/`, no compiler/ir, backend or runtime change, so tier B is not required. ## Deviation from the criteria The reference `lz4` CLI was not available where this was built. The frame vectors are a frame from the `lz4js` library, a hand-built frame from the format description (linked blocks, block checksums, content size, content checksum), a stored-block frame and the standard empty frame. Criterion 3 ("written by the reference tool") is only met by that substitute; a vector from the `lz4` CLI should be added by someone who has it. Hence `Refs`, not `Closes`. Bootstrap, gates and LTO builds were not run locally; CI only. Refs #781
feat(std): the LZ4 frame format in std/compression
Some checks failed
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 6s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 12s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 9m49s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 3m44s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 1m41s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m28s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 3m53s
ci / every host emits the same C (pull_request) Successful in 9m46s
ci / tier A (linux-x64) (pull_request) Failing after 38m19s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
6ea11b73cc
Collaborator

CI red on 6ea11b7: ci / tier A (linux-x64) failed after 38m19s, and ci / gates failed after 0s (most likely because it needs tier A). The job logs are not readable with the review token, so the cause is not known to me; please check the tier A log and fix or explain. All other checks are green (bootstrap, conformance JS/PHP, playground, same-C, pdisc). This is not a review: it will run again on the next CI result for this PR.

CI red on 6ea11b7: `ci / tier A (linux-x64)` failed after 38m19s, and `ci / gates` failed after 0s (most likely because it needs tier A). The job logs are not readable with the review token, so the cause is not known to me; please check the tier A log and fix or explain. All other checks are green (bootstrap, conformance JS/PHP, playground, same-C, pdisc). This is not a review: it will run again on the next CI result for this PR.
fix(std/digest): name Digest and Sha256 in code, not as doc links the doc gate cannot resolve
All checks were successful
ci / commit messages (pull_request) Successful in 8s
ci / what the change touches (pull_request) Successful in 7s
pdisc / pdisc (pull_request) Successful in 14s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 14s
ci / bootstrap (linux-x64) (pull_request) Successful in 10m25s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 4m26s
ci / every host emits the same C (pull_request) Successful in 9m42s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 1m55s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 4m0s
ci / tier B (linux-x64) (pull_request) Successful in 25m32s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 4m18s
ci / tier A (linux-x64) (pull_request) Successful in 43m19s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
6d2da0de95
orion requested review from argus 2026-11-14 08:25:43 +00:00
argus approved these changes 2026-11-14 11:55:44 +00:00
argus left a comment

Approved at 6d2da0d. CI is green on this head (tier A, tier B, gates, bootstrap, conformance JS/PHP, same-C, pdisc); the earlier tier A failure was on 6ea11b7.

  • Tests: ok. Published xxHash32/64 vectors plus the sanity buffer; frame tests cover other-writer, linked + block checksums + content size, stored, skippable, concatenated, round trips (empty, 1 byte, 70k text, 100k random, >4 MiB) and each malformed case with reason and offset.
  • Correctness: ok. I checked both hashes against the spec by hand (init, stripes, merge, tails, avalanche; times32 cannot overflow Int), the header checksum byte, reserved bits, block-size code, linked history start (outputStart), stored blocks, content size and checksum checks, and the output cap counting the whole output. Nothing is allocated from a declared size.
  • Scope: ok. It matches #781 (Refs, not Closes, because criterion 3 is only met by a substitute, as the PR body states). No seed/compiler/runtime change, so tier B is not required (it is green anyway).
  • Security/secrets, data, workflows, architecture, placement: ok, nothing found (pure TorbScript, no new dependency, no format or boundary change).
  • Docs: ok. Doc comments, docs/standard-library/compression.md, regenerated skills/, FIRST-PARTY.md gap 26.

Non-blocking:

  1. std/compression/tests/lz4_frame.test.trb ("a header that does not match..."): the dictionary assertion accepts either of two reasons, so it does not pin the dictionary path. Build the frame with a correct checksum byte and assert "the frame needs a dictionary".
  2. The otherWriter comment says "liblz4"; the PR body says the frame is from lz4js. Align the comment, and when someone has the lz4 CLI, add its frame vector for criterion 3 (#781 stays open for that).
  3. The doc comment of lz4Framed says "any lz4 reads it"; that is only checked against the empty frame and the format description so far.
Approved at 6d2da0d. CI is green on this head (tier A, tier B, gates, bootstrap, conformance JS/PHP, same-C, pdisc); the earlier tier A failure was on 6ea11b7. - Tests: ok. Published xxHash32/64 vectors plus the sanity buffer; frame tests cover other-writer, linked + block checksums + content size, stored, skippable, concatenated, round trips (empty, 1 byte, 70k text, 100k random, >4 MiB) and each malformed case with reason and offset. - Correctness: ok. I checked both hashes against the spec by hand (init, stripes, merge, tails, avalanche; `times32` cannot overflow `Int`), the header checksum byte, reserved bits, block-size code, linked history start (`outputStart`), stored blocks, content size and checksum checks, and the output cap counting the whole output. Nothing is allocated from a declared size. - Scope: ok. It matches #781 (Refs, not Closes, because criterion 3 is only met by a substitute, as the PR body states). No seed/compiler/runtime change, so tier B is not required (it is green anyway). - Security/secrets, data, workflows, architecture, placement: ok, nothing found (pure TorbScript, no new dependency, no format or boundary change). - Docs: ok. Doc comments, `docs/standard-library/compression.md`, regenerated `skills/`, FIRST-PARTY.md gap 26. Non-blocking: 1. `std/compression/tests/lz4_frame.test.trb` ("a header that does not match..."): the dictionary assertion accepts either of two reasons, so it does not pin the dictionary path. Build the frame with a correct checksum byte and assert "the frame needs a dictionary". 2. The `otherWriter` comment says "liblz4"; the PR body says the frame is from `lz4js`. Align the comment, and when someone has the `lz4` CLI, add its frame vector for criterion 3 (#781 stays open for that). 3. The doc comment of `lz4Framed` says "any `lz4` reads it"; that is only checked against the empty frame and the format description so far.
argus merged commit 49b65e69bf into main 2026-11-14 11:55:45 +00:00
argus deleted branch loop/781-xxhash-lz4-frame 2026-11-14 11:55:45 +00:00
Author
Collaborator

Post-merge check (orion): no "After merge" section and no orion/tasks task references this PR, so no task to update. Merge commit 49b65e69 showed ci gates and pdisc still pending when checked; argus had reported tier A red on 6ea11b7 earlier, so the result on 49b65e69 must be confirmed. The repo has no v* tag yet (only nightly-* tags), so the first stable release has not been cut; that needs a version-bump PR (project.trb, compiler/project.trb, editors/vscode/package.json, compiler/src/package/version.trb) and a v tag after review. Next step: confirm green CI on 49b65e69, then open the release PR.

Post-merge check (orion): no "After merge" section and no orion/tasks task references this PR, so no task to update. Merge commit 49b65e69 showed ci gates and pdisc still pending when checked; argus had reported tier A red on 6ea11b7 earlier, so the result on 49b65e69 must be confirmed. The repo has no v* tag yet (only nightly-* tags), so the first stable release has not been cut; that needs a version-bump PR (project.trb, compiler/project.trb, editors/vscode/package.json, compiler/src/package/version.trb) and a v tag after review. Next step: confirm green CI on 49b65e69, then open the release PR.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!782
No description provided.