Skip to content

Commit e49cdd6

Browse files
committed
Correct the public docs the dependency drop left stale
Four review findings, all valid, all mine. Codex P2 -- src/lib.rs and README.md still told downstream users that enabling `std` pulls the external blake3 crate and that the hpc modules import it directly. That was true before this branch and false after it, which is worse than saying nothing: it is wrong feature and dependency information on the crate's two most-read public surfaces. Both rewritten to state that BLAKE3 is in-tree and that blake3 / constant_time_eq / arrayref / arrayvec are absent from the dependency graph at every feature combination. CodeRabbit -- the Cargo.toml comment I wrote in the first commit claimed the in-tree module is "built on ndarray::simd::U32x16 (it is a ChaCha-derived u32 ARX kernel)". That is simply false. src/hpc/blake3.rs says so in its own header: "a portable-only (no SIMD, no unsafe) transcription" of the reference implementation. Its only `simd` reference is crate::simd_ops::array_chunks, a slicing helper. Corrected, and the cycle paragraph now says dropping the dep enables a FUTURE ndarray-backed implementation and the AdaWorldAPI/BLAKE3 fork -- not this module, which is portable. CodeRabbit -- the knowledge doc said "14 call sites" in one place and the swap record said 15. Both were right about different things: 14 calls plus one type position (merkle_tree::truncate_hash's `&blake3::Hash` parameter). Made explicit rather than reconciled to one number, since the distinction is the reason the counts differed. Verified: cargo build --features std clean, fmt clean, and no "pulls blake3" claim survives anywhere in README.md, src/lib.rs or Cargo.toml. Claude-Session: https://claude.ai/code/session_01VdfbkUCBbtZhy3yjSfCDHp
1 parent 9b2dba8 commit e49cdd6

4 files changed

Lines changed: 56 additions & 34 deletions

File tree

.claude/knowledge/blake3-in-tree-measured.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,16 @@ cycle — the only rung of the ladder that has one (`the-simd-ladder.md`).
3535
Cutting it means ndarray owning BLAKE3 rather than consuming the crate.
3636

