Skip to content

fix(state): label a non-draft PR awaiting at open - #59

Merged
Ardnived merged 2 commits into
mainfrom
claude/fix-awaiting-on-open
Sep 7, 2026
Merged

Ardnived merged 2 commits into
mainfrom
claude/fix-awaiting-on-open

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • A PR opened non-draft never gained awaiting, so it was ready for review and invisible on the board.
  • setAwaiting now runs on opened too, gated on pr.draft. The draft → ready path is unchanged.
  • README already promised this — "it appears the moment a PR is ready". The code never did it.

Changes

  • .github/workflows/state-machine.yml — the opened arm assigns the bot and sets awaiting when the PR is not a draft.

The failure this prevents

setAwaiting(n, true, …) on the ready_for_review arm was the only place a PR gained awaiting at open. GitHub emits ready_for_review only on a draft → ready transition, so a PR opened non-draft never reached it. The if / else if chain made it doubly unreachable: opened matches the arm above, so the ready_for_review arm cannot run for an opened PR whatever its draft state.

awaiting is the primary signal for human attention and the board is a lens over it. Four of the five loop PRs open on 2026-09-06 carried no label (#57 has the table). SahajCloud sat at wipCapPerRepo for two days with three such PRs waiting, while journal #51 recorded "Nothing implementable for three runs".

This is a backstop. Two follow-ups it does not fix

Review raised both. Each is its own PR under this repo's one-behaviour rule, and neither belongs here.

1. A loop PR should not be opening non-draft at all. finalize-pr/SKILL.md:244 states it as an invariant — "Every PR opens as a draft, without exception" — and docs/why.md#draft-is-the-prs-baton is why. So #57's table is also evidence that the pipeline skipped the baton on 4 of 5 PRs, three days after that rule landed (#36, 2026-09-03). One verified suspect: the create template at finalize-pr/SKILL.md:231 omits draft:true, while create_pull_request takes that boolean and the prose 13 lines below mandates it.

That matters beyond bookkeeping: with this fix in, a PR born ready puts awaiting in the reviewer's queue at opened, before CI has run — the exact state the baton exists to prevent. Invisible is still worse than premature, so this lands; the create template is the real repair.

2. reopened leaves the identical hole, one line down. closed removes awaiting (:246) and nothing restores it, so a reopened non-draft PR is again ready for review and absent from the board. That arm also clears the linked ticket's awaiting on reopen (:225), so after a reopen neither item carries the signal. Today the nightly drift sweep is the only thing that would notice.

Test results

  • Lean gate: ✓ claude plugin validate ./workflow --strict
  • 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 opens a non-draft PR ❌ no awaiting ✅ awaiting
bot opens a draft PR ✅ none ✅ none
bot marks a draft ready ✅ awaiting ✅ awaiting
someone else opens a PR ✅ no-op ✅ no-op

The defect reproduces on origin/main and only on the case the fix targets. The three paths that must not change do not.

  • Security review: skipped — no path matches securityReview.triggerPattern.
  • Docs: checked, nothing stale.
  • 0299d27 only shortens a comment. YAML re-parsed and the validator re-run; no behaviour touched, so the harness table above still stands.

Manual verification

  1. Open a non-draft PR as the bot in any of the five repos. awaiting appears within seconds.
  2. Open a draft PR. No awaiting until it is marked ready.
  3. Confirm neither path double-labels — setAwaiting reads current labels first.

Notes for reviewer

  • This is the deploy. The callers pin state-machine.yml@main, so merging changes behaviour in all five repos on their next event, with no merge anywhere else. One behaviour, shipped alone, per this repo's rule.
  • Reachability confirmed rather than assumed: every caller subscribes pull_request_target: types: [opened, …], and that payload carries pull_request.draft.
  • The opened arm still falls through to the closed-issue bookkeeping below it — the second if is untouched.
Detail

Why not restructure the chain. Folding ready_for_review into a shared branch would be a second behaviour in the same PR. The two arms answer different questions — "is this ready now?" at open, and "did it just become ready?" on the transition — and setAwaiting's read-before-write makes the overlap free.

The harness is not committed. This repo has no test suite by design (CLAUDE.md: the validator is the entire automated gate, because the skills are prose). Adding a lane for one workflow would be a second behaviour. The harness extracted the script: body from each revision, wrapped it as actions/github-script does, and stubbed github.rest.issues, github.request, github.graphql and core.summary.

Tool limitation hit. /code-review ran against the session's launch directory rather than this checkout and reported "not a git repository", so the review pass here was manual: reachability, event wiring, idempotency under the workflow's own re-trigger, and that no existing arm loses behaviour.

Closes #57

🤖 Written by the sydevs autonomous loop — see what this is

🤖 Generated with Claude Code

https://claude.ai/code/session_015PxdvGktTVasmM1TrVUwi2

`setAwaiting(n, true, …)` on the `ready_for_review` arm was the only place a
PR gained `awaiting` at open. GitHub emits `ready_for_review` only on a
draft -> ready transition, so a PR opened non-draft never reached it. The
`if` / `else if` chain made it doubly unreachable: `opened` matches the arm
above, so the `ready_for_review` arm cannot run for an opened PR whatever its
draft state.

`awaiting` is the primary signal for human attention and the board is a lens
over it, so a loop PR opened non-draft was ready for review and invisible to
the reviewer. Four of the five loop PRs open on 2026-09-06 carried no label.
SahajCloud sat at wipCapPerRepo for two days with three such PRs waiting.

Set the label on `opened` instead, gated on `pr.draft`. `setAwaiting` reads
the current labels first and returns early when they already match, so the
draft -> ready path is unaffected.

Closes #57

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XTcZqseu9xNXP1inapLV4q

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

Holistic. Eleven lines, one file, one behaviour: the diff is exactly the size of #57, smuggles nothing in, and correctly declines the chain restructure. The evidence holds up — the harness reproduces the defect on origin/main and only on the targeted case, and the callers do subscribe pull_request_target: [opened, …], whose payload carries pull_request.draft. The open question is shape, not code. Under docs/why.md#draft-is-the-prs-baton a bot PR is never non-draft at opened, so this new arm is a backstop for a state the system forbids — and #57's own table is unexplained evidence that the finalize pipeline skipped the baton on four PRs out of five. Labelling the symptom removes the only visible sign of that.

Findings

  • should-fix — root cause vs symptom: why did those PRs open non-draft? finalize-pr/SKILL.md:231 omits draft:true from the create template while :244 mandates it. (:218)
  • consider — reopened leaves the identical hole; its own PR, but name it. (:221)
  • consider — the seven-line comment narrates the defect that why: #57 already holds. (:209)

What was checked

  • #57 and the PR body against the diff: git diff origin/main...origin/claude/fix-awaiting-on-open — 1 file, +11/−1, state-machine.yml only.
  • state-machine.yml read whole on both sides: setAwaiting's read-before-write (:86-96), assignBot (:152), and the full opened / reopened / ready_for_review / synchronize / closed chain, plus the header's division of labour.
  • Callers, two of five: this repo's .github/workflows/workflow-state.yml and sydevs/SahajCloud's both subscribe pull_request_target: [opened, reopened, ready_for_review, synchronize, closed] — the opened reachability claim holds.
  • Consumer prose for staleness: finalize-pr steps 7–9 and hard rules, preflight §"never write state the state machine owns", survey-routine's drift-sweep table, work-routine rungs 2/4/5, README:88-90, docs/why.md#draft-is-the-prs-baton. Nothing contradicts the change; the body's "docs: nothing stale" checks out.
  • git log -S"Every PR opens as a draft" → the draft-baton rule landed 2026-09-03 (#36), i.e. before the 2026-09-06 PRs #57 cites, so those four are deviations and not pre-rule history.
  • Reviewer profile: read.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread .github/workflows/state-machine.yml Resolved
Comment thread .github/workflows/state-machine.yml Resolved
Comment thread .github/workflows/state-machine.yml Resolved
Addresses the review on #59.

Seven comment lines for three code lines, four of them narrating the broken
chain. The fact that outlives the incident is one: `ready_for_review` fires
only on a draft -> ready transition. `why: #57` carries the rest, matching
how the `synchronize` arm below already reads.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015PxdvGktTVasmM1TrVUwi2
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Revised in 0299d27. All 3 review findings addressed; the diff stays one behaviour.

  • The opened-arm comment is down to four lines — the durable fact plus why: #57, matching the synchronize arm.
  • Both follow-ups are now in the body, so they are not lost with the threads. I verified the first one's suspect: finalize-pr/SKILL.md:231's create template omits draft:true, while line 244 makes the draft an invariant. The reopened hole is the second.

Neither is fixed here. Each is its own PR under this repo's one-behaviour rule, and this one is still the backstop worth landing — a PR with no awaiting is invisible, which is worse than one that is premature.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@Ardnived
Ardnived merged commit 60e24b8 into main Sep 7, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in SYDevelopers Technical Roadmap Sep 7, 2026
@Ardnived Ardnived removed the awaiting label Sep 7, 2026
Ardnived added a commit that referenced this pull request Sep 7, 2026
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 deleted the claude/fix-awaiting-on-open branch September 7, 2026 15:12
Ardnived added a commit that referenced this pull request Sep 7, 2026
…, and relax the one-behaviour rule (#61)

* fix(loop): pass draft:true when creating the PR

`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.

* fix(state): restore `awaiting` when a non-draft PR is reopened

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.

* docs: make one-behaviour-per-PR a default, not a prohibition

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.
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.

fix(state): a PR opened non-draft never gets awaiting, so most loop PRs are invisible on the board

3 participants