Skip to content

fix(state,loop): open the PR as a draft, restore awaiting on reopen, and relax the one-behaviour rule - #61

Merged
Ardnived merged 3 commits into
mainfrom
claude/followups-from-59
Sep 7, 2026
Merged

Ardnived merged 3 commits into
mainfrom
claude/followups-from-59

Conversation

@Ardnived

@Ardnived Ardnived commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Both follow-ups #59 named and deliberately did not fix. #59 made a non-draft loop PR visible; these two stop it being born non-draft, and stop a reopen hiding it again.

  • finalize-pr's create template omitted draft, so every loop PR opened ready for review — against the invariant stated 13 lines below it.
  • reopened had the identical hole opened had, one line down: closed strips awaiting and nothing restored it.

Three commits, one per behaviour

CLAUDE.md used to forbid this outright. 7168345 changes that: one behaviour per PR is now the
default rather than a prohibition, with one exception kept hard — a skill change and a ceiling
change together, which is genuinely unattributable because you cannot re-run to find out which
one moved the output. These three are disjoint files with one commit each, so any of them reverts
alone.

Changes

Commit File Behaviour
dc29a0b workflow/skills/finalize-pr/SKILL.md:232 create_pull_request template gains draft:true
dc29a0b workflow/.claude-plugin/plugin.json version 0.2.4 → 0.2.5 — the cache key for a skill change
53ef37b .github/workflows/state-machine.yml the label gate widens to reopened; assignBot splits out and stays on opened
7168345 AGENTS.md (CLAUDE.md is a symlink to it) one behaviour per PR becomes a default; the skill/ceiling split stays hard

1. The PR was born ready for review

finalize-pr/SKILL.md:232 is the pipeline's only PR-creation site (grep -rn 'create_pull_request\|gh pr create' workflow/ docs/ returns it and nothing else). Its template listed owner repo head base title body and no draft. The tool defaults that boolean to false.

So the prose 13 lines below — "Every PR opens as a draft, without exception" — was contradicted by the template a model actually copies. #57's table is the outcome: 4 of 5 loop PRs opened on 2026-09-06 were non-draft, three days after #36 landed the rule.

This matters more now that #59 is in. A PR born ready puts awaiting in your queue at opened, before CI has run — the exact state the baton exists to prevent (docs/why.md#draft-is-the-prs-baton). And draft:false is what marks a PR as having been ready at least once, which is what makes rung 5's once-ever review fire once.

