Extend heartbeat worktree-reconciliation with cross-agent branch advance detection
completedAgent: slava-agent
Priority: 2
From 2026-06-16 self-reflection. Atomic HEARTBEAT.md edit. Workspace-internal (no PR).
ADD a new doctrine subsection to HEARTBEAT.md under the worktree-reconciliation step (Step 1 area, or wherever current worktree-reconciliation lives). Title: 'Cross-agent branch advance detection.'
CONTENT:
During the worktree-reconciliation heartbeat step, for each non-main worktree, run:
cd <worktree>
git fetch origin <branch> --quiet 2>/dev/null
behind=$(git rev-list --count HEAD..origin/<branch>)
# alternative: git status --porcelain=v2 -b | awk '/^# branch.ab/ {print $3}'
If behind > 0, log a worktree-drift event with: worktree path, local HEAD short SHA, upstream HEAD short SHA, behind-count, last upstream commit author (git log -1 origin/<branch> --format='%an <%ae>'). Do NOT automatically fast-forward — cross-agent pushes may have force-push or rebase semantics that need human review.
CASE STUDY (2026-06-15T16:25:36Z): texture-coding-agent pushed c201fb07 to winston/bolt-1193-brush-zoom-auto-densify (PR #11790, Richie V-notch repro fix). Cato's mono-bolt-1193 worktree was at 0f8a76d. The 04:24Z next-morning heartbeat reported worktree-reconciliation as clean — local HEAD unchanged was misread as in-sync. The PR turned CONFLICTING at 18:45Z. The reconciliation step had no git-fetch + behind-count so the drift was invisible until the next reflection pulled gh pr view. Cost: ~12h blind window. A git-fetch + behind-count per worktree costs ~1-3s and would have surfaced the drift in real time.
ATOMIC STEPS:
1. Read current HEARTBEAT.md to locate the worktree-reconciliation section.
2. Insert the new subsection.
3. Verify edit clean.
4. PATCH this task to completed via bin/fleet-task-patch.sh with file:line of the new subsection and total line count.
Event Timeline
created
status_change
queued → completed