Files
fusion/.changeset
Fusion (runfusion.ai) 1983dac6e4 fix(FN-5345): refuse empty commits + early empty-own-diff finalize
Three engine-level fixes for the in-review wedge class identified via FN-5345
(verification-only task with empty handoff commit + drifted worktree mapping
escalating to 'merge-deadlock-detected: verified content not on main' after
FN-4999 completion-handoff-limbo recovery exhausts).

D1 — prepare-commit-msg empty-commit guard
  Fusion task worktrees install a prepare-commit-msg hook that refuses
  'git commit --allow-empty' and other zero-staged-diff commits. Amend
  (detected via $2==commit source arg or '--amend' in 'ps -o args= -p $PPID')
  and merge/squash/cherry-pick/revert/rebase ceremonies are allowed.

D5 — early empty-own-diff fast-path in aiMergeTask
  In reuse-task-worktree integration mode, BEFORE any reuse-handoff acquisition,
  detect branches with own_commit_count >= 1 but zero net diff vs merge-base
  (git diff --quiet <mergeBase>..<branch>) and finalize as no-op with
  mergeDetails.noOpMerge=true + task:auto-recover-finalize-already-on-main
  audit (reason: empty-own-diff-early-fast-path). cwd-main integration mode
  is unchanged. classifyOwnedLandedEvidence also detects empty-own-diff so
  self-healing and post-handoff finalize paths benefit too.

D3 — reuse-fallback consults existing branch registration
  Before creating a fresh worktree in merger's reacquireReuseIntegrationWorktree,
  consult 'git worktree list --porcelain' for existing registrations of
  fusion/<id>. Reuse extant usable registrations directly. Prune stale
  registrations first. Eliminates FN-5083-class double-registration where
  'git worktree add -f' on an already-registered branch produced two worktrees
  both claiming the branch and wedged the next handoff gate.

Tests
  - New real-git backstop: prepare-commit-msg-empty-guard.real-git.test.ts
  - New reliability interaction backstop in merge-reuse-task-worktree.test.ts
    ('FN-5345: empty-own-diff branch auto-finalizes via early fast-path')
  - commit-msg-trailer.real-git.test.ts updated to use real commits (it was
    relying on --allow-empty, which the new guard now refuses)
  - Full @fusion/engine suite: 448 files / 5879 tests / 9 skipped, all green
  - pnpm lint green, pnpm build green
2026-05-20 17:31:48 -07:00
..