|
1 | | -## 2026-02-25 — Generalize video API to accept borrowed slices |
| 1 | +## 2026-02-25 — Review of: Generalize video API to accept borrowed slices |
2 | 2 |
|
3 | | -**Done:** Changed `soft_hash_video_v0` and `gen_video_code_v0` from concrete `&[Vec<i32>]` to |
4 | | -generic `<S: AsRef<[i32]> + Ord>` parameters. Updated both FFI wrappers to construct `Vec<&[i32]>` |
5 | | -(borrowed slices) instead of `Vec<Vec<i32>>` (heap-allocated copies), eliminating per-frame |
6 | | -allocations. |
| 3 | +**Verdict:** PASS |
7 | 4 |
|
8 | | -**Files changed:** |
9 | | - |
10 | | -- `crates/iscc-lib/src/lib.rs`: Generalized `soft_hash_video_v0` and `gen_video_code_v0` signatures |
11 | | - to `<S: AsRef<[i32]> + Ord>`. Updated body to use `.as_ref()` for column count and iteration, |
12 | | - and `BTreeSet<&S>` for deduplication. |
13 | | -- `crates/iscc-ffi/src/lib.rs`: Changed both `iscc_gen_video_code_v0` and `iscc_soft_hash_video_v0` |
14 | | - from `Vec<Vec<i32>>` with `.to_vec()` to `Vec<&[i32]>` with direct slice borrows. |
| 5 | +**Summary:** Changed `soft_hash_video_v0` and `gen_video_code_v0` from concrete `&[Vec<i32>]` to |
| 6 | +generic `<S: AsRef<[i32]> + Ord>` parameters. The FFI crate now passes `Vec<&[i32]>` (zero-copy |
| 7 | +borrows from caller memory) instead of `Vec<Vec<i32>>` (heap-allocated copies), eliminating |
| 8 | +per-frame allocations. Clean, focused diff touching only the two files specified in next.md. All |
| 9 | +tests pass, clippy clean, no quality gate issues. |
15 | 10 |
|
16 | 11 | **Verification:** |
17 | 12 |
|
18 | | -- `cargo test -p iscc-lib`: 261 tests passed (208 + 31 + 22), 0 failures |
19 | | -- `cargo test -p iscc-ffi`: 62 tests passed, 0 failures |
20 | | -- `cargo clippy --workspace --all-targets -- -D warnings`: clean (no warnings) |
21 | | -- `.to_vec()` count in `crates/iscc-ffi/src/lib.rs`: 1 (only the unrelated `alg_cdc_chunks` on line |
22 | | - 906 remains — down from 3) |
23 | | -- `mise run check`: all 14 pre-commit hooks passed |
24 | | - |
25 | | -**Next:** The `[normal]` iscc-ffi video frame allocation issue is resolved. Consider the remaining |
26 | | -`[low]` issues: `alg_dct` power-of-two validation, `alg_wtahash` bounds check, iscc-py |
27 | | -`__version__`, iscc-py module docstring, iscc-wasm conformance feature gate, or iscc-wasm stale |
28 | | -CLAUDE.md. |
29 | | - |
30 | | -**Notes:** The generic approach (`AsRef<[i32]> + Ord`) was chosen over concrete `&[&[i32]]` to |
31 | | -maintain backward compatibility — all existing callers that pass `&[Vec<i32>]` compile unchanged |
32 | | -because `Vec<i32>` implements both traits. Only the FFI crate (the actual beneficiary) was modified. |
33 | | -No other binding crate (py, napi, wasm, jni) required changes. |
| 13 | +- [x] `cargo test -p iscc-lib` passes — 261 tests (208 + 31 + 22), 0 failures |
| 14 | +- [x] `cargo test -p iscc-ffi` passes — 62 tests, 0 failures |
| 15 | +- [x] `cargo clippy --workspace --all-targets -- -D warnings` — clean |
| 16 | +- [x] `.to_vec()` count in `crates/iscc-ffi/src/lib.rs` is 1 — only the unrelated `alg_cdc_chunks` |
| 17 | + at line 906 remains (down from 3) |
| 18 | +- [x] `mise run check` — all 14 pre-commit hooks passed |
| 19 | + |
| 20 | +**Issues found:** |
| 21 | + |
| 22 | +- (none) |
| 23 | + |
| 24 | +**Next:** The `[normal]` iscc-ffi video frame allocation issue is resolved and deleted from |
| 25 | +issues.md. Remaining work is all `[low]` priority: `alg_dct` power-of-two validation, `alg_wtahash` |
| 26 | +bounds check, iscc-py `__version__`, iscc-py module docstring, iscc-wasm conformance feature gate, |
| 27 | +iscc-wasm stale CLAUDE.md, iscc-jni exception mapping, or the TypeScript port evaluation. |
| 28 | + |
| 29 | +**Notes:** The generic `AsRef<[i32]> + Ord` approach is backward-compatible — `Vec<i32>` implements |
| 30 | +both traits, so all existing callers (py, napi, wasm, jni binding crates passing `&[Vec<i32>]`) |
| 31 | +compile without changes. Only the FFI crate (the actual beneficiary) was modified. Good design |
| 32 | +choice over concrete `&[&[i32]]` which would have broken all 5 binding crates. |
0 commit comments