Skip to content

Retro stage should check out post-merge ref on pull_request_target closed events #843

Description

@guyoron1

What happened

PR #26 in konflux-ci/refinement added a judge-score gate to AGENTS.md and docs/agents/retro-filing.md (merged 15:52 UTC). When the retro dispatched on PR #26's merge (run 30467986234, ~16:10 UTC), the checkout resolved to 3fa40d5 — the base branch HEAD before the merge commit bf2445e landed. The retro agent ran against the pre-merge repo state: AGENTS.md still had the old pirate-voice instructions (from PR #23), docs/agents/retro-filing.md did not exist in the working tree, and the judge-score gate was invisible. The retro filed agents#528 without applying the scoring rubric. This prompted a follow-up PR #27 to add the gate as a harness skill override — but even that approach is subject to the same checkout-ref issue for the retro analyzing PR #27 itself (.fullsend/skills/retro-filing-policy/ and .fullsend/harness/retro.yaml are also read from the checked-out tree).

What could go better

Judge score: 3/5 — Actionable process gap. The retro dispatch resolves its checkout ref from github.sha, which for pull_request_target events GitHub defines as the base branch HEAD at event creation time — not the merge commit. This is the same class of bug as #5378 (which fixes action.yml reconcile-status) but affects a different code path: the checkout step in the retro stage of reusable-dispatch.yml. For the retro stage specifically, checking out the pre-merge ref means the agent cannot see AGENTS.md changes, .fullsend/ config modifications, or skill additions introduced by the merged PR. The retro needs the latest governance config to guide its own filing behavior, even though it analyzes a workflow that ran under the old config. Evidence: workflow logs show HEAD is now at 3fa40d5 in all jobs of run 30467986234, 18 minutes after the merge commit bf2445e landed. Confidence is moderate — the stale checkout is clearly evidenced in logs, but there is some possibility this is intentional design (retro should see the as-was state). The functional impact argues against that interpretation: the retro's own behavioral guidance (AGENTS.md instructions, filing skills) should reflect the current repo state.

Proposed change

In the retro dispatch path of reusable-dispatch.yml, when the trigger event is pull_request_target with action closed and github.event.pull_request.merged == true, use github.event.pull_request.merge_commit_sha as the checkout ref instead of github.sha. This ensures the retro agent sees the post-merge repo state including AGENTS.md, .fullsend/ config, and skill files. Other agent stages (review, code, fix) should continue using the PR head SHA (github.event.pull_request.head.sha) as they operate on pre-merge state. Related to #5378 (same github.sha root cause, different fix location and different impacted code path).

Validation criteria

The next 3 retro runs triggered by PR merges in repos with per-repo install mode should check out a ref that includes the merged PR's changes. Verify by checking the HEAD is now at log line in the retro job — the commit should be the merge commit or a descendant, not a pre-merge ancestor. Additionally, a retro on a PR that modifies AGENTS.md should show evidence of reading the updated AGENTS.md (not the pre-merge version) in its reasoning trace.


Generated by retro agent from https://github.com/konflux-ci/refinement/pull/27

Metadata

Metadata

Assignees

No one assigned

    Labels

    benchmark-pathBPath B benchmark issuesbugSomething isn't workingcomponent/dispatchWorkflow dispatch and triggerspriority/highSignificant impact, address soontriagedtype/bugConfirmed defect in existing behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions