Commit Graph

1705 Commits

Author SHA1 Message Date
Fusion (runfusion.ai)
be9baad3bb fix(FN-4807): unblock engine build with typed liveness mocks
Fusion-Task-Id: FN-4807
Fusion-Task-Lineage: 3f03bd51-71c3-43c4-abe0-f636edeaf52b
2026-05-16 17:08:09 -07:00
Fusion (runfusion.ai)
52ab8a312f test(FN-4807): complete Step 4 — harden autostash suite timeout and cleanup
Fusion-Task-Id: FN-4807
Fusion-Task-Lineage: 3f03bd51-71c3-43c4-abe0-f636edeaf52b
2026-05-16 17:08:09 -07:00
Fusion (runfusion.ai)
a3ff539619 test(FN-4807): complete Step 3 — bound FN-3936 replay timeout
Fusion-Task-Id: FN-4807
Fusion-Task-Lineage: 3f03bd51-71c3-43c4-abe0-f636edeaf52b
2026-05-16 17:08:09 -07:00
Fusion (runfusion.ai)
8fd47b619f feat(FN-4811): complete Step 3 — update removeWorktree call sites
Fusion-Task-Id: FN-4811
Fusion-Task-Lineage: f3dac123-cb46-4d31-8a7e-dfc664bfdc5f
2026-05-16 16:55:04 -07:00
Fusion (runfusion.ai)
7a438f63ee fix(FN-4811): repair step-session registry wiring recursion
Fusion-Task-Id: FN-4811
Fusion-Task-Lineage: f3dac123-cb46-4d31-8a7e-dfc664bfdc5f
2026-05-16 16:55:03 -07:00
Fusion (runfusion.ai)
69d7b282cf feat(FN-4811): complete Step 1 — add active session registry wiring
Fusion-Task-Id: FN-4811
Fusion-Task-Lineage: f3dac123-cb46-4d31-8a7e-dfc664bfdc5f
2026-05-16 16:55:01 -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)
ba8e912aa8 test(FN-4809): complete Step 3 — cover merge attempt audit emission
Fusion-Task-Id: FN-4809
Fusion-Task-Lineage: bd632e33-b376-47de-ad99-da4610ae4690
2026-05-16 16:50:17 -07:00
Fusion (runfusion.ai)
d898801ec3 test(FN-4809): complete Step 2 — cover merge attempt audit emission
Fusion-Task-Id: FN-4809
Fusion-Task-Lineage: bd632e33-b376-47de-ad99-da4610ae4690
2026-05-16 16:50:16 -07:00
Fusion (runfusion.ai)
df76612d78 feat(FN-4809): complete Step 1 — emit merge attempt audit events
Fusion-Task-Id: FN-4809
Fusion-Task-Lineage: bd632e33-b376-47de-ad99-da4610ae4690
2026-05-16 16:50:15 -07:00
Fusion (runfusion.ai)
4e5bcee14f feat(FN-4809): complete Step 2 — emit merge attempt audit events
Fusion-Task-Id: FN-4809
Fusion-Task-Lineage: bd632e33-b376-47de-ad99-da4610ae4690
2026-05-16 16:50:15 -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 (runfusion.ai)
087b1a7668 feat(FN-4806): complete Step 1 — split reclaim retry failure path
Fusion-Task-Id: FN-4806
Fusion-Task-Lineage: 4192226a-b24c-4681-b0fa-ce86f40fce64
2026-05-16 16:01:22 -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)
b57d3bcc0c test(FN-4787): regression tests for heartbeat identity snapshot
Fusion-Task-Id: FN-4787
Fusion-Task-Lineage: 9f174f4f-d305-4779-ba0d-562f2eab064c
2026-05-16 14:23:14 -07:00
Fusion (runfusion.ai)
7cdd27feae fix(FN-4787): disambiguate identity snapshot soul/instructions/memory states
Fusion-Task-Id: FN-4787
Fusion-Task-Lineage: 9f174f4f-d305-4779-ba0d-562f2eab064c
2026-05-16 14:23:14 -07:00
Fusion (runfusion.ai)
415cd6a111 test(FN-4783): stabilize workspace test lanes for verification
Fusion-Task-Id: FN-4783
Fusion-Task-Lineage: 7a02897b-e303-4947-86b2-3dd7a343f653
2026-05-16 13:46:43 -07:00
Fusion (runfusion.ai)
5e159368dc feat(FN-4783): complete Steps 4-5 — provider rendering and engine wiring
Fusion-Task-Id: FN-4783
Fusion-Task-Lineage: 7a02897b-e303-4947-86b2-3dd7a343f653
2026-05-16 13:46:42 -07:00
Fusion (runfusion.ai)
b48f8f1fac feat(FN-4783): complete Step 2 — add OAuth expiry monitor
Fusion-Task-Id: FN-4783
Fusion-Task-Lineage: 7a02897b-e303-4947-86b2-3dd7a343f653
2026-05-16 13:46:42 -07:00
Fusion (runfusion.ai)
f8c050741c feat(FN-4783): complete Step 1 — add oauth token expired event types
Fusion-Task-Id: FN-4783
Fusion-Task-Lineage: 7a02897b-e303-4947-86b2-3dd7a343f653
2026-05-16 13:46:42 -07:00
Fusion (runfusion.ai)
91895a8b8c feat(FN-4775): add multi-node routing test coverage for hybrid executor
Adds test coverage for multi-node routing in the hybrid executor, specifically covering routing behavior across nodes (FN-4775 Step 3).

