The review found repeated hand-rolled machinery across dog/ that abc already
provides or that should be factored once. This is behaviour-preserving cleanup;
it also de-risks the security tickets, since DOG-008's index-validation fix has
to land in the three duplicate WEAVE decoders unless they are consolidated first.
Distinct from PTR-002 (which is the pointer-arithmetic/buffer-poke style pass) —
this is structural duplication and missed abc reuse (CLAUDE.md #13). Method:
Issues.
WEAVEStep walk"
decoders — wmerge_decode (WEAVE.c:526-581), weave_emit_decode
(:936-966), inline pass-1 in wnext_diff (:350-364); wmerge_decode is a
superset. Consolidate into one validated decoder.u64map (WEAVE.c:610-631) duplicates
HASHx; u64map_cap (:627-631) has a latent u32 overflow (c<<=1 past
2^31 → mask 0 / infinite loop).ULOGCompactLatest pass 1 (ULOG.c:868-887) re-implements
ulog_each_latest (:806-837) line-for-line (already drifted once); extend
the latter with an index-aware callback.seen_contains (:795-800) is an O(K²) linear scan where HASHx fits
(the comment concedes it); ULOG.md:119 misdescribes it as "linear-probe Bu64".ULOGOpenRO (:596-630) duplicates ULOGOpenBooked (:538-589) bar the
booking call; the two unwind blocks already differ subtly. ULOGu8csZbyTs/
ZbyUri (:995-1022) + ulog_path_eq (:1047-1054) triplicate dup/peek/key.hunk_ron60_to_time (:44-51) == htbl_ron60_to_secs (:1661-1668);
empty-text/non-diff blocks copied :1319-1333 from :596-610; the
"prefix+line+\n into dels/adds" motif appears 6× (:1376-1467) though
hk_emit_line (:1153-1159) exists.qsort (:203) where abc/SORT.h exists. HUNK hand-rolls an
uppercase hex table (:77) because abc/HEX ships lowercase only — contribute
an uppercase variant to abc/HEX.h instead.u64map → HASHx (fixes the overflow);
ULOG walks/opens/key-helpers de-duplicated; HUNK ron60 + render blocks folded;
BRAM qsort → abc/SORT.h; uppercase hex upstreamed to abc/HEX.h.dog/ + dog/git libdog, ABC style; strictly behaviour-preserving (all
existing tests stay green); no wire-format change.u64map/seen_contains → HASHx.qsort → SORT; uppercase hex → abc/HEX.h.79612854 — wmerge_decode WEAVE.c:526, weave_emit_decode :936, inline pass in wnext_diff :335+, u64map/u64map_cap :613-631, seen_contains ULOG.c:797, hunk_ron60_to_time HUNK.c:44, qsort BRAM.c:203 all still present. NOTHING landed; WIP UNLANDED in worktree ~/src/DOG-013 (WEAVE.c a.o. modified).