FN-7731: add CLI-level lock retry for task show/move commands

Add bounded exponential-backoff retry above the DB layer so `fn task show`/`fn task move` ride out transient SQLite lock contention instead of failing outright or hanging.

- Add packages/cli/src/lock-retry.ts: retries a thunk on SQLite lock errors (via @fusion/core's isSqliteLockError) with exponential backoff capped by a wall-clock deadline (default 15s, override via FUSION_CLI_LOCK_RETRY_MS); non-lock errors propagate immediately; raises LockRetryExhaustedError on deadline exhaustion.
- Wire lock-retry into packages/cli/src/commands/task.ts for the show/move task-store operations, and close the resolved TaskStore for deterministic exit.
- Export isSqliteLockError from packages/core/src/index.ts for CLI reuse.
- Add packages/cli/src/commands/__tests__/task-lock-retry.test.ts covering retry/backoff/deadline/error-passthrough behavior; extend task.test.ts.
- Document the new behavior/env var in docs/cli-reference.md.
- Add changeset (@runfusion/fusion: patch).

Files changed:
 .changeset/fn-7731-task-cmd-lock-retry.md          |   7 +
 docs/cli-reference.md                              |   9 +
 .../src/commands/__tests__/task-lock-retry.test.ts | 430 +++++++++++++++++++++
 packages/cli/src/commands/__tests__/task.test.ts   |  11 +
 packages/cli/src/commands/task.ts                  | 117 +++++-
 packages/cli/src/lock-retry.ts                     | 117 ++++++
 packages/core/src/index.ts                         |   5 +
 7 files changed, 688 insertions(+), 8 deletions(-)

Fusion-Task-Id: FN-7731

Fusion-Task-Lineage: 85543164-10d6-4da9-8c3c-a84cd86827aa

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
This commit is contained in:
gsxdsm
2026-07-09 10:06:17 -07:00
parent badb86a965
commit 7420abe80e
7 changed files with 688 additions and 8 deletions

View File

@@ -577,6 +577,15 @@ fn task logs FN-001 --follow --limit 50 --type tool
- unavailable-node policy value
- source provenance line (`Source: <origin>`), including parent task / GitHub issue URL context when present
`fn task show`/`fn task move` retry-on-lock (FN-7731): if the board database
(`.fusion/fusion.db`) is momentarily locked by the engine or another agent,
both commands retry with bounded exponential backoff instead of failing
outright. If the lock hasn't cleared once the retry deadline (default 15s)
is reached, the command fails fast with a clear, actionable, non-zero-exit
error naming the task and operation rather than hanging. Override the
deadline with `FUSION_CLI_LOCK_RETRY_MS` (milliseconds). The resolved
`TaskStore` is always closed on exit so the CLI process exits promptly.
### Execution and status
```bash