Repository navigation
fix(python-mutation): apply detect-state pattern with single-line install - #172
Conversation
|
Warning Review limit reached
More reviews will be available in 27 minutes and 47 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ 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
This PR updates the reusable python-mutation.yml workflow to follow the strengthened Wave 1C detect-state pattern, so it can safely handle repos with no pyproject.toml, Poetry-managed repos, and uv repos without a committed uv.lock.
Changes:
- Add a
Detect repo statestep that classifies the repo asskip,poetry-not-supported,uv-locked, oruv-no-lock. - Split dependency installation into two single-line
uv syncsteps gated by detect-state to keep SonarCloud-friendly literal flag usage. - Gate mutation run, analysis, artifact upload, PR comment, and summary steps to only run on uv states.
| - name: Analyze mutation results | ||
| id: analyze | ||
| if: steps.detect.outputs.state == 'uv-locked' || steps.detect.outputs.state == 'uv-no-lock' | ||
| run: | | ||
| echo "Analyzing mutation test results..." |
PR ReviewStatus: ✅ All 24 CI checks pass · ✅ SonarCloud Quality Gate passed · Copilot completed · CodeRabbit rate-limited (no review) · No Critical findings. 3 Important items below; full report (incl. Suggested + Informational tiers) in the local review session. Important (should fix)
Bookkeeping
🤖 Generated with Claude Code |
…tall Apply the Wave 1C strengthened detect-state pattern (see PR #166): split the install step into two if-guarded single-line `run:` steps (uv-locked vs uv-no-lock), each carrying Pattern A inline NOSONAR. Gate downstream steps on detect.outputs.state so skip and poetry-not-supported paths exit cleanly. The pre-existing single-line install (line 169) used a bare `# NOSONAR` without a rule list; replace with explicit S8541 (and S8541,S8544 on the no-lock path) rule lists per the strengthened patterns doc. Trigger unchanged: workflow_call only (CI-053 enforced; mutation testing must remain schedule + workflow_dispatch in downstream callers). The `Run mutation testing` step retains its `run: |` block because the shell logic uses multi-line uv run calls with literal `--frozen`. Per the strengthened guidance, preceding-line NOSONAR inside `run: |` is fragile but the literal `--frozen` keeps S8544 from firing structurally. Verify the SonarCloud gate per PR; if S8541 fires here, restructure to single- line shape per Option 3.
c8ca72f to
18f6541
Compare
…ted uv run Address two findings from PR #172 review (Copilot, local pr-review): 1. Skip path leaves workflow_call outputs empty. The job's score/passed outputs sourced from steps.analyze.outputs.*, which evaluate to empty strings when analyze is gated off on the skip path. Downstream callers using `if: needs.mutation.outputs.passed == 'true'` silently fell through to false. Add a `set-skip-outputs` step that writes deterministic score=0, passed=true, and skipped=true, and coalesce the job-output expressions across analyze and the new step. Expose `skipped` as a new workflow_call output so sophisticated callers can distinguish "skipped" from "tested and passed". 2. Nested `uv run mutmut results --json` subprocess inside the analyze step's Python heredoc omitted --frozen and \$NO_BUILD_FLAG, breaking the PR body's stated invariant that literal --frozen is on every `uv run` line. Build the command in Python so both flags propagate, restoring the lockfile/no-build guarantee on this invocation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Document the python-mutation.yml changes from PR #172 in the [Unreleased] Fixed section, covering the detect-state pattern application, deterministic skip-path outputs (with new `skipped` output), and the nested subprocess --frozen/\$NO_BUILD_FLAG fix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
PR Fix SummaryAddressed all 3 review findings (2 from Copilot, 1 from local pr-review) in two commits on the rebased branch:
1. Copilot: skip path leaves
|
PR #170 strengthened the NOSONAR rule based on Wave 1C (PR #166), which found that comma-separated NOSONAR and inline-trailing NOSONAR inside run: | blocks are not honored. The strengthened rule was framed as "any NOSONAR inside run: | is unreliable; treat Pattern B as a lucky non-failure." Subsequent Waves 2B (PR #172, python-mutation) and 2C (PR #173, python- performance-regression) re-validated Pattern B with passing SonarCloud gates. Both PRs kept multi-line run: | blocks with literal --frozen on every uv line and preceding-line single-rule # NOSONAR(S8541). Both achieved gate=OK with 0 vulns on first push. The evidence supports a more nuanced rule: Pattern B is reliable when three conditions hold simultaneously. 1. Every uv invocation in the run: | block uses literal --frozen (not dynamic $FROZEN_FLAG). 2. NOSONAR is single-rule S8541 only, not comma-separated. 3. NOSONAR is on the preceding line, not inline-trailing. Updates to docs/sonarcloud-nosonar-patterns.md: - TL;DR table: split the prior "Preceding-line with literal --frozen" row into two rows that distinguish the working condition (single-rule S8541) from the failure modes (comma-separated or inline-trailing). - TL;DR Rule of thumb: replace "single-line run: only" framing with "two predictable shapes" framing, listing both Pattern A and the conditioned Pattern B. - Recommended Patterns: replace "Pattern B (fragile)" framing with "Pattern B (acceptable under specific conditions)" plus an explicit three-condition reliability list. Note 3-for-3 empirical track record when conditions hold. - Date line: add "nuanced 2026-05-26" with PR pointer. The earlier strengthened rule was over-pessimistic. This nuance does not contradict it; both PRs #166 and #170 documented failure modes correctly, and PRs #172 and #173 demonstrated the working conditions. Future Phase 2 or 3 implementers should default to Pattern A but may use Pattern B when the three conditions hold. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ce (#174) * docs(sonarcloud): nuance Pattern B reliability with Wave 2B/2C evidence PR #170 strengthened the NOSONAR rule based on Wave 1C (PR #166), which found that comma-separated NOSONAR and inline-trailing NOSONAR inside run: | blocks are not honored. The strengthened rule was framed as "any NOSONAR inside run: | is unreliable; treat Pattern B as a lucky non-failure." Subsequent Waves 2B (PR #172, python-mutation) and 2C (PR #173, python- performance-regression) re-validated Pattern B with passing SonarCloud gates. Both PRs kept multi-line run: | blocks with literal --frozen on every uv line and preceding-line single-rule # NOSONAR(S8541). Both achieved gate=OK with 0 vulns on first push. The evidence supports a more nuanced rule: Pattern B is reliable when three conditions hold simultaneously. 1. Every uv invocation in the run: | block uses literal --frozen (not dynamic $FROZEN_FLAG). 2. NOSONAR is single-rule S8541 only, not comma-separated. 3. NOSONAR is on the preceding line, not inline-trailing. Updates to docs/sonarcloud-nosonar-patterns.md: - TL;DR table: split the prior "Preceding-line with literal --frozen" row into two rows that distinguish the working condition (single-rule S8541) from the failure modes (comma-separated or inline-trailing). - TL;DR Rule of thumb: replace "single-line run: only" framing with "two predictable shapes" framing, listing both Pattern A and the conditioned Pattern B. - Recommended Patterns: replace "Pattern B (fragile)" framing with "Pattern B (acceptable under specific conditions)" plus an explicit three-condition reliability list. Note 3-for-3 empirical track record when conditions hold. - Date line: add "nuanced 2026-05-26" with PR pointer. The earlier strengthened rule was over-pessimistic. This nuance does not contradict it; both PRs #166 and #170 documented failure modes correctly, and PRs #172 and #173 demonstrated the working conditions. Future Phase 2 or 3 implementers should default to Pattern A but may use Pattern B when the three conditions hold. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs(sonarcloud): resolve internal contradictions in Pattern B framing Addresses PR #174 review findings: Critical - Anti-patterns heading at line 145 narrowed from "any NOSONAR inside run: | blocks" to "unreliable NOSONAR forms inside run: | blocks", since the body of the same PR now endorses Pattern B (preceding-line single-rule NOSONAR with literal --frozen) inside run: | blocks. - Hypothesis section (lines 88-107) rewritten: the absolute Wave 1C claim that "no NOSONAR placement inside a run: | block scalar is reliable" was the surviving prior framing that contradicted the new Pattern B framing. Reframed as historical Wave 1C conclusion now superseded by Wave 2B/2C re-validation. Important - "3-for-3" reliability claim qualified: PR #173 is open at time of writing with a passing pre-merge gate; reframed as "2 merged applications plus 1 pre-merge gate pass" so readers do not treat all three legs as production-validated. Suggested - Pattern B uv-line count corrected from "11 uv lines across 4 blocks" to "11 uv lines across 5 blocks" (actual count of run: | blocks added in PR #173). - TL;DR rule-of-thumb sentence deduplicated against the identical sentence in the Pattern B detail section, now references the Verification protocol section instead. Informational - "Lucky non-failure" jargon at line 141 rewritten to be self-contained for first-time readers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>



Summary
Apply the Wave 1C strengthened detect-state pattern (per PR #166 / PR #170) to
python-mutation.yml. Wave 2B of the CI Repair Sprint Phase 2.Changes
Detect repo statestep (skip / poetry-not-supported / uv-locked / uv-no-lock).Install dependenciesstep into twoif:-guarded single-linerun:steps:Install dependencies (uv with lockfile): literal--frozen, inlineNOSONAR(S8541).Install dependencies (uv without lockfile): no--frozen, inlineNOSONAR(S8541,S8544).Skip noticestep withSet skip outputs and notice: emits deterministicscore=0,passed=true,skipped=trueto$GITHUB_OUTPUTso downstream callers no longer see empty strings on the skip path (and exposes a newskippedworkflow_call output).Run mutation testing,Analyze mutation results,Upload mutation reports,Post PR comment, andMutation Testing Summaryonstate == 'uv-locked' || state == 'uv-no-lock'.# NOSONAR(no rule list) on the previous install line with explicit comma-separated rule lists per the strengthened patterns doc.uv run mutmut results --jsonsubprocess inside the analyze step's Python heredoc to pass--frozenand$NO_BUILD_FLAG, restoring the lockfile/no-build guarantee on the 4thuv runinvocation.Trigger preserved (CI-053)
The
on:block remainsworkflow_call:only. Nopull_request:trigger added. Downstream callers must continue to useschedule + workflow_dispatchper manifest CI-053.Pattern notes
run:+ inline NOSONAR). Confirmed reliable perdocs/sonarcloud-nosonar-patterns.md.Run mutation testingstep retainsrun: |because mutmut invocations use multi-line continuations. Literal--frozenis on everyuv runline, including the Python subprocess inside theAnalyze mutation resultsstep (S8544 won't fire structurally). Preceding-line# NOSONAR(S8541)is best-effort per the strengthened doc. If SonarCloud flags S8541 on these lines, the follow-up is restructuring to single-line per Option 3.Test plan
-shellcheck=per feedback_actionlint_shellcheck_embed.md)..githubpasses.gh workflow runonByronWilliamsCPA/maester-testsMutation Testing workflow succeeds.Review response (post-/pr-review)
After
/pr-review(#172 comment trail), two Copilot findings and one CLAUDE.md compliance gap were addressed in commits b08e83f and e30cad7:mutation-score/passedno longer evaluate to empty strings whenstate=skip. Added aset-skip-outputsstep plus a coalescing job-output expression. Newskippedoutput exposed for sophisticated callers.uv runin the Python heredoc. Subprocess now builds the command with--frozenand$NO_BUILD_FLAGfrom env, matching the surrounding install/run steps.### Fixedentry under[Unreleased]summarizing the detect-state pattern application and the two follow-up fixes.Branch was also rebased onto
origin/main(was 1 commit BEHIND#170) to clear the merge gate.Related