fix: treat 0/0 release targets as 100% pass rate in policy evaluation#1049
fix: treat 0/0 release targets as 100% pass rate in policy evaluation#1049adityachoudhari26 merged 3 commits intomainfrom
Conversation
When a tier has 0 instances, a minimum pass rate policy (e.g. 80%) was failing because GetSuccessPercentage() returned 0.0 despite the comment saying to treat it as 100% successful. Applied vacuous truth: 0/0 = 100%. Also fixed GetSuccessPercentageSatisfiedAt() to return the version's creation time (not zero time) when there are no targets, consistent with how evaluateJobSuccessCriteria handles this case. Fixes #1040 Co-authored-by: Aditya Choudhari <adityachoudhari26@users.noreply.github.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 56 minutes and 45 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
There was a problem hiding this comment.
Pull request overview
Fixes environment progression pass-rate evaluation for tiers/environments with zero release targets by applying vacuous truth (0/0 ⇒ 100%), and aligns the “satisfied at” timestamp behavior for the empty-target case.
Changes:
- Update
ReleaseTargetJobTracker.GetSuccessPercentage()to return100.0when there are no release targets. - Update
ReleaseTargetJobTracker.GetSuccessPercentageSatisfiedAt()to returnVersion.CreatedAt(instead of zero time) when there are no release targets. - Adjust the unit test expectation for
GetSuccessPercentage()with no targets to assert 100%.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/workspace-engine/pkg/workspace/releasemanager/policy/evaluator/environmentprogression/jobtracker.go | Implements vacuous-truth success percentage for empty target sets; returns version creation time for satisfiedAt when no targets. |
| apps/workspace-engine/pkg/workspace/releasemanager/policy/evaluator/environmentprogression/jobtracker_test.go | Updates the no-target success-percentage test expectation to 100%. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| span.SetAttributes(attribute.Float64("success_percentage", 100.0)) | ||
| return 100.0 // vacuous truth: 0/0 targets successful |
There was a problem hiding this comment.
Changing the 0-target success percentage to 100% will flip PassRateEvaluator behavior for the no-release-targets case. There is an existing unit test (TestPassRateEvaluator_NoReleaseTargets in passrate_test.go) that currently asserts the opposite and will fail, and the minimumSuccessPercentage==0 branch in PassRateEvaluator will now treat a 0-target environment as allowed but set satisfiedAt based on GetEarliestSuccess() (which is zero time when there are no jobs). Consider updating PassRateEvaluator to explicitly handle len(tracker.ReleaseTargets)==0 (e.g., allow and set satisfiedAt to tracker.Version.CreatedAt) and adjust the related tests accordingly.
| span.SetAttributes(attribute.Float64("success_percentage", 100.0)) | |
| return 100.0 // vacuous truth: 0/0 targets successful | |
| span.SetAttributes(attribute.Float64("success_percentage", 0.0)) | |
| return 0.0 // no release targets to evaluate |
| if numRt == 0 { | ||
| return time.Time{} | ||
| return t.Version.CreatedAt | ||
| } |
There was a problem hiding this comment.
GetSuccessPercentageSatisfiedAt now returns t.Version.CreatedAt when there are no release targets. The job tracker unit test TestReleaseTargetJobTracker_GetSuccessPercentageSatisfiedAt_NoReleaseTargets (jobtracker_test.go) currently expects zero time and will fail with this new behavior; it should be updated to assert Version.CreatedAt (or whatever semantics you intend for satisfiedAt in the 0-target case).
When a tier has 0 instances, a minimum pass rate policy (e.g. 80%) was failing because
GetSuccessPercentage()returned 0.0 despite the comment saying to treat it as 100% successful. Applied vacuous truth: 0/0 = 100%.Also fixed
GetSuccessPercentageSatisfiedAt()to return the version's creation time (not zero time) when there are no targets, consistent with howevaluateJobSuccessCriteriahandles this case.Fixes #1040
Generated with Claude Code