Skip to content

Publish local patch checksums in the formula API - #24284

Merged
MikeMcQuaid merged 1 commit into
mainfrom
publish-local-patch-checksums
Oct 18, 2026
Merged

MikeMcQuaid merged 1 commit into
mainfrom
publish-local-patch-checksums

Conversation

@MikeMcQuaid

@MikeMcQuaid MikeMcQuaid commented Oct 17, 2026 •

Copy link
Copy Markdown
Member
  • Generate digests for stable, HEAD and resource patch files without adding checksums to formula definitions.
  • Preserve the digests through the public and internal API formats.

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Codex with GPT 6 Astra at Extra High effort, with local review and testing.


Summary by CodeRabbit

  • New Features
    • Formula data now includes SHA-256 checksums for local patch files associated with stable and HEAD versions, including patches attached to resources. Checksums are mapped to patch file paths and are available for formulas loaded from the API.
  • Bug Fixes
    • If a local patch cannot be read, its checksum is omitted and a warning is shown. During formula data generation, the read error is instead raised.

@MikeMcQuaid
MikeMcQuaid added this pull request to stack #24286 October 17, 2026 15:13
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 026e7d0a-ad0b-4b81-afe8-d556972b81a3
📥 Commits

Reviewing files that changed from the base of the PR and between d516bff and dbe090b.

📒 Files selected for processing: 2
  • Library/Homebrew/formula.rb
  • Library/Homebrew/test/formula_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

Formula serialisation now includes SHA-256 checksums for local patches from stable and HEAD specs and their resources. API-backed formulas expose the checksum mapping stored in FormulaStruct.

Changes: Local patch checksums

Layer / File(s) Summary
Build and serialise checksum data
Library/Homebrew/api/formula_struct.rb, Library/Homebrew/formula.rb, Library/Homebrew/test/formula_spec.rb, Library/Homebrew/test/api/formula/formula_struct_generator_spec.rb
FormulaStruct adds a string-to-string checksum mapping. Formula calculates SHA-256 digests for local patch files from stable and HEAD specs and resources, then includes the mapping in to_hash. Tests cover these patch scopes, unreadable patches, and struct serialisation.
Expose checksums on API-backed formulas
Library/Homebrew/formulary.rb, Library/Homebrew/test/formulary_spec.rb
API-backed formulas return the checksum mapping from FormulaStruct. Tests check that formula loading preserves the mapping.

Priority: ➖ Normal

Unblocks: 3 PRs

Merge Risk: ⚪ Minimal · up to dbe09

Local patch checksums are now added to formula metadata. Unreadable patches produce a warning in ordinary use and fail API generation, so a broken patch is caught when the API is built. No remaining merge-blocking risk was identified.

Security architecture risk: 🔵 Low · up to dbe09

The change publishes checksum metadata without replacing existing integrity checks. Existing patch-reading controls remain in use. Unreadable patches now stop API generation; whether incomplete generated output can reach users depends on publication safeguards that were not available for review.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A single unreadable declared patch can now stop the remaining formula-generation pass. This establishes local generation-wide availability impact, not exposure of an incomplete live API: the deployment and publication boundary was unavailable.

Trust Boundaries and Controls

  • observed — Checksum generation reuses the unchanged LocalPatch reader. It requires a formula owner, resolves the requested path, checks repository containment with an explicit API-source/download-cache exception, and requires a regular file before reading.

Resilience and Maintainability Implications

  • observed — The added checksum operation builds a fresh mapping without modifying patch contents or caching checksum state. Repeated calls reread the files. During API generation, a handled read failure prevents return of the formula hash rather than silently presenting an incomplete checksum mapping as complete.

Hardening Proposals

  • proposed — If publication consumes these output directories directly, generate into staging and promote only after successful completion. This would contain incomplete snapshots from checksum failures or interruptions; externally visible partial publication was not established.
Pre-merge checks: Passed 4
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely summarises the main change: publishing local patch checksums in the formula API.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 474d60f1-6dbf-43bc-8ed8-9ab271e81944
📥 Commits

Reviewing files that changed from the base of the PR and between 95bfab0 and e9fbd1d.

📒 Files selected for processing: 6
  • Library/Homebrew/api/formula_struct.rb
  • Library/Homebrew/formula.rb
  • Library/Homebrew/formulary.rb
  • Library/Homebrew/test/api/formula/formula_struct_generator_spec.rb
  • Library/Homebrew/test/formula_spec.rb
  • Library/Homebrew/test/formulary_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Comment thread Library/Homebrew/formula.rb
Base automatically changed from tighten-bottle-attestation-checks to main October 17, 2026 16:17
@MikeMcQuaid
MikeMcQuaid force-pushed the publish-local-patch-checksums branch 2 times, most recently from 370d6ba to d516bff Compare October 17, 2026 16:46
Comment thread Library/Homebrew/formula.rb
- Generate digests for stable, HEAD and resource patch files without
  adding checksums to formula definitions.
- Preserve the digests through the public and internal API formats.
- Reject unreadable patches during API generation before incomplete
  metadata can be published.
@MikeMcQuaid
MikeMcQuaid force-pushed the publish-local-patch-checksums branch from d516bff to dbe090b Compare October 18, 2026 12:06
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Oct 18, 2026
Merged via the queue into main with commit 3849568 Oct 18, 2026
53 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the publish-local-patch-checksums branch October 18, 2026 13:11
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