Skip to content

Commit fd728b2

Browse files
docs(sustainabot): document AM010/BP008 budget-resume sweep integration (#223)
## Summary - Adds a "Budget-Resume Sweep Integration" section to `bots/sustainabot/ARCHITECTURE.md`. - Documents how sustainabot should trigger `.git-private-farm/dispatch-templates/budget-resume-sweep.yml` via `workflow_dispatch` when its periodic scan detects >50 PRs blocked only on phantom required contexts (BP008 + AM010). - Includes calling pattern (`gh workflow run ...`), eligibility criteria, DBA002 threshold, and rationale for deferring native Rust integration. - No Rust code changes — this is documentation + TODO only, as specified. ## Test plan - [ ] Read-through: confirm architecture description is accurate and the `gh workflow run` call matches the workflow inputs in `budget-resume-sweep.yml` - [ ] Confirm no Rust code was changed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c1083db commit fd728b2

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

bots/sustainabot/ARCHITECTURE.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,68 @@ Based on code quality: cyclomatic complexity, nesting depth, pattern count.
179179
- `sustainabot-eclexia`: policy evaluation, decisions_to_results
180180
- `sustainabot-fleet`: finding conversion, severity mapping, suggestions
181181

182+
## Budget-Resume Sweep Integration (AM010 / BP008)
183+
184+
**TODO** (future Rust integration — Rust implementation deferred, out of scope for this cycle).
185+
186+
When sustainabot's periodic estate scan detects more than 50 open PRs that are stuck
187+
exclusively on phantom required status-check contexts (BP008 findings), it should trigger
188+
the `.git-private-farm/dispatch-templates/budget-resume-sweep.yml` workflow via
189+
`workflow_dispatch` to admin-merge the eligible PRs in bulk.
190+
191+
### Calling pattern
192+
193+
sustainabot triggers the sweep by dispatching to the farm workflow:
194+
195+
```sh
196+
gh workflow run budget-resume-sweep.yml \
197+
--repo hyperpolymath/.git-private-farm \
198+
--field target_owner=<OWNER> \
199+
--field target_repo=<REPO> \
200+
--field max_merges=20
201+
```
202+
203+
### Eligibility criteria (AM010)
204+
205+
A PR is considered eligible for the sweep when every required status-check context
206+
configured in branch protection (see GitHub API
207+
`repos/{owner}/{repo}/branches/main/protection/required_status_checks`) either:
208+
209+
1. **passes** (conclusion `SUCCESS`, `NEUTRAL`, or `SKIPPED` in the PR's rollup), or
210+
2. **is a phantom** — it is listed as required but has emitted zero check-runs across
211+
the last five commits on main (Hypatia rule BP008), AND it has no rollup entry on
212+
this specific PR (ALARP type-1 mitigation: a path-filtered workflow that happens to
213+
fire on this PR is not treated as phantom even if it was silent on recent main commits).
214+
215+
The `hypatia pr-eligibility --owner X --repo Y --pr N` escript command implements this
216+
check and emits JSON:
217+
218+
```json
219+
{"eligible": true, "reason": "AM010", "phantom_contexts": ["spark-theatre-gate / SPARK Theatre Gate"], "required_contexts": [...]}
220+
```
221+
222+
### Threshold
223+
224+
The dispatch fires when `eligible_pr_count >= 50` (configurable via Hypatia DBA002 rule).
225+
This was the empirically validated threshold from the 2026-05-27 estate sweep where the
226+
GitHub Actions billing cliff-hit first occurred.
227+
228+
### Why Rust integration is deferred
229+
230+
The sweep logic is pure GitHub API orchestration (list PRs → query Hypatia → admin-merge).
231+
This is already fully covered by the shell script inside `budget-resume-sweep.yml` which
232+
clones and builds the Hypatia escript on-demand. Embedding the same logic in Rust would
233+
duplicate the Hypatia eligibility engine and create a maintenance surface. The correct
234+
long-term architecture is for sustainabot to invoke the workflow dispatch (one HTTP call)
235+
rather than re-implement the BP008/AM010 checks natively.
236+
237+
When the Hypatia escript gains a stable gRPC or HTTP API (planned for a future release),
238+
sustainabot-fleet can be updated to call that API directly instead of shelling out.
239+
182240
## References
183241

184242
- [SARIF 2.1.0 Specification](https://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html)
185243
- [Software Carbon Intensity (SCI) Specification](https://sci.greensoftware.foundation/)
186244
- [Green Software Foundation](https://greensoftware.foundation/)
245+
- [Hypatia BP008/AM010 rules](https://github.com/hyperpolymath/hypatia) — phantom required context detection and admin-merge eligibility
246+
- [`.git-private-farm/dispatch-templates/budget-resume-sweep.yml`](https://github.com/hyperpolymath/.git-private-farm/blob/main/dispatch-templates/budget-resume-sweep.yml) — the workflow triggered when eligible PR count exceeds 50

0 commit comments

Comments
 (0)