fix(engine): surface phantom-finalize cause and reset HEAD when branch is authoritative
commitOrAmendMergeWithFixes used to swallow every unexpected throw as `reason: "unknown-phantom"` and the two callers re-threw a bare "verification fix finalize failed (unknown phantom)" with no operator- actionable signal. FN-5422-class wedges (preAttemptHeadSha == currentHead but branchTip ahead with task-trailered commits) couldn't be diagnosed without re-running. The catch now records the original error and probes whether the branch ref itself is authoritative for the task (tip carries Fusion-Task-Id trailer, base..branch is foreign-contamination-free). When it is — i.e. the work isn't lost, the integration worktree just didn't advance — the catch resets rootDir to preAttemptHeadSha so the next merge attempt starts from a known baseline instead of inheriting partial squash state, and returns `reason: "branch-ref-ahead-reset"`. The two callers fold `originalError=` and `branchAuthority=` into the thrown message so the real cause (diff-volume gate, file-scope, transient git, etc.) is visible in the run log. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
9
.changeset/fix-phantom-finalize-diagnostic-reset.md
Normal file
9
.changeset/fix-phantom-finalize-diagnostic-reset.md
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
"@runfusion/fusion": patch
|
||||
---
|
||||
|
||||
Engine reliability: better diagnostics + clean-baseline reset on phantom finalize.
|
||||
|
||||
- `commitOrAmendMergeWithFixes` previously swallowed all unexpected errors as `reason: "unknown-phantom"` and the two callers re-threw a `verification fix finalize failed (unknown phantom)` error with no surface area beyond the SHAs. FN-5422-class tasks wedged in review with no actionable signal in the failure message.
|
||||
- The catch now captures the original error message and runs an `isBranchAuthoritativeForTask` probe (existing branch ref carries this task's `Fusion-Task-Id` trailer + foreign-contamination check against base). When the branch ref is authoritative — meaning the AI's work is safely stored on `fusion/<id>` and only the in-merge attempt's integration worktree drifted — the catch resets rootDir to `preAttemptHeadSha` and returns `reason: "branch-ref-ahead-reset"`. The next merge attempt then starts from a known-good baseline instead of inheriting half-built squash state.
|
||||
- Verification-fix and build-verification-fix callers now include the original error and the branch-authority probe outcome in the thrown error, so operators see the actual failure cause (e.g. diff-volume regression, file-scope violation, transient git error) rather than `unknown phantom`.
|
||||
Reference in New Issue
Block a user