Skip to content

Clean up audit scripts, redundant tests, and verbose comments - #224

Merged
aliencaocao merged 27 commits into
masterfrom
trim/cleanup
Dec 3, 2026
Merged

aliencaocao merged 27 commits into
masterfrom
trim/cleanup

Conversation

@aliencaocao

@aliencaocao aliencaocao commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Removed dead helpers, unused variables, and overly defensive checks across the audit shell scripts (audit-common.sh, cluster-audit-slurm.sh, cluster-audit-k8s.sh, cluster-audit-standalone.sh, host-check.sh, container-check.sh, security-fleet.sh, monitoring-k8s.sh) and core cmax Python modules.
  • Dropped legacy Python 3.9 typing workarounds in favor of Python 3.10+ syntax.
  • Stripped redundant comments and shortened verbose docstrings and inline bash comments across cmax/, cmax/scripts/1-audit/, and .github/.
  • Consolidated repetitive test functions with @pytest.mark.parametrize and shared runner/kubectl helpers and removed duplicate preflight and conftest self-tests (tests/audit/test_environment_preflight.py), reducing the codebase by 12,683 net lines (+8,580 / -21,263 across 102 files).
  • Synced README.md and README_zh.md dry-run YAML output, dev dependencies, and minimum-version schema notes with current CLI and pyproject.toml behavior.
  • Documented brief comment rules and proportional, behavior-focused, hermetic test conventions in AGENTS.md.
  • Preserved bash 3.2 compatibility, set -e safety around read, df, lsblk, and jq probes, unit-separator parsing for empty geo-IP fields, Slurm topology fallback, and PAM 2-field external IDP detection.

Validation

  • Unit and CI checks: pytest tests/ passes on Python 3.10 and 3.12 (2,306 passed, 2,065 subtests passed); tools/check_public_data.py passes; bash -n passes on all audit scripts; all 5 GitHub Actions checks pass (test, minimum-python, CodeQL, Analyze (python), Analyze (actions)).
  • Live Kubernetes (multi-node H100 cluster):
    • cmax audit --k8s -y: exit 0, 42/42 checks in 4m 44s (10 failed, 21 warnings, 35 passed, 45 skipped), audit.values.json passes audit.values.schema.json validation with no shell or jq errors in audit.out.
    • cmax audit security --k8s -y --exit-zero: exit 0, 41/41 checks in 4m 25s (8 failed, 13 warnings, 4 passed, 14 skipped).
  • Live Slurm (multi-node H100 cluster):
    • cmax audit --slurm -y: exit 0, 78/78 checks in 2m 35s (7 failed, 33 warnings, 32 passed, 43 skipped), networking.topologyConfigured=true, no shell or jq errors in audit.out.
    • cmax audit security --slurm -y --exit-zero: exit 0, 77/77 checks in 2m 23s (4 failed, 22 warnings, 3 passed, 10 skipped).
  • Live Standalone:
    • Single H100 compute node: cmax audit --standalone -y --run-here exit 0, 56/56 checks in 25s (5 failed, 23 warnings, 13 passed, 74 skipped), no shell or jq errors in audit.out.
    • Bare-metal Ubuntu 26.04 host (4x RTX PRO 6000 GPUs): verified standalone audit, security audit, NIC topology, and virtio-net collectors with zero regressions.
  • Not run live: AMD/ROCm hardware paths (verified by unit tests and code review).

Note

Low Risk
Changes are overwhelmingly documentation and comment edits with minor refactors; audit grading logic and CI minimum-version workflows are functionally unchanged per the author's validation.

Overview
This PR is primarily a large-scale comment and docstring trim across cmax/, cmax/scripts/1-audit/, and .github/ workflows/scripts, aligned with new AGENTS.md rules that comments must stay shorter than the code they describe and that tests should target observable behavior without prose-pinning.

Beyond wording, changes are mostly small refactors with no intended behavior change: shared _display_bool in audit_report.py, merged duplicate failure handling in audit_runner.py, consolidated Kubernetes nodeInfo jq parsing and a reusable security-version fallback JSON in audit-common.sh, and condensed shell helpers (e.g. one-line print_* functions).

README / README_zh dry-run YAML examples and dev-dependency notes are synced with current CLI output (extra security checks in the sample lists, jsonschema in dev deps, minimum-table schema fallback wording). The internal ClusterMAX-internal sync note is removed from AGENTS.md.

Reviewed by Cursor Bugbot for commit 1421ec6. Bugbot is set up for automated code reviews on this repo. Configure here.

@aliencaocao
aliencaocao marked this pull request as ready for review December 3, 2026 14:05
@aliencaocao
aliencaocao merged commit 607e923 into master Dec 3, 2026
5 checks passed
@aliencaocao
aliencaocao deleted the trim/cleanup branch December 3, 2026 14:05
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.

1 participant