Skip to content

feat(source-control): default pr_open_state to ready per the PR-states rule - #7661

Merged
kyle-sexton merged 13 commits into
mainfrom
feat/7576-pr-open-state
Oct 16, 2026
Merged

kyle-sexton merged 13 commits into
mainfrom
feat/7576-pr-open-state

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Refs: #7576

Summary

Implements Phase 8 slice a (pr-states) of the poteto-review plan under owner decision Q501. Each PR state has one meaning:

  • Save point: commits pushed to the feature branch, with no PR.
  • Draft: a person asked to see the work early, or the PR is a multi-session container.
  • Ready: complete and through the local gates. Ready starts the test lanes, AI review and code-owner requests.

/source-control:pull-request holds the rule. This repository opts into pr_open_state: ready. The bundled default stays draft, by owner decision on this PR, so a repository or user opts in to ready.

Fix

  • Every PR opens as a draft. create opens it as a draft in every case. When the state resolves to ready, create then runs Phase 2.5 (ready) on that PR, so a PR reaches ready only through ready's base merge, reviews and verify gate. If a gate stops, the PR stays a draft and the report says why; nothing forces the flip. This is the existing AGENTS.md exception: a PR this session's own create opened, marked ready only by running ready to completion. No stop in "When to stop and when to keep going" changes. Inside full, full runs Phase 2.5 itself, and a requested draft ends full after create.
  • New request level. An invocation that asks for a draft, or names the PR a multi-session container, wins over every configured level. create records the reason as a Draft: line in the PR body. /source-control:babysit-prs never flips a draft carrying that line, in any tier, including autopilot. check-ready-holds.sh gains --unattended: with it, that line holds the flip (exit 3, the existing hold code), while a person running ready may still flip it. Every unattended caller now invokes ready --unattended: /work-items:work, /work-items:ship run, babysit autopilot and unattended /improvement:improve. New tests in check-ready-holds.test.sh cover three cases: unattended with the line refuses; attended with the line passes; unattended without the line passes.
  • Unattended runs still open a draft. That covers loop lanes, CI lanes, dontAsk sessions, dispatched workers and every --pushed run. Q91 and Q108 say routines and lanes open ready PRs; that change waits for a separate owner decision and is not in this PR.
  • This repository opts in. docs/conventions/source-control.yaml sets pr_open_state: ready. AGENTS.md's "Open a pull request as a draft" section becomes "Pull request states": a pointer to the skill plus this repository's value. The Conventional Commits title rule and the ready-flip rules stay.
  • Text that said draft-first now matches the rule:
    • pull-request: SKILL.md, full-lifecycle.md, stacks.md, native-surfaces.md, the checklist template, and the GitHub provider's create commands
    • babysit-prs
    • /improvement:improve, /improvement:find, /testing:cleanup
    • docs/upstream/cursor-pstack.md and the skill cheat sheet
  • Babysit check. I read babysit-prs and babysit-loop for draft-first assumptions. Their draft handling, became_ready_for_review, the non-draft gates and draft elevation all act on the PR's current draft flag, not on how it was opened. With the Draft: hold added, they agree with this rule.
  • Evals.
    • New plugin-eval case pull-request-create-default-open-state-draft.
    • In pull-request/evals/evals.json:
      • the open-state cases now cover the draft default and the repository and userConfig opt-ins;
      • eval 24 is renamed to pr-open-state-repo-file-ready-opens-draft-then-flips;
      • new case 48 checks that a request for a draft wins.
    • New babysit-prs eval 18 checks that autopilot holds a draft marked Draft:.
  • Test selection. scripts/affected-tests-no-suite.txt maps the four team-layer docs/conventions/*.yaml files to the convention-yaml-schema lane. They are listed one by one, because a * glob would also catch example YAML that no lane reads.
  • Changelog fragments: source-control (minor); improvement, testing and work-items (patch).

Cost. Once a PR is ready, the test and AI review lanes run on every push. Opting into ready therefore spends a review run on each push a session makes. The owner accepted this cost (Q501), and Phase 8 slice b (review_venue: one venue per PR, blocking-only after the first review, Q500) reduces it.

Verification

After npm ci in the worktree, and after merging origin/main into the branch:

Check Exit Result
scripts/check-affected.sh --tests 0 9 passed, 0 skipped
check-skill.sh over source-control, work-items and improvement skills 0 21 passed
validate-cases.py plugins/source-control/evals 0 only the allowed_tools warning every sibling case also gets
check-evals-quality.sh, pull-request 0 PASS; its 5 warnings are all in cases this PR does not touch
check-evals-quality.sh, babysit-prs 0 PASS, 0 warnings
babysit-prs Python suites (contract test updated for ready --unattended) 0 1501 passed
check-ready-holds.test.sh 0 49 passed; each new hold case failed first (the Redraft: negative and the attended pass hold by construction)

Fresh-context code and security reviews (the 9 findings of the first review are fixed) found no blocking defect at ready. Fixed from the ready reviews: the hold matches any line starting Draft:, bare or with a reason (any case, after spaces or a quote marker), control bytes are stripped from its reason, and every babysit flip site passes --unattended. No paid eval runs.

Instruction evidence (instruction economy). This PR replaces a standing instruction; it adds none to an always-loaded surface. AGENTS.md's draft-first section shrinks to a pointer, and the rule body goes into create's reference, which loads only when that action runs. The observed stumbles behind it, more than once on the current model:

  • The draft-first AGENTS.md rule contradicted shipped lane behavior. The owner's 2026-10-15 audit found lane PRs opening ready in feat(pr-pipeline): open work-lane PRs ready and post pipeline statuses #7508 while AGENTS.md still mandated drafts (Q108, re-asked as Q501).
  • Sessions treated every draft alike and could not tell a draft a person asked for from one waiting for ready. Q585 records the conflict, and that is why the Draft: line exists.
  • The owner's decision, Q501, is a team convention checked into git, which is the durable tier the instruction-economy rule exempts.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 11 commits October 16, 2026 16:23
…s rule

create opens every PR as a draft and, when the open state resolves to
ready (the new default), runs ready on it, so a PR reaches ready only
through ready's gates. A draft is kept on request, as a multi-session
container, when a level sets draft, or on an unattended run. AGENTS.md
points at the rule instead of mandating draft-first.

Refs: #7576

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Report an invalid value as its own fallback level, keep a requested draft
inside full, fix the stale default in the pstack upstream record, and make
the default-state eval case independent of a forge.

Refs: #7576

Co-Authored-By: Claude Opus 5.5 <[email protected]>
create writes a `Draft:` body line when a person asked for the draft or
the PR is a multi-session container; babysit-prs holds any draft that
carries it, in every tier. Rename eval 24 to what it now checks.

Refs: #7576

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With no config, create keeps opening a draft; a repository or user opts
into ready, which create reaches by running ready on the new draft. This
repository keeps its opt-in. Eval cases and the default-state plugin-eval
case now check a draft default.

Refs: #7576

Co-Authored-By: Claude Opus 5.5 <[email protected]>
check-ready-holds.sh gains --unattended: with it, a `Draft: requested
early look` or `Draft: multi-session container` body line holds the flip
(exit 3). A person running ready may still flip. Every unattended caller
(work, ship run, babysit autopilot, improve) now invokes
ready --unattended.

Refs: #7576

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The unattended hold now matches any line starting `Draft:` (any case,
after spaces or a quote marker) and strips control bytes from the
reason; babysit's flip sites all pass --unattended, and create states
when an unmarked PR stays a draft.

Refs: #7576

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 16, 2026 21:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T21:19:28.370567Z 98f9a5a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 7m 6s —— View job


Security review in progress

  • Gather context (PR diff, changed files)
  • Check instruction-exception-register for removed/softened guardrails (the AGENTS.md draft-first rule change doesn't drop the existing "when to stop" approval gate — unchanged in this diff)
  • Review shell scripts (check-ready-holds.sh, test script) for injection/logic flaws
  • Review skill/reference docs for trust-boundary or unattended-flip risks — found one candidate gap, verifying now
  • Review eval/scaffold files for unsafe patterns (none found)
  • Adversarially verify candidate finding (in progress)
  • Post final summary

@claude

claude Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 5m 41s —— View job


Code review complete

  • Gather context (diff, CLAUDE.md/AGENTS.md, custom instructions)
  • Invoke /review:code-review per custom instructions
  • Post findings as inline comments
  • Post summary comment

Scope. Reviewed all 42 changed files against origin/main (the pr-states feature: pr_open_state default flip to ready, the new Draft: request level, and the --unattended hold on check-ready-holds.sh). This is docs/skill/script content, not an application change, so the review focused on cross-file consistency and script correctness rather than runtime behavior.

What I checked:

  • Traced the pr_open_state resolution ladder end-to-end across config-resolution.md, create.md §2.4.3, SKILL.md, the schema, and plugin.json — the request/repository/userConfig/default precedence is stated consistently everywhere it appears.
  • Hand-verified the new jq regex in check-ready-holds.sh#L74 against every case in check-ready-holds.test.sh (case-insensitivity, > quote-marker prefix, CRLF stripping, control-byte stripping, mid-line Draft: non-match) by tracing jq's operator precedence and scan/first/gsub semantics manually — the logic matches the asserted test outcomes. I was not able to execute the test suite myself in this sandbox (bash script execution required approval that wasn't granted), so this is a manual trace, not a tool-confirmed run; the author's own "46 passed" verification claim is otherwise unverified by me.
  • Grepped for every remaining pull-request ready call site repo-wide to check the PR's claim that "every unattended caller now invokes ready --unattended" — babysit-prs, work-items:work, work-items:ship run, and improvement:improve are all updated. The other hits (repo-sweep's ## Next/suggestion text, autofix-pr's handoff instructions, changelog entries) are human-facing suggestions, not automated unattended invocations, so they're correctly left alone.
  • Confirmed the four files newly listed in scripts/affected-tests-no-suite.txt (code-metrics.yaml, pr-pipeline.yaml, source-control.yaml, testing.yaml) all exist at the stated paths.
  • Checked test_skill_contract.py's updated asserted substrings against the actual SKILL.md/autopilot.md text — exact matches.

No blocking or important findings. The design is internally consistent across all touched reference docs, the schema, the evals, and the shell script, and I found no correctness gap in the resolution ladder, the hold-check regex, or the unattended-caller sweep.

One low-signal observation, not worth a block: create.md §2.4.3's instruction to run "Phase 2.5 ... right after §2.5" overloads "2.5" (the document's own ## 2.5 Record expected CI workflows heading vs. the lifecycle's "Phase 2.5" ready action) in one sentence. It's disambiguated correctly by the §/Phase prefix convention used consistently elsewhere in the file, so I'm not filing it as a finding, just flagging it as a spot that reads awkwardly on a first pass: create.md#L500.
· Branch

claude-lane-summary: lane=claude-review sha=98f9a5a830e351ecfc42fed6fd3c96ee1345fa32 run=38966326683

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

claude-review has reviewed this pull request through 2d2954f; a later push is reviewed from there.

@claude

claude Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 3m 53s —— View job


Security review complete

  • Gather context (PR diff, changed files)
  • Check skip gate (closed PR, no security surface, already reviewed)
  • Read instruction-exception-register for instruction-surface deletions
  • Review changed files for security issues (injection, authz, secrets, trust boundaries)
  • Review check-ready-holds.sh / check-ready-holds.test.sh changes (hold/bypass logic)
  • Review babysit-prs draft-hold logic changes
  • Post findings / summary

No security issues found. This PR reworks when a pull request reaches ready (repo/user opt-in via pr_open_state), adds a Draft: body-line hold that check-ready-holds.sh --unattended and babysit-prs honor, and threads ready --unattended through every automated caller.

Checks performed:

  • check-ready-holds.sh (commit blob): --argjson unattended "$UNATTENDED" is a literal true/false, not user input, so no jq-filter injection. The new Draft: scan regex is a simple bounded pattern (no catastrophic-backtracking shape) applied to a GitHub-length-limited body. Control bytes are stripped from the embedded reason (gsub("[[:cntrl:]]"; "")) before it's echoed to stdout, and the script's own header comment correctly frames that reason as data, never an instruction for whatever reads it — matching this repo's untrusted-content convention. Covered by new cases in check-ready-holds.test.sh (case-insensitive, blockquote-prefixed, CRLF, control-byte, mid-line-non-match, attended-bypass).
  • Automated ready call sites: grepped every pull-request ready invocation; every unattended/automated one (work-items:work, work-items:ship run, babysit-prs autopilot, unattended improvement:improve) was updated to pass --unattended in this diff. The one plain /source-control:pull-request ready left in playbooks/repo-sweep/SKILL.md is a ## Next pointer (a mention for a human, not an operative invocation, per this repo's skill-authoring convention), not a new automation gap.
  • create always opens a draft now, even when pr_open_state resolves to ready — it then runs the ready phase's own merge/review/verify gates to flip it, so configuring ready doesn't skip review, only automates the flip. -F draft="$DRAFT_JSON" became a literal -F draft=true, removing a variable-driven flag rather than adding one.
  • Instruction-surface check (docs/conventions/instruction-exception-register/README.md): AGENTS.md's "Open a pull request as a draft" → "Pull request states" section replaces an unconditional draft-only rule with a configurable one, but the action gated — marking a PR ready — stays inside AGENTS.md's existing stop-list exception ("a PR whose number this session's own create returned may be marked ready, but only by running ready to completion, which stops on its own gates"), which this PR doesn't touch. No Gate 0 class (irreversible-action, secret-handling, data-integrity, external-publication, legal-compliance, agent-authority) loses its enforcing mechanism; the mechanism (the ready gate sequence) is unchanged and still runs on every flip, attended or not.

claude-lane-summary: lane=claude-security-review sha=98f9a5a830e351ecfc42fed6fd3c96ee1345fa32 run=38966326956

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review has reviewed this pull request through 2d2954f; a later push is reviewed from there.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 98f9a5a830

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

kyle-sexton and others added 2 commits October 16, 2026 17:24
A `Draft:` line with nothing after it now holds an unattended flip;
tests cover it and a `Redraft:` line that must not hold. The work and
ship evals expect `ready --unattended`, and improve's Next names the
unattended form for unattended runs.

Refs: #7576

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@claude

claude Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 2m 1s —— View job


Security review complete

  • Gather context (diff, changed files, skip-gate check)
  • Check instruction-exception-register for removed/softened guardrails
  • Review shell script changes (check-ready-holds.sh, test script) for injection/logic flaws
  • Review skill/reference docs for trust-boundary or unattended-flip risks
  • Review eval/scaffold files for unsafe patterns
  • Adversarially verify candidate findings (none survived to report)
  • Post final summary

No security issues found.

This PR already carried two completed security/code reviews at 98f9a5a (both found no blocking defects). The push to the current head, 2d2954f, is a merge of origin/main plus one feature commit (9cc314d). I diffed 98f9a5a..2d2954f to scope this pass to what's actually new rather than re-deriving the whole PR:

  • check-ready-holds.sh (blob@L74): the Draft: hold regex changed [^\r\n]+ → [^\r\n]*, so a bare Draft: line with no reason text now also holds an unattended flip. This closes a gap rather than opening one — previously a PR body with just Draft: (no trailing text) would not have held, letting an unattended ready --unattended flip a PR a person had explicitly marked draft. No new injection surface: $unattended is still passed via --argjson (a literal boolean, not interpolated text), and the widened match is still line-anchored (^[ \t>]*Draft:), so it does not start matching Redraft: or other non-hold text.
  • check-ready-holds.test.sh: two new cases cover the fix directly — a bare Draft: line now holds (exit 3), and a Redraft: line still does not (exit 0). Consistent with the anchoring above; I traced the regex against both by hand.
  • AGENTS.md, docs/conventions/source-control.yaml, create.md: byte-identical between 98f9a5a and 2d2954f — the instruction-surface analysis from the prior security-review pass still applies unchanged.
  • improve/SKILL.md, work-items eval files: doc/eval text updated to say ready --unattended instead of ready, matching the already-reviewed threading of --unattended through every automated caller. No behavior change beyond that wording.

No CRITICAL / IMPORTANT / SUGGESTION findings to report; no inline comments posted.
· Branch

claude-lane-summary: lane=claude-security-review sha=2d2954f36d11655be0ae253fb2f47524fcf55c63 run=38969500957

@claude

claude Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 2m 21s —— View job


Code review complete

  • Gather context (diff, CLAUDE.md/AGENTS.md, custom instructions)
  • Invoke /review:code-review per custom instructions
  • Post findings as inline comments
  • Post summary comment

Scope. This push (2d2954f3) is a merge of origin/main plus one new commit, 9cc314d8 ("hold a bare Draft: line and align ready evals"), on top of the head (98f9a5a8) the claude-review and claude-security-review lanes already reviewed with no blocking findings. The merge itself brings in unrelated upstream commits (numpy bump, silent-revert fragment-scan fix, stacks GA re-stamp, pr-run-activity) that are not part of this PR's diff against origin/main; I confirmed the actual PR diff against origin/main is the same 44-file set already summarized, so I reviewed the full diff again end-to-end and focused verification on the one genuinely new commit.

What's new since the last reviewed SHA (9cc314d8):

  • check-ready-holds.sh#L75: the hold regex changed Draft:[ \t]*[^\r\n]+ → Draft:[ \t]*[^\r\n]* (+ → *). Traced this by hand: under the old pattern, a line consisting of exactly Draft: with nothing after it (not even a trailing space) failed to match, because [^\r\n]+ required at least one character past the colon — a real gap in a hold meant to catch any Draft: line. The new * closes it, and the new test case (check-ready-holds.test.sh:165-167, body Draft:\n) exercises exactly that case and expects exit 3. The accompanying Redraft: negative case correctly still fails to match, since ^[ \t>]*Draft: anchors at line start and Redraft: has Re in that position — same anchoring as before, unaffected by the +/* change.
  • The improve/SKILL.md ## Next edit and the ship/work eval expected-output edits consistently thread ready --unattended through, matching the rest of the PR's "every unattended caller passes --unattended" claim.

Full-diff re-check. Re-read the complete 44-file diff (via .claude-lane/pr.diff) against the two prior reviews' coverage: the pr_open_state resolution ladder (request > repository > userConfig > default) is stated consistently in config-resolution.md, create.md §2.4.3, SKILL.md, the schema, and plugin.json; every ready call site a lane/orchestrator/loop drives now passes --unattended; create always opens a draft and defers the ready flip to Phase 2.5; and the babysit-prs draft-hold text, autopilot, loop, and orchestration references all now name the Draft: line as a hold ready --unattended itself also enforces. No new correctness gap found.

Not independently re-run: the author's "49 passed" claim for check-ready-holds.test.sh and the other listed suites — this sandbox denies direct script execution, so, same as the prior review pass, I traced the jq regex and bash logic by hand against each test case rather than confirming by running the suite.

No blocking or important findings.
· Branch

claude-lane-summary: lane=claude-review sha=2d2954f36d11655be0ae253fb2f47524fcf55c63 run=38969500735

@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 16, 2026
Merged via the queue into main with commit 55e1c5f Oct 16, 2026
48 of 49 checks passed
@kyle-sexton
kyle-sexton deleted the feat/7576-pr-open-state branch October 16, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant