Skip to content

The merge scripts read pull request snapshots, reviews and the local diff through one Go reader #862

Description

@tbhb-agent

Problem

Every merge-pr script starts from one saved gh pr view response and reads it with helpers in pull-request.sh (165 lines): the field reader, the base commit lookup, the review-decision refusal, the review pages with author types, and the local fetch of pinned base and head objects with the complete diff. This is under the shell freeze in #588. The check-rollup judge in the same file is a separate outcome handled by child 21.

Part of #324, within #588. Child 04 in #324's Children list. Replaces the snapshot, review-page, base-commit, review-decision and local-diff parts of packages/agents/source/skills/merge-pr/shared/scripts/pull-request.sh.

Acceptance criteria

  1. AC1: Given a pull request number, when the snapshot is read, then the requested fields are saved from one GitHub response, and when unattended gating is on and reviews is requested, the review pages with author type are read pinned to that same head.
  2. AC2: Given the head moves while review pages are read, when the snapshot is built, then it fails with an error, exits non-zero, and hands the caller no usable snapshot; the files left behind on this failure are the same as the frozen reader leaves (the initial snapshot may remain on disk), and no caller reads it after the failure.
  3. AC3: Given a review decision of REVIEW_REQUIRED or CHANGES_REQUESTED, when the snapshot is checked, then the caller gets the WAITING_REVIEW message on stderr and exit status 75; given APPROVED, empty or NONE, then it passes; given any other value, then it fails naming the value.
  4. AC4: Given a pinned base and head commit, when the local diff is built, then the objects are fetched without moving a branch, the index or FETCH_HEAD, fork heads included, a shallow clone is unshallowed, and the complete binary diff and the name-status list are written with the same content as the frozen reader writes for the same fixtures, including a diff large enough to exceed a single pipe buffer.
  5. AC5: Given GitHub reports a rate limit, when any reader fails, then the caller sees the original error and the status the shared reader assigns it, with no retry.
  6. AC6: Given the base branch name, when the base commit is read, then it is the commit the branch points at on GitHub for the repository gh merges in, and an absent ref fails with base ref not found.
  7. AC7: Non-functional: the readers run against a fake gh and a scratch Git repository in tests, and run on macOS, Linux and Windows in CI.

Scope and non-goals

Scope: the snapshot, review-page, base-commit, review-decision and local-diff readers, with tests ported from merge-workflow.bats.

Non-goal: the check-rollup verdict (child 21). Non-goal: the unattended gates themselves (child 05). Non-goal: new command-line surface; these are readers consumed by children 05 to 12. Non-goal: changing the shell scripts before child 14.

Approach

Meet AC1 to AC7 with failing cases first: record the shell readers' output on fixtures, then match it. Mechanism is the implementer's choice.

Dependencies

Blocked by: #333.

Prerequisites: #321 (GitHub identity and quota helpers) and #333.

Size

S. One pull request.

Verify plan

  • AC1, AC2: fake-gh tests, one that returns a moved head between pages, asserting the exit status, the error text and the set of files left behind against the frozen reader's on the same fixture.
  • AC3: table over review decisions checking status and stderr.
  • AC4: scratch repositories, including a shallow clone, a fork-style pull ref and the large-diff and shallow-history scenarios of merge-workflow.bats, asserting branch, index and FETCH_HEAD unchanged and comparing the written diff and name-status files byte for byte with the frozen reader's.
  • AC5: a fake gh that prints each rate-limit shape.
  • AC6: a fake gh that returns and omits the ref.
  • AC7: 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 reader that moves a branch or the index would disturb the operator's checkout; AC4 holds that. A snapshot taken across a moving head would bind the wrong review; AC2 holds that. Undo: revert; nothing calls these readers until children 05 and later.

Operator authority

None.

Activity

  1. tbhb-agent commented on Oct 27, 2026

    @tbhb-agent
    ContributorAuthor

    Refinement: READY — The merge scripts read pull request snapshots, reviews and the local diff through one Go reader
    Model: gpt-6-astra

    Child 04 The merge scripts read pull request snapshots, reviews and the local diff through one Go reader

    Verdict: READY

    Checked: AC2 now distinguishes an unusable result from files left behind, matching packages/agents/source/skills/merge-pr/shared/scripts/pull-request.sh:28 and packages/agents/source/skills/merge-pr/shared/scripts/merge-agent.sh:74. Complete diff assertions, shallow-history handling and unchanged Git-state checks cover AC4. Check compatibility remains separately assigned to child 21.

    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