fix(ci): governance-enforce gate can pass having scanned nothing - #39
fix(ci): governance-enforce gate can pass having scanned nothing#39yakimoto wants to merge 3 commits into
Conversation
…ead nothing BASE=HEAD~1 scans one commit of a multi-commit push and reports the rest as passing; when HEAD~1 does not resolve it degrades to BASE=HEAD, an empty diff and a green job. Resolve to the empty-tree object so the full tree is scanned, and add merge_group so the gate runs in the merge queue. Refs #1747.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_4ef0317e-262d-4b3d-a735-f56f58faa358) |
PR Summary by QodoFix governance-enforce diff base resolution to prevent empty/partial scans
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
ApprovabilityVerdict: Approved defc1a5 CI workflow fix to governance enforcement gate, owned by the PR author. Review comments note the intentional design choice (fail loud vs silent pass) and one suggests a guard already present in the code. Low-risk configuration change. You can customize Macroscope's approvability policy. Learn more. |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 46 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Comment |
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTo customize comments, go to the Qodo configuration screen, or learn more in the docs. |
Qodo FixerNo findings are available for this PR yet. Findings appear here once Qodo has reviewed the PR. |
…nnot silently pass Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
| # Indeterminate base (first push / force-push). Do NOT silently scan a partial range — | ||
| # HEAD~1 would skip earlier commits in a multi-commit push and let a violation through | ||
| # (a config-no-silent-noop hole). Diff the full tree against git's empty-tree object so | ||
| # every introduced file is scanned; loud, never a silent empty/partial pass. | ||
| BASE=$(git hash-object -t tree /dev/null) | ||
| echo "::warning::indeterminate diff base; scanning full tree (empty-tree base) so no commit is skipped" |
There was a problem hiding this comment.
🟡 First push of a new branch makes the compliance check scan the whole repository and fail on old, pre-existing problems
When the check cannot determine what to compare against, it now compares the entire repository against nothing (git hash-object -t tree /dev/null at .github/workflows/governance-enforce.yml:56) instead of a recent change range, so every historical file is treated as newly added.
Impact: On a branch's first push (or branch creation), the gate can fail on long-standing legacy issues that the change did not introduce, blocking unrelated work.
Why the empty-tree base conflicts with the workflow's diff-scoped contract
The workflow header states the gate is "Diff-scoped: blocks NEW violations without failing on legacy debt" (.github/workflows/governance-enforce.yml:4-5). With BASE set to the empty-tree object, enforce.mjs --changed <empty-tree> runs git diff <base> HEAD, which lists every tracked file as added, so pre-existing violations anywhere in the repo are reported as new. This path is reached whenever github.event.before is all zeros (branch create) or all base inputs are empty. The trade-off may be intentional (fail loud rather than silent), but it changes the gate from diff-scoped to whole-repo in those events and can hard-block pushes for reasons unrelated to the commit.
Was this helpful? React with 👍 or 👎 to provide feedback.
…back loud, not raw-git-error Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
| # Indeterminate base: first push (before-SHA is all zeros) or force-push (before-SHA is | ||
| # the orphaned old tip, which the clone cannot resolve — hence the cat-file guard; the | ||
| # fail-closed enforcer would otherwise hard-fail on a raw git error). Do NOT silently | ||
| # scan a partial range — HEAD~1 would skip earlier commits in a multi-commit push and | ||
| # let a violation through (a config-no-silent-noop hole). Diff the full tree against | ||
| # git's empty-tree object so every introduced file is scanned; loud, never a silent | ||
| # empty/partial pass. | ||
| BASE=$(git hash-object -t tree /dev/null) | ||
| echo "::warning::indeterminate diff base; scanning full tree (empty-tree base) so no commit is skipped" |
There was a problem hiding this comment.
🔍 Empty-tree fallback turns the diff-scoped gate into a whole-repo scan
The fallback replaces an unresolvable/zero base with git's empty-tree object, so the enforcer diffs the entire tree and scans every tracked file. That contradicts the workflow header's stated design (.github/workflows/governance-enforce.yml:3-6: "Diff-scoped: blocks NEW violations without failing on legacy debt"). The fallback is reachable on first pushes and force-pushes to main/master, where any pre-existing (legacy) secret-pattern or hardcoded-path finding anywhere in the repo will now hard-fail the required enforce check on the default branch rather than on a PR. The trade-off is deliberate per the inline comment, but it's worth confirming the repo is currently clean under a full-tree scan so a force-push doesn't permanently red the branch.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
|
||
| on: | ||
| pull_request: | ||
| merge_group: |
There was a problem hiding this comment.
🔍 merge_group trigger added only to this workflow
merge_group is added here but no other workflow in .github/workflows/ (_checks.yml, foundation-gate.yml, go-lint.yml, public-repo-guard.yml) listens for it. If a merge queue is enabled and those checks are also required, merge-queue entries will stall waiting for checks that never report. Either the queue isn't enabled yet (in which case this is a no-op) or the other required workflows need the same trigger.
Was this helpful? React with 👍 or 👎 to provide feedback.
Defect
.github/workflows/governance-enforce.ymlresolved its diff base toHEAD~1, which scans onlyONE commit of a multi-commit push and reports every earlier commit as passing. On an initial push,
force-push, or shallow clone this degrades further:
HEAD~1fails to resolve and falls back toBASE=HEAD, diffing HEAD against itself — an empty diff, zero lines scanned, job green. A gatethat passes without reading any line is worse than no gate.
Changes (targeted,
.github/workflows/governance-enforce.ymlonly)merge_group:trigger alongsidepull_request:/push:— also clears a latentmerge-queue deadlock (the gate previously never ran in the merge queue).
MERGE_BASE_SHA: ${{ github.event.merge_group.base_sha }}to the env of the step thatcomputes
BASE.BASE="${PR_BASE_SHA:-$PUSH_BEFORE_SHA}"becomesBASE="${PR_BASE_SHA:-${MERGE_BASE_SHA:-$PUSH_BEFORE_SHA}}", and the indeterminate-basefallback (previously
git rev-parse HEAD~1 2>/dev/null || git rev-parse HEAD) now diffs againstgit's empty-tree object (
git hash-object -t tree /dev/null) so the full tree is scanned —loud (
::warning::) and never a silent empty/partial pass.wave-av/wave-conferencing-bridge,wave-monitor,wave-desktop, andwave-multivieweralreadycarry the correct form of this file; this brings the same fix to this repo.
Out of scope (tracked separately, claude-workstation#1747)
This repo's gate still has three OTHER open defects tracked in #1747 which are deliberately NOT
addressed here: fail-open token scope, unpinned install scripts, and a caret (
^) version rangeon the
@wave-av/governancedependency.Refs claude-workstation#1747.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is enabled.Note
Cursor Bugbot is generating a summary for commit b1958cf. Configure here.
Note
Fix governance-enforce gate to scan full tree when diff base is unresolvable
merge_groupas a workflow trigger in governance-enforce.yml so the gate runs on merge queue events.PR_BASE_SHA, thenMERGE_BASE_SHA, thenPUSH_BEFORE_SHA.git hash-object -t tree /dev/nulland scans the full tree, emitting a GitHub Actions warning instead of silently passing or diffing againstHEAD~1.@wave-av/governanceinstall floor from^0.4.4to^0.4.6.Macroscope summarized defc1a5.