Fusion-Task-Id: FN-4775

Fusion-Task-Lineage: d75a91c9-0c6c-421c-8bc9-11586590d6fe
2026-05-16 12:33:10 -07:00
Fusion (runfusion.ai)
a182a93e15 test(FN-4774): complete Step 4 — cover fn_task_search triage tool behavior
Fusion-Task-Id: FN-4774
Fusion-Task-Lineage: f3b81550-fb23-441e-aee7-44ffec63d03d
2026-05-16 11:55:39 -07:00
Fusion (runfusion.ai)
d43350a0d8 feat(FN-4774): complete Step 2-3 — add triage task search and duplicate-check guidance
Fusion-Task-Id: FN-4774
Fusion-Task-Lineage: f3b81550-fb23-441e-aee7-44ffec63d03d
2026-05-16 11:55:39 -07:00
Fusion (runfusion.ai)
55575dbf8c test(FN-4772): add hybrid wiring integration and lifecycle coverage
Fusion-Task-Id: FN-4772
Fusion-Task-Lineage: d296e96a-fe44-4896-928a-fa44da62b41a
2026-05-16 11:32:55 -07:00
Fusion (runfusion.ai)
d9ad416265 feat(FN-4772): complete Step 2 — add hybrid executor gate
Fusion-Task-Id: FN-4772
Fusion-Task-Lineage: d296e96a-fe44-4896-928a-fa44da62b41a
2026-05-16 11:32:55 -07:00
Fusion (runfusion.ai)
ba64de9f2a feat(FN-4772): complete Step 1 — export HybridExecutor
Fusion-Task-Id: FN-4772
Fusion-Task-Lineage: d296e96a-fe44-4896-928a-fa44da62b41a
2026-05-16 11:32:55 -07:00
Fusion (runfusion.ai)
05bd4fcdf9 test(FN-4754): add engine dashboard diff import boundary guard
Fusion-Task-Id: FN-4754
Fusion-Task-Lineage: 69980e60-c1ad-4e19-bee0-970312669d70
2026-05-16 10:50:06 -07:00
Fusion (runfusion.ai)
96be8d4cd7 feat(FN-4743): complete Step 3 — wire mail cleanup into maintenance
Fusion-Task-Id: FN-4743
Fusion-Task-Lineage: 50d1d8e4-66d5-4299-843b-28072a904277
2026-05-16 10:43:48 -07:00
Fusion (runfusion.ai)
d808d8f979 test(FN-4753): complete Step 4 — update unit tests for removeWorktree
Fusion-Task-Id: FN-4753
Fusion-Task-Lineage: 8229b56a-8997-4faf-8872-18e49b9386ff
2026-05-16 10:25:40 -07:00
Fusion (runfusion.ai)
0fc2b9e6b2 feat(FN-4753): complete Step 3 — migrate step-session worktree removal
Fusion-Task-Id: FN-4753
Fusion-Task-Lineage: 8229b56a-8997-4faf-8872-18e49b9386ff
2026-05-16 10:25:40 -07:00
Fusion (runfusion.ai)
2f8719573d feat(FN-4753): complete Step 2 — migrate executor worktree removal
Fusion-Task-Id: FN-4753
Fusion-Task-Lineage: 8229b56a-8997-4faf-8872-18e49b9386ff
2026-05-16 10:25:40 -07:00
Fusion (runfusion.ai)
33755d44fb fix(FN-4742): stabilize worktrunk removal interaction assertions
Fusion-Task-Id: FN-4742
Fusion-Task-Lineage: 59bca56e-c9d9-4066-9f5a-6d8ee252a100
2026-05-16 10:08:02 -07:00
Fusion (runfusion.ai)
378762c4ab fix(FN-4742): address review for worktrunk removal backstop
Fusion-Task-Id: FN-4742
Fusion-Task-Lineage: 59bca56e-c9d9-4066-9f5a-6d8ee252a100
2026-05-16 10:08:02 -07:00
Fusion (runfusion.ai)
251a472458 test(FN-4742): complete Step 5 — add worktrunk removal interaction backstop
Fusion-Task-Id: FN-4742
Fusion-Task-Lineage: 59bca56e-c9d9-4066-9f5a-6d8ee252a100
2026-05-16 10:08:02 -07:00
Fusion (runfusion.ai)
e2de8fed6d feat(FN-4742): complete Step 4 — migrate pool and self-healing removals
Fusion-Task-Id: FN-4742
Fusion-Task-Lineage: 59bca56e-c9d9-4066-9f5a-6d8ee252a100
2026-05-16 10:08:02 -07:00
Fusion (runfusion.ai)
5104553cfc feat(FN-4742): complete Step 3 — migrate merger removals
Fusion-Task-Id: FN-4742
Fusion-Task-Lineage: 59bca56e-c9d9-4066-9f5a-6d8ee252a100
2026-05-16 10:08:02 -07:00
Fusion (runfusion.ai)
477f79f3eb feat(FN-4737): parameterize worktree-escape test to use configured worktree
Adds parameterized test cases to the worktree-liveness test to exercise different configured `worktreesDir` paths, improving coverage of the worktree escape/isolation path.

Fusion-Task-Id: FN-4737

Fusion-Task-Lineage: 40e262ea-2507-461e-b9f5-940b3b4490f9
2026-05-16 09:56:28 -07:00
Fusion (runfusion.ai)
1c4088fe14 test(FN-4746): update monitor assertions for wake message metadata
Fusion-Task-Id: FN-4746
Fusion-Task-Lineage: 04107d0d-4319-4270-8480-7a98341a966d
2026-05-16 09:36:39 -07:00
Fusion (runfusion.ai)
de714b8880 test(FN-4746): complete Step 3 — cover wake trigger diagnostics
Fusion-Task-Id: FN-4746
Fusion-Task-Lineage: 04107d0d-4319-4270-8480-7a98341a966d
2026-05-16 09:36:39 -07:00
Fusion (runfusion.ai)
a152076f1b feat(FN-4746): complete Step 2 — add wake trigger diagnostics
Fusion-Task-Id: FN-4746
Fusion-Task-Lineage: 04107d0d-4319-4270-8480-7a98341a966d
2026-05-16 09:36:39 -07:00
Fusion (runfusion.ai)
b8792c57cb feat(FN-4746): complete Step 1 — plumb wake message metadata
Fusion-Task-Id: FN-4746
Fusion-Task-Lineage: 04107d0d-4319-4270-8480-7a98341a966d
2026-05-16 09:36:39 -07:00
Fusion (runfusion.ai)
396b06daa3 test(FN-4744): complete Step 3 — cover empty message wake reasons
Fusion-Task-Id: FN-4744
Fusion-Task-Lineage: 5ffbea10-4da3-4f85-9cc4-679545eb2383
2026-05-16 09:05:51 -07:00
Fusion (runfusion.ai)
0322d6c9d1 feat(FN-4744): complete Step 2 — annotate empty message wakes
Fusion-Task-Id: FN-4744
Fusion-Task-Lineage: 5ffbea10-4da3-4f85-9cc4-679545eb2383
2026-05-16 09:05:50 -07:00
Fusion (runfusion.ai)
3b6c6b9df5 feat(FN-4733): complete Step 3 — wire chat cleanup into maintenance
Fusion-Task-Id: FN-4733
Fusion-Task-Lineage: 38495ced-c7a0-40aa-be22-7f02fe958806
2026-05-16 08:50:47 -07:00
Fusion (runfusion.ai)
c0980944d4 fix(FN-4718): handle numeric narrowing for days retention
Fusion-Task-Id: FN-4718
Fusion-Task-Lineage: 4553c39c-c174-4993-a4ac-2c8b7d86bda2
2026-05-16 04:44:36 -07:00
Fusion (runfusion.ai)
b4254c2886 test(FN-4718): complete Step 3 — cover days-based auto-archive behavior
Fusion-Task-Id: FN-4718
Fusion-Task-Lineage: 4553c39c-c174-4993-a4ac-2c8b7d86bda2
2026-05-16 04:44:36 -07:00
Fusion (runfusion.ai)
c0eb6d3330 feat(FN-4718): complete Step 2 — wire days-based auto-archive retention
Fusion-Task-Id: FN-4718
Fusion-Task-Lineage: 4553c39c-c174-4993-a4ac-2c8b7d86bda2
2026-05-16 04:44:36 -07:00
Fusion (runfusion.ai)
b85506237e test(FN-4711): complete Step 4 — cover worktrunk install audit emission
Fusion-Task-Id: FN-4711
Fusion-Task-Lineage: 800e3606-c30f-40c5-a707-4dbbf5a9d032
2026-05-16 02:12:58 -07:00