FN-9055: guard archive disposal of live workspace worktrees

Prevent archive cleanup from removing worktrees that still belong to live tasks.

- Add shared archive liveness evaluation and transactional refusal guards.
- Require CLI and extension archive operations to refuse live tasks unless a human uses --force.
- Protect baseline archive worktree disposal and cover CLI, core, and engine paths with tests.

Files changed:
 .changeset/fn-9055-archive-live-worktree-guard.md  |  7 ++
 docs/cli-reference.md                              |  4 +-
 docs/task-management.md                            |  4 +-
 .../extension-task-archive-live-guard.test.ts      | 82 +++++++++++++++++++
 packages/cli/src/bin.ts                            |  6 +-
 packages/cli/src/commands/__tests__/task.test.ts   | 66 ++++++++++++++-
 packages/cli/src/commands/task.ts                  | 49 +++++++++---
 packages/cli/src/extension.ts                      | 25 ++++--
 .../src/__tests__/archive-live-task-guard.test.ts  | 70 ++++++++++++++++
 .../postgres/archive-live-task-fence.pg.test.ts    | 69 ++++++++++++++++
 .../src/__tests__/task-archive-liveness.test.ts    | 19 +++++
 packages/core/src/index.ts                         | 10 +++
 packages/core/src/store.ts                         |  4 +-
 .../core/src/task-store/archive-lifecycle-2.ts     | 27 +++++--
 packages/core/src/task-store/archive-lifecycle.ts  | 20 ++---
 .../src/task-store/async/async-archive-lineage.ts  | 17 +++-
 packages/core/src/tasks/task-archive-liveness.ts   | 56 +++++++++++++
 ...chive-baseline-disposer-live-task-guard.test.ts | 93 ++++++++++++++++++++++
 .../healing/archive-worktree-disposer-install.ts   | 15 +++-
 19 files changed, 592 insertions(+), 51 deletions(-)

Fusion-Task-Id: FN-9055

Fusion-Task-Lineage: 08644626-cc61-4854-abb9-5b415ddc9491

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
This commit is contained in:
gsxdsm
2026-08-15 00:35:12 -07:00
parent 6adcab3b0e
commit c7779e44ac
19 changed files with 592 additions and 51 deletions

View File

@@ -814,12 +814,14 @@ fn task merge FN-001
fn task duplicate FN-001
fn task refine FN-001 --feedback "Add rollback handling"
fn task archive FN-001
fn task archive FN-001 --force
fn task unarchive FN-001
fn task delete FN-001 --force
```
Notes:
- `fn task archive` accepts any live-board task (`triage`, `todo`, `in-progress`, `in-review`, or `done`) and preserves the original column for restore.
- `fn task archive` accepts live-board tasks and preserves the original column for restore. It refuses tasks in a WIP lane or active merge pipeline to protect another process's worktrees; a human operator may use `--force` to override this destructive guard.
- The agent-facing `fn_task_archive` tool returns a structured error for the same live-task refusal and deliberately has no force parameter.
- `fn task unarchive` restores to the saved pre-archive column when available, with legacy archives falling back to `done`.
### Branch conflict handling