version is bumped because a skill body changed and the cache directory is named after it (docs/why.md#an-installed-plugin-does-not-track-main).

2. A reopened PR lost awaiting and never got it back

The closed arm removes awaiting. Nothing restored it, and ready_for_review cannot: GitHub emits that event only on a draft → ready transition, and a reopened PR never transitions. So a reopened non-draft PR was ready for review and off the board.

It compounded. The opened/reopened arm below also clears the linked ticket's awaiting on reopen, on the grounds that the PR carries the signal now. It did not. After a reopen neither item carried it, and only the nightly drift sweep would have noticed.

The fix widens the existing label gate to reopened, keeping !pr.draft. assignBot is split out above rather than widened — unassigning a PR is the kill switch for a delegated one, so re-adding it on reopen would undo a deliberate removal. Its own doc comment ("Called ONLY on pull_request: opened … Never on reopened") stays true.

All five callers already subscribe pull_request_target: types: [opened, reopened, …], checked in each repo's workflow-state.yml. That payload carries pull_request.draft.

Test results

  • Lean gate: ✓ claude plugin validate ./workflow --strict
  • node workflow/lib/rule-delta.mjs --base main workflow/skills → directives: 57 → 57, no directive disappeared.
  • YAML parses; the github-script body passes node --check when wrapped as actions/github-script wraps it.
  • Behaviour harness — the real handler driven against synthetic payloads with a stubbed Octokit, on origin/main and on this branch:
Case origin/main this branch
bot reopens a non-draft PR ❌ no awaiting ✅ awaiting
bot reopens a draft PR ✅ none ✅ none
bot opens a non-draft PR ✅ awaiting ✅ awaiting
bot opens a draft PR ✅ none ✅ none
bot marks a draft ready ✅ awaiting ✅ awaiting
bot pushes (synchronize) ✅ none ✅ none
bot's PR is closed ✅ none ✅ none
someone else opens / reopens ✅ no-op ✅ no-op

One row changes, and it is the one targeted. The bot is assigned on opened only, on both revisions — reopen adds no assignee.

Re-run with a linked ticket stubbed into closingIssuesReferences, to prove the bookkeeping arm I moved code past is untouched:

Case origin/main this branch
open / reopen, ticket → Implemented, unassigned, -awaiting ✅ ✅ identical
close unmerged, ticket → Revising, +awaiting ✅ ✅ identical
  • Security review: skipped — no path matches securityReview.triggerPattern. finalize-pr's frontmatter is unchanged; the edit is one parameter inside a fenced example.
  • Docs: docs/why.md#draft-is-the-prs-baton already states both invariants correctly. Nothing stale — the defect was that the template disagreed with the docs, not that the docs were wrong.

3. One behaviour per PR was a prohibition

Stated absolutely in three places in AGENTS.md, and this PR hit it on the first try. What the
rule protects is attribution — a skill edit takes effect on the next run, never the current
one, so when that run behaves oddly you need to know which change caused it. One commit per
behaviour already gives that. A separate PR is a stronger form of the same guarantee and is not
free: it costs a review round, and wipCapPerRepo bounds how many may be open at once.

The default stands, the prohibition goes, and the one case that is genuinely unattributable — a
skill change and a ceiling change together — stays forbidden. reflect/SKILL.md:161 states that
exception too, unchanged.

Manual verification

  1. Reopen a closed non-draft bot PR in any of the five repos. awaiting appears within seconds.
  2. Reopen a closed draft bot PR. No label until it is marked ready.
  3. Let the loop open its next PR. It should arrive as a draft, with the review already requested.

Notes for reviewer

  • The workflow half is the deploy — the callers pin state-machine.yml@main, so merging changes behaviour in all five repos on their next event. The skill half reaches the routines on their next run.
  • The harness is not committed: this repo has no test lane by design, and adding one for a single workflow would be a third behaviour. It extracts the script: body from each revision, wraps it as actions/github-script does, and stubs github.rest.issues, github.rest.pulls, github.request, github.graphql and core.summary.
  • Comment length: fix(state): label a non-draft PR awaiting at open #59's review asked for the durable fact only, so the new comment is three lines and defers the rest to why: #57, matching the synchronize arm below.

`finalize-pr/SKILL.md:232` is the only place the pipeline creates a PR, and
its `create_pull_request` template omitted `draft`. The tool defaults to
`false`, so every PR the loop opened was born ready for review — while the
prose 13 lines below states the opposite as an invariant: "Every PR opens as
a draft, without exception."

Draft is the PR's baton (docs/why.md#draft-is-the-prs-baton). A PR born ready
puts unfinished work in the reviewer's queue before CI has run, and makes the
once-ever rung 5 review a moving target, because `draft:false` is what marks
a PR as having been ready at least once.

#57's table is the evidence: 4 of 5 loop PRs opened on 2026-09-06 were
non-draft, three days after #36 landed the rule. #59 made those PRs visible
on the board. This stops them being born ready in the first place.

`version` bumped because a skill body changed and the cache key is the
version (why: docs/why.md#an-installed-plugin-does-not-track-main).

Follow-up 1 of 2 from #59.
The `closed` arm removes `awaiting` and nothing put it back, so a reopened
non-draft PR was ready for review and invisible on the board — the same hole
#59 closed one line up for `opened`. `ready_for_review` cannot cover it:
GitHub emits that event only on a draft -> ready transition, and a reopened
PR never transitions.

It compounded. The `opened`/`reopened` arm below also clears the linked
ticket's `awaiting` on reopen, on the grounds that the PR carries the signal
now. It did not. After a reopen neither item carried it, and only the nightly
drift sweep would have noticed.

Widen the label gate to `reopened`, keeping the `!pr.draft` test. `assignBot`
stays on `opened` alone — it is split out above rather than widened, because
unassigning a PR is the kill switch for a delegated one, and re-adding on
reopen would undo a deliberate removal.

Follow-up 2 of 2 from #59.
The rule read as absolute in three places, and #61 hit it immediately: two
follow-ups from #59, disjoint files, one commit each, and no reviewer benefit
from splitting them into two rounds.

What the rule is actually protecting is attribution — you cannot test a change
here by running it, so when the next run behaves oddly you need to know which
change caused it. One commit per behaviour gives that. A separate PR is a
stronger form of the same guarantee, and it is not free: it costs a review
round, and `wipCapPerRepo` bounds how many may be open at once.

So the default stands and the prohibition goes, with one exception kept hard:
a skill change and a ceiling change together. Those two move the next run's
output in the same direction, so a combined PR is genuinely unattributable.

reflect/SKILL.md:161 states that exception too, unchanged and still correct.
@Ardnived Ardnived changed the title fix(state,loop): open the PR as a draft, and restore awaiting on reopen fix(state,loop): open the PR as a draft, restore awaiting on reopen, and relax the one-behaviour rule Sep 7, 2026
@Ardnived
Ardnived merged commit 0dd51a3 into main Sep 7, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in SYDevelopers Technical Roadmap Sep 7, 2026
@Ardnived
Ardnived deleted the claude/followups-from-59 branch September 7, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant