Commit Graph

1531 Commits

Author SHA1 Message Date
Fusion (runfusion.ai)
e0df753bad fix(FN-4855): complete Step 4-5 — verify gates and add changeset
Fusion-Task-Id: FN-4855
Fusion-Task-Lineage: 47f093b7-dffc-4c1a-8dee-2fe01d0c9ed6
2026-05-17 01:08:50 -07:00
gsxdsm
7a6a3d0d22 feat(FN-4856): merge fusion/fn-4856 2026-05-17 01:08:01 -07:00
Fusion (runfusion.ai)
248c7706ca fix(FN-4853): finalize docs changeset and restore workspace build gate
Fusion-Task-Id: FN-4853
Fusion-Task-Lineage: aaad0ff7-714c-4c82-a1e7-c9a725db90cb
2026-05-17 01:01:53 -07:00
Fusion (runfusion.ai)
87bd369673 feat(FN-4854): complete Step 8 — add changeset
Fusion-Task-Id: FN-4854
Fusion-Task-Lineage: 969ec04a-efe3-4dee-b183-2d4f2de6b388
2026-05-17 00:43:48 -07:00
gsxdsm
3ca3b5e471 feat(FN-4851): merge fusion/fn-4851 2026-05-17 00:38:07 -07:00
Fusion (runfusion.ai)
5ca8761656 feat(FN-4849): complete Step 6 — add changeset and docs notes
Fusion-Task-Id: FN-4849
Fusion-Task-Lineage: 624f86c4-0b0f-4543-90d2-381f890da401
2026-05-17 00:37:53 -07:00
gsxdsm
2adc9fa0da feat(FN-4841): merge fusion/fn-4841 2026-05-17 00:22:57 -07:00
Fusion (runfusion.ai)
f0df7cb1d2 feat(FN-4792): complete Step 6 — finalize delivery and changeset
Fusion-Task-Id: FN-4792
Fusion-Task-Lineage: 8e29f9a0-4c9f-4322-9595-3c9c581dacb0
2026-05-17 00:21:13 -07:00
Fusion (runfusion.ai)
1e1e6f9c13 feat(FN-4835): complete Step 7 — add changeset and delivery notes
Fusion-Task-Id: FN-4835
Fusion-Task-Lineage: 09eb6339-a476-4cf1-b7e5-e60fa6c263ce
2026-05-17 00:14:58 -07:00
Fusion (runfusion.ai)
c1cbb668ea feat(FN-4850): complete Step 4 — add changeset
Fusion-Task-Id: FN-4850
Fusion-Task-Lineage: 903d8e4e-eba7-413e-86d8-94eae7318952
2026-05-17 00:06:26 -07:00
Fusion
aa6d1c9851 fix(FN-4847): discard foreign branch and recreate on branch-conflict-unrecoverable
Production failure shape:
  Auto-recovery failed: branch conflict unrecoverable \u2014
  Branch fusion/fn-4847 is already checked out at /.../deft-crane
  (tip a881ccc86660, 24 stranded commits since 0b28388876).
  Run branch recovery and explicitly choose whether to reclaim or
  discard prior work.

The 24 stranded commits are cross-task contamination residue from the
FN-4781/FN-4804/FN-4814 worktree-race era \u2014 they are NOT FN-4847's work.
Previously this paused the task with pausedReason='branch-conflict-
unrecoverable' and the task got stuck forever waiting for human
adjudication.

User intent (FN-4847): 'just create a new branch and keep going and
discard the old one'. Implementation:

1. auto-recovery.ts:actionForMode \u2014 in 'deterministic-only' mode (the
   default), branch-conflict-unrecoverable now returns 'retry' (was
   'pause'). This routes the failure to the handler instead of pausing.

