Skip to content

fix(analyze): bound the forge pass to half the token quota and a short window in CI - #339

Merged
0x73746F66 merged 1 commit into
mainfrom
fix/analyze-forge-quota
Nov 13, 2026
Merged

0x73746F66 merged 1 commit into
mainfrom
fix/analyze-forge-quota

Conversation

@0x73746F66

Copy link
Copy Markdown
Member

What

  • Forge budget (internal/analyze/forge/budget.go): the collector now stops when the remaining quota reaches max(100, limit/2). It used to stop at a fixed 100. The truncation reason reports how many requests were left out of the limit, and points at --forge-window-days.
  • analyze --forge-window-days (default 0, meaning the same as --window-days): sets how far back the GitHub pass reads pull requests, issues and commit reviews, separately from the git history window. The commit-review pass now only asks about non-merge commits inside that window (commitsToReview).
  • vulnetix gha init: the analyze job's extra-args is now
    ${{ github.event_name == 'pull_request' && '--no-forge' || github.event_name != 'workflow_dispatch' && '--forge-window-days=7' || '' }}.
    A pull request still skips the forge pass, as in ci(gha init): stop pull-request scans spending the repository's API quota #336. A push or a release reads the last 7 days. Only a manual run reads the full window.
  • Regenerated .github/workflows/vulnetix.yml with the new generator (gha init --ref v4.24.3; --check reports current) and docs/command-manifest.json. Documented the behaviour in docs/github-actions.md and the analyze help text.

Why

CodeQL and Auto Version were failing on main with API rate limit exceeded for installation. On every push to main, the analyze job read a year of pull requests, issues and commit reviews with GITHUB_TOKEN: several calls per pull request plus up to 300 commit lookups. It kept going until only 100 requests were left. That quota (1,000 an hour) belongs to the whole repository, so CodeQL's SARIF upload and the release dispatch on the same push ran out. Releases are published on almost every merge here, so the release event repeated the same spend.

With this change, a single run can never take more than half the hourly limit. The routine push and release runs read only a week of activity, which costs a small fraction of the requests.

Notes

  • This repository's workflow pins Vulnetix/cli/*@v4.24.3, and that CLI does not know --forge-window-days. Until the pin moves to the release that contains this change, the push run's analyze step exits non-zero, and fail-on-findings: false keeps the job green. No forge requests are made in that time. A follow-up bumps the pin.

How verified

  • go test ./internal/analyze/... ./internal/ghainit/... ./cmd/ pass. New tests:
    • TestBudget_KeepsHalfTheLimitForOtherJobs
    • TestBudget_UnknownLimit
    • TestCommitsToReview_StaysInsideTheForgeWindow
    • TestForgeWindowDays_FollowsTheHistoryWindowUnlessSet
    • TestAnalyzeBoundsTheForgePass (updated render test)
  • just lint (golangci-lint v2.14.0, as CI pins it): 0 issues.
  • actionlint .github/workflows/vulnetix.yml passes. vulnetix gha init --check --ref v4.24.3 reports the workflow is current.

…t window in CI

The vulnetix.yml analyze job read a year of pull requests, issues and commit reviews on every push to main, and kept spending the job token until 100 requests were left. That token's hourly quota belongs to the whole repository, so CodeQL's SARIF upload and the auto-version release dispatch failed with 'API rate limit exceeded for installation'.

- forge budget: stop at max(100, half the hourly limit) instead of a fixed 100.
- analyze: --forge-window-days bounds the GitHub pass apart from the git history
  window; the commit-review pass only asks about commits inside it.
- gha init: on a push or a release the analyze job passes --forge-window-days=7;
  only a manual run reads the full window. Pull requests still pass --no-forge.
- Regenerate .github/workflows/vulnetix.yml and docs/command-manifest.json.
@0x73746F66
0x73746F66 force-pushed the fix/analyze-forge-quota branch from 2c72a7a to 952cdeb Compare November 13, 2026 14:01
@github-actions

Copy link
Copy Markdown
Contributor

Vulnetix config plan

Manager gitops:vulnetix/cli, prune off, plan hash a8bd984f1753c68b180298051dd9e2524ab644d2ebe9e4c7c811ff4126753b5f

Object Action Changes
~ QualityGate/default update (adopt) severity: null -> "high"

0 to create, 1 to update, 0 to delete, 0 unchanged

@github-actions

Copy link
Copy Markdown
Contributor

Vulnetix config plan

Manager gitops:vulnetix/cli, prune off, plan hash a8bd984f1753c68b180298051dd9e2524ab644d2ebe9e4c7c811ff4126753b5f

Object Action Changes
~ QualityGate/default update (adopt) severity: null -> "high"

0 to create, 1 to update, 0 to delete, 0 unchanged

@0x73746F66
0x73746F66 merged commit c3f8633 into main Nov 13, 2026
31 of 34 checks passed
0x73746F66 added a commit that referenced this pull request Nov 13, 2026
v4.24.30 carries the bounded forge pass (#339). The workflow already passes --forge-window-days, which the v4.24.3 CLI does not know.
0x73746F66 added a commit that referenced this pull request Nov 13, 2026
v4.24.30 carries the bounded forge pass (#339). The workflow already passes --forge-window-days, which the v4.24.3 CLI does not know.
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.

1 participant