3737
Scoping finding that made this small: **ndarray's usage is entirely
38-
single-input.** 14 call sites across 8 files use only `hash`,
39-
`Hasher::{new, new_keyed, update, finalize, finalize_xof().fill()}`,
40-
`Hash::as_bytes`, and `Hash` as a signature type. **No `hash_many`.** So the
41-
serial core suffices, and it needs no SIMD at all.
38+
single-input.** 15 `blake3::` references across 8 files — 14 calls plus one
39+
type position (`merkle_tree::truncate_hash`'s `&blake3::Hash` parameter) —
40+
using only `hash`, `Hasher::{new, new_keyed, update, finalize,
41+
finalize_xof().fill()}`, `Hash::as_bytes`, and `Hash` as a signature type.
42+
**No `hash_many`.** So the serial core suffices, and it needs no SIMD at all.
43+
44+
(An earlier revision said "14 call sites", counting calls but not the type
45+
position, while the swap record above counts all 15 references. Raised by
46+
CodeRabbit on #269; both numbers were describing different things, and the
47+
distinction is now explicit rather than a discrepancy.)
4248

4349
## Correctness — proven
4450

Cargo.toml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,23 @@ matrixmultiply = { version = "0.3.2", default-features = false, features=["cgemm
157157
# blake3 — NO LONGER A DEPENDENCY. Do not re-add it.
158158
# =====================================================================
159159
#
160-
# BLAKE3 now lives in-tree at `src/hpc/blake3.rs`, built on
161-
# `ndarray::simd::U32x16` (it is a ChaCha-derived u32 ARX kernel). The
162-
# external crate was removed because even with `default-features = false,
163-
# features = ["pure"]` it carried its own SSE2/SSE4.1/AVX2 intrinsics —
164-
# a second SIMD surface beside `ndarray::simd`, which is exactly what the
165-
# matryoshka pattern exists to prevent. The old comment block here said
166-
# "Tracked, not done here"; this is it being done.
160+
# BLAKE3 now lives in-tree at `src/hpc/blake3.rs`, as a **portable-only
161+
# transcription of the BLAKE3 reference implementation -- no SIMD, no
162+
# unsafe**. See that module's own header. It is the serial path every
163+
# conformant implementation reduces to at `simd_degree() == 1`, which
164+
# suffices here because ndarray's usage is entirely single-input.
165+
#
166+
# The external crate was removed because even with `default-features =
167+
# false, features = ["pure"]` it carried its own SSE2/SSE4.1/AVX2
168+
# intrinsics -- a second SIMD surface beside `ndarray::simd`, which is
169+
# exactly what the matryoshka pattern exists to prevent. The old comment
170+
# block here said "Tracked, not done here"; this is it being done.
167171
#
168172
# It also breaks a cycle. `ndarray -> blake3` meant blake3 could never be
169173
# built ON `ndarray::simd` without cargo seeing `ndarray -> blake3 ->
170174
# ndarray`. Dropping the dep is what makes an ndarray-backed BLAKE3
171-
# possible at all -- here, and in the AdaWorldAPI fork.
175+
# possible -- NOT here (this module is portable), but for a future
176+
# SIMD-backed implementation and for the AdaWorldAPI/BLAKE3 fork.
172177
#
173178
# Separately: blake3 carried `cc` as an unconditional build-dependency, and
174179
# the `pure` feature existed only to stop that `cc` from compiling the

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -210,20 +210,26 @@ cargo test
210210

211211
### Transitive dependencies of the `std` feature
212212

213-
Enabling the `std` feature (the default) pulls in **`blake3`** as a hard
214-
transitive dependency. The cognitive substrate modules under `hpc/`
215-
`plane`, `seal`, `merkle_tree`, `vsa`, `spo_bundle`, `crystal_encoder`,
216-
`compression_curves`, `deepnsm` — import `blake3` directly for integrity
217-
hashing and XOF expansion, and there is no separate feature to enable it.
218-
This was previously gated behind `hpc-extras`, which caused recurring
219-
"missing blake3" build errors for consumers (e.g. `burn-ndarray`) that
220-
selected `default-features = false, features = ["std"]` to shed the
221-
`p64` / `fractal` dependency tree. Pinning blake3 to `std` removes that
222-
footgun: any `std`-enabled build automatically gets blake3.
213+
**None for hashing.** BLAKE3 is in-tree.
214+
215+
The cognitive substrate modules under `hpc/``plane`, `seal`,
216+
`merkle_tree`, `vsa`, `spo_bundle`, `crystal_encoder`, `compression_curves`,
217+
`deepnsm` — use `hpc::blake3` for integrity hashing and XOF expansion. That
218+
is a portable pure-Rust transcription of the BLAKE3 reference
219+
implementation, shipped in this crate: no SIMD, no `unsafe`, no C, and no
220+
build script.
221+
222+
Earlier revisions pulled the external **`blake3`** crate here, first gated
223+
behind `hpc-extras` (which caused recurring "missing blake3" build errors
224+
for consumers such as `burn-ndarray` selecting
225+
`default-features = false, features = ["std"]`), then pinned to `std`.
226+
**Both are gone.** `blake3` and its transitive `constant_time_eq`,
227+
`arrayref` and `arrayvec` no longer appear in the dependency graph at any
228+
feature combination, so the footgun cannot recur.
223229

224230
Consumers building `default-features = false` (no `std`, e.g. the
225-
`thumbv6m-none-eabi` nostd target) skip both the `hpc` module and the
226-
blake3 dep, so the nostd link is unaffected.
231+
`thumbv6m-none-eabi` nostd target) skip the `hpc` module and the BLAKE3
232+
code with it, so the nostd link is unaffected.
227233

228234
## Ecosystem
229235

src/lib.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -485,16 +485,21 @@ pub mod backend;
485485
/// extra deps. Cognitive/research modules (p64_bridge, crystal_encoder,
486486
/// deepnsm, etc.) are gated behind `hpc-extras` inside `hpc/mod.rs`.
487487
///
488-
/// ## blake3 transitive dep
489-
///
490-
/// Enabling `std` (the default) automatically pulls `blake3`, which the
491-
/// cognitive substrate modules (`plane`, `seal`, `merkle_tree`, `vsa`,
492-
/// `spo_bundle`, `crystal_encoder`, `compression_curves`, `deepnsm`)
493-
/// import directly and unconditionally. There is no separate feature
494-
/// to enable; `std` is enough. Consumers building `default-features = false`
495-
/// without `std` (e.g. the `thumbv6m-none-eabi` nostd target) skip both
496-
/// the `hpc` module and the blake3 dep. See the `blake3` comment block
497-
/// in `Cargo.toml` for the rationale.
488+
/// ## BLAKE3 is in-tree — there is no `blake3` dependency
489+
///
490+
/// The cognitive substrate modules (`plane`, `seal`, `merkle_tree`, `vsa`,
491+
/// `spo_bundle`, `crystal_encoder`, `compression_curves`, `deepnsm`) hash
492+
/// with `hpc::blake3`, a portable pure-Rust transcription of the BLAKE3
493+
/// reference implementation that ships inside this crate.
494+
///
495+
/// **Enabling `std` no longer pulls the external `blake3` crate.** It, and
496+
/// its transitive `constant_time_eq`, `arrayref` and `arrayvec`, are gone
497+
/// from the dependency graph entirely.
498+
///
499+
/// Consumers building `default-features = false` without `std` (e.g. the
500+
/// `thumbv6m-none-eabi` nostd target) skip the `hpc` module, and with it
501+
/// the BLAKE3 code. See the `blake3` comment block in `Cargo.toml` for why
502+
/// the dependency was dropped and what it cost.
498503
#[cfg(feature = "std")]
499504
#[allow(clippy::all, unused_imports, unused_variables, unused_mut, dead_code)]
500505
pub mod hpc;

0 commit comments

Comments
 (0)