Skip to content

fix(fleet-monitor): auto-close resolved fleet-tracker issues + stop daily-digest accumulation (#1203) - #1204

Merged
don-petry merged 13 commits into
mainfrom
fix/fleet-monitor-autoclose-resolved
Jul 14, 2026
Merged

fix(fleet-monitor): auto-close resolved fleet-tracker issues + stop daily-digest accumulation (#1203)#1204
don-petry merged 13 commits into
mainfrom
fix/fleet-monitor-autoclose-resolved

Conversation

@don-petry

@don-petry don-petry commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Problem

The Actions Fleet Monitor creates/updates a fleet-tracker issue per (repo × workflow) above 10% failure, but never closes it when the workflow recovers (≤10%) or is deleted. Result: 107 stale open alerts, some stamped Last updated ~55 days ago while the monitor runs daily, plus 4 for the claude.yml workflow deleted in #456. Full write-up: #1203.

Fix

New "Close resolved fleet-tracker issues" step: closes any open fleet-tracker issue whose Last updated ... on <date> stamp is older than STALE_DAYS (default 3 = 3 missed daily runs), with a ✅ Auto-resolved comment. Reopens automatically (fresh issue) if the workflow crosses the threshold again — same lifecycle as org-scorecard.yml.

Safety

  • Gated on fleet_high_failure.json existing → a failed scan can't mass-close.
  • Staleness uses each issue's own stamp (not the current run), so a single bad-scan day never false-closes (stamp only 1 day old).
  • Comment + close are each try/catch — a comment-capped issue still closes.
  • Reuses the existing pinned github-script@v9.0.0 + GH_PAT_WORKFLOWS (cross-repo issues:write).

Validation

  • YAML parses; node --check on the extracted script passes; yamllint clean under the repo's exact config (max 250).

Rollout

On merge, the next daily run auto-closes the recovered/deleted backlog. The 4 deleted-claude.yml issues are being closed immediately by hand (a deleted workflow is never re-scanned).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Juznz5V6su81ffSND8fg7s

Summary by CodeRabbit

  • New Features
    • Automatically closes resolved Fleet Monitor issues after they remain stale for three days.
    • Adds an explanatory comment before closing each resolved issue.
    • Reports counts of closed, retained, and skipped issues in workflow notifications.

The monitor creates/updates a fleet-tracker issue per (repo × workflow) above
10% failure, but never closed them when the workflow recovered or was deleted —
so 107 stale alerts accumulated (some with 'Last updated' stamps ~55 days old
while the monitor runs daily; 4 for the deleted claude.yml #456).

Add a step that closes any open fleet-tracker issue whose 'Last updated on <date>'
stamp is older than STALE_DAYS (default 3 = 3 missed daily runs), with a
✅ Auto-resolved comment. It reopens automatically (fresh issue) if the workflow
crosses the threshold again — same lifecycle as org-scorecard.

Safety: gated on fleet_high_failure.json existing (a failed scan can't mass-close);
staleness uses each issue's own stamp, not the current run, so a single bad-scan
day never false-closes; comment + close are each guarded so a comment-capped issue
still closes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Juznz5V6su81ffSND8fg7s
@don-petry
don-petry requested a review from a team as a code owner July 14, 2026 02:47
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@gemini-code-assist

Copy link
Copy Markdown

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@don-petry, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 7 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6d10a775-3934-4a45-af9d-385a4e51431d

📥 Commits

Reviewing files that changed from the base of the PR and between f5d3cc2 and a296f3a.

📒 Files selected for processing (1)
  • .github/workflows/actions-fleet-monitor.yml
📝 Walkthrough

Walkthrough

The Fleet Monitor workflow adds a conditional step that identifies stale managed issues using repository matches and body timestamps, comments on qualifying issues, closes them as completed, and reports closed, kept, and skipped counts.

Changes

Fleet tracker resolution

Layer / File(s) Summary
Detect and close stale fleet issues
.github/workflows/actions-fleet-monitor.yml
Adds conditional issue pagination, timestamp parsing, stale-issue comments, completed-state closure, skip handling, and summary notices.

Estimated code review effort: 3 (Moderate) | ~15 minutes

Possibly related issues

  • Issue 1203 — Directly covers adding automatic closure for stale fleet-tracker issues.

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: automatically closing resolved fleet-tracker issues.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/fleet-monitor-autoclose-resolved

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.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — waiting on PR blockers (intent: review-changes)

PR: #1204
No changes were committed, but the PR still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews). The retry cron will re-attempt automatically. Next attempt after: 2026-07-14T03:18:14Z

@don-petry

Copy link
Copy Markdown
Collaborator Author

Note

@don-petry I reviewed this PR and no code changes were needed, but it still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews), so I cannot mark it done yet. I'll re-check automatically.
Next attempt after: 2026-07-14T03:18:14Z

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 02:48
@don-petry
don-petry disabled auto-merge July 14, 2026 02:48
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
Issues addressed: 0
- Quality Gate passed with no new issues, security hotspots, or code coverage findings (informational only)
Files changed: None
Skipped (informational): 1 (QG pass report)
```
The PR is clean from a code quality and security scanning perspective. No changes are needed.

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 02:49

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/actions-fleet-monitor.yml:
- Around line 371-372: Update the token configuration in the workflow step using
the github-token field to reference the GH_PAT_WORKFLOWS environment variable
rather than accessing secrets.GH_PAT_WORKFLOWS directly. Preserve the existing
cross-repository issue-writing behavior.
- Line 366: Update the actions/github-script step’s GH_PAT_WORKFLOWS reference
to use the workflow environment variable env.GH_PAT_WORKFLOWS instead of
secrets.GH_PAT_WORKFLOWS, preserving the existing action configuration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 38666435-62f4-4c72-aef0-8d1b258a0810

📥 Commits

Reviewing files that changed from the base of the PR and between d83b3b1 and f5d3cc2.

📒 Files selected for processing (1)
  • .github/workflows/actions-fleet-monitor.yml

Comment thread .github/workflows/actions-fleet-monitor.yml
Comment thread .github/workflows/actions-fleet-monitor.yml Outdated
@don-petry
don-petry disabled auto-merge July 14, 2026 02:53
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 14, 2026
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-reviews (applied)

Changes committed and pushed.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — waiting on PR blockers (intent: review-changes)

PR: #1204
No changes were committed, but the PR still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews). The retry cron will re-attempt automatically. Next attempt after: 2026-07-14T03:34:22Z

@don-petry

Copy link
Copy Markdown
Collaborator Author

Note

@don-petry I reviewed this PR and no code changes were needed, but it still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews), so I cannot mark it done yet. I'll re-check automatically.
Next attempt after: 2026-07-14T03:34:22Z

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 03:04
@donpetry-bot

Copy link
Copy Markdown
Contributor

Advisory bots were rate-limited; auto-approval is withheld until they recover. pr-review-sweep will re-review this PR after 2026-07-14T04:04:36Z.

@don-petry don-petry changed the title fix(fleet-monitor): auto-close resolved fleet-tracker issues (#1203) fix(fleet-monitor): auto-close resolved fleet-tracker issues + stop daily-digest accumulation (#1203) Jul 14, 2026
… them

The 'workflow failures detected <date>' digest embeds the date in its title, so
issues.create ran unconditionally every day — 42 open digests had piled up. Close
the prior open digests (health-check label, matching title prefix) before opening
today's, so only the current snapshot stays open. Complements the fleet-tracker
auto-close in this PR; both stop the monitor accumulating stale issues.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Juznz5V6su81ffSND8fg7s
Copilot AI review requested due to automatic review settings July 14, 2026 03:16
@don-petry
don-petry disabled auto-merge July 14, 2026 04:21
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 04:27
@don-petry
don-petry disabled auto-merge July 14, 2026 04:29
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
**Tier 1 Blockers:**
- ✅ No failed CI checks
- ✅ No `CHANGES_REQUESTED` reviews
- ✅ All checks successful or skipped
**CodeRabbit Review:**
CodeRabbit approved the PR with 2 optional suggestions (not blocking). These relate to refactoring token usage in the workflow, but are independent of the SonarCloud findings and the PR already handles the security context correctly—the workflow sets `GH_PAT_WORKFLOWS` as an env var on line 391 and uses it on line 394, following the established pattern.
---
**Issues addressed:** 0 (SonarCloud report shows all checks passed)  
**Files changed:** None  
**Result:** No actionable issues from bot comment — PR is clean and ready.

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 04:30
@don-petry
don-petry disabled auto-merge July 14, 2026 04:36
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-bot-comment (applied)

Changes committed and pushed.

@donpetry-bot donpetry-bot left a comment

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.

Automated review — APPROVED ✓

Risk: MEDIUM
Reviewed commit: 12e06099cb911868f3bd7b22a8d4029727d41dd0
Review mode: triage-approved (single reviewer)

Summary

Adds an auto-close path to the Actions Fleet Monitor: (1) a new 'Close resolved fleet-tracker issues' step that closes any open fleet-tracker issue whose per-issue 'Last updated' stamp is older than STALE_DAYS=3, with an auto-resolved comment; (2) closes prior open daily-digest issues before creating today's. Fixes the 107-stale-alert backlog described in #1203. Implementation reuses the file's established patterns (same pinned github-script v9.0.0 SHA, same hashFiles gate as the tracking step, GH_PAT_WORKFLOWS via env per repo guidelines) and the stamp regex matches the exact format the tracking step writes.

Linked issue analysis

Linked issue #1203 (fleet-tracker issues never auto-close on recovery/deletion) is substantively addressed: recovered workflows stop being stamped and are closed after 3 missed daily runs; deleted workflows (never re-scanned) age out the same way. Safety properties claimed in the issue are present in the code: step gated on fleet_high_failure.json existing (failed scan cannot mass-close), staleness derived from each issue's own stamp (a single bad-scan day cannot false-close), comment and close individually try/catch'd.

Findings

No blocking findings.

  • Prior reviewer threads all resolved at this head: CodeRabbit's token-sourcing guideline (github-token now from env.GH_PAT_WORKFLOWS) and Copilot's github.paginate Search-API mapping bug (response => response.data.items now present). CodeRabbit's final review is APPROVED.
  • Security: action pinned to the same SHA already used 4x in this file; no new secrets or permissions — GH_PAT_WORKFLOWS cross-repo issues:write is this workflow's existing, documented pattern. Issue bodies are only regex-matched (strict date capture), never executed or interpolated unsafely. Scheduled trigger, no PR-controlled inputs.
  • Secret scan: run_secret_scanning MCP tool not available in this environment; gitleaks CI check is green and the diff introduces no secret material.
  • Minor (non-blocking): search.issuesAndPullRequests is a legacy search endpoint; fine today, may warrant migration if GitHub deprecates it.

CI status

All substantive checks green: CodeQL, gitleaks, ShellCheck, Lint, SonarCloud, agent-shield, Agent Security Scan, unit-tests, bats, holdout-guard, template-drift, gh-aw-compile, validate-agent-profiles/personas. The two cancelled dev-lead jobs are superseded concurrency runs of the agent-orchestration workflow (latest run pending, not a correctness gate); review/review in-progress is this review run itself. mergeStateStatus BLOCKED is due to the required org-leads review.


Reviewed automatically by the PR-review agent (single-reviewer mode: fable 5). Reply if you need a human review.

@don-petry
don-petry disabled auto-merge July 14, 2026 04:41
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — waiting on PR blockers (intent: review-changes)

PR: #1204
No changes were committed, but the PR still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews). The retry cron will re-attempt automatically. Next attempt after: 2026-07-14T05:12:25Z

@don-petry

Copy link
Copy Markdown
Collaborator Author

Note

@don-petry I reviewed this PR and no code changes were needed, but it still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews), so I cannot mark it done yet. I'll re-check automatically.
Next attempt after: 2026-07-14T05:12:25Z

@don-petry
don-petry enabled auto-merge (squash) July 14, 2026 04:42
@sonarqubecloud

Copy link
Copy Markdown

@don-petry
don-petry merged commit 7e72290 into main Jul 14, 2026
29 of 31 checks passed
@don-petry
don-petry deleted the fix/fleet-monitor-autoclose-resolved branch July 14, 2026 04:44

@donpetry-bot donpetry-bot left a comment

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.

Automated review — APPROVED ✓

Risk: MEDIUM
Reviewed commit: a296f3a6f0eeec84820da193ed429a979d1637f6
Review mode: triage-approved (single reviewer)

Summary

Adds lifecycle management to the Actions Fleet Monitor: (1) a new 'Close resolved fleet-tracker issues' step that closes org-wide fleet-tracker issues whose per-issue 'Last updated' stamp is older than STALE_DAYS (3), with an auto-resolved comment; (2) closes prior daily-digest issues before creating today's so only one snapshot stays open; (3) re-plumbs the existing GH_PAT_WORKFLOWS secret through env: blocks per org coding guidelines. Since the prior automated approval at 12e0609, the only changes are the token-plumbing fix (addressing CodeRabbit's guideline comment) and a merge of main — no behavioral change to the reviewed logic.

Linked issue analysis

PR references issue #1203 (fleet-tracker issues never auto-close on recovery/deletion, 107 stale open alerts). The new auto-close step directly implements the fix described in the issue, with the stated safety gates: gated on fleet_high_failure.json existing (failed scan cannot mass-close), staleness computed from each issue's own stamp (single bad-scan day cannot false-close), and per-issue try/catch on comment+close. The digest-accumulation half (42 open dated digest issues) is also addressed. Issue is substantively resolved.

Findings

No blocking findings. Verified: (1) github-script pinned to full SHA (v9.0.0), unchanged; (2) no script injection — scripts read ORG/STALE_DAYS via process.env, no untrusted ${{ }} interpolation inside script bodies; (3) search.issuesAndPullRequests pagination uses the response.data.items mapper (Copilot's earlier finding, resolved); (4) stamp regex only matches monitor-managed bodies, unmatched issues are skipped; (5) all 3 review threads (2 CodeRabbit, 1 Copilot) are resolved and both bot change-requests were dismissed after fixes. Secret-scanning MCP tool unavailable in this session — relied on the green gitleaks CI check; no secrets appear in the diff (existing secret re-plumbed only).

CI status

All required checks green (SonarCloud, CodeQL, agent-shield/AgentShield, dependency-audit/Detect ecosystems), plus Lint, ShellCheck, shellcheck, unit-tests, bats, gitleaks, Agent Security Scan, gh-aw-compile, template-drift, holdout-guard, validate-agent-profiles, validate-personas, CodeRabbit all SUCCESS. dev-lead/dispatch and dev-lead/ci-relay are CANCELLED — non-required relay jobs intentionally skipped via [skip ci-relay] in the head commit. reviewDecision: APPROVED.


Reviewed automatically by the PR-review agent (single-reviewer mode: fable 5). Reply if you need a human review.

@donpetry-bot donpetry-bot left a comment

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.

Automated review — APPROVED ✓

Risk: MEDIUM
Reviewed commit: a296f3a6f0eeec84820da193ed429a979d1637f6
Review mode: triage-approved (single reviewer)

Summary

Adds a stale-based auto-close step for cross-repo fleet-tracker issues and closes prior daily-digest issues before creating today's, fixing the 107-stale-alert backlog described in #1203. Also re-plumbs the existing GH_PAT_WORKFLOWS secret through step-level env per org guidelines (functionally equivalent, no new exposure).

Linked issue analysis

Issue #1203 (fleet-tracker issues never auto-close on recovery/deletion → 107 stale alerts) is substantively addressed. The new "Close resolved fleet-tracker issues" step implements exactly the fix the issue describes: close any open fleet-tracker issue whose per-issue "Last updated ... on " stamp is older than STALE_DAYS (3), with an auto-resolved comment. Deleted workflows are covered by the same staleness path; the 4 deleted-claude.yml issues are being hand-closed per the PR description. The digest de-dup change additionally stops the date-titled daily digest from accumulating (closes prior digests before opening today's).

Findings

  • Safety gating is sound: the close step is gated on hashFiles('fleet_high_failure.json') != '' so a failed scan cannot mass-close, and staleness uses each issue's own stamp, so a single bad-scan day cannot false-close. Comment and close are independently try/catch'd.
  • Correct Search API pagination: github.paginate(search.issuesAndPullRequests, ..., response => response.data.items) uses the mapping function — the earlier Copilot finding on this was addressed (thread resolved).
  • Token handling: GH_PAT_WORKFLOWS moved from direct secrets. reference in with: to step-level env per CodeRabbit's org-guideline comment (thread resolved). Same token, same scope, same steps — no new auth surface; the new step reuses the identical cross-repo issues:write pattern already established in this workflow. Action remains pinned to the full SHA (v9.0.0).
  • No injection surface: scripts read only process.env and API data; untrusted issue bodies/titles are only regex-matched, never interpolated into expressions or commands.
  • Minor (non-blocking): if the whole fleet recovers, the digest-creation step won't run, so the last daily digest stays open until failures recur — at most one open digest, consistent with the "current snapshot stays open" design.
  • Secret-scanning MCP tool unavailable in this environment; gitleaks CI check is green and the diff contains only ${{ secrets.* }} references, no literal credentials.

CI status

All required checks green: SonarCloud ✓, CodeQL ✓, agent-shield / AgentShield ✓, dependency-audit / Detect ecosystems ✓. Also green: Lint, shellcheck/ShellCheck, unit-tests, bats, gitleaks, CodeRabbit, Agent Security Scan, gh-aw-compile, template-drift, holdout-guard. The cancelled dev-lead / dispatch and dev-lead / ci-relay runs are non-required agent-orchestration relays superseded by newer runs; review / review (in progress) is this review. All review threads resolved; reviewDecision is APPROVED.


Reviewed automatically by the PR-review agent (single-reviewer mode: fable 5). Reply if you need a human review.

don-petry added a commit that referenced this pull request Jul 14, 2026
…close (#1242)

A `response => response.data.items` mapFn added to the fleet-tracker auto-close
paginate call (during #1204 review) produced undefined entries, so the step threw
'TypeError: Cannot read properties of undefined (reading repository_url)' and
failed the entire daily monitor — the fleet-tracker/health backlog stopped
clearing. octokit already flattens search results to .items natively; remove the
redundant mapFn and add a defensive .filter(Boolean).


Claude-Session: https://claude.ai/code/session_01Juznz5V6su81ffSND8fg7s

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Don Petry Bot <donpetry+bot@gmail.com>
don-petry added a commit that referenced this pull request Jul 14, 2026
The 'Summarize token usage by workflow' step fetches/unzips every token-usage
artifact and hit an API rate-limit (HTTP 403), failing the whole daily monitor
BEFORE the load-bearing steps ran — issue tracking + the fleet-tracker auto-close
(#1204) never executed, so the backlog didn't clear even after the paginate fix
(#1242). This step is best-effort observability; mark it continue-on-error so a
transient rate-limit can never again abort the monitor and block the auto-close.


Claude-Session: https://claude.ai/code/session_01Juznz5V6su81ffSND8fg7s

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

3 participants