Files
fusion/packages/engine
gsxdsm 8e70d69601 fix(review): Phase D self-healing hardening — finalize-site audit, lease/TOCTOU safety
4-persona review of the Phase-D workspace self-healing. The headline: the P0
single-commit-finalize guard had to be applied across ALL surfaces, not just the
one reconciler U1 patched (FN-5893).

Finalize-site audit (A): gated every site where a workspace task could be
single-commit-finalized on one repo's commit — recoverStuckMergeDeadlocks (the
twin of the U1-patched reconciler, reachable via blocked-dependents),
recoverOrphanOnlyScopeViolations, recoverAlreadyMergedReviewTasks,
recoverBranchMisboundInReviewTasks (workspace tasks carry task.branch so the
Boolean(branch) filter didn't exclude them), plus a defensive filter on
finalizeNoOpReviewTasks. recoverMergedReviewTasks confirmed safe (mergeConfirmed
gate). Each is an isWorkspaceTask early-skip; single-repo behavior unchanged.

Reliability/concurrency:
- The partial-land reconciler now captures enqueueMerge's boolean and bounds
  re-enqueues (mergeStarvationDrops → fail after N) instead of looping silently
  forever on a full queue.
- The phantom-lease reclaim only acts on a terminal owner (null/done/failed) — it
  no longer reclaims the lease of an in-progress executing task that registered it
  early (shared isWorkspaceOwnerLive predicate).
- A new isMergePending(taskId) = mergeActive ∪ mergeQueue seam (exposed from
  ProjectEngine, wired through the runtime) guards both reconcilers against the
  merge-queue dispatch window — a task dequeued-but-not-yet-merging is no longer
  re-enqueued (which, since a same-task land lease isn't contention, could have
  caused a concurrent double-squash).
- FORK-A: a repo whose branch is gone and which isn't landed is parked, not
  re-enqueued forever. Orphan-worktree removal failures log.warn + bound.
  recoverDoneTaskMergeMetadata skips workspace tasks.

Maintainability: dissolved the self-healing↔merger-ai import cycle by moving
isRepoLanded into a dependency-free workspace-land-predicate.ts; removed a
redundant cast.

Gate green: build, typecheck, lint, test:gate (649+58); self-healing + e2e +
project-engine + merger 724.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 02:19:17 -07:00
..
2026-06-19 07:34:26 -07:00
2026-06-19 07:34:26 -07:00