Skip to content

Gate complexity and test strength with PSComplexity and PSMutant - #119

Merged
mvaneijken merged 3 commits into
mainfrom
ccr-5a55522e-x59sy1
Oct 10, 2026
Merged

mvaneijken merged 3 commits into
mainfrom
ccr-5a55522e-x59sy1

Conversation

@mvaneijken

Copy link
Copy Markdown
Collaborator

Measures what the build did not: whether a function has become too
tangled to reason about, and whether a test would notice a fault.

  • Pin Pester 6.2.0, PSComplexity 0.5.1 and PSMutant 0.5.0 exactly, with
    InstallModules.ps1 as the only module list (build.ps1 now calls it).
  • Complexity: 15 cyclomatic / 15 cognitive per unit, with the 32 units
    already over that recorded in complexity-baseline.json (ratchets down).
  • Mutation: psmutant.config.json maps each source file to the tests that
    name its functions, generated and -Check'ed by
    Build/Update-MutationConfig.ps1. Floor 75% from the first measurement.
  • Pull request: QualityChanged judges only the changed files, on the pwsh
    leg, after the tests; skips itself when nothing it measures changed.
  • Weekly: quality-weekly.yml runs both gates on the whole tree and files
    (or updates, or closes) a bug per gate.

Refs #91

Measures what the build did not: whether a function has become too
tangled to reason about, and whether a test would notice a fault.

- Pin Pester 6.2.0, PSComplexity 0.5.1 and PSMutant 0.5.0 exactly, with
  InstallModules.ps1 as the only module list (build.ps1 now calls it).
- Complexity: 15 cyclomatic / 15 cognitive per unit, with the 32 units
  already over that recorded in complexity-baseline.json (ratchets down).
- Mutation: psmutant.config.json maps each source file to the tests that
  name its functions, generated and -Check'ed by
  Build/Update-MutationConfig.ps1. Floor 75% from the first measurement.
- Pull request: QualityChanged judges only the changed files, on the pwsh
  leg, after the tests; skips itself when nothing it measures changed.
- Weekly: quality-weekly.yml runs both gates on the whole tree and files
  (or updates, or closes) a bug per gate.

Refs #91
Copilot AI balanced review requested due to automatic review settings October 10, 2026 12:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It is large CI-gating infrastructure the author notes was never validated on Windows and that carries a confirmed step-summary bug plus several stated open risks, warranting human review.

2 open findings
What changed in this PR

This PR adds two new CI quality gates to the OmadaWeb.PS PowerShell module (refs #91): complexity (via PSComplexity, with a ratcheting complexity-baseline.json) and test strength / mutation testing (via PSMutant, driven by a generated psmutant.config.json). On a pull request both gates run only on changed files on the pwsh leg; a weekly workflow runs both across the whole tree and files/updates/closes a quality-gate bug per gate. Module installation is consolidated into Build/InstallModules.ps1 with Pester 6.2.0, PSComplexity 0.5.1 and PSMutant 0.5.0 pinned exactly.

Changes:

  • Consolidate the build's module list into InstallModules.ps1 (pinned versions) and have build.ps1 call it.
  • Add psake tasks (Complexity, ComplexityChanged, Mutate, MutateChanged, MutationConfigCheck, QualityChanged) plus verdict/report helpers.
  • Add the generated mutation map, complexity baseline, a config generator/checker, and PR + weekly workflows, documented in CONTRIBUTING.md.
File Description
psmutant.config.json Generated source→test mutation map; verified consistent with disk and the generator (-Check passes).
CONTRIBUTING.md Documents the two gates and the baseline/map workflow; minor grammar nit noted.
complexity-baseline.json Records the 32 units currently over the 15/15 ceilings.
Build/​Update-MutationConfig.ps1 AST-based generator/checker for the mutation map.
Build/​psakeBuild.ps1 New quality tasks + helpers; contains a -f precedence bug affecting the step summary.
Build/​InstallModules.ps1 Single pinned module list, PS-version aware.
Build/​build.ps1 Delegates installs to InstallModules.ps1; imports pinned Pester.
.github/​workflows/​quality-weekly.yml Weekly whole-tree gates that file/close quality-gate bugs.
.github/​workflows/​pr-validation.yml Runs QualityChanged and uploads reports on the pwsh leg.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Build/psakeBuild.ps1 Resolved
Comment thread CONTRIBUTING.md Resolved
…sentence

The -f operator took the blank line and the summary as format arguments,
so only the heading reached GITHUB_STEP_SUMMARY.

Refs #91
Copilot AI balanced review requested due to automatic review settings October 10, 2026 12:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It is a large CI/build change that gates merges on external tools (PSComplexity/PSMutant) whose runtime API and report contracts cannot be verified here, and the author lists open risks (not yet run on Windows, source-mode mutation baseline), so human validation is warranted.

0 open findings

2 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Low severity Missing "that" in step-summary phrase

Build/​psakeBuild.ps1:653

This step-summary/bug-report detail string reads "Source files no test names", which is missing the relative pronoun used elsewhere. The same phrasing was corrected in CONTRIBUTING.md (line 97: "Source files that no test names are listed under _untested"), so this instance is now inconsistent with it. Consider adding "that" for consistency.

🧠 Review effort: Balanced

Copy link
Copy Markdown
Collaborator Author

/validate


Generated by Claude Code

The exponential-backoff test measured the gap between attempts, which
holds everything else that ran in between as well. On the Windows
PowerShell leg of PR validation that overhead was about 0.3s on the first
retry, so the first gap (1.32s) came out longer than the second (1.18s)
although the requested delays - [0.5s, 1.0s] and [1.0s, 2.0s] - were in
order. The test now captures what Invoke-OmadaRetryableRequest asks
Start-Sleep for and checks both ranges, as the neighbouring overflow test
already does. It still fails when the backoff stops being exponential,
and no longer sleeps three seconds.

Refs #91

Copy link
Copy Markdown
Collaborator Author

/validate


Generated by Claude Code

Copilot AI balanced review requested due to automatic review settings October 10, 2026 14:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Collaborator Author

copilot-pull-request-reviewer failed on 0560aa3, and the failure is not caused by this PR. The job hit Copilot's weekly rate limit (HTTP 429, "weekly rate limit … reset on October 12, 2026") before it reviewed anything. No fix exists on this side. The review can be re-requested once the limit resets. Re-running before then would hit the same limit, so the job has not been re-run. PR Validation on 0560aa3 is still running and is tracked separately.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

/validate


Generated by Claude Code

@mvaneijken
mvaneijken merged commit dd8c4ab into main Oct 10, 2026
3 of 4 checks passed
@mvaneijken
mvaneijken deleted the ccr-5a55522e-x59sy1 branch October 10, 2026 15:26
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.

3 participants