PR validation and proposed main protection
CI starts for every PR to main, including documentation-only and fork PRs. Every category runs the full existing build, test and packaging matrix. There is no documentation classifier or permitted skip.
Each PR build workflow starts with the shared .github/actions/preflight action. It checks CI scheduling, the aggregate policy, container-monitor contracts, release/Docker/Debian automation and the generated documentation before compiling grate. Run its script checks locally with pwsh -File scripts/ci/Invoke-Preflight.ps1.
In CI, the existing PR validation policy job runs this preflight. Build and Basic_tests wait for it; database, CodeQL and packaging jobs then wait for Build and Basic_tests. Release artifacts and integration tests perform preflight before version resolution, installation checks wait for their documentation/preflight job, and WinGet preparation waits before compiling native MSI actions. Each workflow evaluates its own first job using the same action. Failed, cancelled or skipped preflight prevents its build jobs from starting. The final PR validation and CI result checks still run to report incomplete CI.
PR validation uses always() and requires all seven dependencies to succeed: validation-policy, build-code, test, cli-distributions, packages, standalone and docker. It also queries every page of the current run’s Jobs API and requires all 94 expected jobs and their applicable mandatory producer steps to complete successfully. This includes every All/slim CLI and tool lane, native standalone target, MSI lifecycle and Alpine target. Missing, duplicate, failed, cancelled, unexpectedly skipped, timed-out, neutral, unknown and pending required results fail validation. Reusable workflow jobs are matched by their exact caller/leaf check names. Create test report is diagnostic; successful HTML never overrides failed tests.
For partial reruns, the newest attempt per job is used. Earlier successes from the same immutable run can be reused. API failure or missing context fails closed. Workflow cancellation may cancel the aggregate; a cancelled required check blocks merging. CodeQL and dependency-security checks remain separate controls.
This aggregate covers the required producers in ci.yml. The separate heavyweight Integration tests workflow runs All and slim CommandLine suites against its database-version matrix and propagates native test failures. Its legacy Docker lane remains disabled and advisory. Path-specific skill, installer and release-contract workflows retain their separate checks; they are not silently promoted into required workflows by this proposal.
Permissions and maintenance
The aggregate uses contents: read and actions: read, the ordinary pull_request event and ephemeral github.token. It needs no repository secrets, write permissions, pull_request_target or privileged workflow_run consumer. Checkout does not persist credentials. GitHub may require fork-run approval; never run unknown PR code in a privileged context to avoid that rule.
Run with PowerShell 7:
./scripts/ci/Test-PRValidation.ps1
./scripts/ci/Test-InvokePRValidation.ps1
Update the independent inventory, tests and workflow together when intentionally changing required matrices or steps. Keep run evidence and test PR links in the implementation PR, not in git.
Proposed main ruleset
The ruleset JSON is a disabled proposal, not applied repository settings. It proposes:
- PRs with no required approvals, stale approval dismissal and resolved review threads.
- Required
PR validation,Security analysis / Analyze Code Security,Dependency ReviewandNuGet dependency auditfrom GitHub Actions (app ID 15368), on up-to-date PRs. - Native CodeQL protection rejecting high/critical security alerts, no additional non-security threshold. Green analysis alone does not enforce alert severity. Dependency Review and NuGet audit also use high/critical.
- No main deletion or force pushes; PRs merge using squash.
- Administrator bypass through a PR only for emergencies, with reasons and follow-up recorded in that PR. No actor receives direct-push bypass.
Maintainers with write access can provide voluntary reviews. Confirm current repository permissions and agree ownership before introducing a CODEOWNERS requirement for .github/ or scripts/ci/, then test any agreed requirement. CodeRabbit stays advisory. Merge queue requires a future merge_group trigger and separate verification.
Activation sequence
- Review the implementation PR and actual code, documentation and fork PR runs. Record base/head/run/attempt, permissions and outcomes. Label fixture producers, permission simulations and test-base runs; these do not prove main protection.
- Exercise failure, cancellation, missing members and unexpected skips. Green reporting alongside red tests must give red PR validation. Local policy tests complement hosted verification; they do not replace it.
- Maintainers merge the reviewed configuration. This task does not authorize merging. Refresh main and repeat categories only demonstrated on a test base. Verify the separate security checks and accepted CodeQL baseline/threshold.
- Obtain the user’s review of results and final ruleset before applying active enforcement. Required PR validation waits until configuration is on main and all three contribution categories are verified.
- Inspect effective rules; verify fresh passing PRs are allowed while failing, missing and stale checks block merging. Keep an audited emergency PR path.
See GitHub’s required-check troubleshooting and jobs.<job_id>.needs.