Skip to content

feat: implement issue #954 — Token Cost Report weekly run times out at 30m and silently stops posting - #955

Merged
don-petry merged 5 commits into
mainfrom
dev-lead/issue-954-20260626-2329
Jun 27, 2026
Merged

feat: implement issue #954 — Token Cost Report weekly run times out at 30m and silently stops posting#955
don-petry merged 5 commits into
mainfrom
dev-lead/issue-954-20260626-2329

Conversation

@don-petry

@don-petry don-petry commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Closes #954

Implemented by dev-lead agent. Please review.

Summary by CodeRabbit

  • New Features

    • Token cost reports now have longer run time limits and can notify the tracking issue if generation fails or times out.
    • Artifact collection now uses configurable timeouts and can continue processing available data even if one source is slow.
  • Bug Fixes

    • Prevented report posting from running after a failed or cancelled job.
    • Improved resilience so partial network or artifact download failures no longer block the full report.

@don-petry
don-petry requested a review from a team as a code owner June 26, 2026 23:43
@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.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The workflow now gives token report generation more time, posts the report only after successful completion with output present, and adds a failure/cancellation comment on the tracking issue. The collection script adds per-call timeouts, bounded parallel artifact processing, and matching test coverage.

Changes

Token report timeout and alert flow

Layer / File(s) Summary
Workflow timeout and posting guards
.github/workflows/token-report.yml
The job timeout increases to 60 minutes, the main report-posting step requires success plus token_report.md, and a new github-script step comments on the tracking issue when generation fails or is cancelled.
Artifact timeout and parallel collection
scripts/token_report.sh
ARTIFACT_OP_TIMEOUT and COLLECT_CONCURRENCY are documented, _gh_timeout wraps gh, and collect_org_jsonl now lists and downloads artifacts in bounded parallel passes with repo-tagged JSONL output and marker-based counts.
Timeout coverage
tests/token_report.bats
Tests cover _gh_timeout with enabled and disabled timeouts and exercise collect_org_jsonl with one timed-out artifact and one successful artifact.

Sequence Diagram(s)

sequenceDiagram
  participant token_report_yml
  participant token_report_sh
  participant github_api
  participant tracking_issue

  token_report_yml->>token_report_sh: Generate org-wide token report
  token_report_sh->>github_api: List repos and download token-usage-* artifacts
  github_api-->>token_report_sh: Artifact listings and zip contents
  token_report_yml->>github_api: Post token_report.md when success() and file exists
  token_report_yml->>tracking_issue: Add failure comment when failure() or cancelled()
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the PR’s main change: fixing the Token Cost Report timeout and skipped posting behavior.
Linked Issues check ✅ Passed The changes address the issue’s core requirements: timeout increase, bounded collection, concurrency, and visible failure alerts.
Out of Scope Changes check ✅ Passed The modified workflow, script, and tests all support the linked Token Cost Report fix; no unrelated changes are evident.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-lead/issue-954-20260626-2329

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 — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) June 26, 2026 23:44
@don-petry
don-petry disabled auto-merge June 26, 2026 23:44
@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-06-27T00:44:43Z.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces parallel processing and timeouts to the artifact collection process in scripts/token_report.sh to prevent hung or slow GitHub API calls from stalling the entire job. The feedback recommends adding error handling for mktemp calls to prevent execution with empty paths, replacing shell glob expansion with find to avoid "Argument list too long" errors, and skipping tests that rely on the timeout command when it is not available on the host system.

Comment thread scripts/token_report.sh Outdated
Comment thread scripts/token_report.sh Outdated
Comment thread scripts/token_report.sh Outdated
Comment thread tests/token_report.bats
Comment thread tests/token_report.bats
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 26, 2026
@don-petry

Copy link
Copy Markdown
Collaborator Author

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

Changes committed and pushed.

@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) June 26, 2026 23:47
@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-06-27T00:47:52Z.

@don-petry
don-petry disabled auto-merge June 27, 2026 00:22
@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) June 27, 2026 00:26
@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-06-27T01:26:50Z.

@don-petry
don-petry disabled auto-merge June 27, 2026 04:40
@sonarqubecloud

Copy link
Copy Markdown

@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: b5604a09be6efa1e80eaa9f8dfd94fc629cab38d
Review mode: triage-approved (single reviewer)

Summary

Fixes the weekly Token Cost Report timeout (#954). collect_org_jsonl() is reworked from serial/unbounded to two bounded-parallel passes (xargs -P COLLECT_CONCURRENCY) with a per-gh-call timeout wrapper (_gh_timeout, ARTIFACT_OP_TIMEOUT) so a single hung artifact download can no longer consume the whole job. The workflow raises timeout-minutes 30->60 as a safety margin, gates the post step on success(), and adds a 'fail loudly' step that comments on the tracking issue when generation fails or is cancelled. 82 lines of new bats coverage exercise the timeout and parallel-collection paths.

Linked issue analysis

Closes #954. All four proposed fixes are implemented: (1) per-download/per-listing timeout via _gh_timeout; (2) bounded parallelism over repos and artifacts; (3) timeout-minutes 30->60 stopgap; (4) fail-loudly alert step instead of a silent if-skip. Acceptance criteria are met: render functions stay network-free, a single hung download is bounded (covered by a new test asserting elapsed<15s), and a failed/cancelled run now surfaces a visible comment. Per-record repo tagging is preserved.

Findings

No blocking findings. Prior gemini-code-assist recommendations are all addressed in the head SHA: both mktemp calls now have error guards (skip-repo WARN / return 1); pass-2 aggregation uses find -exec cat instead of shell glob (avoids 'Argument list too long'); and the new timeout-dependent tests skip cleanly when the 'timeout' binary is absent. Security: the new github-script step interpolates no untrusted PR input (only static strings and trusted process.env), and the parallel workers pass repo/id as positional args (no shell injection). coderabbit and codex were rate-limited and did not post a review; the rate-limit window (reset 01:26Z) has since passed with no further bot input, and gemini + SonarCloud + CodeQL + gitleaks all provided clean automated coverage.

CI status

All quality gates green: CI Lint/ShellCheck/shellcheck, bats, validate-agent-profiles, gh-aw-compile, Compile agentic workflows, unit-tests, CodeQL (actions+python), SonarCloud, Secret scan (gitleaks), agent-shield, holdout-guard, test-deletion guard. The two CANCELLED checks are the Dev-Lead Agent's own dispatch/ci-relay jobs (self-cancelled via concurrency; ci-relay intentionally [skip]), not PR quality gates. SKIPPED dependency-audit sub-jobs are non-applicable ecosystems. mergeStateStatus is BLOCKED only on 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

Copy link
Copy Markdown
Collaborator Author

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

PR: #955
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-06-27T05:14:44Z

@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-06-27T05:14:44Z

@don-petry
don-petry merged commit c863f78 into main Jun 27, 2026
28 of 32 checks passed
@don-petry
don-petry deleted the dev-lead/issue-954-20260626-2329 branch June 27, 2026 04:44
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.

Token Cost Report weekly run times out at 30m and silently stops posting

2 participants