Skip to content

scripts/publish-revert-rate.sh's cumulative-since-baseline mining pass re-mines every merged PR since baseline, from scratch, daily, forever

Id: TD-PPagop-26082204 · Status: resolved · Filed: 2026-08-22 · Resolved: 2026-08-25 · Ref: https://github.com/Poetic-Poems/agent-ops/pull/783

scripts/publish-revert-rate.sh publishes three figures per repository each day: rolling (a fixed 14-day window), recent (the last 48h, subtracted from rolling), and cumulative (every labelled pull request merged since the stored Stage 0 baseline — revert_rate_baseline.generated, 2026-08-15). The first two bound their --since to an offset from “now”, so their mined population — and cost — stays roughly constant run to run. The cumulative pass does not: its --since is the fixed baseline date, so the population it re-mines from scratch on every scheduled run is every PR merged since then, and that population only grows as the baseline recedes into the past.

Each mined PR costs roughly three GitHub API calls (reviews, timeline, changed files — see scripts/mine-merge-history.sh’s mine_repo). At filing time this is already on the order of a few hundred calls a day per node across the fleet’s three repositories, and it is unbounded: a year after the baseline, the cumulative pass alone will be re-reading a year’s worth of merged, labelled pull requests every single day, against the 5000/hour core budget lib/github-limit.sh shares with every other script this pipeline runs. Nothing here fails loudly as that happens — the pass just gets slower and spends more of the shared budget, until it starts tripping the fleet-wide rate-limit wait lib/github-limit.sh’s gh wrapper already handles, at which point other scripts sharing the same hourly budget start queuing behind it too.

This was flagged in review of the PR that introduced the script (agent-ops PR #688, pullwright-approver-poetic[bot], 2026-08-22): “the acceptance criteria state ‘if any GitHub API quota edge case appears, document the remedy in code comment rather than silently absorbing it’, and this is the quota edge case the design itself creates.” That PR’s own header comment (scripts/publish-revert-rate.sh, “GitHub API quota” section) now names this growth and points here; this item is where the remedy itself belongs.

Either of two remedies bounds the cost without changing what is published:

  • Memoise settled per-PR outcomes. A PR’s post-merge outcome (revert / follow-up-fix / clean) cannot change once its own 48h observation window has elapsed — scripts/publish-revert-rate.sh’s own “Why two mining passes” section already relies on exactly this fact for the rolling figure’s subtraction argument. Caching each settled PR’s outcome (and its corrective-title/file/xref inputs, so a change to the detection logic can still be told apart from a change in the population) the first time it is mined, keyed by repo and PR number, means only the PRs merged since the last run’s cache — a bounded, roughly-daily-sized population — ever need re-mining.
  • Roll the cumulative row forward. Rather than re-deriving cumulative from the whole population each day, carry forward the previous day’s published {n, reverts, follow_up_fixes} from revert-rate.jsonl and add only the delta: PRs that have newly settled since the last run (merged more than 48h ago but not yet counted) plus a re-check of whatever merged in the last 48h at the time of the previous run (since its outcome may have changed since). This is a narrower version of the same idea as the memoisation above, without a separate cache file — it reads its own prior output instead.

Either remedy needs to handle a repository absent from a previous run (a newly-added repo, or one whose mining pass failed the day before) by falling back to a full baseline-bound mining pass for that repo alone, same as today.

  • scripts/publish-revert-rate.sh — “GitHub API quota” section, and the cumulative-since-baseline pass (mine_window "$slug" "$baseline_since")
  • scripts/mine-merge-history.sh — the miner this script shells out to; its own header explains the REST-over-search and pagination choices this item’s remedy would need to keep working with
  • lib/github-limit.sh — the shared 5000/hour core budget this pass draws against
  • agent-ops PR #688 — introduced the script; review comment pullwright-approver-poetic[bot], 2026-08-22, is where this was found