Harden agent-team apply: reject bad diffs, list draft PRs via App #73

Closed
amoussa1229 wants to merge 2 commits from fix/agent-team-builder-validation-and-app-monitor into main
amoussa1229 commented 2026-06-25 17:38:51 +00:00 (Migrated from github.com)

Summary

Two reliability bugs in the agent-team apply pipeline, found investigating a blank draft PR (#72) and a README task that died silently:

  1. Builder emitted un-appliable / no-op diffs. build_candidate_diff accepted any non-empty diff string. A diff with placeholder hunk headers (@@ -X,Y +A,B @@) was dispatched and rejected by git apply (exit 128) — the task parked with an opaque error; a diff that only created an empty file applied cleanly and opened a blank draft PR (#72). Now a pure shape check fails at build with an actionable reason when a hunk header is non-numeric or the patch has no content.
  2. Draft-PR monitor depended on gh, which is not installed on the R720. gh pr list raised FileNotFoundError every 30s tick, so the runaway/stale monitor was permanently blind. Reuse the App installation-token REST path the dispatcher already uses (GET …/pulls, filtered to draft PRs under agent-team/apply/); fall back to gh only where the App env is absent.

Validation

  • python -m pytest -q → 1533 passed
  • ruff check / ruff format --check → clean
  • New tests: malformed-hunk and no-op-diff rejection (+ valid-diff regression guard); app_draft_pr_lister filtering, fail-soft on auth error, and token-scrubbing on transport error.

Notes

  • The plan-gate human-in-the-loop was not at fault — both plans were approved on Slack; the builder is the root cause.
  • Deploy to the live R720 is the gated /sh-deploy-r720 procedure (Hyper-V snapshot is Adam's manual step); this PR is not auto-deployed.
  • Conventional PR title/body for the bot's apply PRs is a follow-up PR (touches the security-reviewed apply workflow → GPT-4.1 cross-review + /sh-security-review).
## Summary Two reliability bugs in the agent-team apply pipeline, found investigating a blank draft PR (#72) and a README task that died silently: 1. **Builder emitted un-appliable / no-op diffs.** `build_candidate_diff` accepted any non-empty diff string. A diff with placeholder hunk headers (`@@ -X,Y +A,B @@`) was dispatched and rejected by `git apply` (exit 128) — the task parked with an opaque error; a diff that only created an empty file applied cleanly and opened a **blank** draft PR (#72). Now a pure shape check fails at build with an actionable reason when a hunk header is non-numeric or the patch has no content. 2. **Draft-PR monitor depended on `gh`, which is not installed on the R720.** `gh pr list` raised `FileNotFoundError` every 30s tick, so the runaway/stale monitor was permanently blind. Reuse the App installation-token REST path the dispatcher already uses (`GET …/pulls`, filtered to draft PRs under `agent-team/apply/`); fall back to `gh` only where the App env is absent. ## Validation - `python -m pytest -q` → **1533 passed** - `ruff check` / `ruff format --check` → clean - New tests: malformed-hunk and no-op-diff rejection (+ valid-diff regression guard); `app_draft_pr_lister` filtering, fail-soft on auth error, and token-scrubbing on transport error. ## Notes - The plan-gate human-in-the-loop was **not** at fault — both plans were approved on Slack; the builder is the root cause. - Deploy to the live R720 is the gated `/sh-deploy-r720` procedure (Hyper-V snapshot is Adam's manual step); this PR is not auto-deployed. - Conventional PR title/body for the bot's apply PRs is a follow-up PR (touches the security-reviewed apply workflow → GPT-4.1 cross-review + `/sh-security-review`).
amoussa1229 commented 2026-06-26 15:27:57 +00:00 (Migrated from github.com)

Closing: agent-team is being decommissioned (superseded by Open SWE). See removal PR.

Closing: agent-team is being decommissioned (superseded by Open SWE). See removal PR.
This repo is archived. You cannot comment on pull requests.
No description provided.