Skip to content

chore(skills): fixer always verifies and fixes post-merge CI on main - #2250

Merged
carlos-alm merged 2 commits into
mainfrom
chore/fixer-post-merge-ci-gate
Aug 3, 2026
Merged

carlos-alm merged 2 commits into
mainfrom
chore/fixer-post-merge-ci-gate

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

An autonomous /fixer batch run surfaced a real gap in its own merge-gate process. /fixer checks each PR's own pre-merge statusCheckRollup (the five gate conditions in step 2f) before merging with --squash --admin — but this repo also runs a separate CI workflow triggered directly by the push-to-main event at merge time: a full, independent re-run of the entire test suite on the new main HEAD. /fixer never checked that workflow at all.

In practice: two consecutive merges during a batch run each had fully green pre-merge PR checks (verified at the time and re-verified after the fact), but the separate post-merge CI run on main failed both times right after, with an identical Test Node 22 (windows-2022) timeout in a beforeAll hook — never seen in the previous 20 runs on main, and gone again on the very next run. This points to the batch's own rapid-fire merge cadence straining shared Windows-runner capacity, not a real regression in either merged PR — but /fixer had no mechanism to even notice, let alone respond to, that failure.

Changes

  • Invariant I8 (Why this skill is built the way it is): main's own post-merge CI state, not just each PR's pre-merge checks, is the real ground truth for whether a batch is leaving the repo healthy.
  • Step 2f-bis (Phase: Solve and Merge Loop): after every successful merge, identify the post-merge CI run for that exact commit, wait for it in the foreground, and if it's red: diagnose via gh run view --log-failed, fix a genuine regression with a new small PR, or confirm-and-clear a transient failure with one gh run rerun --failed. Never cut the next issue's branch while this is unresolved.
  • Phase: Drain Parked PRs: a pointer applying the same I8 check after each drain-phase merge, since those merges carry the identical risk.
  • Rules section: a new bullet capturing the standing requirement.
  • Artifacts table: post-merge-ci-run scratch-state entry for the run ID being watched.

The five pre-merge gate conditions (G1-G5) are unchanged and still described as "five" — this is a separate, additional post-merge check, not a sixth gate, since it runs after gh pr merge rather than as a precondition to it.

A related resumability gap in the crash-resume reconciliation path (which can bypass this check if a sub-agent crashes between gh pr merge and state.json's write) was found but is out of scope for this change; filed as #2249.

Verification

  • lint: pass (npm run lint)
  • .claude/skills/create-skill/scripts/lint-skill.sh run against the edited file: identical error/warning count to the unmodified file (2 pre-existing false-positive errors, 13 pre-existing warnings) — no new issues introduced by this change.

Two consecutive /fixer merges each had fully green pre-merge PR checks,
but the separate push-triggered CI workflow run on main failed both
times right after -- a risk the PR-level gate (step 2f) never checks.
Add invariant I8, step 2f-bis, and a matching pointer in the drain
phase so every merge is followed by a mandatory wait-and-fix on main's
own post-merge CI before the batch advances to the next issue.
@greptile-apps

greptile-apps Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR makes post-merge main CI verification mandatory after fixer merges and records the watched workflow run as scratch state.

  • Resolves merge commits from the merged PR rather than the mutable main tip.
  • Polls for and watches the matching push-triggered CI run, rerunning failures once before stopping.
  • Extends the requirement to parked-PR draining, although that path does not provide the PR state expected by the referenced commands.

Confidence Score: 4/5

The PR needs a drain-phase PR-identifier fix before merging because that path cannot reliably resolve and verify the CI run for the parked PR it just merged.

The normal merge path now identifies its commit safely, but the drain path holds the merged PR in MERGED_PR while the referenced verification block reads a current-pr file already removed by normal cleanup, causing verification to stop or target stale state.

Files Needing Attention: .claude/skills/fixer/SKILL.md

Important Files Changed

Filename Overview
.claude/skills/fixer/SKILL.md Adds post-merge CI enforcement and immutable merge-SHA selection, but the drain-phase reuse references scratch PR state that is unavailable on that path.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["Merge PR"] --> B["Read immutable mergeCommit.oid"]
  B --> C["Find matching main CI run"]
  C --> D["Watch run"]
  D -->|Green| E["Advance"]
  D -->|Red| F["Inspect and rerun failed jobs"]
  F -->|Green| E
  F -->|Still red| G["Stop and fix regression"]
  H["Drain-phase merge: MERGED_PR"] -. "must be mapped to lookup input" .-> B
Loading

Fix All in Claude Code

Reviews (2): Last reviewed commit: "fix(skills): read post-merge CI SHA from..." | Re-trigger Greptile

Comment thread .claude/skills/fixer/SKILL.md Outdated
Comment on lines +936 to +937
# checkout does not have the new commit until fetched.
git fetch origin main || { echo "ERROR: git fetch failed — cannot identify the merge commit"; exit 1; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Current tip replaces merge SHA

If another actor updates main after gh pr merge succeeds but before this fetch completes, origin/main identifies the later commit instead of this PR's merge commit, causing the fixer to watch the wrong CI run and advance without verifying its own merge.

Fix in Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 912d314 — MERGE_SHA is now read from gh pr view <PR> --json mergeCommit --jq '.mergeCommit.oid' (authoritative and immutable once GitHub records the merge) instead of git rev-parse origin/main after a fetch, which could race with a concurrent push to main.

@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

echo "fixer: state.json entry for PR #$MERGED_PR updated parked -> merged"
```

Then apply I8 exactly as in step 2f-bis: verify the post-merge `CI` workflow run on `main` for this merge's commit, wait for it if still in progress, and diagnose-and-fix (or confirm-transient-via-rerun) a red result before merging the next parked PR or starting another pass. A drain-phase merge lands on `main` the same way a Phase 2 merge does, so it carries the identical risk of tipping shared CI capacity into failure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Drain loses merged PR identity

When a parked PR is merged during the drain phase, applying step 2f-bis exactly reads .codegraph/fixer/current-pr, which normal iteration cleanup has already removed, instead of using the drain phase's MERGED_PR. The verification therefore exits while reading the missing state or uses stale state and watches CI for the wrong PR, leaving the just-merged commit unverified.

Fix in Claude Code

@carlos-alm
carlos-alm merged commit 256a205 into main Aug 3, 2026
33 of 35 checks passed
@carlos-alm
carlos-alm deleted the chore/fixer-post-merge-ci-gate branch August 3, 2026 21:34
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant