Skip to content

The merge preflight report is printed by agentrepo merge #866

Description

@tbhb-agent

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

  1. AC1: Given a pull request number, or the open pull request for the current branch, when agentrepo merge preflight runs, 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.
  2. 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.
  3. AC3: Given gh is not installed, when it runs, then it prints gh is not installed and "Stop here and tell the operator." and exits 0. jq is no longer a prerequisite, so the shell report's jq is not installed outcome does not occur.
  4. 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.
  5. AC5: Given a review decision that still requires approval, when it runs, then it prints WAITING_REVIEW on stderr and exits 75.
  6. 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.
  7. 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.
  8. AC8: Given SQUASH_AGENTMSG absent, 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.
  9. AC9: Given unattended mode, when it runs, then it runs the unattended gates from child 05 and prints the configured squash lint command.
  10. 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.
  11. 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-by trailer and the pull request has the provenance:agent-assisted label. 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 final Status: 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.

Activity

  1. tbhb-agent commented on Oct 27, 2026

    @tbhb-agent
    ContributorAuthor

    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:95 and packages/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.

    • D1 The author verified each AC on the merged head, and the Verification section of the pull request cites each AC ID with its evidence: the command and its result, or a link.
    • D2 An independent reviewer approved the exact merged head, and the author resolved each finding or filed it as a follow-up.
    • D3 The required checks pass on that head, and any loosened gate has the owner's approval of that exact head.
    • D4 The leak scans come back clean: gitleaks, devtools' check-leaks.sh with the repository's private-strings list, and the leak review of each post.
    • D5 The author signed each commit, the squash included.
    • D6 The docs match the change (README, docs/, CHANGELOG or help text), or the Verification section says "No doc impact" and why.
    • D7 The commits and the squash have Assisted-by trailers, and the pull request has the provenance:agent-assisted label.
    • D8 The pull request stays within the size limits, or the owner approved its exact head over the hard limit.
    • D9 The author files follow-ups and deferred findings as issues with at least a Problem and numbered AC and lists them under the Related section of the pull request. Any work left in the code links its issue.
    • D10 The merge closes the issue through a closing reference and the board shows Done. The final Status: comment names the merge commit.
    • devtools-1 mise run check is green, and so are the coverage floors mise run cover-go-check and mise run cover-py-check, which check doesn't run.
    • devtools-2 A change to skill sources under packages/agents/source/ commits what mise run generate-skills, then mise run skill-tokens, then apm install rewrite, in that order, and check-generated-skills (part of lint) passes.
    • devtools-3 A consumer-visible change (the vendored payload, a skill, a reusable workflow, a task or a pin) has its consumer steps in docs/agent-skills-migration.md or the adoption docs, or the PR's Verification says "No consumer impact" and why.

    Round: 3 of 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refinement:readyPassed the Definition of Ready; may be picked up

    Fields

    Priority

    None yet

    Work type

    None yet

    Projects

    • Status
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions