Repository navigation
Description
Problem
preflight.sh (224 lines) is the briefing the merge-pr skill reads before it writes anything. It runs the worktree readiness check, finds the pull request, prints state, review decision, judged checks, the commits being collapsed, the published description, the files, the gh identity, pre-approval and delegation, the reviewer and stamp, and the preconditions including a stale SQUASH_AGENTMSG. It pipes through awk and sort, it runs the unattended gates, and it is under the shell freeze in #588. Agents read this report as their picture of the pull request.
Part of #324, within #588. Child 07 in #324's Children list. Replaces packages/agents/source/skills/merge-pr/shared/scripts/preflight.sh.
Acceptance criteria
- AC1: Given a pull request number, or the open pull request for the current branch, when
agentrepo merge preflightruns, then it prints the same== section ==headers in the same order with the same line shapes as the shell report, and changes no tracked or untracked file of the worktree. - AC2: Given no pull request for the branch and no number, when it runs, then it prints the open pull requests (up to 20) and the instruction to pass a number, and exits 0.
- AC3: Given
ghis not installed, when it runs, then it printsgh is not installedand "Stop here and tell the operator." and exits 0.jqis no longer a prerequisite, so the shell report'sjq is not installedoutcome does not occur. - AC4: Given green, failing, still-running, empty and unreadable check rollups, when the checks section prints, then the sorted lines, the superseded-runs note and the summary sentence match the shell report.
- AC5: Given a review decision that still requires approval, when it runs, then it prints
WAITING_REVIEWon stderr and exits 75. - AC6: Given the rendered commit listing is longer than
MERGE_PREFLIGHT_COMMITS(default 30) times eight lines, when the commits print, then the listing is cut to exactly that many lines, whether the excess comes from many commits or from long messages, and is not capped per commit. - AC7: Given a configured, mismatched or absent
gh_login, a merge pre-approval for the session, a bare commit and pr grant, or a delegation check, when the identity and pre-approval sections print, then each text matches the shell report, including the Touch ID note. - AC8: Given
SQUASH_AGENTMSGabsent, drafted for this pull request, or drafted for another, when it runs, then each state prints its own line and the stale draft is left untouched. - AC9: Given unattended mode, when it runs, then it runs the unattended gates from child 05 and prints the configured squash lint command.
- AC10: Given the worktree readiness check fails, when it runs, then the report stops with the readiness check's message and status, as the shell report does.
- AC11: Non-functional: the command leaves the worktree's tracked and untracked content, the index, the checked-out branch and every branch ref unchanged; the only other writes are the workflow state directory entries, the saved pull request snapshot, and the Git object and history updates that unattended gating needs (fetching the pinned base and head objects and unshallowing a shallow clone), as the shell report does; and it runs on macOS, Linux and Windows in CI.
Scope and non-goals
Scope: agentrepo merge preflight, its golden report tests, and the cases of merge-workflow.bats that cover the report.
Non-goal: porting the worktree readiness check (worktree-ready.sh): its behavior is retained as it is and used as an existing prerequisite; its port is owned by child 02 of the commit skill area (#322). Non-goal: changing what the report says. Non-goal: editing the shell script before child 14.
Approach
Meet AC1 to AC11 with failing cases first: golden reports from the shell script on fixed fake-gh fixtures, then Go output compared byte for byte. Mechanism is the implementer's choice.
Dependencies
Blocked by: #862, #864, #863, #333.
Prerequisites: #321 (pre-approval and delegation readers, harness and reviewer label) and #333. The readiness check is a retained existing prerequisite whose port is owned by #322; this child does not wait for it.
Size
M. One pull request.
Verify plan
- AC1, AC2, AC4, AC6, AC8: golden-report comparison against the shell script, with a case whose few long commit messages reach the line cap.
- AC3, AC5, AC7, AC10: table-driven tests with stub tools and configuration fixtures, including a failing readiness stub.
- AC9: unattended fixture with the gates faked.
- AC11: a test that snapshots the worktree's tracked and untracked content before and after and lists the files written outside it, with a write inventory that permits only the entries named in AC11 (including the object fetch and unshallow in an unattended shallow-clone fixture) and asserts index, checked-out branch and branch refs unchanged; the CI matrix run.
- Definition of done: D1 each AC is verified at the merged head, with the commands and results cited in the pull request's Verification. D2 an independent review approves the exact merged head, and every finding has a recorded disposition. D3 required checks pass with no gate loosened. D4 the leak scans the repository specifies are clean, and every post made for this work passes the per-post leak review before it is posted. D5 every commit is signed. D6 the documentation matches the change or the Verification says why there is no impact. D7 every commit has an
Assisted-bytrailer and the pull request has theprovenance:agent-assistedlabel. D8 the pull request stays within the size limits. D9 follow-ups are filed as issues and listed under Related. D10 the merge closes the issue through a closing reference, the board shows Done, and the finalStatus:comment names the merge commit.
Risks
A changed line shape could mislead an agent reading the report; golden comparison is the control. Undo: revert; the shell script is untouched.
Operator authority
None.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Work type
Projects
- StatusShow more project fieldsBacklog
Activity
tbhb-agent commentedon Oct 27, 2026
Refinement: READY — The merge preflight report is printed by agentrepo merge
Model: gpt-6-astra
Child 07 The merge preflight report is printed by agentrepo merge
Verdict: READY
Checked: AC11 now permits the object fetch and history updates required by unattended gating while protecting worktree content, index and branch refs. This matches
packages/agents/source/skills/merge-pr/shared/scripts/preflight.sh:95andpackages/agents/source/skills/merge-pr/shared/scripts/pull-request.sh:133. Readiness remains an existing prerequisite, with its port assigned to #322 child 02. The report and truncation checks close the earlier findings.Gaps: None.
Split: None needed.
Definition of done
The definition of done for this issue (Feature). Tick each item and give its evidence.
check-leaks.shwith the repository's private-strings list, and the leak review of each post.docs/, CHANGELOG or help text), or the Verification section says "No doc impact" and why.provenance:agent-assistedlabel.Status:comment names the merge commit.mise run checkis green, and so are the coverage floorsmise run cover-go-checkandmise run cover-py-check, whichcheckdoesn't run.packages/agents/source/commits whatmise run generate-skills, thenmise run skill-tokens, thenapm installrewrite, in that order, andcheck-generated-skills(part oflint) passes.docs/agent-skills-migration.mdor the adoption docs, or the PR's Verification says "No consumer impact" and why.Round: 3 of 3