2. auto-recovery-handlers/branch-worktree.ts \u2014 'live-foreign' inspection
   no longer emits irreducible-pause. Instead:
   - Check FN-4811 active-session registry. If the foreign worktree is
     bound to a live executor/merger session, do NOT force-remove it
     (would yank the live agent's filesystem). Just requeue and let
     downstream conflict-recovery handle it.
   - Otherwise: force-delete the foreign worktree (--force) + prune git
     worktree admin entries + force-delete the branch. Errors at each
     step are best-effort and logged.
   - Emit new audit event 'branch-worktree:foreign-branch-discarded'
     with stranded-commit count, live-ownership flag, success flags.
   - Requeue task to 'todo' with preserveProgress, clearing
     branch+baseCommitSha.

3. run-audit.ts \u2014 register new DatabaseMutationType.

4. executor-worktree.test.ts \u2014 update the 'records recovery context'
   test to assert the new retry+requeue contract (was asserting the old
   pause-with-status-failed contract).

Verification:
  - Targeted suite (4 files, 343 tests): pass.
  - pnpm --filter @fusion/engine build: clean.
  - pnpm lint: clean.

Fusion-Task-Id: FN-4847
2026-05-16 23:53:56 -07:00
Fusion (runfusion.ai)
9e5a516997 feat(FN-4826): complete Step 5 — document handoff telemetry
Fusion-Task-Id: FN-4826
Fusion-Task-Lineage: b08a58c8-66ab-43d4-bdf9-69d2b56b7bcc
2026-05-16 23:45:17 -07:00
gsxdsm
df998cb54f feat(FN-4829): merge fusion/fn-4829 2026-05-16 22:26:42 -07:00
Fusion (runfusion.ai)
d4c4d6d7f0 docs(FN-4824): add reliability cross-reference and changeset
Fusion-Task-Id: FN-4824
Fusion-Task-Lineage: 65f53a33-0939-4b6f-b62b-4a255ad14d9e
2026-05-16 21:53:18 -07:00
Fusion (runfusion.ai)
6fa9aef630 feat(FN-4823): complete lease recovery central-claim reconciliation
Fusion-Task-Id: FN-4823
Fusion-Task-Lineage: 0034c04f-df82-4a1b-9f25-b93643a2c157
2026-05-16 21:26:04 -07:00
Fusion (runfusion.ai)
0b28388876 feat(FN-4804): complete Step 4 — add changeset
Fusion-Task-Id: FN-4804
Fusion-Task-Lineage: d2a98aa6-1c5c-427b-ba72-f5d229fdeeb9
2026-05-16 21:17:15 -07:00
Fusion
5c36c0f15f fix(FN-4811): scope-leak guard always allows .changeset/ paths
The [scope-leak] reviewLevel=N enforcement=warn warning was firing on
many in-progress tasks for off-scope .changeset/FN-XXXX-*.md files (the
production signature on FN-4789, FN-4801, FN-4818 \u2014 their branches all
contained .changeset/FN-4811-*.md files from the in-progress fix stack).

By convention every task may add its own changeset entry under
.changeset/ per AGENTS.md 'Finalizing Changes' section, so .changeset/
files are now treated as always-allowed by the scope-leak guard
regardless of the task's declared file scope.

Cross-task changeset leakage is still caught by stronger downstream
guards (file-scope invariant at squash, post-merge audit) at much
higher signal-to-noise. This change only suppresses the noisy
per-execution warning that was flooding logs without adding any
defensive value.

Adds a new exported helper isAlwaysAllowedScopeLeakPath() so the
allowlist surface is easy to extend. Test coverage in
scope-leak-changeset-allowlist.test.ts.

Also (incorporated from interrupted merge state): loosens the
executing-task-lock.test.ts assertion that one losing-instance store
sees zero work-log entries rather than the brittle exact-count of
mockedCreateFnAgent invocations (the no-fn_task_done retry path can
fire on the winning instance, so the count varies).

Fusion-Task-Id: FN-4811
2026-05-16 21:15:10 -07:00
Fusion
b6df11a6a8 fix(FN-4811): process-wide executingTaskLock blocks parallel execute() across instances
Investigating FN-4814 + FN-4811 re-failures after commit 8bef30655 (which
added per-instance synchronous this.executing.add) revealed the per-instance
guard was insufficient. FN-4809 log at 02:48:17-18 UTC:

  02:48:17  [-]                Resuming execution after unpause
  02:48:17  [-]                Step 4 (Testing & Verification) -> pending
  02:48:17  [-]                Step 4 (Testing & Verification) -> pending
  02:48:17  [6097725-y2nb]     Executor detected stale merge state ...
  02:48:18  [6097816-9gde]     Executor detected stale merge state ...

Both runs y2nb and 9gde reached executor.ts:2661 (which is INSIDE execute(),
past the synchronous this.executing.add claim). The only viable explanation
is that there is more than one TaskExecutor instance in the same Node
process (engine restart race, multi-project hybrid runtime, or similar code
path). Each instance has its own executing Set, so the per-instance guard
doesn't help.

Fix: module-level singleton executingTaskLock in active-session-registry.ts,
shared across all TaskExecutor instances. execute() synchronously tryClaim()s
the lock; if false, bails. Every existing this.executing.delete() site also
calls executingTaskLock.release(). Per-instance this.executing kept because
many other call sites use it (this.executing.has at handler gates,
stuck-detector, resumeTaskForAgent, etc.).

Test setup (resetExecutorMocks in executor-test-helpers.ts) clears the lock
between tests so process-wide state doesn't leak (executor-pause and
executor-prompt tests would otherwise show 'expected 2 createFnAgent calls
but got 0' / 'expected not called but called 3 times' flakes).

Tests:
  - executing-task-lock.test.ts: 2 cases. Key case creates TWO TaskExecutor
    instances and races them on the same task ID, asserts only ONE actually
    runs. Verified FAILS on prior code (8bef30655) and PASSES on fix.

Verification:
  - Targeted suite (4 files, 170 tests): pass.
  - pnpm --filter @fusion/engine build: clean.
  - pnpm lint: clean.

Fusion-Task-Id: FN-4811
2026-05-16 21:06:51 -07:00
Fusion (runfusion.ai)
7ab3f7a750 feat(FN-4790): complete Step 5 — documentation and delivery
Fusion-Task-Id: FN-4790
Fusion-Task-Lineage: 4daf3560-7b02-4fbf-9e0a-45e048b795a1
2026-05-16 21:00:48 -07:00
Fusion (runfusion.ai)
27dd927213 feat(FN-4830): complete Steps 4-7 stale lock recovery delivery
Fusion-Task-Id: FN-4830
Fusion-Task-Lineage: d9b8ad72-669f-488e-8e85-be2dce9b8341
2026-05-16 20:54:39 -07:00
Fusion (runfusion.ai)
199f317813 feat(FN-4822): complete Step 6 — enforce central-claim race coverage
Fusion-Task-Id: FN-4822
Fusion-Task-Lineage: 08cc29e8-114a-48dc-80de-8d7fd2ce0e69
2026-05-16 20:48:00 -07:00
gsxdsm
4d5e296049 feat(FN-4801): merge fusion/fn-4801 2026-05-16 20:13:30 -07:00
Fusion (runfusion.ai)
937bed90b9 feat(FN-4789): complete Step 6 — changeset and resolver polish
Fusion-Task-Id: FN-4789
Fusion-Task-Lineage: cef0d12e-556e-43d8-9ce0-e4962c2d091b
2026-05-16 20:06:48 -07:00
Fusion (runfusion.ai)
8e3a635d3d feat(FN-4825): complete Step 4 — add changeset for node-unreachable audits
Fusion-Task-Id: FN-4825
Fusion-Task-Lineage: dc4e633e-fe46-47a8-9ecc-f032073caee9
2026-05-16 19:58:46 -07:00
Fusion (runfusion.ai)
7cd5554641 feat(FN-4810): complete Step 6 — finalize truncation docs and changeset
Fusion-Task-Id: FN-4810
Fusion-Task-Lineage: b7080f83-96b0-4106-9742-e14b20afeab1
2026-05-16 18:57:58 -07:00
Fusion
8bef30655d fix(FN-4811): close concurrent-execute race that produced parallel runs
TaskExecutor.execute() had a classic JS async race window. Original:

  async execute(task) {
    if (this.executing.has(task.id)) return;                       // check
    const assignedAgentId = task.assignedAgentId;
    if (assignedAgentId && await this.shouldDeferForHeartbeat(...)) // AWAIT yields
      return;
    this.executing.add(task.id);                                   // add (too late)
    ...
  }

Two concurrent execute(task) calls (scheduler dispatch + task:moved event
handler + restart-recovery) both:
  1. Pass the synchronous has() check (Set is empty).
  2. Enter the awaited shouldDeferForHeartbeat call (yields the event loop).
  3. Resume and both call this.executing.add(task.id).
  4. Both proceed to create the same worktree path.

Production failure shape (FN-4814 + FN-4811, observed within minutes):

  01:30:56  [runA-caoe]  Worktree created at /...worktrees/bright-mesa
  01:30:56  [runB-w23q]  Worktree created at /...worktrees/bright-mesa
  01:30:58              worktree liveness assertion failed: not_usable_task_worktree
  01:31:48              [thirdRun] also fires liveness assertion fail
  01:37:48              In-review stall surfaced [no-worktree-no-merge-confirmed]

This is the root cause of the entire FN-4781/FN-4804/FN-4814/FN-4811
cascade. Every other guard added today (FN-4811 active-session gate,
self-healing reclaim defer, validation-failed recovery, silent reclaim
recovery, integrity-warning dedup) was patching SYMPTOMS of the
duplicate-run race. With this fix, the symptoms stop appearing.

Fix: claim the slot synchronously immediately after the has() check,
release it on the heartbeat-defer early-return path. No await happens
between check and claim, so the race window is closed.

Test added under
packages/engine/src/__tests__/reliability-interactions/concurrent-execute-race.test.ts
verified to fail on the prior (a1b1f9aa0) executor.ts and pass on the
fixed version:

  - Two concurrent execute() calls produce the SAME number of
    createFnAgent invocations as one execute() call (no amplification).
  - A second sequential execute() after the first completes IS allowed
    (slot was released).

The task must have assignedAgentId set to exercise the race \u2014 without
it, the short-circuit `assignedAgentId && ...` evaluates the left side
to false synchronously, and no await happens.

Full engine suite: 5048+ tests pass. The 7 transient test-file failures
in the broad parallel run are pre-existing flaky real-git tests
(branch-conflicts-zero-unique, branch-conflicts-recovery,
merger-overlap-guard subprocess-guard contention) \u2014 all of them pass
when run alone or as a smaller group, none touch the executor.execute()
path.

Fusion-Task-Id: FN-4811
2026-05-16 18:55:03 -07:00
Fusion (runfusion.ai)
4863e3be8f feat(FN-4786): complete Step 6 — document planning loading fixes
Fusion-Task-Id: FN-4786
Fusion-Task-Lineage: eb683ec8-8b9d-4e3d-852c-7076224afa6b
2026-05-16 18:40:04 -07:00
Fusion
a1b1f9aa05 fix(FN-4811): defer self-healing reclaim when worktree has an active session
The reclaimSelfOwnedBranchConflicts sweep was force-pausing actively-running
tasks. Production failure shape on FN-4819:

  1. Self-healing sweep runs every cycle and inspects branch conflicts.
  2. For FN-4819, inspection classified the conflict as 'tip-already-merged'
     (the task's branch tip was already on main).
  3. Sweep called removeWorktree({ reason: SelfHealingBranchConflict }).
  4. The FN-4811 active-session gate correctly refused: the worktree was
     bound to FN-4819/executor (a live agent session was using it).
  5. The thrown ActiveSessionWorktreeRemovalError was caught by the outer
     reclaim catch block.
  6. The catch escalated to AutoRecoveryDispatcher with class
     'branch-conflict-unrecoverable'.
  7. decision.action === 'pause' marked the task failed + paused +
     pausedReason='branch-conflict-unrecoverable' + moved to in-review.

Net effect: the FN-4811 gate (which is correct \u2014 you can't yank a live
worktree) became a regression source because the self-healing sweep
interpreted the refusal as fatal. Tasks that were actively making progress
got paused with a misleading 'branch conflict unrecoverable' error.

Fix: at the top of the per-task reclaim loop in
reclaimSelfOwnedBranchConflicts, check
activeSessionRegistry.isPathActive(task.worktree) and continue for any
task whose worktree is currently bound to a live session. The reclaim
will retry on the next sweep (sweeps run every cycle) once the session
has finished using the worktree. No data is lost, no decision is forced.

Test added under
packages/engine/src/__tests__/reliability-interactions/reclaim-defers-on-active-session.test.ts
covering:
  - The skip path: when activeSessionRegistry has a registration for
    task.worktree, the sweep MUST NOT call inspectBranchConflict,
    removeWorktree, or isUsableTaskWorktree. The task MUST stay in
    in-progress, not be marked failed/paused, not be moved to in-review.
  - Control: with no registration, the sweep DOES proceed and reaches
    inspectBranchConflict (preserving existing behavior).

Full engine suite: 314 files, 5061 tests pass, 1 skipped. Lint clean.
Build clean.

Fusion-Task-Id: FN-4811
2026-05-16 17:59:03 -07:00
Fusion (runfusion.ai)
4691cbe199 fix(FN-4804): sync quick chat session and room selection
- Clear the active chat room when switching Quick Chat to a direct session
- Keep the hidden session dropdown value and initial-session state aligned with room selection changes
- Add dashboard regression coverage for switching from a room back to a direct chat and include a CLI patch changeset

Fusion-Task-Id: FN-4804
2026-05-16 17:47:48 -07:00
Fusion (runfusion.ai)
b2ca02f743 feat(FN-4813): complete docs, settings, and verification updates
Fusion-Task-Id: FN-4813
Fusion-Task-Lineage: 846893a5-2afa-4817-8f64-8c444d2fd713
2026-05-16 17:31:10 -07:00
Fusion
86237c9a50 fix(FN-4811): unblock @fusion/engine typecheck so verification bootstrap can run
Symptom found while investigating 'tasks are still struggling': every
in-review task hitting pre-merge deterministic verification failed with

  [verification:bootstrap] bootstrap preamble failed (exit 2):
  [test-bootstrap] FAILED: workspace dist artifact rebuild did not complete.
  [test-bootstrap] command: pnpm --filter @fusion/engine build

Because pnpm --filter @fusion/engine build hit 17 TS errors from a prior
autonomous-agent refactor introducing a RemovalReason enum-like object
and two new audit event types. The bootstrap preamble is run by the
merger before every direct-merge verification, so a broken engine
typecheck blocked EVERY task from merging.

Fixes:

1. Duplicate RemovalReason re-export in worktree-pool.ts

   Both  and
    were present for the same identifier,
   producing TS2300 'Duplicate identifier'. RemovalReason is a const
   object with derived type (typeof-keyof pattern), so a single value
   export covers both kinds; the type-only re-export was redundant.

2. GitMutationType union missing the FN-4811 audit event types

   merger.ts and worktree-backend.ts were emitting
   'worktree:removal-refused-active-session' and
   'worktree:removal-forced-over-active-session' audit events, but the
   union in run-audit.ts didn't include them. Added both.

3. self-healing.test.ts vi.mock had wrong RemovalReason keys

   The mock only exposed 5 keys (SelfHealing*) but production code
   references HardCancel, Executor*, Merger*, PoolPrune, etc. Calls
   like removeWorktree({ reason: RemovalReason.MergerPostMerge }) were
   getting reason=undefined, producing confusing 'cannot remove
   worktree: [vitest] No RemovalReason export is defined on mock'
   error messages. Updated the mock to mirror the production const
   exactly.

4. worktree-backend.test.ts removeWorktree calls missing required reason

   The new contract makes reason: RemovalReason a required field on
   removeWorktree's input. Five existing test cases were missing it;
   added reason: RemovalReason.MergerCleanup to each.

5. integrity-warning-persisted-dedup.test.ts Settings cast

   The test's makeStore helper cast a partial settings object to
   Settings; TS rejected the narrowed type. Cast through unknown.

Verification:

  - pnpm --filter @fusion/engine build: clean
  - pnpm lint: clean
  - pnpm build (full workspace): clean
  - pnpm --filter @fusion/engine test: 5045 pass, 1 pre-existing
    aiMergeTask real-git timeout flake, 1 skipped

With this fix, the verification bootstrap can complete and the merger
can finalize tasks again.

Fusion-Task-Id: FN-4811
2026-05-16 17:23:15 -07:00
Fusion
f4aa6d7b8b fix(FN-4811): persist done-task integrity warnings across engine restarts
The periodic self-healing sweep at
SelfHealingManager.reconcileDoneTaskIntegrity() emits a single
'Integrity warning: done-task finalize evidence is unproven (<reason>)' log
entry per task when the task is in 'done' but has no provable on-main
evidence. Dedup was via an in-memory finalizeUnprovenWarned Set per manager
instance, so every engine restart resurfaced the same warning on the next
sweep — significant noise on done tasks that legitimately lack evidence,
typically residue of FN-4811 contamination (FN-4771/FN-4778 in production).

Adds an optional MergeDetails.integrityWarning = { warnedAt, reason } field
and persists it on the first warning. Both warning sites in
reconcileDoneTaskIntegrity() (the unproven-and-still-mergeable branch and
the unproven-final branch) now consult the persisted record:

  - Same reason as persisted → skip re-emitting, just rehydrate the in-memory
    Set for in-process consistency.
  - Different reason → re-warn (so a *new* classification problem still
    surfaces) and update the persisted record.

Tests added under
packages/engine/src/__tests__/reliability-interactions/integrity-warning-persisted-dedup.test.ts
(real-git, 4 cases):

  - First sweep: emits warning + persists record.
  - Second sweep, same instance: in-memory Set dedupes (existing contract).
  - Fresh manager (simulated engine restart) + pre-persisted record:
    persisted dedup suppresses re-emission.
  - Fresh manager + persisted record with different reason: must re-warn
    and overwrite the persisted reason.

Full engine suite: 308 files, 5041 tests pass, 1 skipped. Lint clean.

Fusion-Task-Id: FN-4811
2026-05-16 16:51:43 -07:00
Fusion (runfusion.ai)
42b8eebc8e feat(FN-4809): complete Step 3 — add changeset for merge attempt audit coverage
Fusion-Task-Id: FN-4809
Fusion-Task-Lineage: bd632e33-b376-47de-ad99-da4610ae4690
2026-05-16 16:50:16 -07:00
Fusion
dcd6bf60f3 fix(FN-4811): recover from validation-failed remove + collapse broken FN-4806 nested branches
Two follow-ups stacked on the FN-4811 active-worktree liveness gate:

1. Stale conflict-path recovery (FN-4813 production failure)

   When 'git worktree remove --force' fails with 'fatal: validation failed,
   cannot remove working tree', the worktree directory is missing on disk
   and the git admin entry is stale. Without this recovery, every retry of
   tryCreateWorktree on a stale conflict path failed 3 times with
   'automatic cleanup failed', leaving tasks unable to create worktrees.

   cleanupConflictingWorktree now catches that specific error class, runs
   'git worktree prune' to drop the stale admin entry, best-effort deletes
   the branch, and returns success so the caller can proceed.

   Implementation note: the original attempt used existsSync(worktreePath)
   as a pre-check, but vitest's vi.clearAllMocks() can leave the existsSync
   mock returning undefined, causing the new branch to fire inside tests
   that didn't expect it and leading to worker OOM in
   executor-worktree.test.ts. The error-class-based catch is robust against
   mock state and matches the real production failure signal exactly.

2. Collapsed broken FN-4806 nested branches

   The previous FN-4806 refactor (commit 087b1a766) accidentally nested the
   genuine 'agent finished without calling fn_task_done after N retries'
   failure path INSIDE the silent-recovery branch, meaning ordinary
   failures were being silently requeued (no status=failed, no onError, no
   retry-budget burn) instead of being surfaced.

   Restored the clean two-branch structure:

     } else if (retryAbortedDueToReclaim) {
       // silent recovery (FN-4806)
     } else {
       // genuine no-fn_task_done exhaustion: mark failed, onError, burn budget
     }

   Also clears baseCommitSha on silent recovery (matches the parallel
   session-start-failure path's metadata clearing).

Tests:

  - Adds 'FN-4811 follow-up (FN-4813): recovers from validation failed'
    case to active-worktree-removal-liveness.test.ts (12 total cases).
  - executor-recovery.test.ts no-fn_task_done reclaim coverage now
    asserts baseCommitSha is cleared.
  - executor-recovery.test.ts 'does not mark task as failed when invalid
    transition error occurs on completion' regression fixed by restoring
    the failure-path branch.
  - executor-core.test.ts 'still enforces fn_task_done requirement in
    fast mode' restored.

Full engine suite: 307 files, 5037 tests pass, 1 skipped. Lint clean.

Fusion-Task-Id: FN-4811
2026-05-16 16:25:28 -07:00
Fusion (runfusion.ai)
7310642b68 test(FN-4806): add reclaim retry coverage and changeset
Fusion-Task-Id: FN-4806
Fusion-Task-Lineage: 4192226a-b24c-4681-b0fa-ce86f40fce64
2026-05-16 16:01:23 -07:00
Fusion
4c26aa6e91 fix(FN-4811): refuse to force-remove worktrees actively bound to live sessions
The executor's conflict-recovery paths (cleanupConflictingWorktree,
handleBranchConflict, and tryCreateWorktree's live-foreign/stale-resolved
branches) could force-remove a worktree even when it was currently bound
to an active executor session. This caused the FN-4781/FN-4804 cascade:

  - 'Execution blocked: assigned worktree path disappeared mid-task' as
    git deleted the live agent's filesystem out from under it
  - Two parallel runs for the same task alive simultaneously, with the
    second run started in a fresh worktree while the first was still
    holding the old session
  - Cross-task log attribution (an FN-4804 runContext writing to FN-4781)
  - Post-merge 'branch tip misbound but content found on main via trailer'
    rescues firing on every successful merge as the bookkeeping was
    corrupted mid-merge

Adds a hard liveness gate centralized in findActiveWorktreeOwner(), which
checks both the in-memory activeWorktrees map and the DB for non-done,
non-paused, in-progress tasks bound to the worktree. The gate fires at
two points:

  1. cleanupConflictingWorktree returns false (refuses removal) when an
     active owner is found, logging an FN-4811 refusal entry.
  2. handleBranchConflict short-circuits to 'sticky' BEFORE invoking
     inspectBranchConflict, because some inspection branches force-remove
     unconditionally.

When cleanup is refused, the live-foreign and stale-resolved branches in
tryCreateWorktree now FALL THROUGH to the suffix-rename path (rather
than returning null) so the requesting task can still proceed without
disturbing the live owner.

Tests:

  - New reliability-interactions backstop at
    src/__tests__/reliability-interactions/active-worktree-removal-liveness.test.ts
    covers findActiveWorktreeOwner (5 cases: in-memory match, requesting
    task excluded, DB-level match, paused exclusion, terminal-column
    exclusion, self-exclusion), cleanupConflictingWorktree gate (3 cases:
    in-memory refuse, DB refuse, no-owner proceed), and handleBranchConflict
    gate (2 cases: short-circuit + inspection-skipped, no-owner proceeds).
  - Updates existing executor-worktree.test.ts assertion that was
    documenting the bug behavior (force-removing active worktree) to match
    the new contract (refuses + falls through to suffix-rename).

Full engine suite: 307 files, 5035 tests pass.

Fusion-Task-Id: FN-4811
2026-05-16 15:36:07 -07:00
Fusion
3f8a5e6839 fix(FN-4806): silently recover when worktree/branch reclaimed mid-retry
The executor's no-fn_task_done retry loop has two reclaim signals
(retryAbortedDueToReclaim=true): (1) pre-retry liveness recheck where the
task DB shows worktree/branch was cleared, and (2) session-start failure
because the worktree path no longer exists. Both are engine self-heal
situations triggered by FN-4546 stale-active-branch reclaim, FN-4742
self-healing removals, or related housekeeping paths — the agent never
got a fair retry attempt.

Previously these surfaced as task status=failed with error
'Worktree/branch reclaimed during no-fn_task_done retry — requeueing',
fired onError, and burned the taskDoneRetryCount budget. Three legitimate
problems followed: tasks accumulated spurious failures in the UI, the
exhausted-budget branch escalated reclaimed tasks to in-review instead of
retrying, and the noise masked the underlying worktree-removal regression
(FN-4811).

Now the reclaim branch silently:
- clears stale worktree/branch metadata so the next pickup creates a fresh worktree
- requeues to todo with preserveProgress
- logs an informational 'engine self-heal, no failure' line
- does NOT set status=failed, does NOT bump taskDoneRetryCount, does NOT call onError

The genuine 'agent finished without calling fn_task_done after N retries'
exhaustion path (retryAbortedDueToReclaim=false) is unchanged.

Tests updated in
packages/engine/src/__tests__/reliability-interactions/executor-no-task-done-vs-worktree-reclaim.test.ts
to assert the new silent-recovery contract on all three reclaim paths.

Fusion-Task-Id: FN-4806
2026-05-16 15:16:05 -07:00
Fusion (runfusion.ai)
246609a415 feat(FN-4803): complete Steps 4-5 — docs update and changeset
Fusion-Task-Id: FN-4803
Fusion-Task-Lineage: cbfa10fd-33a6-469c-9cb4-3a647bc47b84
2026-05-16 14:56:56 -07:00
Fusion (runfusion.ai)
fea0b51915 feat(FN-4783): complete Step 8 — documentation and changeset
Fusion-Task-Id: FN-4783
Fusion-Task-Lineage: 7a02897b-e303-4947-86b2-3dd7a343f653
2026-05-16 13:46:43 -07:00
Fusion (runfusion.ai)
fc86c4f429 feat(FN-4784): complete Step 4 — add changeset
Fusion-Task-Id: FN-4784
Fusion-Task-Lineage: e11a4758-93ab-451e-8721-ae8995aaa70d
2026-05-16 13:35:31 -07:00
Fusion (runfusion.ai)
424c61f4f7 feat(FN-4780): complete Step 7 — add changeset
Fusion-Task-Id: FN-4780
Fusion-Task-Lineage: 7f052539-9d15-4997-8135-21434f065d4a
2026-05-16 13:24:56 -07:00
Fusion (runfusion.ai)
a2710fb70f test(FN-4802): stabilize desktop auto-updater setup assertions
Fusion-Task-Id: FN-4802
Fusion-Task-Lineage: a1436633-8000-4b3a-8d22-dcc28be69bcd
2026-05-16 13:15:00 -07:00
Fusion (runfusion.ai)
5a101dc70b feat(FN-4785): complete Step 6 — document and ship agents-load perf fix
Fusion-Task-Id: FN-4785
Fusion-Task-Lineage: be241ee7-9df0-433c-a00b-997bcd558862
2026-05-16 13:04:28 -07:00
Fusion (runfusion.ai)
416bd8b1f5 feat(FN-4785): complete Step 6 — add changeset for agents load perf
Fusion-Task-Id: FN-4785
Fusion-Task-Lineage: be241ee7-9df0-433c-a00b-997bcd558862
2026-05-16 13:04:28 -07:00
Fusion (runfusion.ai)
023a0cc6bd feat(FN-4777): complete Step 6 — add changeset
Fusion-Task-Id: FN-4777
Fusion-Task-Lineage: ed00f639-c928-4c14-be1f-2b43db6022c7
2026-05-16 12:56:31 -07:00
gsxdsm
c6e978286a feat(FN-4779): merge fusion/fn-4779 2026-05-16 12:49:57 -07:00
Fusion (runfusion.ai)
11012b49c9 feat(FN-4774): complete Step 5 — add changeset for triage search tool
Fusion-Task-Id: FN-4774
Fusion-Task-Lineage: f3b81550-fb23-441e-aee7-44ffec63d03d
2026-05-16 11:55:40 -07:00
Fusion (runfusion.ai)
93c3975532 feat(FN-4769): show inline spinners in planning-mode modal during creation
Adds inline loading spinners to the planning mode task-creation modal, replacing any placeholder states during the creation flow, with a new planning-flow test covering the spinner behavior.

Fusion-Task-Id: FN-4769
2026-05-16 11:55:15 -07:00
Fusion (runfusion.ai)
db7b196462 test(FN-4770): complete Steps 3-4 — add tracking async coverage
Fusion-Task-Id: FN-4770
Fusion-Task-Lineage: 8c8d1786-f81b-4544-9275-595b90ea5689
2026-05-16 11:39:37 -07:00
Fusion (runfusion.ai)
b594160e77 feat(FN-4772): complete Step 7 — docs and changeset
Fusion-Task-Id: FN-4772
Fusion-Task-Lineage: d296e96a-fe44-4896-928a-fa44da62b41a
2026-05-16 11:32:56 -07:00