Cortex icon indicating copy to clipboard operation
Cortex copied to clipboard

ci: protect main and require the verified Quality gates

Open dovvnloading opened this issue 2 weeks ago • 2 comments

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 expectation
  • Backend tests — validates all four shards and combined coverage
  • Lint, types and contracts
  • Frontend checks
  • dependency-review (runs on pull requests)
  • Browser tests (skipped on non-browser-impacting PRs; required on affected PRs)
  • CodeQL if 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/main returns protected: true or an active main-targeted ruleset is visible.
  • A PR with a failing heavy or Backend tests check cannot merge.
  • A docs-only PR with legitimately skipped code checks can still merge when heavy and 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.

dovvnloading avatar Nov 13 '26 17:11 dovvnloading

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.

dovvnloading avatar Nov 14 '26 15:11 dovvnloading

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 --squash was refused: "the base branch policy prohibits the merge" (mergeStateStatus: BLOCKED).
  • After Lint, types and contracts, Backend tests and heavy failed, 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.

dovvnloading avatar Nov 14 '26 16:11 dovvnloading