Skip to content

Commit 7ba653c

Browse files
committed
docs(hpc/bulk): F4 - document usize::MAX chunk_size semantics
Codex W3-W6 audit P1: chunk_size==usize::MAX is tested but not documented in the public docstring. One-line addition to bulk_apply and bulk_scan: 'A chunk_size of usize::MAX yields the entire slice as a single chunk.' Also persists the W3-W6 audit doc the audit agent couldn't write itself (sandbox permission for .claude/knowledge).
1 parent 5845ab2 commit 7ba653c

2 files changed

Lines changed: 59 additions & 2 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# W3-W6 Codex Audit
2+
3+
Auditor: codex P0 review agent
4+
Branch: `claude/w3-w6-soa-aos-helpers` (rebased onto master at `3f35170d`)
5+
Commits under review:
6+
- `5095853c` feat(hpc/soa): `SoaVec` + `soa_struct!` + `aos_to_soa` + `soa_to_aos` (W3+W5+W6)
7+
- `5845ab2d` feat(hpc/bulk): `bulk_apply` + `bulk_scan` (W4)
8+
9+
## Verdict
10+
11+
**READY-FOR-PR.** Zero P0 findings. One P1 cosmetic docstring gap (patched on this branch). Three P2 items intentionally deferred per the design contract.
12+
13+
## Verification exit codes (all 0)
14+
15+
| Command | Exit | Notes |
16+
|---|---|---|
17+
| `cargo check -p ndarray --no-default-features --features std` | 0 | |
18+
| `cargo test -p ndarray --lib --no-default-features --features std hpc::soa` | 0 | 29 passed, 0 failed |
19+
| `cargo test -p ndarray --lib --no-default-features --features std hpc::bulk` | 0 | 16 passed, 0 failed |
20+
| `cargo test --doc -p ndarray --no-default-features --features std hpc::soa` | 0 | 10 passed, 1 intentionally ignored |
21+
| `cargo test --doc -p ndarray --no-default-features --features std hpc::bulk` | 0 | 2 passed, 1 intentionally ignored |
22+
| `cargo fmt --all -- --check` | 0 | |
23+
| `cargo clippy -p ndarray --no-default-features --features std -- -D warnings` | 0 | |
24+
25+
## P0 findings
26+
27+
None.
28+
29+
## P1 findings
30+
31+
- **F4**`usize::MAX` chunk-size behavior is tested at `src/hpc/bulk.rs:182-194` but NOT documented in the public docstring of `bulk_apply` (`src/hpc/bulk.rs:46-66`) or `bulk_scan` (`src/hpc/bulk.rs:80-97`). One-line addition: "`chunk_size == usize::MAX` yields the entire slice as a single chunk." **Patched on this branch** before PR opens.
32+
33+
## P2 findings (deferred per design contract)
34+
35+
- **G1** (`bulk_scan` naming): the savant flagged that "scan" conventionally means fold-with-state. Kept as `bulk_scan` for symmetry with `bulk_apply`. Rename to `bulk_for_each` / `bulk_inspect` is a follow-up if downstream consumers find the name misleading.
36+
- **G2** (`SoaVec::iter_rows`): row iterator yielding `[&T; N]` per row is absent. Use `soa.chunks(1)` for the same effect. Deferred to a follow-up once a real use case exists.
37+
- **G3** (`SoaVec` lacks `#[derive(Clone, Debug)]`): macro-generated structs DO support derive passthrough (verified by test at `src/hpc/soa.rs:733-742`), but the generic container does not. Deliberately deferred — adding derives would require `where T: Clone + Debug` bounds that callers don't always want.
38+
39+
## D4 — integration test gate
40+
41+
The `bulk_apply` × `aos_to_soa` integration test at `src/hpc/bulk.rs:295` correctly uses `#[cfg(any())]` (canonical never-compile sentinel). The test body at `src/hpc/bulk.rs:297-324` is sound. Now that `hpc/soa.rs` and `hpc/bulk.rs` are landing in the same PR, the gate could be removed as a follow-up — but worker B's `cfg(any())` gate preserves the safe deferral if the PR review wants to keep them independently mergeable.
42+
43+
## Compliance summary
44+
45+
| Concern | Status | Notes |
46+
|---|---|---|
47+
| Layering rule (no `#[target_feature]`, no per-arch imports, no raw intrinsics) | ✅ clean | Only doc-prose mentions in module headers; zero actual attributes |
48+
| Distance typing (no umbrella `fn distance<T>`, no `enum DistanceMetric`, no `Box<dyn Distance>`) | ✅ clean | Both module headers cite `cognitive-distance-typing.md` and warn against extension toward distance |
49+
| Spec API match (per design doc v2 §C1-C7, §D1-D4) | ✅ exact | `field_n::<const I>()` uses `const { assert!(I < N) }`; all method signatures verbatim |
50+
| Doc coverage (every `pub fn` has `///` doc with working `# Example`) | ✅ complete | After F4 patch |
51+
| Test coverage (per design doc §"Tests" per fn) | ✅ complete | 29 + 16 = 45 unit tests + 12 doctests |
52+
53+
## Recommended next step
54+
55+
Open the W3-W6 PR. F4 fix landed on the same branch as a follow-up commit; integration test stays `cfg(any())`-gated for the PR; P2 items deferred.

src/hpc/bulk.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
/// chunk slice and the absolute index of the chunk's first element.
4848
///
4949
/// The last chunk may be shorter than `chunk_size` when `chunk_size` does
50-
/// not divide `items.len()`.
50+
/// not divide `items.len()`. A `chunk_size` of `usize::MAX` yields the
51+
/// entire slice as a single chunk.
5152
///
5253
/// # Panics
5354
/// Panics if `chunk_size == 0` (`chunks_mut(0)` would otherwise return an
@@ -80,7 +81,8 @@ where
8081
/// Read-only sibling of [`bulk_apply`]. Applies `f` to consecutive immutable
8182
/// chunks of `items`, passing the absolute starting index of each chunk.
8283
///
83-
/// The last chunk may be shorter than `chunk_size`.
84+
/// The last chunk may be shorter than `chunk_size`. A `chunk_size` of
85+
/// `usize::MAX` yields the entire slice as a single chunk.
8486
///
8587
/// # Panics
8688
/// Panics if `chunk_size == 0`.

0 commit comments

Comments
 (0)