Skip to content

feat: add blake3 command#3658

Merged
jqnatividad merged 12 commits into
masterfrom
blake3-command
Apr 1, 2026
Merged

feat: add blake3 command#3658
jqnatividad merged 12 commits into
masterfrom
blake3-command

Conversation

@jqnatividad

Copy link
Copy Markdown
Collaborator

For computing and checking BLAKE3 hashes of files.

Used primarily for:

  • as future cache key, to ensure we don't recompute stats for identical files with different names and filesystem metadata
  • for reproducibility manifest of Cowork plugin, so we don't need to depend on b3sum CLI

jqnatividad and others added 5 commits March 31, 2026 15:32
Add a new `blake3` command that computes BLAKE3 cryptographic hashes of files,
functionally similar to b3sum. Supports keyed hashing, key derivation,
variable-length output, checksum verification, tagged output, and stdin input.
Uses mmap+rayon for maximum throughput.

Also fixes the command name lowercase check to allow digits, since
`'3'.is_lowercase()` returns false.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…s for --raw/--keyed/stdin

Address review findings:
- Merge `use crate::CliError` into the main import block
- Validate hex checksum strings (even length, hex chars only) before comparison
- Add tests for --raw, --keyed, stdin (-), --output, --num-threads, and invalid hex

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
wrk.stdout() already runs the command and panics on failure, so the
subsequent wrk.assert_success() just re-executes the command for no benefit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use the same -j/--jobs flag name as other qsv commands (snappy, stats,
etc.) and delegate to util::njobs() instead of manual rayon pool setup.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jqnatividad jqnatividad requested review from Copilot March 31, 2026 20:46
Comment thread tests/test_blake3.rs Fixed
Comment thread tests/test_blake3.rs Fixed
Comment thread tests/test_blake3.rs Fixed
Comment thread tests/test_blake3.rs Fixed
Comment thread tests/test_blake3.rs Fixed
Comment thread tests/test_blake3.rs Dismissed
Comment thread tests/test_blake3.rs Dismissed
Comment thread tests/test_blake3.rs Dismissed
Comment thread tests/test_blake3.rs Dismissed
Comment thread tests/test_blake3.rs Dismissed
@codacy-production

codacy-production Bot commented Mar 31, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 90 complexity

Metric Results
Complexity 90

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

…tive

Update tests/test_blake3.rs to use cmd_2 instead of cmd2 in two test functions and adjust argument chaining for readability. Standardizes the local command variable name and cleans up minor formatting.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new qsv blake3 subcommand to compute and verify BLAKE3 hashes for files/stdin, along with documentation and an integration test suite.

Changes:

  • Introduces blake3 command implementation with hashing modes (default/keyed/derive-key), output formats, and checksum verification.
  • Registers the new command in the CLI dispatcher and command/module listings.
  • Adds help docs + README/TableOfContents entries and a comprehensive tests/test_blake3.rs integration test file.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/tests.rs Registers the new test_blake3 integration test module.
tests/test_blake3.rs Adds end-to-end tests for hashing, verification, stdin, raw output, and options.
src/main.rs Wires blake3 into the command list, enum, dispatcher, and relaxes command-name validation to allow digits.
src/cmd/mod.rs Exposes the new cmd::blake3 module.
src/cmd/blake3.rs Implements the qsv blake3 command (hashing + check mode + output formatting).
README.md Adds blake3 to the command list in the README.
docs/help/TableOfContents.md Adds blake3 to the help Table of Contents.
docs/help/blake3.md Adds generated help documentation for blake3.

Comment thread src/cmd/blake3.rs
Comment thread src/cmd/blake3.rs Outdated
Comment thread src/cmd/blake3.rs
Comment thread src/cmd/blake3.rs Outdated
Comment thread src/cmd/blake3.rs Outdated
jqnatividad and others added 6 commits March 31, 2026 16:55
…d, error messages

- Reject `-` in --keyed mode since stdin is consumed for the key
- Stream stdin incrementally (8KiB chunks) instead of read_to_end
- Stream --no-mmap file reads via BufReader instead of fs::read
- Remove Path::exists() pre-check, rely on actual I/O errors
- Replace fail!("") with fail_clierror! for meaningful error on check failure

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Read directly from File with 8KiB buffer instead of wrapping in
BufReader, which was adding a redundant intermediate buffer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add feature gate `#[cfg(any(feature = "feature_capable", feature = "datapusher_plus"))]`
to exclude blake3 from the qsvlite binary variant.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace manual 8KiB read loops with blake3's update_reader() for both
  stdin and --no-mmap file paths
- Use finalize().to_hex() for default 32-byte output (stack-allocated
  Hash + ArrayString, no heap allocation) instead of finalize_xof() +
  OutputReader clone + Vec + manual hex loop
- Return Hasher from hash_input instead of OutputReader, letting caller
  choose finalization strategy
- Remove finalize_to_bytes helper, inline the xof path

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ustom length paths

Extract hex string computation into a single conditional, then share
one formatting block for no_names/tag/default output modes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Register a new 'blake3' command in the CLI: add it to the command list, introduce a Command::Blake3 enum variant, and dispatch to cmd::blake3::run(argv) in the main match. Also relax the command-name validation to accept ASCII digits in addition to lowercase letters so commands containing numbers are allowed.
@jqnatividad jqnatividad merged commit 72bfbc0 into master Apr 1, 2026
16 of 17 checks passed
@jqnatividad jqnatividad deleted the blake3-command branch April 1, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants