Skip to content

feat(compliance-audit): add added/existing/removed issue count summary#255

Merged
don-petry merged 14 commits into
mainfrom
feat/issue-count-summary
May 16, 2026
Merged

feat(compliance-audit): add added/existing/removed issue count summary#255
don-petry merged 14 commits into
mainfrom
feat/issue-count-summary

Conversation

@don-petry
Copy link
Copy Markdown
Contributor

@don-petry don-petry commented May 12, 2026

Summary

Surfaces a count of added, existing, and removed issues in every compliance audit run.

Changes

scripts/compliance-audit.sh

  • Adds three global counters: ISSUES_ADDED, ISSUES_EXISTING, ISSUES_REMOVED
  • create_issue_for_finding: increments ISSUES_ADDED (new issue) or ISSUES_EXISTING (updated issue)
  • close_resolved_issues: increments ISSUES_REMOVED when a resolved finding's issue is closed
  • After issue processing, writes issue-counts.json to REPORT_DIR
  • Appends an Issue Management table to summary.md

.github/workflows/compliance-audit-and-improvement.yml

  • Exposes issues_added, issues_existing, issues_removed as job outputs (parsed from issue-counts.json)
  • Passes the counts into the Claude Phase 6 prompt context
  • Adds a count summary table to the Issues Created/Updated section of the Phase 6 summary template

Result

Both the Compliance Audit job step summary and the Claude-generated weekly report now include:

Action Count
Added (new) N
Existing (updated) N
Removed (resolved) N

Summary by CodeRabbit

  • New Features
    • Compliance audit now captures and reports issue-management metrics, including counts of added, existing, and removed issues
    • Issue metrics are integrated into audit analysis and summary reporting for enhanced visibility into issue-management activity

Review Change Stack

Track and surface the count of issues added (new), existing (updated),
and removed (resolved) in each compliance audit run.

Changes:
- scripts/compliance-audit.sh: add ISSUES_ADDED/EXISTING/REMOVED global
  counters; increment them in create_issue_for_finding and
  close_resolved_issues; write issue-counts.json to REPORT_DIR; append
  an 'Issue Management' table to summary.md after issue processing.
- .github/workflows/compliance-audit-and-improvement.yml: expose
  issues_added/existing/removed as job outputs by reading issue-counts.json;
  pass these values into the Claude Phase 6 prompt context and summary
  template so the step summary includes the count table.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@don-petry don-petry requested a review from a team as a code owner May 12, 2026 11:55
Copilot AI review requested due to automatic review settings May 12, 2026 11:55
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Warning

Rate limit exceeded

@don-petry has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 21 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d03aebae-5d59-4a6a-ae53-e62d726494a9

📥 Commits

Reviewing files that changed from the base of the PR and between 65e6b4b and ae4a4a6.

📒 Files selected for processing (2)
  • .github/workflows/compliance-audit-and-improvement.yml
  • scripts/compliance-audit.sh
📝 Walkthrough

Walkthrough

The PR extends the compliance audit workflow and script to track and report issue-management metrics. The script now initializes counters for added, existing, and removed issues, increments them during create/update/close operations, and outputs counts to JSON and a summary table. The workflow reads those counts from the JSON file, declares them as job outputs, includes them in the Claude analysis prompt, and reports them in the final step summary.

Changes

Issue Metrics Tracking in Compliance Audit

