Skip to content

Add mutation and CRAP quality indicators#64

Open
jmcte wants to merge 8 commits into
mainfrom
codex/quality-mutation-crap
Open

Add mutation and CRAP quality indicators#64
jmcte wants to merge 8 commits into
mainfrom
codex/quality-mutation-crap

Conversation

@jmcte
Copy link
Copy Markdown
Contributor

@jmcte jmcte commented May 23, 2026

Summary

Adds a lightweight quality gate for mutation testing and CRAP-style hotspot reporting.

Refs #55.

Changes

  • Add scripts/ci/run-quality-indicators.sh.
  • Add scripts/quality/crap_indicator.py, a dependency-free Rust function hotspot reporter that uses the CRAP formula and optional LCOV coverage.
  • Detect ordinary Rust functions plus qualified forms such as async fn, const fn, unsafe fn, and extern "C" fn.
  • Ignore bodyless trait/prototype declarations, including multiline generic declarations, and keep declaration skipping separate from concrete Rust body completion.
  • Document mutation testing with cargo-mutants and coverage-backed CRAP reporting with cargo-llvm-cov in docs/QUALITY_GATES.md.
  • Wire the quality indicator test wrapper into scripts/ci/run-fast-checks.sh so the new tooling is covered by the existing cheap PR gate.

Verification

  • python3 scripts/quality/crap_indicator.py --self-test - passed
  • ./scripts/test-quality-indicators.sh - passed
  • bash scripts/ci/run-quality-indicators.sh - passed and produced a conservative 0%-coverage CRAP hotspot report
  • bash scripts/ci/run-fast-checks.sh - passed
  • git diff --check - passed

Notes

Mutation testing is opt-in via APW_RUN_MUTATION=1 because it is intentionally slower than PR Fast CI and requires cargo-mutants on the runner. Coverage-backed CRAP scoring is opt-in via APW_RUN_COVERAGE=1 and requires cargo-llvm-cov.

@jmcte jmcte requested a review from pheidon as a code owner May 23, 2026 21:06
@athena-omt athena-omt added area:infra Infrastructure, CI, release, governance, scripts, or repo setup. lane:daedalus Daedalus implementation/forge lane. review:athena Athena review governance requested. risk:medium Medium-risk change; normal care required. state:waiting-checks Waiting for CI/check status to settle. status:needs-review PR is ready for Athena review. labels May 23, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a266231a23

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/quality/crap_indicator.py Outdated
Comment on lines +108 to +112
if "{" in line:
seen_body = True
depth -= line.count("}")
if seen_body and depth <= 0:
break
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Ignore bodyless fn declarations in CRAP parsing

parse_functions treats every fn match as a concrete function body and keeps scanning until it sees a {/} balance, which misparses trait/prototype declarations like fn strategy(&self) -> &'static str; (e.g., in rust/src/daemon.rs). In that case it creates a synthetic metric spanning unrelated lines and skips subsequent declarations, so hotspot ordering and coverage attribution become inaccurate for files containing trait method signatures.

Useful? React with 👍 / 👎.

@pheidon pheidon added state:needs-repair PR needs repair before review can proceed. codex:P2 Codex Connector P2 finding. priority:P2 Codex Connector P2; blocks execution until Athena validates. and removed state:waiting-checks Waiting for CI/check status to settle. labels May 24, 2026
@athena-omt athena-omt added the state:waiting-checks Waiting for CI/check status to settle. label May 24, 2026
jmcte added 6 commits May 24, 2026 03:21
…n-crap

# Conflicts:
#	scripts/ci/run-fast-checks.sh
Extract the bodyless function declaration predicate and extend the self-test with a multiline generic trait method so CRAP metrics do not attribute declarations as concrete Rust function bodies.
Use an explicit helper for closed function bodies so declaration skipping remains separate from concrete Rust body parsing.
Move function body scanning into a dedicated helper that returns whether a concrete body was found, keeping bodyless declarations from participating in metric generation.
@jmcte jmcte removed state:waiting-checks Waiting for CI/check status to settle. state:needs-repair PR needs repair before review can proceed. labels May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:infra Infrastructure, CI, release, governance, scripts, or repo setup. codex:P2 Codex Connector P2 finding. lane:daedalus Daedalus implementation/forge lane. priority:P2 Codex Connector P2; blocks execution until Athena validates. review:athena Athena review governance requested. risk:medium Medium-risk change; normal care required. status:needs-review PR is ready for Athena review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants