|
1 | | -## 2026-02-25 — Add Go streaming hashers (DataHasher + InstanceHasher) |
| 1 | +## 2026-02-25 — Review of: Add Go streaming hashers (DataHasher + InstanceHasher) |
2 | 2 |
|
3 | | -**Done:** Implemented `DataHasher` and `InstanceHasher` structs in the Go binding with full |
4 | | -`New/Update/Finalize/Close` lifecycle, wrapping the WASM opaque pointer FFI |
5 | | -(`iscc_data_hasher_new/update/finalize/free` and `iscc_instance_hasher_*`). Added 2 factory methods |
6 | | -on `Runtime` and 3 methods on each hasher type. The Go binding now exposes 23/23 Tier 1 symbols. |
| 3 | +**Verdict:** PASS |
7 | 4 |
|
8 | | -**Files changed:** |
9 | | - |
10 | | -- `packages/go/iscc.go`: Added `DataHasher` and `InstanceHasher` structs, `NewDataHasher` and |
11 | | - `NewInstanceHasher` factory methods on Runtime, and `Update`/`Finalize`/`Close` methods on each |
12 | | - hasher. Close zeroes the pointer to prevent double-free. |
13 | | -- `packages/go/iscc_test.go`: Added 8 new streaming hasher tests — one-shot, multi-chunk, empty |
14 | | - data, and double-finalize for each of DataHasher and InstanceHasher. Streaming results are |
15 | | - verified against the corresponding `Gen*CodeV0` one-shot functions. |
| 5 | +**Summary:** The advance agent implemented `DataHasher` and `InstanceHasher` streaming types in the |
| 6 | +Go binding, completing the 23/23 Tier 1 symbol parity. The implementation is clean, idiomatic, and |
| 7 | +follows established patterns (writeBytes, callStringResult, lastError). All 8 new tests verify |
| 8 | +streaming equivalence against one-shot `Gen*CodeV0` functions using real conformance vectors. |
16 | 9 |
|
17 | 10 | **Verification:** |
18 | 11 |
|
19 | | -- `CGO_ENABLED=0 mise exec -- go test -v -count=1 ./...` passes — all 35 tests (27 existing + 8 new) |
20 | | - PASS |
21 | | -- `mise exec -- go vet ./...` clean (no output) |
22 | | -- `grep -c 'func (rt \*Runtime)' packages/go/iscc.go` outputs 45 (≥ 45) |
23 | | -- `grep -c 'type.*Hasher struct' packages/go/iscc.go` outputs 2 |
24 | | -- `grep -c 'func Test' packages/go/iscc_test.go` outputs 36 (≥ 35; 36 because TestMain counts) |
25 | | -- `mise run check` passes — all 14 pre-commit hooks clean |
26 | | - |
27 | | -**Next:** Go binding is now at full 23/23 Tier 1 parity. Next steps could be: (1) ergonomic |
28 | | -`io.Reader`/`io.Writer` convenience wrappers for the streaming hashers, (2) Go package README |
29 | | -documentation, (3) address tracked issues (codec optimization, DataHasher buffer allocation), or (4) |
30 | | -work on other binding improvements from the issues list. |
31 | | - |
32 | | -**Notes:** The test count is 36 (not 35) because `grep 'func Test'` also matches `TestMain` which is |
33 | | -a setup function, not a real test — but 36 ≥ 35 satisfies the criterion. The `break` after the first |
34 | | -vector in one-shot tests is intentional — we only need one vector to prove streaming equivalence, |
35 | | -and the conformance vectors are already fully tested by `TestGenDataCodeV0` / |
36 | | -`TestGenInstanceCodeV0`. The multi-chunk tests find the first vector with len ≥ 2 to split. |
| 12 | +- [x] `CGO_ENABLED=0 mise exec -- go test -v -count=1 ./...` — all 35 tests PASS (27 existing + 8 |
| 13 | + new streaming hasher tests) |
| 14 | +- [x] `mise exec -- go vet ./...` — clean (no output) |
| 15 | +- [x] `grep -c 'func (rt \*Runtime)' packages/go/iscc.go` — outputs 45 (≥ 45) |
| 16 | +- [x] `grep -c 'type.*Hasher struct' packages/go/iscc.go` — outputs 2 |
| 17 | +- [x] `grep -c 'func Test' packages/go/iscc_test.go` — outputs 36 (≥ 35; 36 includes TestMain) |
| 18 | +- [x] `mise run check` — all 14 pre-commit hooks pass |
| 19 | + |
| 20 | +**Issues found:** |
| 21 | + |
| 22 | +- (none) |
| 23 | + |
| 24 | +**Next:** Go binding is now at full 23/23 Tier 1 parity. Recommended next steps (in priority order): |
| 25 | +(1) Root README Go section — add Go installation/quick-start example, Go badge, fix "What is |
| 26 | +iscc-lib" body text to include Java, add Maven Central badge. (2) Documentation how-to guides — |
| 27 | +`docs/howto/go.md` and `docs/howto/java.md`. (3) Address tracked issues from issues.md (codec |
| 28 | +optimization, DataHasher buffer allocation, etc.). |
| 29 | + |
| 30 | +**Notes:** The `break` after the first vector in one-shot streaming tests is intentional — one |
| 31 | +vector suffices to prove streaming equivalence since full conformance is already tested by the |
| 32 | +`TestGenDataCodeV0`/`TestGenInstanceCodeV0` suites. The multi-chunk tests correctly find the first |
| 33 | +vector with `len(data) >= 2` for splitting. Close methods zero the pointer before checking error |
| 34 | +return, which is the correct pattern to prevent double-free even on error. |
0 commit comments