From 28fb4386ed1bdc9c77911aed197edaeec6c87957 Mon Sep 17 00:00:00 2001 From: Will Date: Wed, 27 May 2026 08:05:22 +0100 Subject: [PATCH] =?UTF-8?q?retro:=202026-05-27=20memory=20updates=20?= =?UTF-8?q?=E2=80=94=20fetch-before-merge=20on=20long-lived=20branches?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/memory/MEMORY.md | 1 + ...fetch-before-merge-on-long-lived-branch.md | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .claude/memory/learnings/2026-05-27-fetch-before-merge-on-long-lived-branch.md diff --git a/.claude/memory/MEMORY.md b/.claude/memory/MEMORY.md index ba146c8..e00153c 100644 --- a/.claude/memory/MEMORY.md +++ b/.claude/memory/MEMORY.md @@ -15,6 +15,7 @@ Keep this file under 200 lines — anything longer is content bloat, not memory. - [learnings/vercel-bot-status-as-deploy-health-fallback](learnings/2026-05-26-vercel-bot-status-as-deploy-health-fallback.md) — When Vercel MCP/CLI auth is broken, read the GitHub Vercel-bot's commit status on the latest PR HEAD as a deploy-health fallback - [learnings/manager-agent-yaml-needs-manual-bootstrap](learnings/2026-05-26-manager-agent-yaml-needs-manual-bootstrap.md) — `manager.agent.yaml` edits do NOT auto-deploy; a human must run `npm run bootstrap` from `ai-manager/` with `ANTHROPIC_API_KEY`+`AGENT_ID` to push the prompt to the live agent (ENG-28) - [learnings/sentry-dedupe-must-check-closed-tickets](learnings/2026-05-27-sentry-dedupe-must-check-closed-tickets.md) — step-2 Sentry dedupe must match closed tickets too, not just open — canary errors (no Sentry write tools / ENG-21) get re-filed forever otherwise (APP-1 → ENG-17 closed → ENG-29 dup) +- [learnings/fetch-before-merge-on-long-lived-branch](learnings/2026-05-27-fetch-before-merge-on-long-lived-branch.md) — On long-lived branches, run `git fetch origin ` before `git merge origin/`; local origin ref goes stale during review-feedback rounds (PR #12 round 3 escalation) ## Decisions - [decisions/mcp-for-small-writes-checkout-for-big](decisions/2026-05-26-mcp-for-small-writes-checkout-for-big.md) — Single-file writes go through GitHub MCP; multi-file or test-needing changes use the mounted checkout + `git push` diff --git a/.claude/memory/learnings/2026-05-27-fetch-before-merge-on-long-lived-branch.md b/.claude/memory/learnings/2026-05-27-fetch-before-merge-on-long-lived-branch.md new file mode 100644 index 0000000..760cef9 --- /dev/null +++ b/.claude/memory/learnings/2026-05-27-fetch-before-merge-on-long-lived-branch.md @@ -0,0 +1,27 @@ +# `git fetch origin ` before `git merge origin/` on long-lived branches + +When a review-feedback round runs hours after a branch was opened — long enough for other PRs to merge to the base — the session's local `origin/` ref is stale. `git merge origin/` then resolves to the branch's original `base.sha`, not the current tip on the remote. The merge "succeeds" but brings in old state, dropping anything that landed in between. + +PR #12 (memory: pw-capture-script) hit this on round 3 (2026-05-26). The branch was opened at 09:19Z against `af2431b`. By round 3 (10:32Z) PR #13 had merged to main (`1072c9b`), adding `learnings/2026-05-26-vercel-bot-status-as-deploy-health-fallback.md` plus a `MEMORY.md` index line in the slot this branch reused. The round-3 session ran `git merge origin/main` without `git fetch` first, so it merged stale `af2431b` and the resulting branch diff showed the vercel-bot-status learning file as deleted. Mergeable state went `dirty`. Reviewer caught it on round 3, posted `AGENT_REVIEW: ESCALATE` (3-round limit), and the PR is still open the next morning waiting for a human to re-merge. + +## Rule + +Before any `git merge origin/` on a branch that's been open for more than a few minutes: + +```sh +git fetch origin +git merge origin/ +``` + +Or chain it: `git fetch origin main && git merge origin/main`. + +Applies to: +- Review-feedback rounds (manager wakes hours after PR open). +- Retro PRs that resolve conflicts against main. +- Any time the session was kicked off well after the branch HEAD was last touched. + +Does not apply when the session JUST cloned/checked-out from the mount — the initial fetch covers it. The risk is specifically the second-and-later `merge origin/` within the same long-running branch lifecycle. + +## Why this slipped through + +The escalation comment on PR #12 has the full trace. Existing `review-feedback-fanout` learning addresses the *parallel-session* race; this is the *time-passed* race on a single session. Same root cause shape ("the remote moved while you weren't looking"), different trigger.