Repository navigation
refactor: route sha256 hex digests through content-hash - #1790
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR routes 56 single-update SHA-256 hexadecimal digest calculations across 38 source files through the existing shared hashing helper. Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review This PR is a useful, behavior-preserving consolidation, and no concrete patch defect was found. Current main still contains the duplicated implementations; no merged fixing PR supersedes this work. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherClawSweeper uses content fingerprints to identify review inputs, verify artifacts, and correlate durable records. The shared hashing helper converts text or bytes into the hexadecimal fingerprints consumed by these workflows. flowchart TD
A[Review text and artifact bytes] --> B[Existing serialization]
B --> C[Shared SHA-256 helper]
C --> D[Hexadecimal fingerprint]
D --> E[Artifact integrity checks]
D --> F[Record and delivery identities]
Technical reviewBest possible solution: Keep one shared owner for single-update SHA-256 digests while preserving exact inputs, durable identities, and direct TypeScript loading. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR consolidates existing implementations without claiming a user-facing bug. Is this the best way to solve the issue? Yes: extending the existing helper is a narrow solution, and the diff preserves serialization, encoding, truncation, and direct-source imports. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 405764da3257. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 9, 2026, 2:27 AM ET / 06:27 UTC (Revision 2). |
019a473 to
cf0a216
Compare
What
Route every single-update SHA-256 hex digest in
src/throughsha256()fromsrc/content-hash.ts. This rewrites 56 hand-rolledcreateHash("sha256").update(x).digest("hex")chains in 38 files and drops thecreateHash/ defaultcryptoimports that become unused.createHmac,randomUUID,timingSafeEqual), andcomment-webhook.tskeeps its defaultcryptoimport for HMAC/signing.record-tuple.tsandtelegram-proof-evidence.tsimport../content-hash.ts, because their tests load them as bare.ts. Telegram's privatehashwrapper is inlined.commentBodySha256passed an explicit"utf8". That is Node's default string encoding, sosha256(String(body ?? ""))returns the same digest.target-validation.ts(7 multi-update/streaming hashes) andscheduled-review-noop.ts(a capsule proof loads it as a bare.tsfile).test/content-hash.test.ts.Why
This gives sha256 hex hashing a single owner. Before this PR,
src/had 65 rawcreateHash("sha256")sites next to an existingcontent-hash.tsowner. After it, 9 remain: the owner itself, the 7 multi-update sites in target-validation and the capsule-loaded noop. Overall the diff is net-negative (159+/172−, including the new test and changelog fragment).Proof
createHash("sha256")sites insrc/: 65 → 9 (git grep -c).string(default utf8) or aBuffer/Uint8Arrayto a singleupdate, andsha256()does exactly that.test/content-hash.test.tscheckssha256()against rawcreateHashfor strings (empty, ASCII, NUL, non-BMP unicode, JSON), explicit-utf8strings,BufferandUint8Array, plus the NIST""/"abc"vectors.prompt-rest,prompt-lean,prompt-dump,async-proof/{base,branch},retire-proof/166090; 9 reports) withrender-comments.mjs, comparing anorigin/maindist with this branch's dist. The output is byte-identical in all 6 sets (cmp), with 0 render failures.pnpm run build:all: pass.pnpm run check: check:static, build, lint and coverage:changed pass. The full suite had 6948/6988 pass with 3 failures. Two were 120s/180s load timeouts incommand-proof-consumer.test.tsand one was a supervisor-completion timing failure inreview-git-acquisition.test.ts, all on a loaded host (load avg ~20). Re-running both files alone: 42/42 pass.6270db414(resolved import conflicts with refactor: import asRecord and login from value-coerce #1787 inissue-implementation-intake.tsandreview-activity-cursor.ts): build, lint and format:check pass, and the 10 test files covering the conflicted/neighbouring modules plus the new test pass (335/335).Codex dispositions
codex review --base origin/mainfound no P0–P2 issues: "The refactor preserves hash inputs, encoding, and digest truncation."Merge Danger
Low. Every digest is byte-identical, so persisted hashes (ledger keys, delivery IDs, receipts, cursors, packet digests) are unchanged. The only risk is import resolution for modules loaded as bare
.ts. The two known cases use the.tsspecifier, and the capsule-loadedscheduled-review-noop.tsis left alone. A follow-up PR removes the redundantsha256dependency injection.