Skip to content

[codex] Fix PR-batch Goal-mode completion contract - #52

Merged
justin808 merged 9 commits into
mainfrom
jg-codex/pr-batch-goal-mode-completion
Jul 1, 2026
Merged

[codex] Fix PR-batch Goal-mode completion contract#52
justin808 merged 9 commits into
mainfrom
jg-codex/pr-batch-goal-mode-completion

Conversation

@justin808

@justin808 justin808 commented Jul 1, 2026

Copy link
Copy Markdown
Member

Summary

This PR fixes the PR-batch Goal-mode closeout contract so a batch cannot be reported as complete while any target is still waiting on checks/review, unknown, or otherwise non-terminal.

What changed

  • Adds a canonical Goal Mode Completion Contract to workflows/pr-processing.md.
  • Carries the contract into $pr-batch and generated plan-pr-batch goal prompts.
  • Adds a focused regression/pressure guard for the false-completion scenarios.
  • Extends the prompt-size guard to pin the new goal prompt wording.

Why

Batch closeout could previously report a useful per-target state such as waiting-on-checks-or-review while still letting the overall Goal-mode task look complete. The new contract makes that state explicitly non-terminal for the overall goal unless the run is status-only/timeboxed or there is a real blocker with exact resume instructions.

Validation

  • ruby skills/pr-batch/bin/goal-completion-contract-test.rb
  • ruby skills/plan-pr-batch/scripts/check_goal_prompt_size.rb
  • bin/validate
  • codex review --uncommitted was attempted in the clean worktree, but this local Codex CLI recursively spawned another codex review; I stopped the review process. A prior independent codex review --uncommitted on the same diff reported no discrete correctness or blocking maintainability issues, and the clean worktree validation above passed.

Merge authority

merge_authority: auto_merge_when_gates_pass per the maintainer request to get this PR to merge.

Summary by CodeRabbit

  • New Features

    • Added clearer goal-mode completion rules so batch status is only marked complete when all targets are truly finished.
    • Improved guidance for restart behavior and merge handling in goal-based workflows.
  • Bug Fixes

    • Tightened status handling for pending checks, unresolved review threads, and unknown states.
    • Clarified terminal-state behavior for no-merge-authority and auto-merge scenarios.
  • Tests

    • Added checks to keep completion rules consistent across workflow guidance and batch instructions.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@justin808, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 94106af4-52ca-4901-a53a-d8dc926a8948

📥 Commits

Reviewing files that changed from the base of the PR and between f4cbe0f and cfb45a8.

📒 Files selected for processing (5)
  • skills/plan-pr-batch/SKILL.md
  • skills/plan-pr-batch/scripts/check_goal_prompt_size.rb
  • skills/pr-batch/SKILL.md
  • skills/pr-batch/bin/goal-completion-contract-test.rb
  • workflows/pr-processing.md

Walkthrough

Introduces a "Goal Mode Completion Contract" in workflows/pr-processing.md, propagated into pr-batch and plan-pr-batch skill prompts and execution rules. Adds a Ruby test verifying contract consistency across sources, extends prompt-size validation with headroom checks, and wires the new test into bin/validate.

Changes

Goal Mode Completion Contract

Layer / File(s) Summary
Canonical contract definition
workflows/pr-processing.md
Adds the Goal Mode Completion Contract section defining terminal vs. non-terminal states, pressure checks, and restart guidance.
pr-batch skill prompt and closeout lane
skills/pr-batch/SKILL.md
Adds the completion contract line to the Goal Prompt Template and updates the Coordinator Closeout Lane to reference the canonical contract.
plan-pr-batch prompt, file-touch map, and execution rules
skills/plan-pr-batch/SKILL.md
Rewrites the goal-prompt intro/preflight text, reshapes File-touch map and Items sections, and revises Execution rules for dispatch, worker constraints, and merge gating.
Contract consistency test
skills/pr-batch/bin/goal-completion-contract-test.rb
Adds a Minitest suite that loads the workflow and skill files, extracts goal prompt templates, and asserts phrase presence, byte-for-byte contract equality, and terminal-state wording.
Prompt size/headroom validation and CI wiring
skills/plan-pr-batch/scripts/check_goal_prompt_size.rb, bin/validate
Adds a minimum headroom constant/check, extends required prompt phrases, prints a new headroom metric, and wires the new test into bin/validate.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Test as GoalCompletionContractTest
  participant Workflow as pr-processing.md
  participant PrBatch as pr-batch/SKILL.md
  participant PlanPrBatch as plan-pr-batch/SKILL.md

  Test->>Workflow: read_repo_file, extract contract phrases
  Test->>PrBatch: extract_goal_prompt_template, check contract link
  Test->>PlanPrBatch: extract_goal_prompt_template, check contract line
  Test->>Test: assert_text_includes required phrases
  Test->>Test: assert byte-for-byte contract equality
  Test->>Test: assert terminal-state wording (ready-no-merge-authority, auto_merge_when_gates_pass)
