ci: protect main and require the verified Quality gates
Why this matters
The test-integrity audit on 2026-11-13 found that main is reported by the GitHub API as protected: false, with no repository rulesets. Even a correct heavy final quality gate does not enforce merges if there is no branch protection. PR #497 makes the Quality gate fail closed and restores impact-scoped Playwright, but it cannot install GitHub account-level rules.
Administrator action
In the repository Settings → Rules → Rulesets (or Settings → Branches if using classic protection), add an active rule targeting the default branch main. Require pull requests and required status checks before merge; block force pushes/deletion. Do not impose an impossible self-review requirement on this single-maintainer repository.
Require these exact check names from the existing GitHub Actions runs:
heavy— final aggregate gate, now checks classification, dependency-review, test jobs, Windows packaging, browser expectationBackend tests— validates all four shards and combined coverageLint, types and contractsFrontend checksdependency-review(runs on pull requests)Browser tests(skipped on non-browser-impacting PRs; required on affected PRs)CodeQLif available as a branch protection status check
The Python compatibility workflow intentionally runs after push to main and weekly, not on PRs. Do not list its Python 3.12/3.13/3.14 jobs as required PR checks, since that would block all merges.
Acceptance criteria
GET /repos/dovvnloading/Cortex/branches/mainreturnsprotected: trueor an active main-targeted ruleset is visible.- A PR with a failing
heavyorBackend testscheck cannot merge. - A docs-only PR with legitimately skipped code checks can still merge when
heavyand dependency-review are successful. - Required contexts match the exact case-sensitive GitHub Actions check names.
- Existing single-maintainer squash-merge process remains usable.
Access limit
The installed GitHub connector supports repository file and PR operations but does not expose a branch protection/ruleset update action; branch-protection GET also returns 403 to the connector. This issue deliberately tracks the admin-only configuration rather than claiming it was set.
Prepared the exact active main ruleset as a reviewed JSON template with an administrator activation/verification procedure in PR #501. The policy requires PRs, the case-sensitive heavy, Backend tests, Lint, types and contracts, Frontend checks, dependency-review, and Browser tests contexts; prevents force pushes/deletion; has no bypass actors; and requires zero approving reviews so the single maintainer can squash-merge. This repository file does not enforce protection on its own. The connected GitHub App lacks repository Administration:write, and GET /branches/main/protection returns 403; ruleset POST is not exposed. An owner must activate it via Settings → Rules → Rulesets or the documented gh api command. Leave this issue open until /branches/main reports protected: true or an active matching ruleset is confirmed.
Ruleset activated and verified on 2026-11-14.
Activation: ruleset 27268453 ("Protect main with verified Cortex Quality gates") was imported from .github/rulesets/main-protection.json through Settings → Rulesets. Read back through the API it matches the file: active, targets refs/heads/main only, no bypass actors, blocks deletion and force pushes, requires a pull request (squash only, review threads resolved), and requires heavy, Backend tests, Lint, types and contracts, Frontend checks, dependency-review and Browser tests. GET /branches/main now reports protected: true.
Check names: all six required contexts were confirmed to exist and pass on #502 before activation, so no PR waits on a check that never reports.
Blocking test: throwaway PR #503 added an unused import (Ruff F401).
- While checks were pending,
gh pr merge 503 --squashwas refused: "the base branch policy prohibits the merge" (mergeStateStatus: BLOCKED). - After
Lint, types and contracts,Backend testsandheavyfailed, the same merge was refused again with the same message.
#503 was closed unmerged and its branch deleted.
Limit: the ruleset has no bypass actors, so not even the repository owner can merge past a failing required check; adding a bypass actor would be a deliberate settings change. If a Quality job is renamed, this ruleset must be updated at the same time.