Skip to content

fix(builtin): seed hashes from platform entropy - #4160

Merged
bobzhang merged 1 commit into
mainfrom
codex/add-process-hash-seed
Sep 3, 2026
Merged

fix(builtin): seed hashes from platform entropy#4160
bobzhang merged 1 commit into
mainfrom
codex/add-process-hash-seed

Conversation

@peter-jerry-ye

@peter-jerry-ye peter-jerry-ye commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Why

Hasher() already uses a process-wide random seed on JavaScript, while native and LLVM use a fixed zero seed. That leaves hash-table layouts predictable on those native backends and allows collision sets to be prepared in advance.

What

  • Initialize the native and LLVM process seed through the runtime random provider.
  • Fall back to zero when platform entropy is unavailable.
  • Keep both Wasm targets unchanged and preserve deterministic hashing through an explicit seed=0.

Why this is correct and minimal

The change binds the existing runtime entropy source directly in builtin, avoiding a dependency cycle through env. It changes only the default process seed on native and LLVM; explicit seeds and the hashing algorithm remain unchanged.

Linear Wasm is deliberately excluded because eager module initialization can run before a Preview 1 component adapter is fully wired. Wasm protection and collision-triggered per-table randomization remain separate follow-up design work.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 540cb8d90d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread builtin/hasher.mbt Outdated
@coveralls

coveralls commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 6542

Coverage decreased (-0.02%) to 89.19%

Details

  • Coverage decreased (-0.02%) from the base build.
  • Patch coverage: 4 uncovered changes across 1 file (0 of 4 lines covered, 0.0%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
builtin/hasher.mbt 4 0 0.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 18169
Covered Lines: 16205
Line Coverage: 89.19%
Coverage Strength: 275214.4 hits per line

💛 - Coveralls

@peter-jerry-ye
peter-jerry-ye force-pushed the codex/add-process-hash-seed branch from 540cb8d to 8417fa8 Compare September 2, 2026 08:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T08:12:30.031326Z fc0cb58 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@bobzhang
bobzhang force-pushed the codex/add-process-hash-seed branch from 8417fa8 to 789cbfa Compare September 3, 2026 07:41
Comment thread builtin/hasher.mbt Outdated
///|
// `builtin` cannot depend on `env`, so bind the runtime entropy source here.
#cfg(any(target="native", target="llvm"))
fn random_seed_native() -> Int? {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline this?

@peter-jerry-ye
peter-jerry-ye force-pushed the codex/add-process-hash-seed branch 2 times, most recently from 1bd8256 to fc0cb58 Compare September 3, 2026 08:09
@bobzhang
bobzhang force-pushed the codex/add-process-hash-seed branch from fc0cb58 to d887241 Compare September 3, 2026 13:38
@bobzhang
bobzhang enabled auto-merge (rebase) September 3, 2026 13:38
@bobzhang
bobzhang merged commit 65b074b into main Sep 3, 2026
16 checks passed
@bobzhang
bobzhang deleted the codex/add-process-hash-seed branch September 3, 2026 13:47
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.

3 participants