|
| 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. |
0 commit comments