OSAC-2141: replace draft PRs with GitHub validation labels - #53
Conversation
Stop using draft PRs as a quality signal for validation failures and non-zero exit codes. Instead, apply configurable GitHub PR labels (ai-validation-failed, ai-nonzero-exit) that communicate the issue without delaying CI or reviewer engagement. - Always create regular PRs (draft only from repo config pr.draft) - Always transition Jira ticket to "in review" - Apply/clear validation labels when code is pushed - Leave labels unchanged when AI produces no changes - Add PRValidationLabels config with empty-string-disables pattern Assisted-by: Claude Opus 4.6 (1M) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (2)
WalkthroughAdds configurable GitHub PR validation labels, propagates them through project settings, and applies or clears them in new-ticket and feedback pipelines based on validation results and process exit codes. Draft creation now follows repository configuration directly. ChangesPR validation label workflow
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant Pipeline
participant GitService
participant GitHubPR
Pipeline->>Pipeline: Evaluate validation result and exit code
Pipeline->>GitService: Add target label or clear configured labels
GitService->>GitHubPR: Update pull request labels
🚥 Pre-merge checks | ✅ 11 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (11 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 8
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@executor/feedback.go`:
- Around line 496-506: Restrict the label updates in the loop around
validationLabel and repoInfos to repositories present in repoSHAs, skipping
unchanged entries before calling setPRValidationLabel or
clearPRValidationLabels. Preserve the existing label behavior for changed
repositories, and add a regression test covering repoInfos with only one
repository included in repoSHAs.
In `@executor/labels_test.go`:
- Around line 528-542: The “empty target only removes others” test only checks
the removal count, so duplicate removals can pass without verifying both
configured labels were removed. Update the assertions in the test around
SetPRValidationLabel, including the corresponding case near the referenced
second location, to compare removed against the exact set of distinct validation
labels while preserving the existing added-label assertion.
- Around line 563-569: Strengthen the best-effort error tests in
executor/labels_test.go at lines 563-569 and 611-620 by using an observed zap
logger and asserting the expected warning entries. Cover both add and removal
failures in the “errors are swallowed” subtest, and verify the removal-failure
warning includes error context in the second subtest; ensure each test has
assertions for the observable logs.
In `@executor/labels.go`:
- Around line 137-147: Update the removal log in the label cleanup flow and the
addition log around targetLabel to include structured owner, repo, and pr_number
fields alongside the existing label and error fields. Use the existing PR
context variables owner, repo, and prNumber, while preserving the current log
levels and messages.
In `@executor/pipeline_test.go`:
- Around line 3194-3197: Update the test around p.Execute to capture both its
result and error, then assert the expected successful no-change outcome before
checking labelTouched. Do not discard the Execute error; ensure unrelated early
failures cause the test to fail rather than producing a false positive.
In `@executor/pipeline.go`:
- Around line 981-983: Propagate the first multi-repo PR’s draft state into
JobResult: ensure repoPR carries the PR draft flag when PRs are created, then
assign result.Draft from prs[0].draft alongside PRURL and PRNumber. Preserve the
existing validation flow.
In `@models/config_test.go`:
- Around line 1888-1972: Extend the configuration tests around LoadConfig and
PRValidationLabels with a partial-disable case where validation_failed is
explicitly empty while nonzero_exit has a custom value, and assert both decoded
values. Also cover the inverse case if required by the existing per-label
behavior, preserving the current omitted-label and fully populated cases.
- Line 1850: Update the temporary-file setup and cleanup in the affected tests
to check and report errors from file Close calls, and replace deferred os.Remove
calls with t.Cleanup callbacks that handle removal failures through the test’s
error-reporting mechanism. Apply this consistently to the temporary key paths
around the existing test setup blocks, without discarding any returned errors.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: a2334811-c7da-4689-ae5c-07d179f66448
📒 Files selected for processing (16)
AGENTS.mdconfig.example.yamlexecutor/executor.goexecutor/executortest/stubs.goexecutor/export_test.goexecutor/feedback.goexecutor/labels.goexecutor/labels_test.goexecutor/pipeline.goexecutor/pipeline_test.gojobmanager/manager.gomodels/config.gomodels/config_test.gomodels/project_settings.goprojectresolver/resolver.goprojectresolver/resolver_test.go
- Only update validation labels on repos that received a commit in multi-repo feedback (fixes bug where unchanged repos' labels were modified) - Propagate first repo's draft status into JobResult for multi-repo new-ticket path - Assert expected error in no-changes feedback test to avoid false-positive passes - Add owner/repo/pr fields to validation label log messages for debugging concurrent runs Assisted-by: Claude Opus 4.6 (1M) <noreply@anthropic.com>
…abled When ValidationFailed is "" (disabled) but NonzeroExit is configured, validationLabel() returned "" before reaching the NonzeroExit check, causing the caller to clear labels instead of applying the only configured one. Assisted-by: Claude Opus 4.6 (1M) <noreply@anthropic.com>
Summary
ai-validation-failed,ai-nonzero-exit) that communicate the issue without delaying CI or reviewer engagementPRValidationLabelsconfig following the existing empty-string-disables patternTest plan
-race -count=1ai-nonzero-exitlabel, creates regular PR, transitions to in-reviewai-validation-failedlabel (takes precedence over nonzero exit)pr.draft: truestill creates draft PR, still transitions to in-reviewPRValidationLabelsround-trips through YAML/mapstructurePRValidationLabelspasses through fromProjectConfigtoProjectSettingsvalidationLabel()andvalidationPassed()(12 cases covering precedence)setPRValidationLabelandclearPRValidationLabels(7 cases)Assisted-by: Claude noreply@anthropic.com
Packages affected
executor/: Implements configurable PR validation labeling (validation_failed/nonzero_exit) using mutually exclusive label management, applied/cleared across both “new ticket” and “feedback” flows (while honoringpr.draft: trueconfig for draft PR creation).models/: AddsPRValidationLabelsto project/Jira configuration schema and project settings.projectresolver/: Propagates per-projectPRValidationLabelsinto resolved project settings.jobmanager/: Updates documentation/comments clarifying that draft PRs are created only when repo config enablespr.draft: true(validation failures no longer trigger drafts).services/: GitHub integration adds/implementsAddPRLabelandRemovePRLabeloperations for PR labels.scanner/: Extends PR labeler stubs/tests to support add/remove PR label behavior (used by scanner’s labeler integration, e.g., idle-label handling).config/ docs: Updatesconfig.example.yamlandAGENTS.mdto document the newpr_validation_labelsconfiguration and behavior.Execution pipeline
pr.draft: true.ai-validation-failedwhen validation is explicitly failed.ai-nonzero-exitwhen the container exits non-zero and validation was not explicitly reported as failed.Configuration and deployment
jira.pr_validation_labels(using the empty-string-disables pattern) documented inconfig.example.yamlandAGENTS.md.