Skip to content

Preserve and validate no_linkage metadata - #24263

Merged
p-linnane merged 1 commit into
mainfrom
no-linkage-api-metadata
Oct 15, 2026
Merged

p-linnane merged 1 commit into
mainfrom
no-linkage-api-metadata

Conversation

@p-linnane

@p-linnane p-linnane commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Formula#to_hash drops :no_linkage, so formulae loaded from the API lose the linkage expectations that brew linkage uses to exempt a dependency from the unnecessary-dependency check and to report unexpected linkage. This emits a no_linkage_dependencies name list beside the existing string arrays for stable, HEAD and each variation, and overlays it when building FormulaStruct dependencies, so the role arrays keep their shape and older readers keep working; uses_from_macos entries already carried their tags.

Because the overlay is keyed by name, all declarations of one dependency within a spec and platform must now agree on :no_linkage; a contradiction raises FormulaSpecificationError when the spec is instantiated, including for an inactive HEAD spec, and the rule is documented in the depends_on docs and the Formula Cookbook. All 356 homebrew-core formulae that use :no_linkage load without conflicts across the 16 platform tags. New examples cover the writer, the generator, both API loaders end to end from formula source on macOS and Linux tags and the declaration validation.


  • 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 (GPT-6 Astra) wrote the change, tests and Cookbook text, verified the new examples fail without the change (four pin existing behaviour and pass on both), scanned homebrew-core and ran brew lgtm --online; Claude Code (Mythos 5.1) reviewed it, round-tripped synthetic and homebrew-core formulae through the public and internal loaders on macOS and Linux tags, repeated the red and green runs against the base, ran the docs checks (brew style docs, Vale and mdl) and ran brew lgtm --online on this commit.


Summary by CodeRabbit

  • New Features
    • Formula dependency information now identifies dependencies that are required but not linked against, including across stable and HEAD versions.
  • Bug Fixes
    • Conflicting no-linkage declarations for the same dependency within a spec and platform are rejected with a clear error.
  • Documentation
    • Updated dependency guidance to explain the no-linkage annotation and when declarations must agree.

@p-linnane
p-linnane added this pull request to stack #24264 October 14, 2026 23:27
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3e223863-0ddc-483a-a6f5-8fc7aa260dbe
📥 Commits

Reviewing files that changed from the base of the PR and between ee524cb and a9aa984.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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: f8615705-f09c-4b15-b852-7234100ff885
📥 Commits

Reviewing files that changed from the base of the PR and between d135da1 and ee524cb.

📒 Files selected for processing: 1
  • 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; 5 remain after this review.

📝 Walkthrough

Formula dependency serialisation now includes no_linkage_dependencies. Spec evaluation rejects conflicting :no_linkage declarations for non-implicit dependencies. Formula API conversion preserves the annotation in dependency entries.

Changes: No-linkage dependency metadata

Layer / File(s) Summary
Formula dependency validation and serialisation
Library/Homebrew/formula.rb, Library/Homebrew/test/formula_spec.rb, docs/Formula-Cookbook.md
Formula hash output includes no_linkage_dependencies, excluding dependencies provided by macOS. Spec evaluation rejects conflicting declarations for a non-implicit dependency. Tests and documentation cover serialisation and declaration rules.
Formula API dependency conversion
Library/Homebrew/api/formula/formula_struct_generator.rb, Library/Homebrew/test/api/formula/formula_struct_generator_spec.rb, Library/Homebrew/test/formulary_spec.rb
The formula struct generator annotates matching dependency entries with :no_linkage. Tests cover stable and HEAD data, platform variations, and API round trips.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to ee524

The change carries no-linkage expectations through formula metadata and API loading; the described stable, HEAD, and variation cases reveal no concrete compatibility or runtime risk.

### Architecture Summary

Architecture risk: 🔵 Low · up to ee524

The change affects 2 systems.

Changed systems: Library, docs

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — Library (service) was modified; 5 changed files map to changed impact.
  • observed — docs (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in Library/Homebrew/api/formula/formula_struct_generator.rb: The stable dependency hash now carries no_linkage_dependencies, defaulting to an empty array when absent.
  • observed — Modified behavior in Library/Homebrew/api/formula/formula_struct_generator.rb: process_dependencies now wraps main dependencies named in no_linkage_dependencies with the :no_linkage type. It also adds :no_linkage to matching build, test, recommended or optional dependency types; non-matching entries retain their previous representation.
  • observed — Modified behavior in Library/Homebrew/formula.rb: spec_eval now raises FormulaSpecificationError when a non-implicit dependency has conflicting :no_linkage declarations in the same spec; dependencies with no such declarations or with all declarations agreeing pass this check.
  • observed — Modified behavior in Library/Homebrew/formula.rb: The formula hash output gains an empty no_linkage_dependencies field alongside the other dependency categories.
Pre-merge checks: Passed 4
Passed Passed checks: 4 passed
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 changes: preserving no_linkage metadata and validating conflicting declarations.
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.

@p-linnane
p-linnane force-pushed the no-linkage-api-metadata branch from d135da1 to ee524cb Compare October 14, 2026 23:55

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

Base automatically changed from formula-struct-tag-arrays to main October 15, 2026 07:38
- `Formula#to_hash` dropped `:no_linkage`, so formulae loaded from the
  API lost the linkage expectations `brew linkage` relies on.
- Emit a `no_linkage_dependencies` name list beside the existing string
  arrays and overlay it when loading, keeping older readers working.
- Reject conflicting `:no_linkage` declarations for one dependency
  within a spec and platform at load time, since the overlay is by name.

Signed-off-by: Patrick Linnane <patrick@linnane.io>
@MikeMcQuaid
MikeMcQuaid force-pushed the no-linkage-api-metadata branch from ee524cb to a9aa984 Compare October 15, 2026 07:38
@p-linnane
p-linnane added this pull request to the merge queue Oct 15, 2026
Merged via the queue into main with commit 20383ec Oct 15, 2026
52 checks passed
@p-linnane
p-linnane deleted the no-linkage-api-metadata branch October 15, 2026 15:43
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