From d61b8fbaeb41521330539f3042e0d7ebec83c164 Mon Sep 17 00:00:00 2001 From: Day Dreamer <87640074+HugoXK@users.noreply.github.com> Date: Thu, 19 Nov 2026 01:40:12 +0000 Subject: [PATCH] ci(controller): stop adding the retired agent-pr label (#1161) The owner banned `agent-pr` repo-wide and the sweep stripped it from every object, but the controller still added it back on each run, so the two kept undoing each other. Drop the add from MANAGED, its reason, the docstring line, and the `is_agent_pr` rule with the agent-author/branch-prefix heuristics that only it read. The two `controller.json` keys that fed those heuristics go with it; `labels.json` still defines the label (create-only sync, inert) and is left alone. Not a gate change: `review-gate.yml` has no label filter, so no check stops judging PRs either way. --- .claude/skills/fix-issue/SKILL.md | 2 +- .github/agent/controller.json | 6 +-- .github/scripts/controller.py | 26 +++---------- AGENTS.md | 16 ++++---- changelog.d/1161-controller-drop-agent-pr.md | 5 +++ tests/test_process_controller.py | 40 +++++++++++--------- 6 files changed, 46 insertions(+), 49 deletions(-) create mode 100644 changelog.d/1161-controller-drop-agent-pr.md diff --git a/.claude/skills/fix-issue/SKILL.md b/.claude/skills/fix-issue/SKILL.md index 7d86bc49..a3dac3d3 100644 --- a/.claude/skills/fix-issue/SKILL.md +++ b/.claude/skills/fix-issue/SKILL.md @@ -48,7 +48,7 @@ never write the key anywhere. - Push the branch (never `main`, never `--force`), open the PR with the template: imperative title, `Fixes #N`, short body, `Tip SHA:` / `Ran:` / - `Not run:`. Assign `Birfy`; labels `agent-pr` + type + area. + `Not run:`. Assign `Birfy`; labels type + area (never `agent-pr`: retired, #1161). - Tier: `python3 .github/scripts/risk_gate.py --pr `. ## 5. Review at the tip diff --git a/.github/agent/controller.json b/.github/agent/controller.json index 3f697eac..3cf0b3bf 100644 --- a/.github/agent/controller.json +++ b/.github/agent/controller.json @@ -1,8 +1,8 @@ { "note": "Read by .github/scripts/controller.py from the default branch. Editing this file is T3. Maintainers listed here are the only people whose agent-ready label (and whose later edits) keep an issue agent-ready.", - "maintainers": ["Birfy"], - "agentBranchPrefixes": ["agent/"], - "agentAuthors": [], + "maintainers": [ + "Birfy" + ], "claimTtlHours": 6, "maxPrsPerRun": 50, "maxIssuesPerRun": 50 diff --git a/.github/scripts/controller.py b/.github/scripts/controller.py index 24209313..67ab4902 100644 --- a/.github/scripts/controller.py +++ b/.github/scripts/controller.py @@ -9,8 +9,9 @@ (``Fixes #N``); changed files are read only through the API and judged by the risk gate's rules. - - sets ``agent-pr`` on pull requests an agent opened, and ``risk:T0..T3`` - (the risk gate's tier) on every open PR not on ``hold`` + - sets ``risk:T0..T3`` (the risk gate's tier) on every open PR not on + ``hold``. It never adds the retired agent PR label: the owner banned it + (#1161) - removes ``agent-ready`` (and ``agent-working``) when someone who is not a maintainer labeled the issue, or edited its text after it was labeled - removes ``agent-working`` from a claim older than the TTL with no recent @@ -43,11 +44,11 @@ RISK = ["risk:T0", "risk:T1", "risk:T2", "risk:T3"] MANAGED = { # label -> what the controller may do with it. It can never ADD agent-ready. - "add": set(["agent-pr"] + RISK), + "add": set(RISK), "remove": set(["agent-ready", "agent-working"] + RISK), } MAX_OPS = 200 -REASONS = {"labeled-by-non-maintainer", "edited-by-non-maintainer", "claim-expired", "risk-tier", "agent-pr"} +REASONS = {"labeled-by-non-maintainer", "edited-by-non-maintainer", "claim-expired", "risk-tier"} # ---- mode ------------------------------------------------------------------- @@ -82,20 +83,6 @@ def closing_refs(body: Optional[str], repo: str) -> List[int]: return sorted(out) -def is_agent_pr(pr: Dict[str, Any], config: Dict[str, Any], repo: str, agent_issues: Iterable[int]) -> bool: - """By author, or a branch of this repository with an agent prefix, or a - branch of this repository that closes an agent-ready/agent-working issue. - A fork PR counts only by author.""" - if any(_same(a, pr["author"]) for a in config["agentAuthors"]): - return True - if not pr["sameRepo"]: - return False - if any(p and pr["headRef"].startswith(p) for p in config["agentBranchPrefixes"]): - return True - agent_issues = set(agent_issues) - return any(n in agent_issues for n in closing_refs(pr["body"], repo)) - - def _last(events: List[Dict[str, Any]], pred: Callable[[Dict[str, Any]], bool]) -> Optional[Dict[str, Any]]: hits = sorted((e for e in events if pred(e)), key=lambda e: e["at"]) return hits[-1] if hits else None @@ -154,7 +141,6 @@ def push(kind: str, number: int, found: List[Dict[str, str]], reason: str) -> No else: ops.append({"kind": kind, "number": number, "op": f["op"], "label": f["label"], "reason": reason}) - agent_issues = {i["number"] for i in state["issues"]} for issue in state["issues"]: labels = issue["labels"] if any(_same(l, "hold") for l in labels): @@ -183,8 +169,6 @@ def push(kind: str, number: int, found: List[Dict[str, str]], reason: str) -> No want = f"risk:{pr['tier']}" push("pr", pr["number"], _diff_labels(pr["labels"], add=[want], remove=[l for l in RISK if l != want]), "risk-tier") - if is_agent_pr(pr, config, state["repo"], agent_issues): - push("pr", pr["number"], _diff_labels(pr["labels"], add=["agent-pr"]), "agent-pr") if len(ops) > MAX_OPS: notes.append(f"{len(ops)} operations; keeping the first {MAX_OPS}") del ops[MAX_OPS:] diff --git a/AGENTS.md b/AGENTS.md index 06ee6c54..5da6820c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -80,8 +80,9 @@ Source of truth: [`.github/labels.json`](.github/labels.json), synced by the - **Source:** `self-test` (filed by the self-test routine; issues only). - **State:** `needs-info` (spec unclear), `needs-human` (needs Danyang's decision; the last comment says what), `agent-ready`, `agent-working`, - `agent-pr`, `awaiting-approval` (green T2/T3 PR waiting for a PASS and - Danyang's click), `hold` (automation leaves the item alone). + `awaiting-approval` (green T2/T3 PR waiting for a PASS and Danyang's click), + `hold` (automation leaves the item alone). `agent-pr` is retired: the owner + banned it and the controller no longer sets it (#1161). - **Risk:** `risk:T0` … `risk:T3`, set by the controller only, never by hand. ### Triage: when an issue is `agent-ready` @@ -98,16 +99,17 @@ question in a comment. Agents develop **only** `agent-ready` issues. - Before work: skip an issue someone else is assigned to. Otherwise assign `Birfy`, add `agent-working`, and comment naming the branch. - Stopping without a PR: unassign, remove `agent-working`, say why. -- The PR says `Fixes #N`, is assigned to `Birfy`, labeled `agent-pr` plus its - type and area. Agent branches start with `agent/`. +- The PR says `Fixes #N`, is assigned to `Birfy`, labeled with its type and + area — never `agent-pr`, which is banned. Agent branches start with `agent/`. ## Controller [`.github/workflows/controller.yml`](.github/workflows/controller.yml) runs every 30 minutes with the built-in `GITHUB_TOKEN` only (no GitHub App, no secrets) and -changes labels and nothing else: it sets `risk:T*` and `agent-pr` on open PRs, -removes `agent-ready`/`agent-working` when a non-maintainer set or edited an -issue after it was approved, and expires a claim after 6 h with no linked push. +changes labels and nothing else: it sets `risk:T*` on open PRs, removes +`agent-ready`/`agent-working` when a non-maintainer set or edited an issue after +it was approved, and expires a claim after 6 h with no linked push. It never +adds `agent-pr`; that label is retired (#1161). It never adds `agent-ready`, never merges, comments or closes. | Repository variable | Effect | diff --git a/changelog.d/1161-controller-drop-agent-pr.md b/changelog.d/1161-controller-drop-agent-pr.md new file mode 100644 index 00000000..f78afa00 --- /dev/null +++ b/changelog.d/1161-controller-drop-agent-pr.md @@ -0,0 +1,5 @@ +Fixed +The label controller no longer adds the retired `agent-pr` label, so a +scheduled run cannot undo the repository-wide strip the owner made: the add +block, its reason string and the agent-author/branch heuristics behind it are +gone, and `controller.json` drops the two keys only that rule read (#1161). diff --git a/tests/test_process_controller.py b/tests/test_process_controller.py index 070d43d5..55ed20fe 100644 --- a/tests/test_process_controller.py +++ b/tests/test_process_controller.py @@ -77,15 +77,6 @@ def test_closing_refs_reads_this_repository_only(): assert c.closing_refs(body, REPO) == [12, 13, 14] -def test_is_agent_pr(): - cfg = dict(CONFIG, agentAuthors=["bot-x"]) - assert c.is_agent_pr(pr(1, author="bot-x", same=False), cfg, REPO, set()) - assert c.is_agent_pr(pr(1, head="agent/fix-3"), cfg, REPO, set()) - assert not c.is_agent_pr(pr(1, head="agent/fix-3", same=False), cfg, REPO, set()), "fork: by author only" - assert c.is_agent_pr(pr(1, body="Fixes #7"), cfg, REPO, {7}) - assert not c.is_agent_pr(pr(1, body="Fixes #8"), cfg, REPO, {7}) - - def test_judge_ready(): ok = issue(1, ["agent-ready"], [ev("labeled", "2026-10-19T01:00:00Z", "Birfy", "agent-ready")]) assert c.judge_ready(ok, CONFIG)["demote"] is None @@ -117,11 +108,24 @@ def test_plan_issues(): assert {"number": 4, "label": "*", "reason": "hold"} in out["skipped"] -def test_plan_prs_get_one_risk_label_and_agent_pr_by_rule(): +def test_plan_prs_get_one_risk_label_and_nothing_else(): out = run(prs=[pr(10, ["risk:T1", "risk:T3"], tier="T3"), pr(11, tier="T0", head="agent/x"), pr(12, ["hold"], tier="T3"), pr(13, tier=None)]) ops = {(o["number"], o["op"], o["label"]) for o in out["ops"]} - assert ops == {(10, "remove", "risk:T1"), (11, "add", "risk:T0"), (11, "add", "agent-pr")} + assert ops == {(10, "remove", "risk:T1"), (11, "add", "risk:T0")} + + +def test_a_plan_never_adds_agent_pr_not_even_on_an_agent_branch(): + """The owner banned ``agent-pr`` repo-wide and the sweep strips it, so the + controller must not put it back — whatever the author, the branch prefix or + the issue the PR closes (#1161).""" + closed = issue(7, ["agent-ready"], [ev("labeled", "2026-10-19T01:00:00Z", "Birfy", "agent-ready")]) + out = run(issues=[closed], + prs=[pr(11, tier="T0", head="agent/x"), + pr(12, tier="T2", head="agent/fix-7", body="Fixes #7"), + pr(13, tier="T1", head="feat/plain", author="bot-x")]) + assert [o for o in out["ops"] if o["label"] == "agent-pr"] == [] + assert "agent-pr" not in c.MANAGED["add"] def test_a_missing_label_is_skipped_never_created(): @@ -141,10 +145,12 @@ def test_plan_only_proposes_managed_labels_and_never_adds_agent_ready(): @pytest.mark.parametrize("bad", [ None, {}, {"version": 2, "ops": []}, - {"version": 1, "ops": [{"number": 0, "op": "add", "label": "agent-pr", "reason": "agent-pr"}]}, - {"version": 1, "ops": [{"number": True, "op": "add", "label": "agent-pr", "reason": "agent-pr"}]}, - {"version": 1, "ops": [{"number": 1, "op": "close", "label": "agent-pr", "reason": "agent-pr"}]}, - {"version": 1, "ops": [{"number": 1, "op": "add", "label": "agent-ready", "reason": "agent-pr"}]}, + {"version": 1, "ops": [{"number": 0, "op": "add", "label": "risk:T1", "reason": "risk-tier"}]}, + {"version": 1, "ops": [{"number": True, "op": "add", "label": "risk:T1", "reason": "risk-tier"}]}, + {"version": 1, "ops": [{"number": 1, "op": "close", "label": "risk:T1", "reason": "risk-tier"}]}, + {"version": 1, "ops": [{"number": 1, "op": "add", "label": "agent-ready", "reason": "risk-tier"}]}, + # the banned label is refused even in a hand-written plan (#1161) + {"version": 1, "ops": [{"number": 1, "op": "add", "label": "agent-pr", "reason": "risk-tier"}]}, {"version": 1, "ops": [{"number": 1, "op": "remove", "label": "hold", "reason": "risk-tier"}]}, {"version": 1, "ops": [{"number": 1, "op": "add", "label": "risk:T0", "reason": "because"}]}, {"version": 1, "ops": [{"number": 1, "op": "add", "label": "risk:T0", "reason": "risk-tier"}] * 201}, @@ -179,12 +185,12 @@ def test_apply_writes_only_label_endpoints_and_rechecks_the_state(): {"number": 2, "op": "add", "label": "risk:T1", "reason": "risk-tier"}, {"number": 3, "op": "remove", "label": "risk:T3", "reason": "risk-tier"}, {"number": 4, "op": "remove", "label": "agent-working", "reason": "claim-expired"}, - {"number": 5, "op": "add", "label": "agent-pr", "reason": "agent-pr"}, + {"number": 5, "op": "add", "label": "risk:T1", "reason": "risk-tier"}, ] api = FakeApi({1: {"state": "open", "labels": []}, 2: {"state": "closed", "labels": []}, 3: {"state": "open", "labels": [{"name": "risk:T3"}, {"name": "hold"}]}, 4: {"state": "open", "labels": [{"name": "agent-working"}]}, - 5: {"state": "open", "labels": [{"name": "agent-pr"}]}}) + 5: {"state": "open", "labels": [{"name": "risk:T1"}]}}) out = c.apply({"version": 1, "ops": ops}, api, REPO) assert [o["number"] for o in out["done"]] == [1, 4] assert {s["number"]: s["why"] for s in out["skipped"]} == {2: "closed", 3: "hold", 5: "already"}