Skip to content

fix(pr-pipeline): read the lane sweep's whole 24-hour window - #9323

Merged
kyle-sexton merged 2 commits into
mainfrom
fix/lane-audit-window
Oct 23, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
fix/lane-audit-window

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Refs: #9297

Summary

The lane sweep's collect job made one run listing for its 24-hour window. GitHub's run listing returns at most 1,000 runs per filtered search, so the audit saw about the last 4 hours of the day (defect D1 of the GitHub API efficiency plan). It now reads every run of the window inside its 350-call budget, and a read it cannot finish is reported as partial instead of passing for a full day.

Automation Lanes owns this lane and agreed this session builds the change; Automation Lanes reviews the head.

Fix

  • listRuns lists workflow by workflow (every workflow but the sweep's own, so slice A still sees every workflow's failures). One per_page=1 call over the whole window reads each workflow's count; a workflow with no run costs that call alone, and a range whose count reaches the 1,000 cap is halved at a whole second until each part fits. Runs are kept by id, so a split never counts one twice.
  • The window's end is fixed when the run starts. Listing stops before the last 170 calls, which the open PR and issue reads and the most the units can spend need, so the units still get their details.
  • A workflow read only in part is named in a ::warning:: with what it read and its count, and its A or D unit carries window_complete: false beside window_start and the new window_end. The judge prompt tells the model to call such counts partial, never a full day's. The lane sweep section of docs/conventions/pr-pipeline/README.md describes the listing.

Verification

  • node --test .github/scripts/maintenance-audit-lane-runs/*.test.mjs: 46 of 46 pass, exit 0. New tests against a fake that caps each listing at 1,000 runs, as GitHub does:
    • 2,550 runs (2,500 in one workflow) are all read once, each workflow gets exactly one full-window per_page=1 count, an empty workflow costs one call, and the read stays under 350 − 170 calls;
    • a budget that runs out names the part-read workflow with what it read and its count, never spends the reserve, and gives total: null for a workflow whose count was never read;
    • main writes window_complete: false on the part-read workflow's unit and true on the full one, and prints the warning.
  • With the split disabled the listing tests fail (2 of 8 in collect.test.mjs).
  • bash scripts/check-affected.sh --tests: exit 0, 10 passed, 4 skipped (after rebasing onto main, which had touched the same README).
  • Left out: a live run of the workflow; it runs on its daily schedule from main.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits October 23, 2026 00:48
The collect job made one run listing for the window, and GitHub returns
at most 1,000 runs per filtered listing, so it saw about the last 4 hours.
It now lists workflow by workflow: one per_page=1 call reads each count,
and a range at the cap is halved until each part fits, inside the
350-call budget with 170 calls kept for the units. A workflow read only in
part is named in a warning and its unit carries window_complete: false,
which the judge prompt reports as partial.

Refs: #9297

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 23, 2026 05:03
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-23T05:03:15.429162Z 9058dd5 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 9058dd559621da7066a3b2963e03e2912941116a: 0 finding(s), 0 as inline comments.

Security review of PR 9323 at 9058dd5: no security issues found.

I read the full diff. It changes the lane sweep's collector, its test, the judge prompt, a convention doc and a changelog fragment.

  • Injection and path handling: The new API URLs in collect.mjs interpolate only values the collector controls: repo from the workflow environment, a numeric workflow id from the GitHub API, and timestamps built from Date. API-sourced strings (workflow paths, run data) are used only for filtering and comparison, never in a URL or a command.
  • Trust boundary: Run data, job logs and annotations were already untrusted input to the judge, and this PR adds no new source. The new window_complete, window_start and window_end fields are computed by the collector and are not derived from run text. The added prompt.md sentence only tells the judge to report partial counts as partial. It removes no guardrail and widens no authority, so the instruction-surface deletion check does not apply.
  • Credentials and outputs: writeOutput now takes the output file path as a parameter, and main passes env.GITHUB_OUTPUT. It keeps the random per-call delimiter, and the values written are a JSON array of unit ids and a call count. A workflow-run value cannot inject extra output keys. The test redirects fetch and GITHUB_OUTPUT to temporary files. Nothing reaches the network or real secrets.
  • Resource limits: Listing stops before the last 170 calls of the 350-call budget, so the fan-out cannot exhaust the API budget or loop without bound. The range halving ends once a range is under 2 seconds wide.
  • Plugin manifests: None changed.
  • GitHub Actions: No workflow file changed.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 9058dd559621da7066a3b2963e03e2912941116a: 0 finding(s), 0 as inline comments.

Code review: PR #9323 (lane sweep reads the whole 24-hour window)

No findings. I posted no inline comments.

What I checked

  • Range splitting (collect.mjs, listRuns): the two halves [a, mid] and [mid+1000, b] cover the range with no gap and no overlap on whole-second timestamps. mid + 1000 <= b holds whenever b - a >= 2000, and a range under 2,000 ms falls through to paging. A range that cannot be split further is reported as partial, not silently truncated. Runs are kept by id, so a split cannot count a run twice.
  • Reserve arithmetic: the 170-call reserve matches the unit-detail code.
    • Open PR and issue reads: 1 + up to 3 = 4.
    • Each A unit: 5 runs × (1 jobs read + 3 failed jobs × 2 reads) = 35, so 140 for four units.
    • Each D unit: 3 jobs reads, so 6 for two units.
    • Each C unit: 10 check-run reads, so 20 for two units (MAX_UNITS = 8).
    • The total is 4 + 140 + 6 + 20 = 170.
  • Budget guards: every listing call is guarded by room() or sits behind a room() check before it, so listing cannot spend into the reserve. The one thing I could not check is how GitHub reports total_count on a capped search; the split logic works whether it reports the true total or caps it at 1,000.
  • Unit marking: units carry workflow, so window_complete is set for A and D units and left unset for C units. The new prompt.md text and the README section match the code.
  • Tests: I read the three new tests against the fake API. The call counts in the budget-cut tests (178 calls, then 12, then 3) match the code path, and main is exported so the end-to-end test does not trigger the CLI guard. I did not run the tests myself; the PR body's pass counts are author-claimed and unverified here.
  • Changelog fragment: bump: patch fits a bug fix. The change adds no plugin manifest, so no manifest <field> lines apply.
  • Closing issue: the PR uses Refs: #9297, so no issue is closed and there are no acceptance criteria to check.

Minor, not worth blocking

  • A workflow whose count is 0 is flagged partial, with a "0 of 0 runs" warning, if the budget room is already gone by the time it is processed. That needs more than about 180 workflows; this repository has 30 files in .github/workflows, so it cannot happen here.
  • If one half of a split fails because a single second holds more than 1,000 runs, the other half is skipped even with budget left. The workflow is still reported partial.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit dcf9180 Oct 23, 2026
59 checks passed
@kyle-sexton
kyle-sexton deleted the fix/lane-audit-window branch October 23, 2026 05:27
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