Repository navigation
Code health with ai-health: strict profile, delta gate, ruff - #3
Merged
Merged
Conversation
added 10 commits
November 23, 2026 21:14
Own 1-10 score per file and per part (python-cli, python-tests, shell, ansible), modelled on CodeScene Code Health with the published Python defaults; standard library plus PyYAML. `python3 -m code_health` / `uvx nox -s code-health` with --json and --changed; --gate in the pre-commit hook and the CI unit job; code-health-baseline.json as the ratchet below 9.5. Docs in docs/code-health.md, AGENTS.md section, two reviewed skills from skills.sh. OpenSpec change code-health.
Owner decision Q9: at CodeScene's 30 % the rule fired for 26 of 33 judged python-cli files; at 50 % it flags files where most arguments are primitives.
…mponent check Owner decision 2026-11-23: ai-health (pinned commit in scripts/aihealth) replaces the own checker, which stays as a cross-check for now. OpenSpec change updated accordingly.
Owner decision 2026-11-23 (Q8, Q9): one Python linter and formatter in all repositories; black's formatting and flake8's rules and line length kept, structure rules off because ai-health is the only source for those findings.
docs/code-health.md and its Steckbrief describe the ai-health setup; the own checker no longer gates (hook and CI step removed) and stays as a report until its removal. Skills approved by the owner on 2026-11-24.
- CI pre-commit job skips aihealth-delta (no uv there; the code-health job gates the delta), uv pinned, merge base in its own step - wrapper: paths go only to their component, ROOT from the script's location, usage errors exit 2, clear hint without uvx - component check: a drop of exactly 0.01 passes (rounding) - docs, spec and design name the excludes and the final measurements
test_homelab_node_role needs ansible.posix; the unit jobs installed the collections only after pytest (failing on main as well). Also drops the full fetch depth the unit job no longer needs.
ditschi
marked this pull request as ready for review
November 24, 2026 00:24
added 5 commits
November 24, 2026 01:37
… pin Owner rule 2026-11-24: no own logic where ai-health can do it. Hooks, CI and nox call ai-health per component with --config; the component score comparison stays because ai-health has none. No cosmetic type aliases; AGENTS.md says type hints are never weakened to silence a smell.
…raw subcommand Covered by a test of the exact ai-health calls.
Steckbrief worst files from main, merge-base wording, the tests delta hook in the pre-commit-checks spec, history labels in tasks.md, an exact type hint for the component totals.
Owner decision Q6 (2026-11-26): deleting a healthy file lowered the LoC-weighted mean and failed the CI check; new and changed files are judged per file by aihealth delta.
…/ai-health#4) Owner decision Q18.1 (2026-11-26): two configs in all repositories until ai-health supports overrides per path; no primitive-obsession suppressions in test code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of two PRs for the OpenSpec change
code-health(openspec/changes/code-health/). The refactorings toward score 10 follow in a second PR.What
033d186(v0.4.0).scripts/aihealthis the only place with the pin and passes every argument through (exec uvx ...).python-cliandshellwith.aihealth.toml(profile strict: CodeScene thresholds, file 600 lines, primitive obsession 30 %, decay 8, density_loc 100000, tolerance 0),python-testswith.aihealth-tests.toml(same profile; excess arguments, primitive obsession and low cohesion off).tests/unit/test_aihealth_config.pykeeps the shared sections equal.aihealth-deltaandaihealth-delta-tests(delta --stagedper component) andaihealth-suppression-reason(pygrep:# aihealth: disable=<smell> -- <reason>). CI jobcode-health:deltaper component against the merge base, component score comparison, scan report, uv and grammar cache. The CIpre-commitjob skips the two delta hooks (no uv there;--stagedchecks nothing in CI).docs/code-health.md: Ansible (ansible-lint only), Python scripts without extension (Detect extensionless Python scripts by shebang (like shell scripts) epatel/ai-health#3), test smells, third-party skills.code_health/) is removed, following the owner rule "no own logic where a tool exists"; its measurements are kept in design.md and the Steckbrief.skills-lock.json, excluded from pre-commit and ai-health).AGENTS.mdsection (incl. "never weaken type hints to silence a smell"),docs/code-health.mdwith the Steckbrief, CI unit jobs install the Ansible collections before pytest.Own logic that remains, and why
scripts/aihealth(oneexecline): the single pin for hook, CI and nox.scripts/aihealth_components.py(~95 LoC + tests): ai-health has no language filter and no comparison between two revisions; the script splits the scan JSON into components and compares merge base and head (owner decision Q6).tests/unit/test_aihealth_config.py: ai-health reads exactly one config per call (no include), so the duplicated profile sections are guarded.Reviews
Two independent reviews (fresh reviewer, only diff, repo and AGENTS.md).
scan --reportwriting one report per component is intended.machine_cli/machineis not seen by ruff (itsuv run --scriptshebang is not tagged as Python) - pre-existing, black did not see it either.uvx nox -s code-healthscans four times (text report plus the component JSON) - acceptable for a manual command. 'The component comparison failed when a healthy file was deleted; fixed in dfd82b8 by comparing only files present in both revisions (owner decision Q6).'Validation
pytest tests/unit/test_aihealth_config.py tests/unit/test_aihealth_components.py -q: green; fullpytest tests/unit -qgreen except pre-existingtest_device_tunnel.pyand load-dependent pty flakes intest_command_prefix.py.scripts/aihealth delta --base "$(git merge-base origin/main HEAD)" --head HEAD --config ...for both components andscripts/aihealth_components.py --compare ...: pass.openspec validate code-health --strict: valid.apt-rpi-zero (26.04)andapt-home-laptopfail exactly as on main (zsh health check seesgit-credential-env: GITHUB_TOKEN is not set); 'not caused by this PR. Owner decision: this PR waits until that zsh startup error is fixed in its own change, then merges on fully green CI.'🤖 Generated with Claude Code