Skip to content

ci: llvm-collision guard (no closure holds two unprefixed LLVMs) - #1062

Merged
bryan-minimal merged 3 commits into
mainfrom
llvm-collision-guard
Nov 3, 2026
Merged

bryan-minimal merged 3 commits into
mainfrom
llvm-collision-guard

Conversation

@bryan-minimal

@bryan-minimal bryan-minimal commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

What

A new blocking CI guard, llvm-collision-guard. No package or collection closure may hold two unprefixed LLVM providers.

llvm and llvm-bootstrap both install LLVM into /usr: usr/bin/clang, usr/lib/clang/<N>/**, usr/lib/cmake/{llvm,clang}, usr/include/llvm*. Closure members are hardlinked into one tree, and a path present in two of them resolves silently (lowest spec hash wins). Two unprefixed LLVMs in one closure therefore mix headers, cmake exports and the clang resource dir from different releases.

It has the same shape as ruby-flavor-guard: dump the catalog on amd64 and arm64, then check each package's runtime closure and build closure.

Rules

  1. closure: more than one unprefixed provider in a runtime closure (what a session gets) or a build closure (the build deps and the package's own runtime deps, each with its runtime closure, which is what a build sandbox mounts) fails. The providers are:
    • llvm and llvm-bootstrap;
    • any package whose output globs name LLVM's /usr paths. This catches a copy under a new name, for example a prebuilt clang.
  2. prefix: a package named llvm-<N> must keep every output under usr/lib/llvm-<N>/. If it doesn't, it also counts as a provider under rule 1.

Policy:

  • Prefixed and unprefixed together in one closure is allowed: the paths are disjoint, and llvm-22 is itself built by llvm-bootstrap.
  • Two prefixed lines together are allowed: the prefixes are distinct.

The guard exits 2 (UNVERIFIED) on a dump that is empty or unparseable, or that contains no unprefixed provider. A guard that can't see the catalog doesn't go green.

Verified

  • Unit tests: 12 pass (python3 -I .github/scripts/test_llvm_collision_guard.py).
  • Real dumps: PASS on main (640/638 packages) and on llvm-22, llvm-23: prefixed LLVM lines under /usr/lib/llvm-<N> #1061's branch (642/640). Derived detection finds exactly llvm and llvm-bootstrap.
  • Negative controls:
    • A real dump with a stack pulling llvm and llvm-bootstrap, plus llvm-23's bins glob moved to usr/bin/*, gives exit 1 with both violations.
    • Disabling the closure check turns 6 tests red; disabling the prefix check turns 1 red.

Independent of #1061 and can merge in either order.

🤖 Generated with Claude Code

`llvm` and `llvm-bootstrap` both install LLVM into /usr (usr/bin/clang,
usr/lib/clang/<N>/**, usr/lib/cmake/{llvm,clang}, usr/include/llvm*). A
path present in two closure members resolves silently (lowest spec hash
wins), so two unprefixed LLVMs in one closure blend headers, cmake exports
and the clang resource dir from different releases.

Same shape as ruby-flavor-guard: dump the catalog on both arches and fail
when a package's or collection's runtime closure, or build closure, holds
more than one unprefixed provider. Providers are `llvm`, `llvm-bootstrap`
and any package whose output globs name LLVM's /usr paths. A package named
`llvm-<N>` must keep every output under usr/lib/llvm-<N>/.

Policy: prefixed + unprefixed in one closure is ALLOWED (disjoint paths;
llvm-22 is built by llvm-bootstrap); two prefixed lines are ALLOWED.
Exit 2 (UNVERIFIED) on an empty/unparseable dump or one with no unprefixed
provider, so a blind guard cannot go green.

Passes on main and on the llvm-22/llvm-23 branch (amd64 + arm64). Negative
controls: a real dump with a stack pulling llvm + llvm-bootstrap and
llvm-23 outputs moved to usr/bin fails with both violations; disabling the
closure or prefix check turns the unit tests red.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryan-minimal
bryan-minimal requested a review from a team as a code owner October 25, 2026 18:42
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 53 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 74 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 8f25b19 and 583810d.

Files selected for processing: 3
  • .github/scripts/llvm_collision_guard.py
  • .github/scripts/test_llvm_collision_guard.py
  • .github/workflows/llvm-collision-guard.yml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

The runtime-closure rule and the prefix rule look right, and the workflow is tight (pull_request, contents: read, SHA-pinned checkout). One false-pass in the build-closure rule:

.github/scripts/llvm_collision_guard.py:137-141: the build closure leaves out the package's own runtime_deps. check() builds build only from build_deps and their runtime closures. A package's runtime_deps are injected into its build sandbox too (AGENTS.md, "Dependencies"), so a package with build_deps = [llvm-bootstrap] and runtime_deps = [llvm] gets both unprefixed LLVMs at build time. Its runtime closure holds 1 provider (llvm) and its computed build closure holds 1 (llvm-bootstrap), so the guard passes it.

Fix: also union the runtime closures of the package's own runtime_deps into build (not runtime_closure(name) itself, which would put the package in its own build closure and fail llvm). Add a test for exactly this shape, and update the docstring and PR body's "build deps plus their runtime closures" definition. ruby_flavor_guard.py on main has the same gap (check(), lines 103-107), so it's worth a follow-up there.

bryan-minimal and others added 2 commits November 2, 2026 11:13
…ntime_deps (review)

A build sandbox mounts a package's runtime_deps as well as its build_deps
(AGENTS.md "Dependencies"), so build_deps = [llvm-bootstrap] plus
runtime_deps = [llvm] put both unprefixed LLVMs in the build while each
computed closure held one, and the guard passed it. Union the runtime
closures of both dep lists (not runtime_closure(name), which would count
the package in its own build and fail `llvm`).

Tests: that exact shape now fails (it passes against the old check(), the
negative control), and `llvm` itself still passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryan-minimal

Copy link
Copy Markdown
Member Author

@mitodrummer good catch, it's a real false-pass. In minimal's Transitives::new_with_seenset, a package's runtime_deps are chained into its own closure regardless of include_build_deps, so they're in the build sandbox. Fixed in 583810d:

  • check() now builds build from the runtime closures of build_deps and the package's own runtime_deps. It doesn't use runtime_closure(name), so the package isn't counted in its own build.
  • New test test_own_runtime_dep_counts_in_build_closure, for exactly your shape: build_deps = [llvm-bootstrap], runtime_deps = [llvm]. Negative control: it fails against the old check() and passes with the fix. test_package_is_not_in_its_own_build_closure keeps llvm (built by llvm-bootstrap) passing. All 14 tests pass.
  • The docstring and the PR body's definition now say "build deps and the package's own runtime deps, each with its runtime closure".
  • I ran an approximate text-level scan of the catalog under the new rule (from build.ncl imports, not mip dump) and it flags nothing. The workflow's real dump is the check.

I also merged main (dc91ac5); the branch was 199 behind. ruby_flavor_guard.py has the same gap, and I'll take that as a separate follow-up so this PR stays LLVM-only.

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

The fix is right. check() now unions the runtime closures of the package's own runtime_deps into build (.github/scripts/llvm_collision_guard.py:137-145), not runtime_closure(name). The new test_own_runtime_dep_counts_in_build_closure covers exactly the build_deps = [llvm-bootstrap], runtime_deps = [llvm] shape, and test_package_is_not_in_its_own_build_closure keeps llvm passing. The docstring and body match. The guard job passed on 583810d, which runs the unit tests and the real amd64/arm64 dump.

The one open item is CI: the build-bot hasn't posted a minimal build check on 583810d yet. I'll approve once it's green.

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

My point was already fixed at 583810d, and minimal build is now green on that head with every other check passing. Approving.

@bryan-minimal
bryan-minimal added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 19f7ec1 Nov 3, 2026
12 checks passed
@bryan-minimal
bryan-minimal deleted the llvm-collision-guard branch November 3, 2026 04:45
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