Skip to content

feat: support platform-specific SHA256 verification - #766

Draft
albertocavalcante wants to merge 2 commits into
bazelbuild:masterfrom
albertocavalcante:feat/platform-specific-sha256-verification
Draft

albertocavalcante wants to merge 2 commits into
bazelbuild:masterfrom
albertocavalcante:feat/platform-specific-sha256-verification

Conversation

@albertocavalcante

@albertocavalcante albertocavalcante commented Jan 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem and behavior

Multiplatform projects cannot share a single Bazel binary hash. Select the first nonempty expected hash for the resolved artifact:

  1. BAZELISK_VERIFY_SHA256_NOJDK_<OS>_<ARCH>, when NOJDK is enabled.
  2. BAZELISK_VERIFY_SHA256_<OS>_<ARCH>.
  3. BAZELISK_VERIFY_SHA256.

The README lists DARWIN, LINUX, and WINDOWS, each with ARM64 and X86_64, and explains artifact architecture fallback and configuration-source precedence. No applicable hash preserves the existing behavior of skipping expected-hash verification.

The same selected value drives cache/download verification and %h in custom URLs. Comparisons ignore letter casing; URL substitution preserves the configured casing. Filename formatting uses its explicit OS argument, including Windows suffixes.

Fixes #522.

Dependency and readiness

Depends on #827, which fixes existing generic expectations being ignored on cache hits. This branch currently includes that prerequisite so the complete behavior can be tested. After it lands, rebase this PR onto the merged upstream target and remove the prerequisite from the diff.

Keep this PR in draft until the prerequisite and required upstream checks are complete. The original feature head is retained locally as a backup, and the feature commit preserves its original author and author date.

Validation

Check Result
go test ./... Passed on native macOS ARM64, Go 1.27.3
go vet ./core ./platforms Passed
Shell syntax and git diff --check Passed
Offline download/cache cases 18 passed, including wrong platform/NOJDK expectations on warm caches
Selector and URL cases Raw casing, NOJDK/generic fallback, layered sources, and Darwin artifact fallback passed
Foreign-OS filename tests Windows and non-Windows suffix cases passed; these are not native OS execution claims
Behavioral parent/mutation checks URL cases fail the intended assertions on the cache-only parent; generic-only selection fails both warm-cache feature regressions
Independent complete final-diff review No remaining actionable findings
Native Bazel integration attempt Interrupted for low disk space before tests executed; not a pass
Upstream Buildkite Passed 3795: Ubuntu 22.04, Ubuntu 24.04, macOS ARM64, and Windows
CLA Passed on the published head

The shell integration test now writes .bazeliskrc and calls the harness function directly, replacing the failing env ... bazelisk calls. It covers platform-over-generic precedence and changed expectations on a warm cache. Its six pinned Bazel 9.0.0 digests match official checksum files; six native platform combinations have not been claimed as executed.

Limits and rollback

Verification compares the expected value with a recorded cache digest on cache hits; it does not rehash cached binaries. Key specificity precedes source precedence, as documented and tested. Runmux was unavailable; this contribution leaves required upstream Buildkite infrastructure unchanged.

Reverting the feature removes platform-key support. Consumers using only those keys need matching generic configuration per platform and NOJDK flavor to retain verification. No cache migration or deletion is required.

Hash selection stays private and raw; comparison uses strings.EqualFold. The generic config-normalization TODO from #767 is removed because this design does not need that broader abstraction. Reconcile that issue after the feature lands.

Review evidence

Reviewed publication head: 949097d0a5668bdde737bdaf252280df4c7edf3e.

Cache prerequisite: acbfe36c8f432701cac6360c129a8450adbbb34e (#827).

Independent review inspected the complete eight-file diff against upstream, including the cache prerequisite and relevant IO paths. A disposable-archive parent check failed five platform/NOJDK URL assertions; a generic-only selection mutant failed both warm-cache feature rejection assertions. Disposable review archives were removed.

@albertocavalcante
albertocavalcante force-pushed the feat/platform-specific-sha256-verification branch 9 times, most recently from 658831a to 76873b5 Compare January 25, 2026 15:56
@albertocavalcante
albertocavalcante force-pushed the feat/platform-specific-sha256-verification branch 2 times, most recently from f78653c to 81f96d5 Compare January 28, 2026 20:33
Comment thread README.md Resolved
@valco1994

Copy link
Copy Markdown
Contributor

@albertocavalcante Do you need any help with this feature? From what I can see, you've already done most of the work.

@albertocavalcante

Copy link
Copy Markdown
Contributor Author

@valco1994, thank you for offering assistance. I really appreciate it. To be honest, I had some issues with GitHub recently, and as a side effect, I ended up forgetting to finish it. I'll resume and finish it today or this weekend; otherwise, I will let you know.

Apologies.

@albertocavalcante
albertocavalcante force-pushed the feat/platform-specific-sha256-verification branch from 81f96d5 to 4718ef3 Compare May 1, 2026 10:10
@valco1994

Copy link
Copy Markdown
Contributor

Wounderful, thank you for your work!

Check the configured expectation before reusing a recorded cache digest as
well as after downloads. Reject mismatches without deleting cached content
or retrying a download, and preserve case-insensitive hash comparison.

Cover warm and cold cache behavior with an offline downloader fixture. The
warm-cache mismatch regression fails on the parent revision.

Co-authored-by: Alberto Cavalcante <alberto@cavalcante.uk>
Select NOJDK, platform, and generic expectations for the resolved artifact.
Use the selected raw value in custom URL hash substitution and compare it
case-insensitively for both cached and downloaded content.

Keep filename formatting independent of the host, document supported names
and source precedence, and invoke the shell integration wrapper directly.
Cover URL casing, layered config, Darwin fallback, warm-cache rejection,
NOJDK downloads, and platform override behavior.

Fixes bazelbuild#522

Co-authored-by: Alberto Cavalcante <alberto@cavalcante.uk>
@albertocavalcante
albertocavalcante force-pushed the feat/platform-specific-sha256-verification branch from 4718ef3 to 949097d Compare November 6, 2026 01:34
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.

Support BAZELISK_VERIFY_SHA256 for multiplatform projects

3 participants