Layer / File(s) Summary
Script issue counter tracking and output
scripts/compliance-audit.sh
Script initializes counters for added/existing/removed issues, increments them during create/update/close operations, and writes counts to issue-counts.json and appends summary table to summary.md.
Workflow job outputs declaration, reading, and usage
.github/workflows/compliance-audit-and-improvement.yml
Workflow declares issues_added, issues_existing, and issues_removed outputs; reads counts from issue-counts.json (defaults to 0 if missing); includes metrics in Claude analysis prompt and final step summary reporting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • petry-projects/.github#12: Both modify the compliance audit workflow and scripts' issue-management logic; the related PR implements creating/updating/closing compliance issues, while this PR adds counters, JSON output, and summary reporting for those operations.
  • petry-projects/.github#14: Both modify scripts/compliance-audit.sh and the compliance audit flow; the related PR adds CLAUDE/AGENTS checks and expands audit scope, while this PR adds issue-count tracking and metrics output.
  • petry-projects/.github#13: Both change the compliance audit pipeline; the related PR adds the initial compliance-audit-and-improvement workflow and audit job outputs, while this PR extends those outputs to include issue metrics.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a summary of issue counts (added/existing/removed) to the compliance audit workflow.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/issue-count-summary

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces issue management tracking to the compliance audit script by implementing counters for added, existing, and removed issues. These metrics are now exported to a JSON file and appended as a summary table to the final report. Feedback indicates that the new summary section is currently appended after the report's footer, which breaks the document structure; it is recommended to move the footer generation to the end of the execution to maintain a proper layout.

Comment thread scripts/compliance-audit.sh Outdated
Comment on lines +1438 to +1447
cat >> "$SUMMARY_FILE" <<HEREDOC

## Issue Management

| Action | Count |
|--------|-------|
| Added (new) | $ISSUES_ADDED |
| Existing (updated) | $ISSUES_EXISTING |
| Removed (resolved) | $ISSUES_REMOVED |
HEREDOC
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The Issue Management section is appended to the end of the summary file. However, the generate_summary function (called on line 1399) already appends a footer containing a horizontal rule and a timestamp (lines 1309-1313). This results in the new section appearing after the report's footer, which breaks the document structure. Consider moving the footer generation logic out of generate_summary and placing it at the very end of the main function to ensure it remains the final element of the report.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds run-level issue management metrics to the compliance audit so downstream workflow steps (including the Claude analysis prompt and weekly report) can display how many issues were added, updated, and closed during an audit run.

Changes:

  • Track ISSUES_ADDED, ISSUES_EXISTING, and ISSUES_REMOVED in scripts/compliance-audit.sh and emit them as issue-counts.json, plus append an “Issue Management” section to summary.md.
  • Expose those counts as outputs from the audit job in .github/workflows/compliance-audit-and-improvement.yml and render them in the Phase 6 summary template and Claude prompt context.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
scripts/compliance-audit.sh Adds global counters, increments them during issue create/update/close, writes issue-counts.json, and appends an Issue Management table to summary.md.
.github/workflows/compliance-audit-and-improvement.yml Reads issue-counts.json into step/job outputs and includes the counts in the Claude Phase 6 prompt + report template.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/compliance-audit.sh Outdated
Comment on lines +1001 to +1012
# Ensure claude label is present on pre-existing issues
gh issue edit "$existing" --repo "$ORG/$repo" --add-label "claude" 2>/dev/null || true
info "Updated existing issue #$existing in $repo for: $check"
ISSUES_EXISTING=$((ISSUES_EXISTING + 1))
Comment thread scripts/compliance-audit.sh Outdated
Comment on lines +1227 to +1233
--comment "Resolved! This check is now passing as of $(date -u +%Y-%m-%d). Closing automatically." \
2>/dev/null || true
info "Closed resolved issue #$issue_num in $repo: $issue_title"
ISSUES_REMOVED=$((ISSUES_REMOVED + 1))
Comment on lines 33 to +36
FINDINGS_FILE="$REPORT_DIR/findings.json"
SUMMARY_FILE="$REPORT_DIR/summary.md"
ISSUES_FILE="$REPORT_DIR/issues.json"
ISSUE_COUNTS_FILE="$REPORT_DIR/issue-counts.json"
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f0046637-c43b-46fb-9146-eb3f3a42a43c

📥 Commits

Reviewing files that changed from the base of the PR and between fea867c and 65e6b4b.

📒 Files selected for processing (2)
  • .github/workflows/compliance-audit-and-improvement.yml
  • scripts/compliance-audit.sh

Comment thread scripts/compliance-audit.sh Outdated
@donpetry-bot
Copy link
Copy Markdown
Contributor

