Skip to content

feat(governance): enforce owner-approved only on strict R2 - #71

Merged
cgl-agent-coordinator[bot] merged 1 commit into
mainfrom
feat/strict-owner-only-r2
Dec 4, 2026
Merged

cgl-agent-coordinator[bot] merged 1 commit into
mainfrom
feat/strict-owner-only-r2

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

AI assistance

  • Model: Antigravity (planning + implementation); verified locally with all Node test suites.

What changed

  • Added optional require_owner_approval_on_r2 policy boolean (pr-governance/policy.schema.json, pr-governance/scripts/gate.cjs): when true, R2 changes specifically require owner-approved and reject agent-approved alone, while refusing contradictory require_owner_approval_on_r2: true + require_clearing_label_on_r2: false configurations.
  • Configured require_owner_approval_on_r2: true on the strict tier and false on standard and relaxed tiers (scripts/policy-tiers.json, scripts/sync-policies.mjs).
  • Added unit tests covering agent-approved rejection, bound owner-approved acceptance, conflict validation, and tier sync in pr-governance/scripts/test-gate.cjs and scripts/test-sync-policies.cjs.

How verified

  • node --test pr-governance/scripts/test-*.cjs scripts/test-*.cjs: all tests passed (0 failures).
  • /usr/local/bin/gitleaks git --config pr-governance/.gitleaks.toml --log-opts="origin/main..HEAD" --redact: no leaks found.

Why

  • Ensures high-risk live-trading, credential, and governance R2 changes in strict repositories cannot be cleared by agent-approved alone without explicit Owner sign-off.

Risk

  • R2 (pr-governance/scripts/gate.cjs, pr-governance/policy.schema.json, scripts/policy-tiers.json, scripts/sync-policies.mjs): backwards-compatible default (false when unset); strict repositories opt in via policy sync once their pinned PrGovernance SHA includes this change.

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

Copy link
Copy Markdown

AI Code Review (opencode / glm-5.4)

The PR adds an optional require_owner_approval_on_r2 policy flag that tightens R2 clearing on strict repositories to require the owner-approved label specifically, with schema, evaluator validation (including a contradictory-flags check), tier manifest, sync script, and tests all updated consistently. The core logic is correct: needsOwnerOnly implies the clearing-label requirement, tierOK correctly requires labels.applied === 'owner' in that mode, the default (undefined/false) preserves existing behavior, and the schema/field-list parity test was updated. No security, permissions, or workflow-pinning issues; no secrets or real identifiers introduced. Remaining items are low-severity: a rollout-ordering hazard (policies synced with the new field will fail validation on evaluators pinned to older SHAs that reject unknown fields, and sameTier will now flag every repository as off-tier until resynced), a small test gap for non-boolean values of the new field and the volume-escalated owner-required text branch, and a slightly convoluted nested ternary for the gate reason text.

Reviewed commit: 84e8837fbc · Coverage: complete · Unresolved findings: false

Findings

  • [LOW] scripts/sync-policies.mjs: Rollout ordering hazard: once this merges, sameTier will treat every existing repository policy as off-tier (none contain require_owner_approval_on_r2), so the sync script will open PRs against all repositories. If a repository's workflow pins a PrGovernance SHA that predates this change, its evaluator's POLICY_OPTIONAL_FIELDS will not include the new key and policy validation will fail (fail-closed gate breakage) until the pin is bumped. The PR description documents the intended order, but the script itself neither enforces nor warns about it; consider noting the pin prerequisite in the generated PR body.
  • [LOW] pr-governance/scripts/test-gate.cjs: Test gap: no test asserts that a non-boolean require_owner_approval_on_r2 (e.g., a string) throws 'Invalid require_owner_approval_on_r2', and the volume-escalated branch of the new owner-required text ('diff volume exceeded; needs owner-approved') is not exercised. Both are simple additions to the existing test.
  • [LOW] pr-governance/scripts/gate.cjs: Minor maintainability: gateReasonText is now a three-branch nested ternary mixing needsOwnerOnly and risk.volumeEscalated conditions with inline strings ('needs owner-approved', 'diff volume exceeded; needs owner-approved') that bypass the existing GATE_TEXT constant pattern; a small lookup or helper would keep this readable and consistent.

@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 b540fc2 into main Dec 4, 2026
11 checks passed
@cgl-agent-coordinator
cgl-agent-coordinator Bot deleted the feat/strict-owner-only-r2 branch December 4, 2026 22:46
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