Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude/memory/MEMORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <base>` before `git merge origin/<base>`; 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`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# `git fetch origin <base>` before `git merge origin/<base>` 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/<base>` ref is stale. `git merge origin/<base>` 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/<base>` on a branch that's been open for more than a few minutes:

```sh
git fetch origin <base>
git merge origin/<base>
```

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/<base>` 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.