Skip to content

fix(#69): audit stops on API errors, fails dangling pointers, scans workflow comments - #71

Merged
enricopiovesan merged 1 commit into
bootstrap-governancefrom
claude/issue-69-audit-gaps
Nov 23, 2026
Merged

enricopiovesan merged 1 commit into
bootstrap-governancefrom
claude/issue-69-audit-gaps

Conversation

@enricopiovesan

@enricopiovesan enricopiovesan commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #69. Fixes the gaps the fallback reviews of #68 and registry#680 found in the org audit, and the drift it could not see.

Governing Spec

no-spec-needed (governance compliance; the rules are in docs/ai-agent-hardening.md)

Project Item

Refs #69 (Project 1, In Progress, agent:claude, claimed with claim.sh).

What Changed

  • API errors stop the audit. has_file and a new fetch helper send gh stderr to a temp file. A 404 still means "absent"; any other failure (5xx, rate limit) prints audit incomplete: GitHub API error reading <repo>/<path> and exits 2. The tags read and the workflow directory listing are covered too. Before, a transient error on CLAUDE.md, AGENTS.md or the constitution turned the size-cap, prose and copy cells green.
  • Dangling pointer fails. AGENTS.md → CLAUDE.md requires CLAUDE.md to exist.
  • Wider prose-version check. Also matches a version written before the word (v1.3.0 of governance, 1.6.0 .github), and scans the comment lines of .github/workflows/*.yml|*.yaml. Code lines (uses: ...@v1.6.0, actions/checkout@v4.2.0) are not scanned.
  • Root cause of the workflow drift. rollout_governance.sh wrote (governance $VERSION) into the header comment of every generated cla.yml / governance.yml. It now points at .governance-version instead.
  • org-audit.yml appends audit errors to the report, so an exit-2 run does not open an issue with a partial table and no reason.
  • CHANGELOG: [Unreleased] entry; the 1.6.0 entry now says "five" drift checks. Test script is executable.

No release tag: consuming repos keep their v1.6.0 pin, and org-audit.yml runs the script from this branch.

Live run (this branch)

traverse, registry, reference-apps, claude-skills and website now fail "no prose versions" on the (governance v1.0.1) / (governance v1.2.0) header comment the old rollout template wrote into their cla.yml / governance.yml. repo-template and .github pass. Follow-up PRs in those five repos drop the comment (traverse's pin to v1.6.0 is still the maintainer's step).

Validation

  • bash scripts/org/audit_compliance_test.sh: 29 checks pass. New: dangling pointer, version-before-word, workflow comment, workflow code lines not flagged, and HTTP 500 on CLAUDE.md, AGENTS.md, .governance-version, dependabot.yml, the constitution, the workflow listing and the tags (each exits 2).
  • The new test file run against the old audit_compliance.sh fails all 10 new cases.
  • bash -n on all changed scripts; org-audit.yml parses as YAML.

🤖 Generated with Claude Code

…orkflow comments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@enricopiovesan

Copy link
Copy Markdown
Contributor Author

This is a post-merge review. The PR merged at 2026-11-23T21:17Z without a review record. It covers the single PR commit 1827fdb (squash 3ece2e8).

Rubric

  1. Matches the issue scope: pass. All six DoD items are addressed: non-404 errors exit 2, the dangling pointer fails, the prose check works in both directions and scans workflow comments, the rollout header comment is fixed, CHANGELOG says "five" and the test script has mode 100755, and the live run is in the PR body.
  2. Failure modes explicit: partial. One read still fails open (D1), and the new EXIT trap can hide an abort status on bash 3.2 (D2).
  3. No gate weakened: partial. The cells are stricter now. But D1 lets a failed repo listing report "All repos compliant", and D2 turns a set -u abort into exit 0 on macOS bash.
  4. Minimal: pass.
  5. Tests assert behaviour: pass, with a gap. Every case checks the exit code and the exact cell or message. But two of the HTTP 500 cases fail on a different read than the one they are named for (N1).

Defects

  • D1: scripts/org/audit_compliance.sh:116-118. The repo listing still fails open. gh repo list runs inside < <(...) with no stderr capture and no status check, so neither set -e nor pipefail sees it fail. Scenario: a GraphQL rate limit or 5xx on gh repo list gives an empty repos array. On bash 5 (the ubuntu runner) the loop runs zero times and the script prints "All repos compliant." with exit 0. org-audit.yml then opens no issue. I reproduced this with a stub gh that fails repo list ("GraphQL: API rate limit exceeded"): exit 0, empty table. This is the failure DoD item 1 rules out, and the PR says every read is covered. Fix: list="$(gh repo list ... 2>"$ERR_FILE")" || api_failed "repo list", then build repos from $list. Also treat zero repos as exit 2. Add a test with a stubbed repo list failure.
  • D2: scripts/org/audit_compliance.sh:36. The new trap 'rm -f "$ERR_FILE"' EXIT hides the abort status on bash 3.2. On /bin/bash 3.2.57 (macOS, where maintainers run the audit by hand), set -euo pipefail; trap 'rm -f "$t"' EXIT; a=(); for x in "${a[@]}"; do :; done exits 0. Without the trap it exits 1. With D1 on macOS, the script prints repos[@]: unbound variable and still exits 0. Plain exit 2 and set -e failures keep their status, so only set -u aborts are affected. Fix: trap 'rc=$?; rm -f "$ERR_FILE"; exit "$rc"' EXIT, and use ${repos[@]+"${repos[@]}"} or a length guard for the empty array.
  • D3: scripts/org/rollout_governance.sh:158. Rollout still writes a prose version. When a repo has neither CLAUDE.md nor AGENTS.md, rollout writes a CLAUDE.md containing https://github.com/traverse-framework/.github, version $VERSION. prose_versions flags this line (.github, version v1.6.0), so a fresh rollout produces a repo that fails "no prose versions". Rollout also writes no AGENTS.md in that case, so the pointer column fails too. This has the same root cause as the header-comment fix in this PR, which missed it. Fix: say "the adopted release is in .governance-version" there as well, and write an AGENTS.md pointer.

Non-blocking notes

  • N1: audit_compliance_test.sh:141. FAKE_FAIL matches any substring of the path. So constitution.md fails on the org .github/constitution.md read before any repo constitution is read, and .github/workflows fails on has_file .../cla.yml before workflow_comments runs. Neither the per-repo constitution read nor the workflow_comments subshell is tested on its own. I checked both by hand with an exact-path stub: both exit 2 with "audit incomplete". So the $(...) + set -e path works (wf_comments="$(...)" propagates the 2). Use an exact-path match or anchor the pattern so the tests cover these paths.
  • N2: The rulesets read (2>/dev/null || echo __unreadable__) still turns a 5xx into ?, and ? is not counted as a failure. This is documented for missing admin read and was there before this PR, but a 500 also shows a non-failing ?. Consider telling 403/404 apart from other errors.
  • N3: Edge cases in the prose patterns, from probes: v1.3.0 of the org-wide governance is missed (the org + group does not allow org-wide). Rust 1.95.0 governance-free is flagged. Trailing comments (uses: x@v1 # governance v1.0.1) are not scanned, because only lines starting with # are read. IP addresses, .github#57 and actions/checkout@v4.2.0 are correctly not flagged.
  • N4: org-audit.yml now sends all stderr to audit-errors.txt. Any stderr (for example from stale_claims.sh) on an exit 0/1 run adds an "Audit errors (exit N)" section. The YAML and the backtick-fence quoting are correct, and failed=$rc is right.
  • fetch with printf -v works on bash 3.2. The 404 detection matches gh's real gh: Not Found (HTTP 404) stderr, and the stub's 404, 500 and directory handling matches gh. bash -n passes on all three changed scripts, and audit_compliance_test.sh passes 29/29 at 3ece2e8.

Live audit (3ece2e8, read-only): exit 1, 1 check failing

repo version pin pin is v1.6.0 dependabot CLA wf governance wf agent docs AGENTS.md → CLAUDE.md CLAUDE.md ≤ 6 KB no prose versions no constitution copy needs-review label ruleset
website ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
registry ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
.github ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
claude-skills ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
reference-apps ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
traverse ✅ ❌ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
repo-template ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅

The only failure is traverse's pin, which is not yet on v1.6.0. That bump is the maintainer's step. The workflow-comment follow-ups in the other five repos have landed, so "no prose versions" is green everywhere.

enricopiovesan added a commit that referenced this pull request Nov 24, 2026
…s the audit (#72)

Fixes from the post-merge review of #71.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review Full-CI PR waiting for an independent cross-tool review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Org audit: fail on API errors, dangling AGENTS.md pointer, wider prose-version check

1 participant