Route trusted compile admission through persistent Macs

Closed
TE
2mo ago
+2805-32

Summary

Implements the bounded pilot from #13198 using Glaeda's merged native Apple front door from teamleaderleo/glaeda#1048.

  • trusted same-repository PRs may use one owned Apple Silicon compile producer behind CI_PERSISTENT_MAC_COMPILE;
  • fork/untrusted PRs keep the existing hosted admission path;
  • the required macOS compile admission job remains the check/log/artifact owner;
  • PR-editable CI has read-only Actions permission; dispatch/cancellation lives in a default-branch workflow_run router;
  • the owned compile job has empty GitHub-token permissions and receives no repository secrets;
  • Glaeda owns persistent DerivedData, SwiftPM, module-cache, and Xcode compilation-cache state;
  • exact commit/tree, clean source, Xcode, SDK, architecture, Package.resolved, submodules, cache lineage, warning budget, and early CLI probes are revalidated before adoption;
  • dirty/incompatible/interrupted state moves to Glaeda cold reset/quarantine handling;
  • queue/execution timeout, producer failure, artifact mismatch, or validation failure falls through to the existing hosted compile;
  • metrics record queue-to-start, source prep, package readiness, compile, warning validation, publication, total admission wall time, runner allocation, and hot/partially-warm/cold-reset/hosted-fallback class.

Authority split

The PR workflow publishes only an immutable route request artifact. The default-branch router binds that request to the exact originating CI workflow run, live PR head/base, synthetic merge commit, and Git tree before it may dispatch the producer.

The producer uses public Git fetches rather than actions/checkout. It pins merged Glaeda #1048 at 3e7001b3702459df2e6177c6beacc715215a7aa0, including exact commit/tree/clean-source admission. Glaeda owns cache placement/admission/recovery; CMUX owns semantic pass/fail through cmux.macos.compile-admission@1 and cmux-workload-result/v1.

Rollout

Default behavior stays hosted. The pilot is enabled only after this PR and #13411 are merged and the admin runner setup is complete. The producer refuses candidates that lack canonical cmux.macos.compile-admission@1:

  • CI_PERSISTENT_MAC_COMPILE=pilot
  • CI_PERSISTENT_MAC_COMPILE_COHORT=<PR number or head branch>
  • optional bounded queue/execution variables

The external runner group is cmux-persistent-compile, restricted to this repository and the main-branch producer workflow.

Validation

This PR adds focused contract tests for trust/cohort routing, source-run binding, fallback budgets, Glaeda state retention/reset policy, producer permissions, runner-group isolation, canonical semantic-receipt validation, exact source/toolchain revalidation, and metrics. Existing warning-budget and early CLI validation stay in the required admission job.

The producer cannot run from this PR branch because its workflow and privileged router intentionally become dispatchable only from the default branch after merge. CI here therefore proves the hosted fallback and repository-side contracts. Real PR-head measurements begin with the opt-in cohort after merge.

Closes #13198 only after pilot evidence/admin cutover is accepted; this PR itself keeps the selector off by default.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Implements the bounded pilot that routes trusted compile admission through persistent Macs; default behavior stays hosted, and forks and untrusted PRs keep the existing hosted path.

Pilot behavior

  • Trusted same-repository PRs may opt into one owned Apple Silicon compile producer behind CI_PERSISTENT_MAC_COMPILE.
  • The required macOS compile admission job stays the check, log, validation, and artifact owner; it may consume the producer's product after revalidating commit/tree, Xcode, SDK, architecture, Package.resolved, submodules, canonical receipt, cache lineage, and warning budget.
  • The producer pins Glaeda to the merged Apple front-door head, runs the canonical cmux.macos.compile-admission@1 profile through a semantic entrypoint, and owns persistent DerivedData, SwiftPM, module-cache, and Xcode compilation-cache state.
  • The semantic entrypoint refuses to run (exit 78) until the canonical profile and registry are on the exact source; its executable bit is contract-tested.
  • Dispatch and cancellation live only in a default-branch workflow_run router bound to the originating run's synthetic merge commit and tree, so PR CI keeps read-only Actions permission and no repository secrets.
  • The hosted compile starts before the router observation; the pilot never delays the fallback path, and interleaving with the hosted compile, host fallback, queuing, and route observation is non-serialized, cancellation-aware, and capped by a hosted observation timeout.
  • The runner guard test now also rejects mapping-form self-hosted runner labels; contract tests additionally pin the hosted observation bound and keep routing off the fallback critical path.
  • Any dispatch, queue, execution, download, or validation miss falls through to the hosted compile in the same required job.

Rollout

  • Enabled only after merge/admin setup with CI_PERSISTENT_MAC_COMPILE=pilot and a concrete CI_PERSISTENT_MAC_COMPILE_COHORT.
  • The owned runner group cmux-persistent-compile is restricted to this repository and the default-branch producer workflow.
  • This PR keeps the selector off by default; #13198 closes only after pilot evidence and admin cutover are accepted.

Summary by CodeRabbit

  • New Features

    • Added a controlled persistent macOS compile pilot for eligible pull-request builds.
    • Eligible builds can reuse validated compile products from a dedicated Mac runner; other builds continue using hosted compilation.
    • Added compile timing, admission, routing, and fallback details to CI artifacts and summaries.
  • Bug Fixes

    • Added safeguards verifying source, toolchain, cache, and product compatibility before reuse.
    • Invalid, unavailable, or timed-out persistent builds automatically fall back to hosted compilation.
  • Documentation

    • Documented runner restrictions, eligibility rules, fallback behavior, and rollout controls.