Skip to content

Fix: use Bun.hash() when running under Bun#2

Open
notSido wants to merge 1 commit intoithiria894:masterfrom
notSido:fix/bun-hash-support
Open

Fix: use Bun.hash() when running under Bun#2
notSido wants to merge 1 commit intoithiria894:masterfrom
notSido:fix/bun-hash-support

Conversation

@notSido
Copy link
Copy Markdown

@notSido notSido commented Apr 6, 2026

Summary

  • Claude Code runs on Bun, which uses Bun.hash() (wyhash) instead of FNV-1a for hashing the user identity
  • All three scripts (reroll.js, shiny_hunt.js, verify.js) now auto-detect Bun and use Bun.hash(), falling back to FNV-1a on Node
  • Without this fix, scripts produce incorrect buddy rolls that don't match what Claude Code actually generates

Test plan

  • Run node verify.js auto — should use FNV-1a (unchanged behavior)
  • Run bun verify.js auto — should use Bun.hash() and show different results
  • Compare bun verify.js auto output against actual /buddy result in Claude Code

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Improved hash computation performance across core modules. The system now automatically leverages native optimizations when available in compatible environments, while maintaining consistent behavior and full compatibility with all runtime platforms.

Claude Code runs on Bun, which uses Bun.hash() (wyhash) instead of
FNV-1a. The scripts were producing incorrect rolls because the hash
function didn't match the runtime. Now auto-detects Bun and uses the
correct hash, falling back to FNV-1a on Node.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e1d05e5e-672c-4465-8e67-73e7789cdb4a

📥 Commits

Reviewing files that changed from the base of the PR and between 0a14faa and 73157e0.

📒 Files selected for processing (3)
  • reroll.js
  • shiny_hunt.js
  • verify.js

📝 Walkthrough

Walkthrough

Three hashing functions now conditionally leverage Bun's native hashing when the Bun runtime is detected, converting results to 32-bit unsigned integers, while falling back to existing FNV-1a implementations in other environments.

Changes

Cohort / File(s) Summary
Bun Runtime Hashing Optimization
reroll.js, shiny_hunt.js, verify.js
Updated hashing functions (hashString/hash) to check for Bun runtime availability and use Bun.hash(s) with 32-bit conversion (Number(Bun.hash(s) & 0xFFFFFFFFn)) when present, maintaining FNV-1a fallback for other runtimes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 Bun speeds up the hash today,
With native calls along the way!
FNV-1a stands as backup friend,
When Bun's not here, we still won't bend! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding Bun.hash() support with automatic runtime detection across three scripts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Alfex4936
Copy link
Copy Markdown

this worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants