Skip to content

feat(tasks): background TaskRunner executor + expanded task states - #182

Merged
Patel230 merged 1 commit into
mainfrom
feat/task-executor
Aug 6, 2026
Merged

feat(tasks): background TaskRunner executor + expanded task states#182
Patel230 merged 1 commit into
mainfrom
feat/task-executor

Conversation

@Patel230

@Patel230 Patel230 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Closes the last gap from the KiroCrew line-by-line comparison: hawk's TaskStore was store-only — it had persistence, retry budgets (MarkFailed), replan (Requeue), and checkpoint APIs, but nothing executed tasks. KiroCrew's TaskRunner/TaskExecutor actually run tasks in a loop with retry, recovery, and a watchdog.

What this adds

1. TaskRunner background executor (internal/tool/task_executor.go)

  • Picks up ready work (pending tasks with no open blockers) via GetReadyWork().
  • Runs each task through a host Execute callback (with optional per-task timeout).
  • On failure applies the store's retry budget (MarkFailed) with exponential backoff (retryBackoffTick respected via dueTasks).
  • Tasks that exhaust their budget are replanned via OnReplan + Requeue (fresh budget), bounded by MaxReplans per task.
  • Watchdog: MaxTotalTasks caps distinct tasks reaching a terminal state (default 50) so a runaway graph can't loop forever.
  • Cancellation: Stop()/ctx-done cancels in-flight executions and parks tasks as cancelled (not consuming retry budget).
  • Quiesces correctly even when a dependent is permanently blocked behind a failed/skipped/cancelled blocker (no infinite spin).
  • Run (blocking) / Start / Stop / Wait / Status.

2. Expanded task states (KiroCrew parity)

  • New statuses: reviewing, skipped, cancelled.
  • TaskStore.Skip / TaskStore.Cancel (reasons recorded in metadata).
  • Schedule() validation extended to accept the new states.
  • TaskUpdateTool accepts the new states and resets the retry budget on any explicit exit from failed (not just pending).

3. Live wiring

  • ToolContext.TaskExecutor arms the new TaskRunTool: the agent can invoke TaskRun to drive all ready tasks through the executor and get a run summary.
  • The session arms it with an agent-spawn based executor: each stored task's subject/description/checkpoint become a general sub-agent's prompt.

Verification

  • go build ./..., go vet, golangci-lint, boundary scripts — clean.
  • go test ./internal/tool/... ./internal/engine/ ./cmd/ — green.
  • New tests cover: completion, dependency ordering, retry-within-budget, park-after-budget, replan, watchdog, stop-cancellation, quiescence-behind-failed-blocker, progress events, Skip/Cancel, TaskRunTool (executes / requires-executor / cancels-on-ctx-timeout).

Stacked on #181 (base feat/security-hygiene-cli).

@Patel230
Patel230 force-pushed the feat/security-hygiene-cli branch from 26c3782 to c21fe18 Compare August 6, 2026 03:01
Base automatically changed from feat/security-hygiene-cli to main August 6, 2026 03:16
Closes the last KiroCrew gap: the TaskStore was store-only — nothing
consumed its retry/replan/checkpoint machinery. Add the execution half:

- TaskRunner (internal/tool/task_executor.go): a background executor loop
  that picks up ready work (pending, no open blockers), runs each task
  through a host Execute callback, applies the store's retry budget with
  exponential backoff via MarkFailed, replans tasks that exhaust their
  budget (OnReplan + Requeue, bounded by MaxReplans), enforces a
  MaxTotalTasks watchdog, and cancels in-flight tasks on stop.
- New task states (KiroCrew parity): reviewing, skipped, cancelled, with
  TaskStore.Skip/Cancel and Schedule() validation extended.
- TaskRunTool + ToolContext.TaskExecutor: the agent (or host) can invoke
  TaskRun to drive ready tasks; the session arms it with an agent-spawn
  based executor (subject/description/checkpoint become the sub-agent
  prompt). TaskUpdateTool accepts the new states and resets the retry
  budget on any explicit exit from failed.
@Patel230
Patel230 force-pushed the feat/task-executor branch from cd6ec89 to 791a5a5 Compare August 6, 2026 03:19
@Patel230
Patel230 merged commit 6603f20 into main Aug 6, 2026
23 checks passed
@Patel230
Patel230 deleted the feat/task-executor branch August 6, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant