Skip to content

Phase 2: base squash/diff on the captured post-rebase bump tip (T9)#2

Merged
petemoore merged 1 commit into
mainfrom
rework/phase2-t9-squash-base
Jun 15, 2026
Merged

Phase 2: base squash/diff on the captured post-rebase bump tip (T9)#2
petemoore merged 1 commit into
mainfrom
rework/phase2-t9-squash-base

Conversation

@petemoore

Copy link
Copy Markdown
Collaborator

Phase 2 of the rework (docs/WORKPLAN.md): the T9 narrow fix. Confirmed empirically in Phase 0 (see docs/WORKPLAN.md → Validation experiments).

The bug (T9)

squashBranch reset the agent's work onto the scan-time pr.HeadSHA. The Phase-0 rebase rewrites the branch head, so that SHA is stale; git reset --soft <stale> then produces a "fix" commit whose diff bundles every unrelated main change merged since the branch's original base. On petemoore/taskcluster #193 the "fix" commit is 300 files / +27,957/−42,840 for a ~3-file query-string compat fix.

The fix

Keep inherit-and-rebase (Q11 → A); only change the base SHA the squash uses.

  • Capture the real tip in cloneAndBranch right after checkout -b branch pr.HeadRef, before the worker runs — the true post-rebase bump commit — onto a new Pipeline.bumpTipSHA field. rev-parse failure is now fatal (this SHA is load-bearing).
  • Single canonical base (M4): bumpTipSHA is now the base for the squash and the reviewer diff/commit listing. The reviewer previously diffed origin/<HeadRef>...HEAD — mis-based, and reads empty/wrong once the worker force-pushes (MINOR-1). Both now use the stable captured commit.
  • Plumb it to the orchestrator (MAJOR-1 / N4): added RunResult.TipSHA, set on every exit path via a named return + one defer. The gave_up path records its terminal outcome — and the sticky comment's SHA marker — against TipSHA (via terminalSHA(tip, scan)), so the next scan's SHA-skip fires on the rebased head instead of re-entering the expensive agent. Every other recordOutcome call stays on pr.HeadSHA per the agreed scope.

⚠️ Phase 0 finding (flagged, not blocking)

#193's bloat is dominated by the -X theirs rebase reverting 289 unrelated files into the bump commit — a broader form of the Q11 residual. This narrow fix is correct and necessary but does not by itself clean a #193-style branch (it bases off that same polluted bump tip). Recorded in docs/questions.md for a maintainer decision; out of scope here (would relitigate Q11).

Tests

  • TestSquashBranchUsesCapturedTipNotStaleBase — git integration: builds bump + 2 agent commits, squashes on the captured tip, asserts the fix commit is parented on the bump and contains only the agent's files; demonstrates the stale base would bundle the bump file.
  • TestTerminalSHA, TestGaveUpSkipFiresAfterRebase — the N4 SHA selection and that the skip fires on the rebased head.

Local: go build/vet/test ./..., gofmt, staticcheck all clean.

🤖 Generated with Claude Code

petemoore added a commit that referenced this pull request Jun 15, 2026
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@petemoore petemoore marked this pull request as ready for review June 15, 2026 18:23
The squash/finalize reset the agent's work onto the scan-time pr.HeadSHA. A
Phase-0 rebase rewrites the branch head, so that SHA is stale, and `reset --soft
<stale>` bundles every unrelated `main` change merged since the branch's
original base into the single "fix:" commit (confirmed on petemoore/taskcluster

Narrow fix (Q11 kept inherit-and-rebase):

- Capture the branch's actual tip SHA in cloneAndBranch, right after
  `checkout -b branch pr.HeadRef` and before the worker runs — the true
  post-rebase bump commit — on a new Pipeline.bumpTipSHA field.
- Use it as the single canonical base for the squash AND the reviewer diff/commit
  listing (which used origin/<HeadRef>, mis-based and empty/wrong after the
  worker force-pushes — M4 / MINOR-1).
- Plumb it out via RunResult.TipSHA (named return + one defer stamps every exit
  path) and record the gave_up terminal outcome — and its sticky comment SHA
  marker — against it, so the next scan's SHA-skip fires on the rebased head
  instead of re-entering the expensive agent (N4 / MAJOR-1). Every other
  recordOutcome call stays on pr.HeadSHA per the agreed scope.

Tests:
- TestSquashBranchUsesCapturedTipNotStaleBase — git integration: squashing on the
  captured tip yields a fix commit parented on the bump with ONLY the agent's
  files; shows the stale base would bundle the bump file (the #193 pollution).
- TestTerminalSHA / TestGaveUpSkipFiresAfterRebase — the N4 SHA selection and
  that the skip fires on the rebased head.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@petemoore petemoore force-pushed the rework/phase2-t9-squash-base branch from fd6ac8a to 1128e05 Compare June 15, 2026 18:30
@petemoore petemoore merged commit 0d1965c into main Jun 15, 2026
1 check passed
@petemoore petemoore deleted the rework/phase2-t9-squash-base branch June 15, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant