Skip to content

fix(scripts): tighten owner approval queue predicate and tests - #70

Merged
cgl-agent-coordinator[bot] merged 1 commit into
mainfrom
fix/owner-approve-queue-hardening
Dec 4, 2026
Merged

cgl-agent-coordinator[bot] merged 1 commit into
mainfrom
fix/owner-approve-queue-hardening

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

AI assistance

What changed

  • Hardened isPendingOwnerApproval in scripts/owner-approve-queue.mjs to hydrate risk-gate commit status descriptions via gh api repos/<repo>/commits/<sha>/status and require a clearing-label failure reason (needs owner-approved|clearing_label_required|diff volume exceeded) plus passing pr-template, refusing unresolved threads or missing descriptions fail-closed.
  • Added injectable runGh adapter, strict flag validation (--org, --repo), case-insensitive org filtering, --limit 100, --repo skip for repos.json, and surfaced auto-merge warning errors.
  • Replaced real repo/PR names in scripts/test-owner-approve-queue.cjs with synthetic placeholders and added tests for status-description hydration and the interactive --approve path.

How verified

  • node --test scripts/test-owner-approve-queue.cjs: 4 passed, 0 failed.
  • /usr/local/bin/gitleaks git --config pr-governance/.gitleaks.toml --log-opts="origin/main..HEAD" --redact: no leaks found.

Why

Risk

  • R1 (scripts/owner-approve-queue.mjs, scripts/test-owner-approve-queue.cjs): tooling CLI and unit tests only; no pr-governance/ evaluator changes.

Co-authored-by: Antigravity <noreply@google.com>
@cgl-opencode-reviewer

Copy link
Copy Markdown

AI Code Review (opencode / glm-5.4)

The diff is a generally sound hardening of the owner-approve queue: the tightened predicate fails closed on missing/mismatched risk-gate descriptions, hydration errors are surfaced as warnings while still failing closed, flag validation is tested, gh calls are injection-safe (execFileSync array args), and real repo names were replaced with synthetic fixtures per the public-repo rule. Tests cover the core predicate, hydration, TTY refusal, and the interactive approve path. Remaining concerns are low-severity: no test exercises the new case-insensitive --org manifest filtering or the manifest read-error path (despite the manifestPath injection added for testability); the usage comment advertises --list but parseArgs neither parses nor validates it and unknown flags are silently ignored; CLEARING_REASON_RE is a substring OR-match, so a description that combines a clearing reason with a blocking reason (e.g., unresolved threads) would still qualify; and pr-template is required to be SUCCESS when present but not required at all when absent (and a SKIPPED pr-template excludes the PR) — worth confirming intended semantics. No high or medium correctness, security, or critical-test gaps found.

Reviewed commit: 9f26da0515 · Coverage: complete · Unresolved findings: false

Findings

  • [LOW] scripts/owner-approve-queue.mjs: New --org case-insensitive manifest filtering and the manifest read-error path (return 1) have no test coverage, even though a manifestPath dependency was added specifically to make this testable. Consider adding a test with a synthetic manifest covering org filtering (including case differences) and unreadable manifest handling.
  • [LOW] scripts/owner-approve-queue.mjs: The usage comment advertises [--list] but parseArgs neither recognizes nor validates it; unknown flags are silently ignored. Either parse/validate --list explicitly or reject unrecognized flags so typos (e.g., --aprove) do not silently change behavior.
  • [LOW] scripts/owner-approve-queue.mjs: CLEARING_REASON_RE is a case-insensitive substring OR-match. If the evaluator ever emits a combined description containing both a clearing reason and a blocking reason (e.g., 'needs owner-approved ... unresolved review threads'), the PR would still be selected for owner-approved. Consider matching the exact evaluator-emitted reason strings or anchoring the pattern.
  • [LOW] scripts/owner-approve-queue.mjs: pr-template handling is asymmetric: a present-but-SKIPPED pr-template excludes the PR, while a entirely absent pr-template imposes no requirement (fail-open). Confirm this is intended; if pr-template is mandatory where the evaluator runs, consider requiring its presence.
  • [LOW] scripts/owner-approve-queue.mjs: Minor duplication: both isPendingOwnerApproval and hydrateRiskGateDescription re-run hasPassingNonGateChecks and re-find the risk-gate rollup entry. A small shared helper returning the risk-gate entry (or null) would remove the repeated lookup.

@cgl-agent-coordinator cgl-agent-coordinator Bot added the agent-approved Agent-approved governance exception label Dec 4, 2026
@cgl-agent-coordinator
cgl-agent-coordinator Bot merged commit 143011a into main Dec 4, 2026
11 checks passed
@cgl-agent-coordinator
cgl-agent-coordinator Bot deleted the fix/owner-approve-queue-hardening branch December 4, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-approved Agent-approved governance exception

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant