Skip to content

fix(controller): skip draft pull requests when labelling - #1195

Merged
Birfy merged 1 commit into
mainfrom
agent/1192-draft-skip
Nov 20, 2026
Merged

Birfy merged 1 commit into
mainfrom
agent/1192-draft-skip

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1192.

What changed

.github/scripts/controller.py:

  • read_prs records draft from the pull list it already fetches — no extra API request.
  • plan skips a draft PR right after hold, with reason draft in the existing skipped shape: {"number": n, "label": "*", "reason": "draft"}. A skip is no add and no remove, so a draft keeps the labels it already has; hold is still checked first, so an operator-held draft reports hold.
  • no new plan key: plan() still returns {"ops", "skipped", "notes"}, render prints the entry as - #20 ?: draft, validate_plan and apply see exactly today's plan. apply is unchanged, so a PR converted to draft between plan and apply can still take one round of labels; that window is a recorded known gap, not fixed here.

AGENTS.md: the controller paragraph now says "open non-draft PRs" instead of "open PRs" — the one clause this change makes stale.

changelog.d/1192-draft-skip.md: Fixed.

Why this is live, not hypothetical

Run 44773778580 (event: pull_request, created_at 2026-11-20T16:28:42Z, head_sha cd5a608b…) was #1194's own opened event executing that branch's new trigger with main's script. Its plan job reported "4 operation(s), 0 skipped" (16:28:54Z) and apply succeeded; the labels landed as #1194 agent-pr + risk:T3 from 16:29:04Z and the parked draft #1191 risk:T2 at 16:29:05Z, agent-pr at 16:29:06Z — no cron, no dispatch. Once #1187 merges, every opened/ready_for_review/reopened fires that full pass, so skipping drafts in plan is what keeps a parked draft out of the queue.

Red first at 050235a4

Clean worktree at 050235a4 with only the new test file copied in (git status --short → ?? tests/test_process_controller_draft.py):

pytest tests/test_process_controller_draft.py -o addopts="" -q
→ 4 failed, 1 passed
  • test_read_prs_records_the_draft_flag_it_already_fetches — KeyError: 'draft': the base record has no such field.
  • test_a_draft_pr_is_skipped_and_keeps_the_labels_it_has — base plan() for a draft: true PR returns add risk:T2 + add agent-pr with skipped: [].
  • test_a_ready_pr_next_to_it_is_labelled_normally — the same ops appear beside the draft: false control row, which must stay untouched.
  • test_the_draft_reason_needs_no_new_plan_key_and_renders — the base renders | PR #30 | add | risk:T2 | risk-tier | where the skip belongs.

The one pass is the hold control, which must hold before and after.

At this tip: 144 passed in the ten-file focused set; python -m tools.changelog_fragments check → 7 fragments OK. Full offline suite on the pre-rebase tree (b64388b0, identical diff): 7940 passed, 32 failed, 29 skipped — the same 32 environment rows red at the base (15 test_era_* without numpy in the sandbox runner, 12 test_sandbox_container without a Docker daemon, 2 test_integrations, test_genesis_example::test_a_shared_toolchain_directory_is_not_mounted, test_merge_golden, test_test_package_resolution).

Tip SHA: 83bae39

Ran:

  • the ten-file focused set (test_process_controller, test_process_controller_draft, test_controller, test_workflow_actions_pinned, test_process_labels, test_process_risk_gate, test_process_review_gate, test_process_merge_lane_base, test_changelog_fragments, test_safety_controller) at this tip → 144 passed
  • python -m tools.changelog_fragments check → 7 changelog fragment(s) OK
  • full offline suite at b64388b0, the same diff before the rebase onto 050235a4 → 7940 passed, 32 failed, 29 skipped, the same 32 ids red at the base

Not run:

  • full offline suite at this exact tip — the rebase replayed b64388b0 onto 050235a4; the focused set was re-run at the tip
  • Docker sandbox rows and the wheel smoke — host environment, unrelated to a label filter
  • mkdocs build --strict — no docs/ or mkdocs.yml change

No UI surface: the controller script, its tests, and one clause in AGENTS.md.

@HugoXK HugoXK added bug Something isn't working area:ci CI workflows, release, packaging and the repo process (.github/, AGENTS.md) labels Nov 20, 2026
@HugoXK HugoXK added the agent-pr Pull request opened by an agent label Nov 20, 2026
The cron labels every open PR, so a draft that nobody asked to review yet
picked up `agent-pr` and `risk:T*` and sat in the review queue. `read_prs`
already receives the pull list, which carries `draft`; it now records the
field, and `plan` skips a draft with reason `draft` in the existing `skipped`
shape, so the plan JSON gains no key and `apply` is unchanged. A skip is no
add and no remove, so a draft keeps the labels it has; `hold` is still
checked first. `draft: false` PRs are labelled exactly as before.

AGENTS.md said the controller labels "open PRs"; it now says "open non-draft
PRs", the one clause this change makes stale.

Refs #1192
@github-actions github-actions Bot added the risk:T3 Risk tier T3 (core loop, release, process; needs Danyang's click), set by the controller label Nov 20, 2026
@Birfy

Birfy commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Review (Birfy)

Tip SHA: 83bae39
Ran:

  • .github/scripts/risk_gate.py --repo ThinkFlowLab/agentdescent --pr 1195 → T3 (.github/scripts/controller.py, AGENTS.md; 137 lines / 4 files)
  • pytest -o addopts="" -p no:cacheprovider -q tests/test_process_controller.py tests/test_process_controller_draft.py tests/test_controller.py tests/test_workflow_actions_pinned.py tests/test_process_labels.py tests/test_process_risk_gate.py tests/test_process_review_gate.py tests/test_changelog_fragments.py tests/test_safety_controller.py at this tip → 140 passed
  • python -m tools.changelog_fragments check → 7 changelog fragment(s) OK
  • Required CI at this tip → green (build, test (3.9)–test (3.13), otel-wire; deploy skipped; risk tier / reviewed tip report-only)
    Not run:
  • Full offline suite locally — the CI test matrix is the line
  • mkdocs build --strict — AGENTS.md only, no generated docs change
    Findings:
  • No actionable defects. read_prs records the draft flag already present on the pull list (no extra request). plan skips a draft after hold, with no add and no remove, so existing labels stay; a ready PR next to it is still labelled. The known plan/apply window for a PR converted to draft mid-run is acceptable and documented.
    Verdict: PASS

@Birfy
Birfy merged commit 8d75685 into main Nov 20, 2026
10 checks passed
@Birfy
Birfy deleted the agent/1192-draft-skip branch November 20, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-pr Pull request opened by an agent area:ci CI workflows, release, packaging and the repo process (.github/, AGENTS.md) bug Something isn't working risk:T3 Risk tier T3 (core loop, release, process; needs Danyang's click), set by the controller

Projects

None yet

Development

Successfully merging this pull request may close these issues.

controller: a draft PR gets agent-pr/risk:T* from the cron, so a parked draft sits in the review queue

2 participants