Skip to content

ci: PR checks validate the branch head, nothing validates main after merge — concurrent PRs combined into a lint violation neither was tested in (#671 + #672) #679

Closed

Description

@bpalermo

Summary

PR CI validates the PR head, and nothing validates main after a merge. Two PRs that each pass against their own base can therefore combine into a state neither was ever tested in, and that state ships to main silently. It just happened.

The instance

newCNIMetrics in agent/internal/cni/server/metrics.go is at gocognit complexity 16 against a limit of 15 on main at cf68f1b, and no PR ever failed CI for it:

commit change registrations at CI time CI
#671 763f5b3 +1 (spiffe_id_override_rejected) 15 pass
#672 head f5d540a branched before #671 merged; +2 (prune_breaker_engaged, storage.stale_pods) onto a file at 13 15 pass
#672 squash cf68f1b main = #671 + #672 16 never run

Verified: git show f5d540a:agent/internal/cni/server/metrics.go has 15 registrations; cf68f1b has 16. The test workflow on main at cf68f1b did not run — gh run list --branch main shows only e2e for that sha (the unit/lint leg is PR-only).

The violation then surfaced on two unrelated PRs: #676 (mesh-dns forward pool) failed its test job because //agent/internal/cni/server:server is in its reverse-transitive impact set via xds/cache, and the #667 branch hits it directly. Cleared by #678, but the class remains.

Why the existing gate cannot catch this

.github/workflows/ci.yaml runs bazel build --config=ci + bazel test --config=ci over the bazel-diff impact set of the PR head vs its merge-base. That is the correct scope for the PR's own change. It is structurally blind to the combination of two concurrently-open PRs, because the combined state does not exist anywhere until the second merge creates it — at which point no workflow looks at it.

--config=ci is not at fault: it linted cni/server:server on #672's head (it was in impacted_build.txt) and correctly found 15.

Options

  1. Post-merge main run of the unit+lint leg (bazel build --config=ci + bazel test --config=ci over the impact set of the merge commit vs its first parent, or simply a full //... since main merges are infrequent). Cheapest; catches the skew after it lands, with a clear signal (red main) instead of a mystery failure on a bystander PR days later. Does not prevent the bad merge.
  2. Require branches to be up to date before merge (branch protection required_status_checks.strict = true). Forces a re-run against current main before every merge. Prevents the skew; costs a re-run per merge when main moved, and serialises merges of concurrent PRs. Fully solves the class for the linted set, but bazel-diff against the new base still scopes to the PR's own change — which is fine, since the combined delta is then the PR's delta against a base that already contains the other PR.
  3. GitHub merge queue. Same guarantee as (2) with batching; more setup, and interacts with the bazel-diff base computation (scripts/ci-impacted-targets.sh assumes a PR merge-base — check it handles the queue's temporary branches).

(1) is the floor and should land regardless. (2) is the actual fix and is a repo-settings change, not code. Recommend both; (3) only if merge throughput becomes a problem.

Note

This is not specific to gocognit. Any additive check with a global budget — a stats-cardinality cap, a chart-size limit, a flag count, a deps_test allow-list — has the same exposure. The complexity threshold was just the first one to be hit by two additive PRs in the same week.

Related: #678 (clears this instance), #676 and #667 (where it surfaced). The project_bazel_diff_ci notes already record the seed-missing-at-base gotcha; this is a different, second gap in the same design.

Activity

  1. bpalermo commented on Sep 5, 2026

    @bpalermo
    OwnerAuthor

    Applied 2026-09-05 (user-authorized): the main ruleset now has no bypass actors (current_user_can_bypass: never). The pull_request rule keeps squash-only but requires 0 approving reviews and no code-owner / last-push approval — with a single collaborator, GitHub's no-self-approval rule made any review requirement equivalent to a permanent lockout, so the admin bypass had been the only way anything merged, and every push to main showed result: bypass. required_status_checks is unchanged: ci + proxy, strict=true.

    Effect: gh pr merge --admin no longer works; a PR merges only when both checks are green on a branch that is current with main. Together with the main-post-merge job from #685 that closes the merge-skew class (#671 + #672 → 16/15 gocognit) both before and after the merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions