feat: guard autonomy decisions with shared policy - #14
Conversation
Co-Authored-By: Codex <noreply@openai.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
🤖 Codex PR Review✅ Merge allowed: No issues found Review by Codex PR Review bot • PR |
Co-Authored-By: Codex <noreply@openai.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7434126d5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "LICENSE", | ||
| ".gitignore", | ||
| }) | ||
| DEFAULT_POLICY_PATH = Path(".github/codex_auto_merge_policy.json") |
There was a problem hiding this comment.
Package the shared policy with the deployed service
In the normal VPS deployment, scripts/deploy_codex_audit_service.sh sets the systemd WorkingDirectory to DEPLOY_DIR and only copies service/ into that directory, so .github/codex_auto_merge_policy.json is absent there. Because this default path is relative to the service cwd, load_autonomy_policy() returns {} in production and the new policy_version/risk_policy behavior is silently bypassed. Please either install the policy with the service package or resolve it from a path that is actually deployed.
Useful? React with 👍 / 👎.
| for tier in (RISK_CRITICAL, RISK_HIGH, RISK_MEDIUM, RISK_LOW): | ||
| rule = risk_policy.get(tier) | ||
| if isinstance(rule, dict) and _policy_matches(path, rule): | ||
| return tier |
There was a problem hiding this comment.
Enforce high as the policy fallback
The checked-in shared policy's risk_policy.high section has only a reason (source code changes require review), and existing policy consumers treat any non-low/non-medium path as high. Here that high rule is ignored unless it also has exact or prefixes, after which built-in fallback classifies paths such as service/ai_gateway_service.py or arbitrary scripts as medium, allowing auto_pr at 70–84% confidence instead of escalating under the shared policy. Please make the high policy section the catch-all after low/medium checks, or require explicit high patterns in the policy.
Useful? React with 👍 / 👎.
| risk = classify_changes_risk(changed_paths or []) | ||
| action = decide_action(confidence, risk, config=config, repo=repo) | ||
| active_policy = policy if policy is not None else load_autonomy_policy() | ||
| risk = classify_changes_risk(changed_paths or [], policy=active_policy) |
There was a problem hiding this comment.
Apply policy file-count limits before auto-merge
When a review request includes many low-risk changed_paths, this only classifies the paths and ignores max_changed_files from the active shared policy. The checked-in policy caps auto-merge at 30 files, but 31 docs/test files still classify as low here and can return auto_merge at 60%+ confidence, bypassing the limit enforced by the existing guarded auto-merge policy consumers. Please treat file-count limit violations as requiring human review before deciding.
Useful? React with 👍 / 👎.
| changed_paths, | ||
| repo=repo if repo else None, | ||
| policy=load_autonomy_policy(), | ||
| health_status=get_health_monitor().status, |
There was a problem hiding this comment.
Record review health before trusting runtime guard
In deployments where /v1/ai/review is the slow or failing endpoint, this status remains healthy because _handle_review never records its latency or failures in HealthMonitor (repo search only found records for analyze/execute/job paths). The new runtime guard therefore cannot cap auto_merge recommendations for review-specific degradation; record the review endpoint health before using it to gate the action.
Useful? React with 👍 / 👎.
Co-Authored-By: Codex <noreply@openai.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Co-Authored-By: Codex <noreply@openai.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d150e220f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if not env_path: | ||
| return {} |
There was a problem hiding this comment.
Wire the autonomy policy path into deployment
Fresh evidence for the earlier deployment concern: this revision now requires CODEX_AUDIT_SERVICE_AUTONOMY_POLICY_PATH, but the VPS installer still only copies service/ (scripts/deploy_codex_audit_service.sh:186-190) and the generated systemd environment block does not set this variable (scripts/deploy_codex_audit_service.sh:242-262). In the normal deployed service, load_autonomy_policy() therefore returns {} here, so /v1/ai/review silently drops the shared risk_policy and policy_version; install the policy and set this env var, or pass a deployed policy path.
Useful? React with 👍 / 👎.
| changed_paths, | ||
| repo=repo if repo else None, | ||
| policy=load_autonomy_policy(), | ||
| health_status=get_health_monitor().status, |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| except re.error: | ||
| continue |
There was a problem hiding this comment.
Fail closed on invalid blocked-path regexes
When an operator adds a malformed custom blocked_path_patterns regex to the deployed policy, this path silently ignores it and continues classifying files, so a path that the policy intended to block can still be treated as low risk and return auto_merge. The existing guarded auto-merge policy parser fails closed on the same condition (scripts/run_monthly_codex_audit.py:2271-2275), so this service-side policy path should also force human review instead of continuing.
Useful? React with 👍 / 👎.
Summary
Validation