Loading

Related Issues: None specified

Related PRs: None specified

Suggested labels: documentation, skills, testing

Suggested reviewers: None specified

🐰 A rabbit hops through prompts and threads,
Marking terminal states with care it treads,
No waiting-on-checks shall claim it's done,
Till every UNKNOWN's fight is won,
Then merged, closed out — the contract's spread!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and clearly matches the main change: fixing the PR-batch Goal-mode completion contract.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jg-codex/pr-batch-goal-mode-completion

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Summary

Reviewed the Goal Mode Completion Contract addition (bin/validate, skills/plan-pr-batch/SKILL.md, skills/plan-pr-batch/scripts/check_goal_prompt_size.rb, skills/pr-batch/SKILL.md, skills/pr-batch/bin/goal-completion-contract-test.rb, workflows/pr-processing.md).

Overall: the substance of the rule (don't call a batch complete while any target is still waiting-on-checks-or-review, has untriaged CI/review state, or is UNKNOWN) is sound and closes a real gap. No security issues, no consumer-repo hardcoding introduced, no shell-injection concerns in the new Ruby test or bin/validate line.

Main issue (left as inline comments): the canonical contract text is pasted into 4 places (workflows/pr-processing.md, skills/pr-batch/SKILL.md x2, skills/plan-pr-batch/SKILL.md x1) with three different exact wordings, rather than having the skill files link back to the canonical section. This repo already has an explicit convention for this - see the 'Canonical batch handoff copy... should point here instead of duplicating this section' comment guarding 'Batch Handoff Format' in workflows/pr-processing.md - which this change doesn't follow for the non-prompt-template copy in pr-batch/SKILL.md. The new goal-completion-contract-test.rb only checks that specific substrings are present in each copy, so the wordings can keep drifting (e.g. already: 'configured review agents' vs 'review agents') without any test failing.

I verified textually (couldn't execute ruby/bin/validate in this sandbox - execution was blocked pending approval) that all required substrings for goal-completion-contract-test.rb and check_goal_prompt_size.rb are currently present in the three source files, and that the goal-prompt template body is about 3.8k of the 4k character budget after this change, leaving little headroom for future growth.

Details in inline comments.

Comment thread skills/pr-batch/SKILL.md Outdated
Comment thread skills/plan-pr-batch/SKILL.md Outdated
@justin808
justin808 force-pushed the jg-codex/pr-batch-goal-mode-completion branch from 0cda8e9 to d5b18e7 Compare July 1, 2026 06:33

@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: d5b18e7838

ℹ️ 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".

Comment thread skills/plan-pr-batch/SKILL.md Outdated
@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown

Code Review

This PR adds a canonical Goal Mode Completion Contract to workflows/pr-processing.md and carries the same directive text into the $pr-batch and generated plan-pr-batch goal prompts, so a batch can no longer be reported complete while a target is merely waiting-on-checks-or-review. It's backed by a new regression test (skills/pr-batch/bin/goal-completion-contract-test.rb) and a tightened prompt-size guard (GOAL_PROMPT_MIN_HEADROOM).

I ran 8 finder angles (correctness, removed-behavior, cross-file, reuse, simplification/efficiency, altitude, conventions) and verified each surviving candidate. Two flagged "Ruby regex needs a multiline flag" correctness concerns and a "lost auto_merge_when_gates_pass instruction" concern were all refuted on inspection/execution — Ruby's ^/$ anchors already match line boundaries by default (no /m needed), and the "done means merged and closed out" instruction wasn't dropped, it moved into the new Goal Mode Completion Contract line. Only two lower-severity cleanup findings survived verification:

  1. workflows/pr-processing.md:797 (and skills/pr-batch/SKILL.md:178, skills/plan-pr-batch/SKILL.md:191) — duplication/drift risk (PLAUSIBLE). The Goal Mode Completion Contract sentence is pasted as literal text in three places instead of using this repo's established "point at canonical, don't duplicate" pattern (see the Coordination: line in the same SKILL.md files, which explicitly says it "intentionally points at the canonical workflow rules instead of duplicating them"). The new test enforces phrase-presence in all three copies and byte-identity between the two dispatch-prompt copies, but not full-text sync against the canonical workflow prose (which is deliberately paraphrased). Any future edit to the canonical wording risks silently drifting from the dispatch-prompt copies beyond what the required-phrase checks catch.
  2. skills/pr-batch/bin/goal-completion-contract-test.rb:28 — fence-extraction lacks the nested-fence guard its sibling has (CONFIRMED). The new extract_goal_prompt_template(skill_text, heading) finds the closing fence via section_body.index(/^```\s*$/) over the unbounded rest of the file, whereas the existing extract_goal_prompt_template in skills/plan-pr-batch/scripts/check_goal_prompt_size.rb bounds the section to the next ## heading and aborts if it finds more than one bare closing-fence line (guarding against nested fences). If a stray/nested ``` line is ever added to a SKILL.md before the intended closing fence, this new extractor would silently mis-extract instead of failing loudly like its sibling does.

No portability violations found (no consumer-repo commands/labels/branches hardcoded in the changed skills//workflows/ lines), and the Ruby helpers in bin/ and skills/*/bin/ don't shell out or take untrusted input, so no shell-safety issues either.

Comment thread workflows/pr-processing.md Outdated
Comment thread skills/pr-batch/bin/goal-completion-contract-test.rb Outdated

@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: f4cbe0f6c0

ℹ️ 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".

Comment thread skills/pr-batch/bin/goal-completion-contract-test.rb Outdated

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
skills/pr-batch/bin/goal-completion-contract-test.rb (1)

1-115: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Cross-skill test placed inside a single skill's bin/ folder.

This suite validates consistency across workflows/pr-processing.md, skills/pr-batch/SKILL.md, and skills/plan-pr-batch/SKILL.md, so it isn't scoped to pr-batch alone. As per coding guidelines, skills/*/bin/** scripts should live "in the skill folder that invokes them, unless the helper is explicitly repo-wide." Consider moving this to a repo-wide location (e.g. top-level bin/) to make its cross-skill scope explicit and discoverable from either skill.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@skills/pr-batch/bin/goal-completion-contract-test.rb` around lines 1 - 115,
The new Ruby contract test is cross-skill and should not live under a single
skill’s bin folder. Move the test out of GoalCompletionContractTest’s current
location into a repo-wide or otherwise clearly shared bin location, and keep the
test logic intact so it still validates workflows/pr-processing.md,
skills/pr-batch/SKILL.md, and skills/plan-pr-batch/SKILL.md from one shared
place.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@skills/plan-pr-batch/scripts/check_goal_prompt_size.rb`:
- Around line 155-156: The required prompt phrase in check_goal_prompt_size.rb
is missing the opening backtick, so the phrase won’t match the canonical Goal
Mode Completion Contract text. Update the string in required_prompt_phrases to
include the full quoted phrase exactly as it appears in
workflows/pr-processing.md, using the existing required_prompt_phrases array as
the reference point.

---

Nitpick comments:
In `@skills/pr-batch/bin/goal-completion-contract-test.rb`:
- Around line 1-115: The new Ruby contract test is cross-skill and should not
live under a single skill’s bin folder. Move the test out of
GoalCompletionContractTest’s current location into a repo-wide or otherwise
clearly shared bin location, and keep the test logic intact so it still
validates workflows/pr-processing.md, skills/pr-batch/SKILL.md, and
skills/plan-pr-batch/SKILL.md from one shared place.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e682c363-c4ba-4e5c-ba27-ec661f94e99b

📥 Commits

Reviewing files that changed from the base of the PR and between ac08178 and f4cbe0f.

📒 Files selected for processing (6)
  • bin/validate
  • skills/plan-pr-batch/SKILL.md
  • skills/plan-pr-batch/scripts/check_goal_prompt_size.rb
  • skills/pr-batch/SKILL.md
  • skills/pr-batch/bin/goal-completion-contract-test.rb
  • workflows/pr-processing.md

Comment thread skills/plan-pr-batch/scripts/check_goal_prompt_size.rb Outdated
@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review

Reviewed the diff (6 files, +171/-21). This PR adds a canonical Goal Mode Completion Contract to workflows/pr-processing.md and threads it into the $pr-batch and generated plan-pr-batch goal-prompt templates, plus a new regression test (skills/pr-batch/bin/goal-completion-contract-test.rb) and a GOAL_PROMPT_MIN_HEADROOM guard in check_goal_prompt_size.rb.

I traced every phrase/assertion in the new test against the actual file contents (execution was blocked in this sandbox, so this was done by manual string comparison):

  • The Goal Mode Completion Contract: line is byte-for-byte identical between skills/pr-batch/SKILL.md and skills/plan-pr-batch/SKILL.md, matching the new test_dispatch_prompt_contracts_stay_byte_for_byte_aligned assertion.
  • All required phrases (ready-no-merge-authority terminal condition, auto_merge_when_gates_pass done-means-merged clause, the "5 PRs, 3 pending hosted checks" pressure sentence, explicit merge approval) are present in workflows/pr-processing.md and both goal-prompt templates.
  • The markdown anchor #goal-mode-completion-contract is unique (only one ### Goal Mode Completion Contract heading) and matches GFM's anchor-slug rules.
  • Portability: no consumer-repo-specific commands, labels, branches, or paths are introduced by this diff; the pre-existing shakacode/react_on_rails fixture URLs in check_goal_prompt_size.rb are untouched context, not part of this change.
  • bin/validate wiring for the new test is correctly added.

No correctness bugs found. One minor (non-blocking) cleanup note:

Duplicated fence-extraction logicgoal-completion-contract-test.rb's extract_goal_prompt_template re-implements the same "find ## heading → find ```text fence → find closing fence" logic already in skills/plan-pr-batch/scripts/check_goal_prompt_size.rb, but less defensively: the existing script bounds its search to the next ## heading and errors out if it finds more than one bare closing-fence line in that range, while the new test's version just scans the rest of the file for the first bare ``` line after the opening fence. Functionally equivalent today (there's only one such section per file), but it's a second, slightly different copy of tricky markdown-parsing logic that can silently drift. Not blocking — just worth a follow-up if a shared helper is ever justified.

Everything else (prose compression in plan-pr-batch/SKILL.md's goal prompt, the new GOAL_PROMPT_MIN_HEADROOM size guard, the canonical-contract pointer link in pr-batch/SKILL.md) looks correct and consistent with existing conventions in the repo.

Comment thread skills/plan-pr-batch/SKILL.md Outdated
Comment thread workflows/pr-processing.md
@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review summary

This PR adds a canonical Goal Mode Completion Contract to workflows/pr-processing.md and carries the identical line verbatim into the $pr-batch and generated plan-pr-batch goal prompts, backed by a new goal-completion-contract-test.rb regression test and a headroom guard in check_goal_prompt_size.rb. I checked correctness, portability, and shell/Ruby helper safety.

Portability: clean. The new contract text and pressure-check bullets are fully generic (placeholder PR/issue counts, no org/repo names, labels, or branches). skills/pr-batch/bin/goal-completion-contract-test.rb only reads repo-relative doc/skill files and does no shelling out — safe. The pre-existing shakacode/react_on_rails references in check_goal_prompt_size.rb's test fixtures are untouched by this diff.

Verification: the three copies of the contract line (workflows/pr-processing.md, skills/pr-batch/SKILL.md, skills/plan-pr-batch/SKILL.md) are byte-for-byte identical, matching what the new test enforces. The extract_goal_prompt_template fence-parsing logic (reused/duplicated from check_goal_prompt_size.rb) correctly isolates each goal-prompt section given the current heading/fence structure.

Findings (posted inline)

  1. skills/plan-pr-batch/SKILL.md:214 — condensing the File-touch map bullet to fit the new contract line dropped the "report discovered paths" instruction. A worker that hits an out-of-scope path is now only told to "stop and wait," without being told to surface which path it found, which could stall a batch without giving the coordinator enough info to unblock it.
  2. workflows/pr-processing.md:797 — the new ### Goal Mode Completion Contract heading is inserted mid-section, so the final-state list ("Every target must use one explicit final state:") and its uncertainty/QA rules now render nested under the new heading instead of staying under ### Batch Handoff Format, where they conceptually belong.

Minor/optional (not posted inline, low confidence)

  • The new GOAL_PROMPT_MIN_HEADROOM = 300 check in check_goal_prompt_size.rb isn't reflected in SKILL.md's own char-budget guidance (still says "under 4000 characters"), so a contributor following only the docs could be surprised by the stricter script-enforced headroom.
  • skills/plan-pr-batch/SKILL.md's condensed "Reservations -> path(s) (reason/later owner)" bullet lost the "Batch-level reservations, not tied to a single item" framing, which made it slightly less clear that this line isn't a per-PR/issue map entry like the others in the list.

No security or performance concerns — this is a docs/prompt + test-only change with no new executable surface beyond the reviewed Ruby helpers.

@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: 907acc007d

ℹ️ 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".

Comment thread skills/pr-batch/bin/goal-completion-contract-test.rb Outdated
Comment thread workflows/pr-processing.md Outdated
@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review summary

Reviewed the diff focusing on code quality, bugs, security, performance, portability (shared skill/workflow genericity), and shell/Ruby helper safety.

Overall: this is a well-scoped, low-risk docs + test change. Findings:

  • The canonical Goal Mode Completion Contract line is byte-for-byte identical across all 4 locations (workflows/pr-processing.md ×2, skills/pr-batch/SKILL.md, skills/plan-pr-batch/SKILL.md) — verified directly, matching the new regression test's intent.
  • skills/pr-batch/bin/goal-completion-contract-test.rb's section-extraction logic (heading → fence → next-heading boundary) correctly bounds each goal-prompt template; checked heading positions in all three source files (workflows/pr-processing.md, skills/pr-batch/SKILL.md, skills/plan-pr-batch/SKILL.md) to confirm no accidental overrun into later sections (e.g. the new "Goal Mode Completion Contract" heading itself).
  • bin/validate wiring for the new test is correctly added.
  • skills/plan-pr-batch/scripts/check_goal_prompt_size.rb's new GOAL_PROMPT_MIN_HEADROOM check is a reasonable safety margin given the heavily condensed rewrite of the plan-pr-batch goal prompt template (needed to make room for the new contract line under the 4000-char budget); the required-phrase list still matches the condensed wording.
  • No consumer-repo-specific commands, labels, branches, or paths are introduced by this diff (the pre-existing react_on_rails fixture URL in check_goal_prompt_size.rb is untouched context, not new).
  • The new test file is read-only (no shell-out, no eval, no untrusted input) — no security concerns.
  • Left one non-blocking inline nit about a slightly out-of-place bullet in the new "Goal Mode Completion Contract" section.

No functional bugs found. I wasn't able to execute the Ruby test suite directly in this sandbox (script execution required approval that wasn't available), so this is a static review; the PR description's own bin/validate / test run results stand as the executed-validation evidence.

Comment thread skills/plan-pr-batch/scripts/check_goal_prompt_size.rb
Comment thread skills/plan-pr-batch/SKILL.md Outdated
Comment thread skills/plan-pr-batch/SKILL.md Outdated
@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review summary

This PR adds a canonical Goal Mode Completion Contract to workflows/pr-processing.md and propagates it verbatim into the $pr-batch and plan-pr-batch goal-prompt templates, so a batch can no longer be reported complete while a target is still waiting-on-checks-or-review/pending/unknown. It adds a focused regression test (skills/pr-batch/bin/goal-completion-contract-test.rb) and a new headroom guard in check_goal_prompt_size.rb.

Portability / AGENTS.md editing rules: no violations found — the new contract text and test are fully generic (no consumer-repo commands, labels, branches, or paths hardcoded), and the doc/anchor cross-references (workflows/pr-processing.md#goal-mode-completion-contract) resolve correctly in both the source checkout and installed layouts.

Shell/Ruby helper safety (bin/, skills/*/bin/): the new test file only reads fixed repo-relative paths with File.read, no shell-outs or user-controlled input — no injection or safety concerns.

Findings posted inline (3):

  1. skills/plan-pr-batch/scripts/check_goal_prompt_size.rb:210 — the new GOAL_PROMPT_MIN_HEADROOM = 300 guard is already down to 301 chars of headroom on the plan-pr-batch goal prompt template (measured: 3699/4000 chars) — 1 character above its own new minimum, so almost any future one-character addition will trip bin/validate.
  2. skills/plan-pr-batch/SKILL.md:213 — condensing the dispatch execution rule dropped "group dependent items only when shared context is required" with no equivalent guidance restored elsewhere, leaving dispatch-time handling of dependent lanes (built during planning) unspecified.
  3. skills/plan-pr-batch/SKILL.md:217 — "bounded doctor/status" was condensed to "bounded status," losing the distinct reference to the agent-coord doctor --json probe that the canonical workflow treats separately from targeted status checks.

Nothing else rose to a blocking level — the byte-for-byte alignment tests, section-boundary regexes, and anchor links in the new/changed Ruby all check out correctly against the actual heading structure of workflows/pr-processing.md.

Comment thread skills/plan-pr-batch/SKILL.md Outdated
Comment thread skills/plan-pr-batch/SKILL.md Outdated
Comment thread skills/plan-pr-batch/scripts/check_goal_prompt_size.rb
Comment thread skills/pr-batch/bin/goal-completion-contract-test.rb
Comment thread skills/pr-batch/bin/goal-completion-contract-test.rb
@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review summary

This PR adds a "Goal Mode Completion Contract" paragraph to workflows/pr-processing.md and carries it verbatim into the $pr-batch and plan-pr-batch goal prompt templates, plus a new regression test (skills/pr-batch/bin/goal-completion-contract-test.rb) and a headroom guard in check_goal_prompt_size.rb. The core goal (making waiting-on-checks-or-review non-terminal for the overall batch) is sound and well-tested — I verified the contract line is byte-for-byte identical across all 4 required locations and that bin/validate correctly wires up the new test.

Findings posted as inline comments, most notable first:

  1. skills/plan-pr-batch/SKILL.md:213 — the condensed Execution Rules bullet merges "dispatch one subagent per independent item" and "dispatch only the current file-disjoint wave" into an ambiguous slash phrase ("...per independent item/current file-disjoint wave"), which is the rule that prevents concurrent workers from colliding on shared paths.
  2. skills/plan-pr-batch/SKILL.md:211 — the same compaction pass drops the explicit git fetch --prune origin <base-branch> command down to "fetch/prune it", and replaces "verify the installed or repo-local $pr-batch skill and pr-processing.md workflow are available" with an undefined "verify repo root plus $pr-batch/pr-processing.md". Both are consumed as literal dispatch-prompt text for an LLM agent, so the lost precision isn't just cosmetic.
  3. skills/plan-pr-batch/scripts/check_goal_prompt_size.rb:205 — the new GOAL_PROMPT_MIN_HEADROOM = 200 guard is added in the same PR that spends much of that headroom on the new ~700-char Contract sentence; worth confirming the actual printed goal_prompt_template_headroom= value rather than assuming real slack remains.
  4. skills/pr-batch/bin/goal-completion-contract-test.rb:19extract_goal_prompt_template/extract_markdown_section duplicate the section-extraction logic already in check_goal_prompt_size.rb (extract_goal_prompt_template/extract_section) instead of sharing one helper.
  5. skills/pr-batch/bin/goal-completion-contract-test.rb:128 — three test methods (pending-checks, ready-no-merge-authority, auto-merge-done) are copy-paste identical aside from the one phrase checked; could be one parameterized test.

No security or portability issues found — no consumer-repo-specific hardcoding was added (the pre-existing shakacode/react_on_rails reference in check_goal_prompt_size.rb predates this PR and is unchanged), and no CLAUDE.md/AGENTS.md rule violations.

@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review

Reviewed HEAD cfb45a80693d32cb082cc132910dcfc874257bfd (6 files: bin/validate, skills/plan-pr-batch/SKILL.md, skills/plan-pr-batch/scripts/check_goal_prompt_size.rb, skills/pr-batch/SKILL.md, skills/pr-batch/bin/goal-completion-contract-test.rb, workflows/pr-processing.md).

Note: this PR has already been through many automated review rounds today (8 prior claude comments plus 9 commits addressing them). I re-verified the current diff from scratch rather than trusting older comments, since several are now stale against HEAD (e.g. concerns about a missing nested-fence guard in goal-completion-contract-test.rb's extract_goal_prompt_template, a dropped "report discovered paths" instruction, and an ambiguous merged dispatch bullet in plan-pr-batch/SKILL.md — all of these are already fixed/present correctly in the current file content, which I read directly).

Substance: sound and closes a real gap — waiting-on-checks-or-review is now explicitly non-terminal for overall Goal-mode completion, with an explicit pressure scenario ("5 PRs, 3 pending hosted checks... is NOT COMPLETE") backed by a new regression test.

Portability (AGENTS.md editing rules): clean. The new contract text, pressure checks, and test file are fully generic — no consumer-repo commands/labels/branches/paths hardcoded. The pre-existing shakacode/react_on_rails placeholder URLs in check_goal_prompt_size.rb's test fixtures predate this PR and aren't touched by this diff.

Shell/Ruby helper safety: goal-completion-contract-test.rb only does File.read on fixed repo-relative paths — no shell-out, no eval, no untrusted input. bin/validate's one-line addition is a plain path reference. No injection surface.

Verified directly against HEAD:

  • The Goal Mode Completion Contract: line is byte-for-byte identical across all 4 locations (workflows/pr-processing.md x2 copies, skills/pr-batch/SKILL.md, skills/plan-pr-batch/SKILL.md), matching what test_canonical_and_dispatch_prompt_contracts_stay_byte_for_byte_aligned enforces.
  • extract_goal_prompt_template in the new test file does bound its search to the next heading and aborts on a nested bare fence line (same defensive pattern as its sibling in check_goal_prompt_size.rb) — this guard is correctly in place now.
  • The #goal-mode-completion-contract anchor link from pr-batch/SKILL.md resolves to a unique ### Goal Mode Completion Contract heading placed as its own section after ### Batch Handoff Format, not nested inside it.
  • Condensed plan-pr-batch/SKILL.md prose (needed to keep the goal prompt under 4000 chars with the new GOAL_PROMPT_MIN_HEADROOM = 100 guard after adding the contract sentence) preserves the functional content of each trimmed bullet (e.g. "stop, report paths, and wait..." is still present; "bounded doctor/status" is still present, not narrowed to just "status").

Non-blocking observation: the contract sentence is pasted as literal text in multiple files rather than referenced from one canonical source — necessary here since goal prompts must be self-contained text blobs handed to a worker LLM, not links. The new byte-for-byte alignment test is the correct mitigation for drift risk given that constraint, so this isn't a defect, just worth remembering that all 4 copies need a matching edit if the wording changes again.

Could not execute ruby skills/plan-pr-batch/scripts/check_goal_prompt_size.rb or the new test directly in this sandbox (interpreter execution is blocked here), so this is a static/textual verification of the required phrases and char budget; the PR description's own local bin/validate run is the executed-validation evidence for the exact character counts.

No blocking issues found.

@justin808
justin808 merged commit 4225b08 into main Jul 1, 2026
11 checks passed
@justin808
justin808 deleted the jg-codex/pr-batch-goal-mode-completion branch July 1, 2026 07:55
justin808 added a commit that referenced this pull request Jul 4, 2026
…h-merge-readiness-route

* origin/main:
  [codex] Make plan-pr-batch goals Codex-pasteable (#50)
  [codex] Add host adapter and Codex plugin metadata
  [codex] Add pause restart prompt skill
  [codex] Add batch titles and audit defaults
  [codex] Fix PR-batch Goal-mode completion contract (#52)
  Add strict trust mode to preflight (#48)
  [codex] Add generic PR-batch continuation prompt (#49)
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