Skip to content

fix(python-compatibility): detect repo state instead of hardcoding uv sync --frozen - #156

Merged
williaby merged 2 commits into
mainfrom
chore/python-compatibility-detect-poetry-uv
May 25, 2026
Merged

williaby merged 2 commits into
mainfrom
chore/python-compatibility-detect-poetry-uv

Conversation

@williaby

@williaby williaby commented May 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Restores Python Compatibility matrix across the 11 uv-managed downstream repos failing since the workflow assumed every caller has uv.lock + pyproject.toml at root. Adds explicit, actionable handling for the three caller categories that crashed.

Root cause

The Install dependencies step ran uv sync --all-extras --frozen unconditionally, crashing on:

Category Repos Symptom
No pyproject.toml DeQA-Doc (docs-only fork) error: No pyproject.toml found in current directory or any parent directory
uv with no lockfile yet scattered uv-no-lock repos --frozen requires uv.lock
Poetry-managed PromptCraft, ledgerbase, data_ingestor, pp-security-master uv sync cannot read poetry projects

Fix

New Detect repo state step examines pyproject.toml + lockfile presence and emits one of four states. Each install + test step is gated on the detected state:

State Behavior
skip No pyproject.toml. Emits notice + step summary. Job succeeds.
uv-locked uv sync --all-extras --frozen $NO_BUILD_FLAG (current behavior)
uv-no-lock uv sync --all-extras $NO_BUILD_FLAG (no --frozen)
poetry-not-supported Fails fast with actionable error directing to org policy + migration tracking issues

Per the org's uv-only policy for reusable workflows, Poetry repos are explicitly rejected rather than silently muddling through. Migration issues are being filed against the 4 Poetry repos as a separate workstream.

Affected downstream repos (15)

Outcome Repos
Repaired (11) DeQA-Doc (skip), cookiecutter-template-sample, maester-tests, llc-manager, Unify, dna, GCS, image-preprocessing-detector, monte_carlo, testing, zen-mcp-server
Still failing (intentional, awaits migration) (4) PromptCraft, ledgerbase, data_ingestor, pp-security-master

Most callers use @main floating refs and pick up immediately. SHA-pinned callers will need a follow-up pin bump (deferred per CI Repair Sprint plan).

SonarCloud impact (added 2026-05-25)

The initial commit 0f43328 triggered 6 new MAJOR SonarCloud findings on
.github/workflows/python-compatibility.yml, failing the Quality Gate
(Security Rating C, required A). Follow-up commit eecbaa3 addresses
them:

  • S8544 (lockfile) x2 on the Run tests step: eliminated by dropping
    the FROZEN_FLAG env var and using literal --frozen unconditionally.
    The install step always produces uv.lock before tests run, so the
    literal is safe in both uv-locked and uv-no-lock states.
  • S8544 (lockfile) x1 on the uv-no-lock install step: suppressed
    with # NOSONAR(S8544) and rationale. No uv.lock exists by design on
    this path; that is the entire point of the state.
  • S8541 (--no-build) x3 on the uv-no-lock install and Run tests
    steps: suppressed with # NOSONAR(S8541) and rationale. --no-build
    is opt-out via the no-build workflow input (NO_BUILD_FLAG env at
    line 187, per PR feat(workflows): add no-build opt-out input to all reusable workflows #112); SonarCloud cannot follow the env-var
    indirection. The pre-existing uv-locked install step (line 292) uses
    the same pattern and is already accepted by SonarCloud.

Also addresses the Copilot inline review on the Upload coverage artifact step: gated on the same detected states as Run tests so
docs-only callers (state=skip) and poetry-not-supported callers no
longer emit upload-artifact "No files were found" warnings.

Test plan

  • Pre-commit passes locally
  • After merge, spot-check 2-3 @main callers (e.g., python-libs, Unify): confirm next Python Compatibility run succeeds
  • Spot-check DeQA-Doc: confirm it now skips with a notice instead of failing
  • Spot-check a Poetry repo (e.g., ledgerbase): confirm it fails with the new actionable error pointing at migration

Reference: docs/audits/cve-scan-coverage-2026-05-25.md (CI Repair Sprint addendum, Task 9 in current session).

Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Enhanced CI/CD workflow with improved repository state detection before installing dependencies
    • Added early error detection for incompatible project configurations
    • Optimized test execution and coverage reporting paths based on project setup
    • Improved workflow efficiency by streamlining conditional steps

Review Change Stack

… sync --frozen

Restores the Python Compatibility matrix across all 11 uv-managed downstream
repos that have been failing since the workflow assumed every caller had a
uv.lock at the repo root. Adds explicit handling for two edge cases the prior
implementation crashed on.

Root cause: the "Install dependencies" step ran `uv sync --all-extras
--frozen` unconditionally. This crashed for three caller categories:

1. Repos without pyproject.toml at root (e.g., DeQA-Doc which is a docs-only
   fork): error "No pyproject.toml found in current directory or any parent
   directory."

2. uv-managed repos with PEP 621 pyproject.toml but no uv.lock committed
   yet: --frozen requires uv.lock to exist.

3. Poetry repos (PromptCraft, ledgerbase, data_ingestor,
   pp-security-master): uv sync cannot read poetry-locked projects.

Fix: add a Detect repo state step that examines pyproject.toml + lockfile
presence and emits one of four states:

- skip: no pyproject.toml; emit a notice and continue (no install or tests
  run, the job succeeds with a step summary)
- uv-locked: uv.lock present; install via uv sync --all-extras --frozen
- uv-no-lock: PEP 621 only; install via uv sync --all-extras (without
  --frozen) so the lockfile is generated in-job
- poetry-not-supported: poetry.lock or [tool.poetry] present; fail with an
  actionable error directing the caller to convert to uv per org policy
  (separate migration workstream)

Install + Run tests steps are gated by the detected state so each caller
runs only the correct path. The FROZEN_FLAG env var lets the test command
template handle the with/without-lockfile case without branching.

Impact: repairs Python Compatibility on 11 uv repos (cookiecutter-template-
sample, maester-tests, llc-manager, Unify, dna, GCS, image-preprocessing-
detector, monte_carlo, testing, zen-mcp-server, plus DeQA-Doc which now
skips cleanly). The 4 Poetry repos surface an actionable error pointing at
the poetry-to-uv migration tracking issues.

Reference: docs/audits/cve-scan-coverage-2026-05-25.md addendum (CI Repair
Sprint, Task 9 in current session).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 25, 2026 20:12
@coderabbitai

coderabbitai Bot commented May 25, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The Python compatibility workflow restructures dependency installation and testing to detect repository "uv readiness" before execution. It adds a detection phase that skips when pyproject.toml is missing, rejects Poetry-based repos, and branches on uv.lock presence. Tests and artifact uploads are gated on the same detected conditions, ensuring commands and expectations align.

Changes

uv readiness detection and conditional workflow gating

Layer / File(s) Summary
Repo state detection and conditional install paths
.github/workflows/python-compatibility.yml
New detection step checks for pyproject.toml and uv.lock presence, failing on Poetry and branching into uv sync --frozen (locked) or uv sync (unlocked) paths based on lock file existence.
Conditional test execution with coverage flags
.github/workflows/python-compatibility.yml
Test step gates on the same uv-install detection conditions, runs uv run --frozen consistently, and conditionally includes coverage generation options when enabled.
Artifact upload gating alignment
.github/workflows/python-compatibility.yml
Coverage artifact upload condition is tightened to only run for the same uv install states and when coverage reporting is enabled, preventing artifact upload attempts when no coverage is expected.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

A rabbit hops through workflows true,
Now uv checks the path it's due.
Lock files guide the way so clear,
Tests and coverage, never fear! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: moving from hardcoding uv sync --frozen to detecting repository state before deciding how to install dependencies.
Description check ✅ Passed The description covers all critical template sections including Summary, Root cause analysis, Fix approach, affected repos, test plan, and SonarCloud mitigation. Follows the template structure with detailed context.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/python-compatibility-detect-poetry-uv

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@williaby

Copy link
Copy Markdown
Collaborator Author

Cross-linking the poetry-to-uv migration tracking issues that this PR's poetry-not-supported branch directs callers to:

Filed 2026-05-25. Each issue documents the migration steps and acceptance criteria. After those 4 repos complete migration, this PR's poetry-rejection branch becomes effectively dead code (all callers will pass detection); we can leave it as a defensive guardrail or remove in a follow-up.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the python-compatibility.yml reusable workflow, which previously hardcoded uv sync --all-extras --frozen and broke downstream callers that lacked pyproject.toml, lacked a uv.lock, or used Poetry. A new detection step categorizes the caller into one of four states and gates install/test steps accordingly, restoring 11 downstream repos and explicitly rejecting the 4 Poetry repos with an actionable error.

Changes:

  • Adds a "Detect repo state" step emitting skip / uv-locked / uv-no-lock / poetry-not-supported.
  • Splits the install step into lockfile vs. no-lockfile variants and adds a skip-notice step; Poetry repos fail fast with a directing error.
  • Threads a FROZEN_FLAG env into the test step so uv run drops --frozen when no lockfile is present.

Comment on lines +300 to +309
- name: Skip notice (no pyproject.toml)
if: steps.detect.outputs.state == 'skip'
env:
MATRIX_PYTHON: ${{ matrix.python }}
MATRIX_OS: ${{ matrix.os }}
run: |
echo "## Python Compatibility Skipped" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "No pyproject.toml at repo root, nothing to test on Python $MATRIX_PYTHON / $MATRIX_OS." >> $GITHUB_STEP_SUMMARY
shell: bash
@williaby

Copy link
Copy Markdown
Collaborator Author

PR Review

BUILD FAILING: SonarCloud Quality Gate failed (Security Rating C on new code, required A). 6 new MAJOR vulnerabilities introduced.

Review status: Copilot not requested · CodeRabbit rate-limited · SonarCloud failed · 23/24 CI green


Critical

  1. CI: SonarCloud Code Analysis failed Quality Gate (C Security Rating, required ≥ A). Blocking merge.

  2. S8544 .github/workflows/python-compatibility.yml:326-332: Test step lost the literal --frozen token. The install step always generates a lockfile before tests run, so --frozen can be reapplied unconditionally:

    uv run --frozen $NO_BUILD_FLAG $TEST_COMMAND

    Drop FROZEN_FLAG entirely. Eliminates 2 of 3 S8544 findings.

  3. S8544 .github/workflows/python-compatibility.yml:297: uv sync on the uv-no-lock path is unavoidable (no uv.lock yet). Either suppress with a SonarCloud per-finding annotation or document the accepted exception in the PR body.

Important

  1. S8541 .github/workflows/python-compatibility.yml:297, 326, 332: Three findings for absent literal --no-build. SonarCloud cannot follow $NO_BUILD_FLAG substitution. Apply the PR feat(workflows): add no-build opt-out input to all reusable workflows #112 pattern: branch at the step level into a with no-build step and a without step, each with the literal flag.

  2. PR description omits the SonarCloud regression. The change introduces 6 new MAJOR vulnerabilities and degrades the Security Rating from A to C, but the body frames the change purely as a fix. Update the description to acknowledge the trade-off (or fix all findings).

  3. CodeRabbit hit its rate limit and did not review. Re-request after the next push, or consciously accept the gap.

Suggested

  1. Add a one-line comment on the FROZEN_FLAG env line (.github/workflows/python-compatibility.yml:320) noting the SonarCloud trade-off so the next person doesn't "clean it up".

SonarQube: 6 issues (3x S8541, 3x S8544), 0 hotspots, all MAJOR severity, all PR-introduced.

Copilot: not requested. Investigate copilot_code_review rule in the org ruleset.

Generated with Claude Code

williaby added a commit that referenced this pull request May 25, 2026
…OSONAR S8541

Follow up to PR #156 team feedback. Step-level branching for uv-locked vs
uv-no-lock just shuffles the S8541 finding to the without-frozen branch
(allowing builds is intentional and configurable via the no-build input).
Collapsing to a single Install dependencies step with FROZEN_FLAG env var
indirection plus # NOSONAR S8541 suppression matches the established
convention in line 292 of python-compatibility.yml and halves the YAML
maintenance surface.

Test crypto imports step already used the FROZEN_FLAG pattern; no change
needed there.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 25, 2026
…nv + NOSONAR S8541

Follow up to PR #156 team feedback. Step-level branching for uv-locked vs
uv-no-lock just shuffles the S8541 finding to the without-frozen branch
(allowing builds is intentional and configurable via the no-build input).
Collapsing to a single Install dependencies step with FROZEN_FLAG env var
indirection plus # NOSONAR S8541 suppression matches the established
convention in python-mutation.yml (lines 159-169) and halves the YAML
maintenance surface.

Applied to both codeql and python-security jobs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…nale

Restores the SonarCloud Quality Gate (Security Rating A on new code) on
PR #156 by addressing the 6 MAJOR vulnerabilities introduced by the
uv-no-lock detection logic, plus the Copilot finding on coverage upload.

Changes:

1. Test step: drop FROZEN_FLAG env var; use literal --frozen
   unconditionally. The install step always produces uv.lock before this
   step runs (uv-no-lock generates one during sync; uv-locked has one
   committed). Eliminates 2 of 3 S8544 findings.

2. uv-no-lock install (line 297): add NOSONAR(S8541,S8544) suppression
   with rationale. No uv.lock exists by design on this path; --no-build
   is opt-out via the no-build workflow input (NO_BUILD_FLAG env at line
   187), and SonarCloud cannot follow env-var indirection statically.
   Matches the convention of the existing uv-locked install step at line
   292 which uses the same pattern and is accepted by SonarCloud as
   pre-existing code.

3. Test step run block (lines 326, 332): add NOSONAR(S8541) suppression
   on each uv run invocation for the same reason as #2.

4. Upload coverage artifact: tighten if: gating to match Run tests, so
   docs-only callers (state=skip, e.g. DeQA-Doc) and poetry-not-supported
   callers do not emit upload-artifact "No files were found" warnings
   when no coverage XML was produced. Addresses Copilot inline review
   comment on PR #156.

Verified locally: pre-commit clean (yamllint, secrets, em-dash checks),
YAML structurally valid. actionlint deferred to CI.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 25, 2026
…ONAR S8541

Follow up to PR #156 team feedback. Step-level branching for uv-locked vs
uv-no-lock just shuffles the S8541 finding to the without-frozen branch
(allowing builds is intentional and configurable via the no-build input).
Collapsing to a single Install dependencies step with FROZEN_FLAG env var
indirection plus # NOSONAR S8541 suppression matches the established
convention in python-mutation.yml (lines 159-169) and halves the YAML
maintenance surface.

Applied to both quality-checks and matrix-testing jobs. The 9 downstream
uv run steps already used the FROZEN_FLAG pattern; only the 2 install
steps needed collapsing.

Layout-precondition hardening from project_python_ci_audit_2026_05 is
preserved untouched.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@williaby

Copy link
Copy Markdown
Collaborator Author

PR Fix Summary

Addressed all 7 findings from the /pr-review pass (6 SonarCloud + 1 Copilot) in a single commit: eecbaa3.

SonarCloud (6 of 6 resolved)

  • S8544 x2 on Run tests (lines 326/332): eliminated by dropping FROZEN_FLAG and hardcoding literal --frozen. The install step always produces uv.lock before tests run, so the literal is safe in both uv-locked and uv-no-lock states.
  • S8544 x1 on uv-no-lock install (line 297): suppressed with # NOSONAR(S8544) and rationale. By design, no uv.lock exists on this path.
  • S8541 x3 (lines 297, 326, 332): suppressed with # NOSONAR(S8541) and rationale. --no-build is opt-out via the no-build workflow input (NO_BUILD_FLAG env at line 187); SonarCloud cannot follow env-var indirection. Matches the convention of the pre-existing uv-locked install step (line 292) which uses the same pattern.

Copilot review (1 of 1 resolved)

  • Upload coverage artifact (line 336-337): gated on the same detected states as Run tests, so docs-only callers and `poetry-not-supported` callers no longer trigger the "No files were found" warning. (Could not post inline reply on the thread because the API endpoint was permission-denied; tracking the resolution here instead.)

PR description: updated with a ## SonarCloud impact section explaining the trade-off and the suppressions.

Local validation passed

  • pre-commit (yamllint, secrets, em-dash, commitizen) clean
  • YAML structurally valid
  • actionlint deferred to CI (not installed locally)

Deferred (not in scope)

  • CodeRabbit hit its rate limit and did not review. Will re-trigger on next push.
  • Copilot was not auto-requested via the org ruleset, but did post the inline review comment that was addressed here. Worth investigating whether the copilot_code_review rule needs re-application for this repo, but unrelated to this fix.

CI re-run triggered by the push.

Generated with Claude Code

@sonarqubecloud

Copy link
Copy Markdown

@williaby
williaby merged commit ecf5f06 into main May 25, 2026
27 of 28 checks passed
@williaby
williaby deleted the chore/python-compatibility-detect-poetry-uv branch May 25, 2026 20:59
williaby added a commit that referenced this pull request May 25, 2026
… --frozen

Same pattern as PR #156 (python-compatibility.yml), applied to both jobs in
python-fips-compatibility.yml.

Root cause: both the fips-check and fips-runtime-test jobs hardcoded `uv run
--frozen` and `uv sync --all-extras --frozen` respectively. These failed
across the fleet for the same caller categories:

1. Repos without pyproject.toml at root: no error context to anchor on
2. uv-managed repos with no uv.lock yet: --frozen requires uv.lock
3. Poetry repos (PromptCraft, ledgerbase, data_ingestor, pp-security-master):
   uv cannot read poetry-locked projects

Fix: add a Detect repo state step to each job that examines pyproject.toml +
lockfile presence and emits one of four states (skip, uv-locked, uv-no-lock,
poetry-not-supported). Subsequent uv commands gate on the detected state and
swap the --frozen flag in via FROZEN_FLAG env. Poetry repos fail fast with an
actionable error pointing at the migration tracking issues.

Affected jobs:
- fips-check (Run FIPS compatibility check step, lines 181 + 190 of original):
  uv run --frozen --> uv run $FROZEN_FLAG, gated on detect state
- fips-runtime-test (Install dependencies + Test crypto imports steps): same
  pattern as python-compatibility.yml

Impact: repairs FIPS Compatibility across 6 uv repos (maester-tests, dna,
GCS, monte_carlo, testing, zen-mcp-server). The 4 Poetry repos
(PromptCraft, ledgerbase, data_ingestor, pp-security-master) surface the
new actionable error directing to their migration tracking issues
(williaby/PromptCraft#328, williaby/ledgerbase#147,
williaby/data_ingestor#38, ByronWilliamsCPA/pp-security-master#38).

Reference: docs/audits/cve-scan-coverage-2026-05-25.md addendum
(CI Repair Sprint, Task 9 in current session).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 25, 2026
…OSONAR S8541

Follow up to PR #156 team feedback. Step-level branching for uv-locked vs
uv-no-lock just shuffles the S8541 finding to the without-frozen branch
(allowing builds is intentional and configurable via the no-build input).
Collapsing to a single Install dependencies step with FROZEN_FLAG env var
indirection plus # NOSONAR S8541 suppression matches the established
convention in line 292 of python-compatibility.yml and halves the YAML
maintenance surface.

Test crypto imports step already used the FROZEN_FLAG pattern; no change
needed there.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 25, 2026
… --frozen (#157)

* fix(python-fips): detect repo state instead of hardcoding uv sync/run --frozen

Same pattern as PR #156 (python-compatibility.yml), applied to both jobs in
python-fips-compatibility.yml.

Root cause: both the fips-check and fips-runtime-test jobs hardcoded `uv run
--frozen` and `uv sync --all-extras --frozen` respectively. These failed
across the fleet for the same caller categories:

1. Repos without pyproject.toml at root: no error context to anchor on
2. uv-managed repos with no uv.lock yet: --frozen requires uv.lock
3. Poetry repos (PromptCraft, ledgerbase, data_ingestor, pp-security-master):
   uv cannot read poetry-locked projects

Fix: add a Detect repo state step to each job that examines pyproject.toml +
lockfile presence and emits one of four states (skip, uv-locked, uv-no-lock,
poetry-not-supported). Subsequent uv commands gate on the detected state and
swap the --frozen flag in via FROZEN_FLAG env. Poetry repos fail fast with an
actionable error pointing at the migration tracking issues.

Affected jobs:
- fips-check (Run FIPS compatibility check step, lines 181 + 190 of original):
  uv run --frozen --> uv run $FROZEN_FLAG, gated on detect state
- fips-runtime-test (Install dependencies + Test crypto imports steps): same
  pattern as python-compatibility.yml

Impact: repairs FIPS Compatibility across 6 uv repos (maester-tests, dna,
GCS, monte_carlo, testing, zen-mcp-server). The 4 Poetry repos
(PromptCraft, ledgerbase, data_ingestor, pp-security-master) surface the
new actionable error directing to their migration tracking issues
(williaby/PromptCraft#328, williaby/ledgerbase#147,
williaby/data_ingestor#38, ByronWilliamsCPA/pp-security-master#38).

Reference: docs/audits/cve-scan-coverage-2026-05-25.md addendum
(CI Repair Sprint, Task 9 in current session).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* refactor(python-fips): collapse install steps via FROZEN_FLAG env + NOSONAR S8541

Follow up to PR #156 team feedback. Step-level branching for uv-locked vs
uv-no-lock just shuffles the S8541 finding to the without-frozen branch
(allowing builds is intentional and configurable via the no-build input).
Collapsing to a single Install dependencies step with FROZEN_FLAG env var
indirection plus # NOSONAR S8541 suppression matches the established
convention in line 292 of python-compatibility.yml and halves the YAML
maintenance surface.

Test crypto imports step already used the FROZEN_FLAG pattern; no change
needed there.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(quality): suppress S8541/S8544 in python-fips with rationale; tighten gates

Mirrors the eecbaa3 pattern already on python-compatibility.yml main.
Restores the SonarCloud Quality Gate (Security Rating A on new code) and
closes the structural gaps the pr-review surfaced.

fips-check job (no install step pre-generates uv.lock, so $FROZEN_FLAG
must remain dynamic; suppression with rationale is the correct path):

1. Add multi-line rationale comment before the step explaining the
   env-var indirection SonarCloud cannot follow statically.
2. Suppress both uv run invocations with NOSONAR(S8541,S8544) plus inline
   rationale, replacing the previous absent suppression at lines 201, 210.
3. Add shell: bash to the run block for declaration consistency with the
   detect step above.
4. Add #ASSUME and #VERIFY RAD tags on the FROZEN_FLAG ternary per repo
   CLAUDE.md (mandatory for reusable workflow gating logic).

fips-runtime-test job (mirrors python-compatibility.yml exactly):

1. Split Install dependencies into uv-locked / uv-no-lock variants so the
   literal --frozen stays visible to the scanner on the locked path.
2. uv-no-lock variant carries NOSONAR(S8541,S8544) with rationale
   (replaces the previous incomplete `# NOSONAR S8541` at line 440).
3. Test crypto imports: drop FROZEN_FLAG env, use literal --frozen with
   inline NOSONAR(S8541). Safe because the install step above always
   produces uv.lock before this step runs.
4. Add shell: bash to all new run steps.

Tighten if: gates to avoid false failures and noisy artifact warnings:

5. Upload FIPS report: add detect-state condition so docs-only callers
   (state=skip) and poetry-not-supported callers do not emit upload-
   artifact "No files were found" warnings when the FIPS check produced
   no report.
6. Check result: add detect-state condition so skip / poetry-not-supported
   callers do not trigger a false failure from the empty exit_code output
   (`empty != '0'` would otherwise evaluate true).

Verified locally:
- pre-commit clean (yamllint, secrets, em-dash checks)
- YAML structurally valid
- All six SonarCloud open vulnerabilities (S8541 + S8544 at lines 201,
  210, 449, 440) addressed with the suppression style python-compatibility
  uses on main.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* docs: empirical findings on SonarCloud NOSONAR placement in GHA YAML

Captures the observation that preceding-line NOSONAR comments inside a
YAML pipe block scalar do NOT suppress S8544 when the next line uses a
dynamic flag (FROZEN_FLAG), even though the same placement pattern DOES
suppress S8541 when the next line carries the literal --frozen token.

Inline NOSONAR on a YAML run: line works for any rule combination. The
team has multiple reusable workflows using these rules; this doc gives
them the verification protocol and the recommended patterns up front so
the next remediation does not iterate empirically.

Source data:
- python-compatibility.yml on main: inline + preceding-line patterns,
  quality gate passing
- python-fips-compatibility.yml in PR #157 commit e797676: preceding-line
  NOSONAR(S8541,S8544) inside a pipe block left 4 of 6 vulnerabilities
  unsuppressed

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(quality): restructure fips-check to expose literal --frozen for SonarCloud

Phase C re-fix following commit e797676. The preceding-line
NOSONAR(S8541,S8544) inside the fips-check pipe block was not honored by
SonarCloud (still flagged lines 210, 220). Restructure to mirror the
python-compatibility.yml sibling exactly: add install steps before the
FIPS check, then use literal --frozen on the uv run lines (Pattern A
from docs/sonarcloud-nosonar-patterns.md).

Changes to fips-check job:

1. Add Install dependencies (uv with lockfile) step gated on
   state=uv-locked, using literal uv sync --all-extras --frozen
   NO_BUILD_FLAG. No suppression needed; literal --frozen is visible.

2. Add Install dependencies (uv without lockfile) step gated on
   state=uv-no-lock, using uv sync --all-extras NO_BUILD_FLAG with
   inline NOSONAR(S8541,S8544) and rationale.

3. Run FIPS compatibility check: drop FROZEN_FLAG env var, use literal
   uv run --frozen NO_BUILD_FLAG python SCRIPT_PATH on both
   invocations. Add NOSONAR(S8541) as a preceding bash comment in
   the pipe block (Pattern B from the same doc).

4. Update preamble comment to reflect new structure; keep ASSUME and
   VERIFY RAD tags pointing at the install steps.

Trade-off: adds 1-2 min of cache-friendly install runtime per
fips-check job invocation that previously skipped it. Acceptable for
the deterministic suppression behavior; matches the sibling design.

Verified locally: pre-commit clean (yamllint, em-dash, secrets);
FROZEN_FLAG completely removed from the file.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 25, 2026
…g uv sync/run --frozen

Same pattern as PR #156 (python-compatibility.yml) and #157 (python-fips-compatibility.yml).

Root cause: codeql and python-security (Bandit) jobs hardcoded
`uv sync --frozen` and `uv run --frozen`, which failed on three caller
categories: repos without pyproject.toml (DeQA-Doc), uv-managed repos
without uv.lock yet, and Poetry repos (uv cannot parse poetry projects).

Fix: detect-state step + gated install/run steps in both jobs (codeql,
python-security). Each job has its own Detect step because every job
runs on a fresh runner with a fresh checkout. The detect step exits 1
with an actionable error for Poetry repos, prints a job summary notice
when pyproject.toml is absent, and drops --frozen when uv.lock is not
yet present.

Impact: repairs Security Analysis across the uv repos in the fleet. The 4
Poetry repos (PromptCraft, ledgerbase, data_ingestor, pp-security-master)
surface the new actionable error directing to their migration tracking
issues (williaby/PromptCraft#328, williaby/ledgerbase#147,
williaby/data_ingestor#38, ByronWilliamsCPA/pp-security-master#38).

Reference: docs/audits/cve-scan-coverage-2026-05-25.md (CI Repair Sprint).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 25, 2026
…nv + NOSONAR S8541

Follow up to PR #156 team feedback. Step-level branching for uv-locked vs
uv-no-lock just shuffles the S8541 finding to the without-frozen branch
(allowing builds is intentional and configurable via the no-build input).
Collapsing to a single Install dependencies step with FROZEN_FLAG env var
indirection plus # NOSONAR S8541 suppression matches the established
convention in python-mutation.yml (lines 159-169) and halves the YAML
maintenance surface.

Applied to both codeql and python-security jobs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 25, 2026
…-frozen

Same pattern as PR #156 (python-compatibility.yml) and #157 (python-fips-compatibility.yml).

Root cause: the quality-checks and matrix-testing jobs ran `uv sync --all-extras --frozen` and `uv run --frozen` unconditionally, crashing on (1) repos without pyproject.toml, (2) uv-managed repos without uv.lock yet, and (3) Poetry repos that should not be served by this uv-only workflow. Added a Detect repo state step in both jobs that emits one of four states (skip, uv-locked, uv-no-lock, poetry-not-supported) and gated every install and test step on that state. uv run sites now read FROZEN_FLAG from the detect step so the --frozen flag is dropped only when no lockfile exists. The Validate source layout precondition (per project_python_ci_audit_2026_05.md) is preserved unchanged. The llm-governance job does not use uv and was not modified.

Impact: repairs CI across the uv repos in the fleet. The 4 Poetry repos
(PromptCraft, ledgerbase, data_ingestor, pp-security-master) surface the
new actionable error directing to their migration tracking issues
(williaby/PromptCraft#328, williaby/ledgerbase#147,
williaby/data_ingestor#38, ByronWilliamsCPA/pp-security-master#38).

Reference: docs/audits/cve-scan-coverage-2026-05-25.md (CI Repair Sprint).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 25, 2026
…ONAR S8541

Follow up to PR #156 team feedback. Step-level branching for uv-locked vs
uv-no-lock just shuffles the S8541 finding to the without-frozen branch
(allowing builds is intentional and configurable via the no-build input).
Collapsing to a single Install dependencies step with FROZEN_FLAG env var
indirection plus # NOSONAR S8541 suppression matches the established
convention in python-mutation.yml (lines 159-169) and halves the YAML
maintenance surface.

Applied to both quality-checks and matrix-testing jobs. The 9 downstream
uv run steps already used the FROZEN_FLAG pattern; only the 2 install
steps needed collapsing.

Layout-precondition hardening from project_python_ci_audit_2026_05 is
preserved untouched.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 25, 2026
…-frozen (#159)

* fix(python-ci): detect repo state instead of hardcoding uv sync/run --frozen

Same pattern as PR #156 (python-compatibility.yml) and #157 (python-fips-compatibility.yml).

Root cause: the quality-checks and matrix-testing jobs ran `uv sync --all-extras --frozen` and `uv run --frozen` unconditionally, crashing on (1) repos without pyproject.toml, (2) uv-managed repos without uv.lock yet, and (3) Poetry repos that should not be served by this uv-only workflow. Added a Detect repo state step in both jobs that emits one of four states (skip, uv-locked, uv-no-lock, poetry-not-supported) and gated every install and test step on that state. uv run sites now read FROZEN_FLAG from the detect step so the --frozen flag is dropped only when no lockfile exists. The Validate source layout precondition (per project_python_ci_audit_2026_05.md) is preserved unchanged. The llm-governance job does not use uv and was not modified.

Impact: repairs CI across the uv repos in the fleet. The 4 Poetry repos
(PromptCraft, ledgerbase, data_ingestor, pp-security-master) surface the
new actionable error directing to their migration tracking issues
(williaby/PromptCraft#328, williaby/ledgerbase#147,
williaby/data_ingestor#38, ByronWilliamsCPA/pp-security-master#38).

Reference: docs/audits/cve-scan-coverage-2026-05-25.md (CI Repair Sprint).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* refactor(python-ci): collapse install steps via FROZEN_FLAG env + NOSONAR S8541

Follow up to PR #156 team feedback. Step-level branching for uv-locked vs
uv-no-lock just shuffles the S8541 finding to the without-frozen branch
(allowing builds is intentional and configurable via the no-build input).
Collapsing to a single Install dependencies step with FROZEN_FLAG env var
indirection plus # NOSONAR S8541 suppression matches the established
convention in python-mutation.yml (lines 159-169) and halves the YAML
maintenance surface.

Applied to both quality-checks and matrix-testing jobs. The 9 downstream
uv run steps already used the FROZEN_FLAG pattern; only the 2 install
steps needed collapsing.

Layout-precondition hardening from project_python_ci_audit_2026_05 is
preserved untouched.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(quality): restructure python-ci to expose literal --frozen for SonarCloud

Applies the same restructure pattern landed in PR #157 (python-fips) and
PR #158 (python-security-analysis) to python-ci.yml. See
docs/sonarcloud-nosonar-patterns.md for the full background.

Changes across both jobs in python-ci.yml (quality-checks and
matrix-testing):

1. Split Install dependencies steps into uv-locked / uv-no-lock variants.
   uv-locked uses literal uv sync --all-extras --frozen $NO_BUILD_FLAG;
   uv-no-lock carries inline NOSONAR(S8541,S8544) with rationale.

2. Drop FROZEN_FLAG env var from every downstream step in both jobs:
   - Ruff formatter check, Ruff linter, BasedPyright
   - Dead code detection with Vulture
   - Unit / integration / security tests (3 pytest invocations)
   - Combined coverage report (4 coverage invocations)
   - Security scan with Bandit (2 invocations, if/else branches)
   - Dependency vulnerability scan with pip-audit (2 invocations)
   - Matrix test runner

3. Replace every $FROZEN_FLAG with literal --frozen on uv run lines.

4. Add # NOSONAR(S8541) as a preceding bash comment to every uv run line
   in the run: blocks (17 total).

5. Update the echo error-message hint in Ruff formatter check from
   uv run $FROZEN_FLAG to uv run --frozen so the displayed remediation
   command matches what the workflow now executes.

Trade-off: matches sibling design. No new install runtime; the install
step was already running unconditionally on every CI job. Quality
gate should flip to A on new code after re-analysis.

Verified locally: pre-commit clean (yamllint, em-dash, secrets,
commitizen); FROZEN_FLAG completely removed from the file; no empty
env: blocks; indentation preserved across if/else shell branches.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 25, 2026
…g uv sync/run --frozen

Same pattern as PR #156 (python-compatibility.yml) and #157 (python-fips-compatibility.yml).

Root cause: codeql and python-security (Bandit) jobs hardcoded
`uv sync --frozen` and `uv run --frozen`, which failed on three caller
categories: repos without pyproject.toml (DeQA-Doc), uv-managed repos
without uv.lock yet, and Poetry repos (uv cannot parse poetry projects).

Fix: detect-state step + gated install/run steps in both jobs (codeql,
python-security). Each job has its own Detect step because every job
runs on a fresh runner with a fresh checkout. The detect step exits 1
with an actionable error for Poetry repos, prints a job summary notice
when pyproject.toml is absent, and drops --frozen when uv.lock is not
yet present.

Impact: repairs Security Analysis across the uv repos in the fleet. The 4
Poetry repos (PromptCraft, ledgerbase, data_ingestor, pp-security-master)
surface the new actionable error directing to their migration tracking
issues (williaby/PromptCraft#328, williaby/ledgerbase#147,
williaby/data_ingestor#38, ByronWilliamsCPA/pp-security-master#38).

Reference: docs/audits/cve-scan-coverage-2026-05-25.md (CI Repair Sprint).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 25, 2026
…nv + NOSONAR S8541

Follow up to PR #156 team feedback. Step-level branching for uv-locked vs
uv-no-lock just shuffles the S8541 finding to the without-frozen branch
(allowing builds is intentional and configurable via the no-build input).
Collapsing to a single Install dependencies step with FROZEN_FLAG env var
indirection plus # NOSONAR S8541 suppression matches the established
convention in python-mutation.yml (lines 159-169) and halves the YAML
maintenance surface.

Applied to both codeql and python-security jobs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 25, 2026
…g uv sync/run --frozen (#158)

* fix(python-security-analysis): detect repo state instead of hardcoding uv sync/run --frozen

Same pattern as PR #156 (python-compatibility.yml) and #157 (python-fips-compatibility.yml).

Root cause: codeql and python-security (Bandit) jobs hardcoded
`uv sync --frozen` and `uv run --frozen`, which failed on three caller
categories: repos without pyproject.toml (DeQA-Doc), uv-managed repos
without uv.lock yet, and Poetry repos (uv cannot parse poetry projects).

Fix: detect-state step + gated install/run steps in both jobs (codeql,
python-security). Each job has its own Detect step because every job
runs on a fresh runner with a fresh checkout. The detect step exits 1
with an actionable error for Poetry repos, prints a job summary notice
when pyproject.toml is absent, and drops --frozen when uv.lock is not
yet present.

Impact: repairs Security Analysis across the uv repos in the fleet. The 4
Poetry repos (PromptCraft, ledgerbase, data_ingestor, pp-security-master)
surface the new actionable error directing to their migration tracking
issues (williaby/PromptCraft#328, williaby/ledgerbase#147,
williaby/data_ingestor#38, ByronWilliamsCPA/pp-security-master#38).

Reference: docs/audits/cve-scan-coverage-2026-05-25.md (CI Repair Sprint).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* refactor(security-analysis): collapse install steps via FROZEN_FLAG env + NOSONAR S8541

Follow up to PR #156 team feedback. Step-level branching for uv-locked vs
uv-no-lock just shuffles the S8541 finding to the without-frozen branch
(allowing builds is intentional and configurable via the no-build input).
Collapsing to a single Install dependencies step with FROZEN_FLAG env var
indirection plus # NOSONAR S8541 suppression matches the established
convention in python-mutation.yml (lines 159-169) and halves the YAML
maintenance surface.

Applied to both codeql and python-security jobs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(quality): restructure python-security-analysis to expose literal --frozen for SonarCloud

Applies the same restructure pattern landed in PR #157 (python-fips-
compatibility.yml) to python-security-analysis.yml. See
docs/sonarcloud-nosonar-patterns.md for the full background; the short
version is that SonarCloud cannot follow $FROZEN_FLAG env-var
indirection, and preceding-line NOSONAR(S8541,S8544) inside a `|` block
is not honored.

Changes to both jobs in python-security-analysis.yml:

CodeQL job (lines 169-183):
1. Split Install dependencies into uv-locked / uv-no-lock variants.
   uv-locked uses literal `uv sync --no-dev --frozen $NO_BUILD_FLAG`;
   uv-no-lock carries inline NOSONAR(S8541,S8544) with rationale.

Python SAST (Bandit) job (lines 295-332):
2. Same Install split.
3. Bandit Static Analysis step: drop FROZEN_FLAG env, use literal
   `uv run --frozen $NO_BUILD_FLAG bandit ...` with preceding-line
   NOSONAR(S8541). Add shell: bash explicitly.

Trade-off: adds ~1-2 min of cache-friendly install runtime to the
uv-no-lock path on the CodeQL job; matches sibling design.

Verified locally: pre-commit clean (yamllint, em-dash, secrets);
FROZEN_FLAG completely removed from the file.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* chore(python-security-analysis): add reciprocal keep-in-sync pointer to detect-state block

The python-security job's detect-state block already references the codeql
job ("Same logic as the codeql job above; each job runs on its own
runner..."), but the codeql block had no reciprocal pointer. Adds a
one-line "Mirrored in the python-security job below; keep both blocks in
sync" comment so future edits in either direction surface the duplication
constraint.

Pure comment change; no behavior delta. Pre-commit clean.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 25, 2026
…run --frozen (#160)

Apply split-install detect-state pattern (validated by merged PRs #156, #157,
#159). Branches on pyproject.toml + lockfile presence: skip when no
pyproject (test job notice; release job fails fast), reject poetry repos
with actionable error, use literal --frozen on uv-locked path, no --frozen
on uv-no-lock path.

Avoids the dynamic-FROZEN_FLAG anti-pattern (preceding-line NOSONAR inside
run: block scalars is not honored by SonarCloud's githubactions rule set
for dynamic flags; see BWCPA/.github docs/sonarcloud-nosonar-patterns.md
delivered in PR #157).

Affects test job (1 install + 4 uv run steps) and release job (1 install
+ uv build + SBOM gen). publish-pypi job unchanged (uses uv publish only,
no --frozen).
williaby added a commit that referenced this pull request May 26, 2026
…nc --frozen

Apply the split-install detect-state pattern established by merged PRs #156-#160.
Branches on pyproject.toml + lockfile presence: skip when no pyproject, fail
fast on poetry repos with actionable error, use --frozen on uv-locked repos
and bare uv sync on uv-no-lock repos.

Install step is split into two if-guarded variants so SonarCloud sees literal
--frozen on the uv-locked path (S8544 cannot fire). The uv-no-lock variant
inlines NOSONAR(S8541,S8544) with rationale; uv.lock does not exist by design
on that path. The shell branching on extra-dependencies input is preserved
inside each install step (flattening to step variants would obscure intent).

The pytest run step uses literal --frozen with a preceding-line NOSONAR(S8541)
for --no-build only; this placement is honored when the underlying line is
otherwise clean per python-mutation.yml:159-169 precedent. Downstream analysis
steps (Verify coverage, SonarCloud Scan, Wait, Check Quality Gate, Quality Gate
Summary, Upload coverage artifacts, Fail on Quality Gate) gain detect-state
guards so the skip path exits the job cleanly.
williaby added a commit that referenced this pull request May 26, 2026
…njection

Addresses CodeQL alerts #182 and #183 (py/code-injection) and Important findings
from /pr-review on PR #166.

Critical:
- Map steps.extras.outputs.flag to env UV_EXTRAS on both install steps so it
  reaches bash as a variable value rather than being interpolated into the run:
  script via GitHub-side template expansion. Template expansion runs before bash
  sees the line; without env mapping, any shell metacharacters in flag would
  become script text. The flag derives from inputs.extra-dependencies, a
  caller-controlled reusable workflow input.
- Add #CRITICAL / #VERIFY RAD annotations near the install steps documenting
  the env-mapping invariant per project CLAUDE.md.

Pattern alignment with PRs #156/#158/#160:
- Remove NOSONAR(S8541) on the uv-locked install step. The canonical precedent
  keeps the locked install line bare on the rationale that literal --frozen
  makes the line scanner-clean; only the uv-no-lock branch carries NOSONAR.

Polish:
- Strip leading space in FLAG accumulator so the for-loop branch produces the
  same shape as --all-extras and empty branches.
- Escape ] explicitly in poetry detection regex for reader clarity (functional
  no-op; the original was correct ERE).
- Document why the downstream if: conditions use the positive disjunction
  (state == 'uv-locked' || state == 'uv-no-lock') rather than the shorter
  negative form; the negative form would incorrectly run downstream steps when
  steps.detect.outputs.state is empty after an upstream failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 26, 2026
The previous commit (6fa51ff) removed NOSONAR(S8541) on the uv-locked install
line on the assumption that it would match the #156/#158/#160 precedent of
keeping the locked-install line bare. SonarCloud's Quality Gate on PR #166
empirically rejected this assumption: S8541 (security rating C) fires on this
line regardless of the literal --frozen, because $NO_BUILD_FLAG remains a
dynamic env var.

Why this workflow differs from #156/#158/#160: the install steps in those PRs
likely resolve to a literal --no-build, no flag, or no install at all on the
locked path. python-sonarcloud.yml's locked install step uses dynamic
$NO_BUILD_FLAG (the no-build: workflow input is opt-out by design for PEP 517
consumers like hatchling), so S8541 matches.

Restored the inline NOSONAR(S8541) and updated the header comment to document
the empirical divergence so a future reader does not re-attempt the same
"match precedent" cleanup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
williaby added a commit that referenced this pull request May 26, 2026
* fix(python-sonarcloud): detect repo state instead of hardcoding uv sync --frozen

Apply the split-install detect-state pattern established by merged PRs #156-#160.
Branches on pyproject.toml + lockfile presence: skip when no pyproject, fail
fast on poetry repos with actionable error, use --frozen on uv-locked repos
and bare uv sync on uv-no-lock repos.

Install step is split into two if-guarded variants so SonarCloud sees literal
--frozen on the uv-locked path (S8544 cannot fire). The uv-no-lock variant
inlines NOSONAR(S8541,S8544) with rationale; uv.lock does not exist by design
on that path. The shell branching on extra-dependencies input is preserved
inside each install step (flattening to step variants would obscure intent).

The pytest run step uses literal --frozen with a preceding-line NOSONAR(S8541)
for --no-build only; this placement is honored when the underlying line is
otherwise clean per python-mutation.yml:159-169 precedent. Downstream analysis
steps (Verify coverage, SonarCloud Scan, Wait, Check Quality Gate, Quality Gate
Summary, Upload coverage artifacts, Fail on Quality Gate) gain detect-state
guards so the skip path exits the job cleanly.

* fix(python-sonarcloud): inline NOSONAR per uv sync line in uv-no-lock install step

Preceding-line NOSONAR(S8541,S8544) inside the uv-no-lock install step's
multi-line run block is not honored by SonarCloud's githubactions rule set
(documented anti-pattern in docs/sonarcloud-nosonar-patterns.md). Moving
suppression to inline trailing comments on each of the three uv sync lines
within the block. The step-level rationale moves into the header comment.

Verified: SonarCloud PR #166 flagged S8541 L293 + S8544 L293, L299, L301 (the
three uv sync lines). Lines 280 and 282 (uv-locked path, literal --frozen)
were NOT flagged, confirming preceding-line NOSONAR(S8541) is honored when
the underlying line is otherwise clean of S8544.

* fix(python-sonarcloud): collapse install steps to single-line for SonarCloud

SonarCloud's githubactions rule set ignores NOSONAR (both preceding-line
and inline) inside multi-line run: | blocks for S8541/S8544. Even with
inline trailing NOSONAR per uv sync line, PR #166 commit bb31ec1 still
flagged 5 vulnerabilities (L296, L302, L304).

Restructure: extract the EXTRA_DEPENDENCIES branching into a separate
Resolve extras flag step that outputs steps.extras.outputs.flag, then
collapse each install step to a single-line run: shape. This is the only
reliable Pattern A position for SonarCloud (per docs/sonarcloud-nosonar-patterns.md).

Two install steps remain (uv-locked, uv-no-lock); the resolve step
unconditionally handles all three extras-modes and outputs a literal
flag string consumed by both.

* fix(python-sonarcloud): map UV_EXTRAS via env to block GHA template injection

Addresses CodeQL alerts #182 and #183 (py/code-injection) and Important findings
from /pr-review on PR #166.

Critical:
- Map steps.extras.outputs.flag to env UV_EXTRAS on both install steps so it
  reaches bash as a variable value rather than being interpolated into the run:
  script via GitHub-side template expansion. Template expansion runs before bash
  sees the line; without env mapping, any shell metacharacters in flag would
  become script text. The flag derives from inputs.extra-dependencies, a
  caller-controlled reusable workflow input.
- Add #CRITICAL / #VERIFY RAD annotations near the install steps documenting
  the env-mapping invariant per project CLAUDE.md.

Pattern alignment with PRs #156/#158/#160:
- Remove NOSONAR(S8541) on the uv-locked install step. The canonical precedent
  keeps the locked install line bare on the rationale that literal --frozen
  makes the line scanner-clean; only the uv-no-lock branch carries NOSONAR.

Polish:
- Strip leading space in FLAG accumulator so the for-loop branch produces the
  same shape as --all-extras and empty branches.
- Escape ] explicitly in poetry detection regex for reader clarity (functional
  no-op; the original was correct ERE).
- Document why the downstream if: conditions use the positive disjunction
  (state == 'uv-locked' || state == 'uv-no-lock') rather than the shorter
  negative form; the negative form would incorrectly run downstream steps when
  steps.detect.outputs.state is empty after an upstream failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(python-sonarcloud): re-add NOSONAR(S8541) on uv-locked install line

The previous commit (6fa51ff) removed NOSONAR(S8541) on the uv-locked install
line on the assumption that it would match the #156/#158/#160 precedent of
keeping the locked-install line bare. SonarCloud's Quality Gate on PR #166
empirically rejected this assumption: S8541 (security rating C) fires on this
line regardless of the literal --frozen, because $NO_BUILD_FLAG remains a
dynamic env var.

Why this workflow differs from #156/#158/#160: the install steps in those PRs
likely resolve to a literal --no-build, no flag, or no install at all on the
locked path. python-sonarcloud.yml's locked install step uses dynamic
$NO_BUILD_FLAG (the no-build: workflow input is opt-out by design for PEP 517
consumers like hatchling), so S8541 matches.

Restored the inline NOSONAR(S8541) and updated the header comment to document
the empirical divergence so a future reader does not re-attempt the same
"match precedent" cleanup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants