fix(compliance): record unreadable alert counts as unknown, not 0
Problem
The health-survey job of compliance-audit-and-improvement.yml read dependabot/alerts, secret-scanning/alerts and code-scanning/alerts and turned any gh error into a count of 0. Until 2026-10-29 ORG_SCORECARD_TOKEN lacked code-scanning read (surfaced by the combsmith/.github#1411 dry run), so every repo's code_scanning_open was silently 0 and the weighted finding_score under-counted. The token is fixed, but the next permission, rate-limit or API failure would be just as silent. The reads also took only the first page, so counts capped at 30.
Change
scripts/lib/health-alerts.sh(new) — the alert reads move out of inline YAML (AGENTS.md "Decision Logic Lives in a Pure, Tested Script"):health_alert_error_kind— classifies a failed read. Only GitHub's "no analysis found" / Advanced Security not enabled (code scanning, mirroringalerts_error_kind()inscripts/codeql-audit.sh), "Dependabot alerts are disabled" and "Secret scanning is disabled" mean 0; matched per endpoint. Anything else is an error.health_alert_count—gh api --paginate …?state=open&per_page=100; echoes the count,0for the disabled cases, ornullplus a::warning::on failure. A failure mid-pagination is unknown, never a partial count.health_security_json/health_findings_score— per-reposecurityobject and weighted score.
- Per-repo JSON:
securitygainsdependabot_read_error,secret_scanning_read_error,code_scanning_read_errorandunknown_counts; an unreadable count isnull. Report gains top-levelrepos_with_unknown_alert_counts. - Surfacing: step summary lists repos with unreadable counts;
has_findingsis true when any count is unknown; the Claude analysis prompt says unknown ≠ zero, no per-repo alert issues from a null count, and one deduplicated telemetry-gap issue in this repo instead. health-surveynow checks out this repo (actions/checkoutv7.0.1, SHA verified via the GitHub API,persist-credentials: false) to source the lib.compliance-audit-tests.ymlshellchecks the lib; its bats suite already coverstest/scripts/compliance-audit/and triggers onscripts/lib/**.
Verification
bats test/scripts/compliance-audit/health-alerts.bats— 26/26 pass (classification, pagination, stubbed-ghsuccess/403/disabled/mid-pagination failure, JSON shape, score).shellcheck --severity=warningon the lib: clean.actionlint: no new findings (the four SC2129 style notes exist on main).test/workflows/compliance-audit/fleet-pause suite: pass.- Ran the real
collectstep locally againstcombsmith/.github-private:- live:
code_scanning_open: 49(old code capped at 30), no read errors. - with a
ghshim returning 403 for code-scanning:code_scanning_open: null,code_scanning_read_error: true,repos_with_unknown_alert_counts: 1, summary lists the repo,has_findings=true.
- live:
Not verified live: the exact Dependabot/secret-scanning "disabled" and code-scanning "Advanced Security must be enabled" message texts — no org repo currently has those features off. If GitHub words them differently, the effect is fail-safe: the count shows as unknown, not as 0.
🤖 Generated with Claude Code