Repository navigation
perf(adapters): use native SHA-256 for tool identity digests - #7670
Conversation
Use Bun one-shot SHA-256 in the four tool identity normalization paths. Preserve wire bytes and provider-local allocation policies, with independent known-answer and collision regression coverage. Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com>
…rk760-dev-bd5-20261024
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Bun SHA-256 call sites src/adapters/google-wire-compiler.ts, src/adapters/kiro-wire.ts, src/adapters/tool-call-id.ts, src/responses/muse-tool-name-alias.ts |
The four call sites use Bun.SHA256.hash instead of Node’s createHash. Hash inputs and digest-prefix lengths remain unchanged. |
Identity compatibility coverage tests/adapters/tool-identity-hash.test.ts, tests/fixtures/test-layout-expected.json, scripts/test-layout/layout-adapters.json, structure/transports/inventory.md |
Tests specify wire-name vectors and check collisions, aliases, and restoration across adapters. Test-layout mappings include the new test, and the transport inventory describes digest behavior. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Refactor
Possibly related PRs
- lidge-jun/opencodex#7606: Updates the shipped Bun runtime to 1.4.4, which provides the runtime API used by these hash call sites.
Merge Risk: 
Minimal · up to ec56a
-
The change presents no established merge-blocking risk under the supported Bun runtime contract.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "perf(adapters): use native SHA-256 for tool identity digests" matches the main change. Four adapter and response modules replace node:crypto createHash with Bun.SHA256.hash(input, "hex") for tool-name and tool-call-id suffix digests. The PR objectives confirm the same scope: Anthropic, Google, Kiro, and Muse suffix calculations. The title is concise, specific, and follows a conventional-commit style. It does not describe the added tests or layout registration, which is expected for a title.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 9 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
|
✅ Deterministic PR hygiene checks passed. |
# Conflicts: # scripts/test-layout/layout-adapters.json # tests/claude-integration/claude-picker-upload.test.ts
|
Integration evidence (owner decision decision:b607a677, approved): independent gpt-6.1-sol review PASS at 41d5662; the current head ec56abd only adds a merge of origin/dev (after #7667 touched the transport inventory). Exact-head PR CI run 40170367942 and exact-head ci.yml lane=all run 40170390637 both succeeded. Static merge simulation on current dev 4049f40 (this Mac): dev=4049f40c48b618d673571764ce292bef365ace8c base=6672cfb4a2b9a1dc72e26ed159c1d70368fe0ca7 pr_files= 8 overlap=[tests/fixtures/test-layout-expected.json ]; merge clean; install exit=0; gui install exit=0; tsc exit=0; tsc doctor exit=0; structure:check exit=0; privacy:scan exit=0; layout+ratchet guards exit=0 54 pass 0 fail ; Merged by the triage manager as maintainer integration (MAINTAINERS.md, dev only) with green exact-head PR CI, an independent review PASS, and the owner's approval of this bundle. |
Summary
Tool identity normalization constructs a streaming Node-compatible hash object even when the complete identifier is already available. Use
Bun.SHA256.hash(input, "hex")for the four request-scoped Anthropic, Google, Kiro and Muse suffix calculations.Preserve SHA-256, UTF-8 encoding, eight lowercase hexadecimal suffix characters, conforming-name fast paths, truncation, collision salts and restoration. Kiro's machine fingerprint and authentication/HMAC helpers are unchanged.
Add known-answer vectors, lone-surrogate and real UTF-8 collision regressions, with the required layout registration and Structure invariant.
Verification
1505798acd4e936415bdb0cbcc06ca9dfa34e3a4normally merges thedevbaseline and the shared chore(test): align Bun runner with the 1.4.4 security baseline #7627 transition. Runtime and test runner both use Bun 1.4.4. Thedevcomparison contains eight hashing/registration/documentation files plus eleven shared transition files.CI=true bun test --isolate --timeout 60000, fresh processes for the tool-identity, Anthropic tool-call ID, Google wire-compiler, Muse alias and Kiro adapter files: 143 passed / 0 failed / 823 assertions.test:changedcoverage was not fully green: 52 of 60 failures reproduced on the untouched base, and the remaining eight selected cases had identical per-case outcomes on both trees, including three timeouts. That remains historical comparison evidence, not a full-suite success.cicheck. The skipped jobs do not establish native Windows/macOS matrix execution.enforce-targetand metadata checks, maintainer review and any required security acceptance are tracked separately before merge. If the still-unmerged chore(test): align Bun runner with the 1.4.4 security baseline #7627 runner transition is introduced ahead of its parent, its exact-candidate full cross-platform promotion proof remains required; the PR CI result above does not supply that proof.Checklist
Co-authored-by: luvs01 27862058+luvs01@users.noreply.github.com
Summary by CodeRabbit