donpetry-bot commented May 12, 2026

Superseded by automated re-review at e27d86d82624d1ba036be285157c3cf90ceb6ec2 — click to expand prior review.

Review — fix requested (cycle 1/3)

The automated review identified the following issues. Please address each one:

Findings to fix

[Findings would be inserted here]

Additional tasks

  1. Resolve all unresolved review thread comments from other reviewers
  2. Ensure all CI checks pass after your changes
  3. Rebase on the target branch if behind
  4. Do NOT modify files unrelated to the findings above

The review cascade will automatically re-review after new commits are pushed.

Enhance the step summary and Claude Phase 6 report with:

1. Grouping by compliance check type (not by repo) — the same check
   failing in N repos now appears once with all N repos listed, avoiding
   repeated rows for the same systemic problem.

2. Hyperlinks to every GitHub Issue and related open PR — the new
   'Issues & Related PRs' section (shell script) and updated Phase 6
   template (Claude) render each issue as [#N](url) and look up open
   PRs via closingIssuesReferences (one GraphQL call per affected repo).

3. Per-repo scorecard table — compact errors/warnings/total view so
   repos with the most debt are immediately visible.

Scripts/compliance-audit.sh:
- generate_summary: replace per-repo subsections with a 'Findings by
  Check Type' table (grouped by check, sorted by severity then alpha)
  and a new 'Per-Repo Scorecard' compact table.
- append_issue_pr_links: new function called after issue creation;
  fetches linked PRs via GraphQL per affected repo and appends a
  '## Issues & Related PRs' section grouped by check type.
- Footer and issue-management table moved to end of main() so they
  always appear after all appended sections.

.github/workflows/compliance-audit-and-improvement.yml:
- Phase 5: add grouping rule (same check type in N repos = 1 issue)
  and PR-lookup instruction before Phase 6 summary is written.
- Phase 6 template: replace flat repo/issue table with per-check-type
  subsections (#### 'check' (severity), N repos, issue links, PR links).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
donpetry-bot
donpetry-bot previously approved these changes May 12, 2026
Copy link
Copy Markdown
Contributor

@donpetry-bot donpetry-bot left a comment

Choose a reason for hiding this comment

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

Automated review — APPROVED ✓

Risk: MEDIUM
Reviewed commit: e27d86d82624d1ba036be285157c3cf90ceb6ec2
Cascade: triage → deep (triage: haiku 4.5 → deep: sonnet 4.6 + duck: o4-mini → audit: opus 4.7)

Summary

All CI gates pass (ShellCheck, Lint, SonarCloud 0 new issues, CodeQL, AgentShield). The CodeRabbit CHANGES_REQUESTED is stale — it reviewed only the first commit; the second commit fixed the footer-ordering defect flagged by Gemini, and CodeRabbit's subsequent run hit a rate limit before completing. No security issues, no injection risks; minor robustness gaps around jq error handling are low-consequence.

Findings

  • info: CodeRabbit CHANGES_REQUESTED was posted against the first commit (65e6b4b). The second commit (e27d86d) addressed the reported footer-ordering defect. CodeRabbit hit its rate limit before re-reviewing; its status context is SUCCESS but the PR-level review decision remains CHANGES_REQUESTED. This gate blocker is stale.
  • info: CodeRabbit docstring-coverage warning (33.33% vs 80%) is its generic check applied to bash function headers — not a meaningful standard for shell scripts. No action required.
  • minor: In the workflow, jq '.added' / jq '.existing' / jq '.removed' lack the -r flag. For JSON integer values this is functionally safe (integers are not quoted), but if issue-counts.json is malformed or a key is missing, jq exits non-zero and the variable becomes empty, writing issues_added= to GITHUB_OUTPUT. Adding || echo 0 would guard against this.
  • minor: In append_issue_pr_links, the GraphQL query uses first:100 for open PRs per repo. Repos with more than 100 open PRs will silently miss some PRs in the Related PRs column. Unlikely in practice but worth noting for future pagination.
  • info: The gh search prs instruction appears only inside the Claude AI prompt template (a multi-line string passed to the model), not as a shell command executed by the workflow runner. No automated enumeration occurs.

Reviewed by the PR-review cascade (triage: haiku 4.5 → deep: sonnet 4.6 + duck: o4-mini → audit: opus 4.7). Reply if you need a human review.

@donpetry-bot donpetry-bot enabled auto-merge (squash) May 12, 2026 13:13
Two bugs in append_issue_pr_links caused the Issues & Related PRs
section to render empty:

1. NDJSON slurp: ISSUES_FILE is newline-delimited JSON (one object per
   line) but jq was called without -n '[inputs]', so only the first
   record was ever processed. Fixed all ISSUES_FILE reads to use
   'jq -rn/cn [inputs]' instead of 'jq -r/c'.

2. Missing severity field: the jq records written to ISSUES_FILE in
   create_issue_for_finding (both existing and new issue branches)
   omitted the severity field, causing sort_by severity to fail.
   Added --arg severity and included it in both jq writes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
don-petry and others added 2 commits May 12, 2026 13:45
…_links

1. repos_in_issues used '[.[].repo]' on NDJSON — only first repo was
   ever queried. Fixed to 'jq -rn [inputs | .repo] | unique[]'.

2. GraphQL --jq used $repo as an unbound jq variable (gh -f flags set
   GraphQL vars, not jq vars), causing every repo_prs to silently
   return []. Fixed by piping raw GraphQL response to 'jq --arg repo'
   so the repo name is properly available in the jq expression.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Auto-rebase blocked — the base branch contains .github/workflows/ changes that require the workflows permission to merge into this branch, but the auto-rebase workflow's token does not have that permission.

Please rebase this branch manually:

git fetch origin
git rebase origin/main
git push --force-with-lease

donpetry-bot
donpetry-bot previously approved these changes May 14, 2026
Copy link
Copy Markdown
Contributor

@donpetry-bot donpetry-bot left a comment

Choose a reason for hiding this comment

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

Automated review — APPROVED ✓

Risk: MEDIUM
Reviewed commit: 1d43ea553e06ff154c0a9dcd0e3876d9dc01b4cb
Cascade: triage → deep (triage: haiku 4.5 → deep: sonnet 4.6 + duck: o4-mini → audit: opus 4.7)

Summary

Non-trivial shell script and workflow changes adding issue-count tracking and a grouped summary section; all security checks pass (CodeQL, SonarCloud 0 new issues, ShellCheck) and no injection or secret risks are present. The CodeRabbit CHANGES_REQUESTED is stale — it reviewed only the first commit and was rate-limited before re-reviewing; the footer-ordering defect it flagged was fixed in commit 2. Branch is BEHIND main and requires a manual rebase before merge, but CI ran on the merge commit so test results are valid against a recent baseline.

Findings

  • INFO [review-process]: CodeRabbit CHANGES_REQUESTED was posted against commit 65e6b4b (first commit only). Commit e27d86d fixed the footer-ordering defect it flagged. CodeRabbit hit its hourly rate limit before re-reviewing; its status context shows SUCCESS but the PR-level review decision remains CHANGES_REQUESTED. This gate blocker is stale and not a meaningful code-quality signal.
  • INFO [merge-state]: Branch is BEHIND main (mergeStateStatus=BEHIND). Auto-rebase is blocked because the branch touches .github/workflows/ and the bot lacks the 'workflows' permission. A manual 'git fetch origin && git rebase origin/main && git push --force-with-lease' is required before merging. CI ran on merge commit 1d43ea5 (which already integrated main as of 2026-05-12T19:01Z), so existing test results are valid against a recent baseline.
  • MINOR [robustness]: In the workflow's 'Parse issue management counts' block, jq '.added', jq '.existing', and jq '.removed' lack the -r flag. For JSON integer values this is functionally safe (integers are unquoted), but if issue-counts.json is malformed or a key is absent, jq exits non-zero and the variable becomes empty, writing issues_added= to GITHUB_OUTPUT. Adding || echo 0 after each jq call would guard against this edge case.
  • MINOR [robustness]: In append_issue_pr_links, the GraphQL query uses first:100 for open PRs per repo. Repos with more than 100 open PRs will silently miss some entries in the Related PRs column. Unlikely in practice for this org, but worth noting if the audit is extended to larger orgs.
  • INFO [security]: The gh search prs command referenced in the diff appears only inside a heredoc string passed as a prompt to the Claude AI model (Phase 6 template), not as a shell command executed by the workflow runner. No automated enumeration of PRs across repos occurs at workflow runtime.
  • INFO [correctness]: NDJSON handling is correctly fixed in commits 3 and 4: all ISSUES_FILE reads now use jq -rn '[inputs]' or jq -cn [inputs] instead of plain jq -r/c, and the missing severity field was added to both the existing-issue and new-issue branches of create_issue_for_finding. GraphQL variables are passed via -f flags (not shell-interpolated into query strings), so no injection surface exists.

Reviewed by the PR-review cascade (triage: haiku 4.5 → deep: sonnet 4.6 + duck: o4-mini → audit: opus 4.7). Reply if you need a human review.

@donpetry-bot
Copy link
Copy Markdown
Contributor

Automated review — human attention needed

This PR has been through 3 automated review cycles (cap: 3) without converging on an approval-and-merge state. Further automated review has been paused to avoid infinite loops.

Please take a look manually, or close this PR if it's no longer needed. Once a human review resolves the situation, remove the needs-human-review label and the cascade can be re-engaged on the next push.

Posted by the donpetry-bot PR-review cascade.

@don-petry
Copy link
Copy Markdown
Contributor Author

@claude - Please review and address all comments, marking as resolved when fixed. Confirm CI is working. Request a re-review when ready.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 14, 2026

Claude finished @don-petry's task in 3m 12s —— View job


Review Comments Addressed

  • Gather context and read changed files
  • Verify footer ordering fix (Gemini #1608) — already correct in prior commit; no change needed
  • Fix: Update header comment to include issue-counts.json in Outputs (Copilot enhancement: Review Dependabot PRs with major version jumps in .github repo #36)
  • Fix: ISSUES_EXISTING counter — only increments when gh issue comment actually succeeds (Copilot #1045)
  • Fix: ISSUES_REMOVED counter — only increments when gh issue close actually succeeds (Copilot #1268)
  • Fix: Issue-count JSON/summary is now conditional on issue management running; shows a "skipped" notice when DRY_RUN=true or CREATE_ISSUES=false (CodeRabbit #1608)
  • Commit and push — 6dade1b

What was changed

All changes are in scripts/compliance-audit.sh only.

Cannot address: The jq missing -r flag in .github/workflows/compliance-audit-and-improvement.yml (noted by donpetry-bot as MINOR). Workflow files cannot be modified by this GitHub App token — you'll need to apply that manually if desired. The existing || echo 0 fallback in the workflow already guards the empty-variable case.

CI status: Push triggered a new CI run. The branch was previously BEHIND main; this commit includes the existing merge of main (74bdf11), so the rebase blocker noted by the auto-rebase bot should now be resolved.
|

…d output

- Add issue-counts.json to header Outputs comment (Copilot #36)
- ISSUES_EXISTING: only increment when gh issue comment succeeds, not on || true failure (Copilot #1045)
- ISSUES_REMOVED: only increment when gh issue close succeeds, not on || true failure (Copilot #1268)
- Make issue-count JSON/summary conditional on issue management running; show skip notice when DRY_RUN=true or CREATE_ISSUES=false (CodeRabbit #1608)
- Footer is now always the final element, written after the conditional Issue Management section

Co-authored-by: Don Petry <don-petry@users.noreply.github.com>
@don-petry
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@sonarqubecloud
Copy link
Copy Markdown

@don-petry don-petry merged commit 7601f5a into main May 16, 2026
25 of 27 checks passed
@don-petry don-petry deleted the feat/issue-count-summary branch May 16, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants