Skip to content

Add lifecycle hooks for tasks and the overall workflow graph#116

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/discussion-useful-hooks
Draft

Add lifecycle hooks for tasks and the overall workflow graph#116
Copilot wants to merge 3 commits intomainfrom
copilot/discussion-useful-hooks

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

Implements onSuccess and onFailure lifecycle hooks at two scopes: individual tasks and the overall workflow graph.

New types (internal/types/lifecycle.go)

  • LifecycleHook — specifies a hook command via command (array) or sh (inline script), matching the existing task command pattern
  • Lifecycle — groups onSuccess and onFailure hooks; nil-safe accessors on both Lifecycle and Task

Per-task hooks (Task.Lifecycle)

Run after a task transitions to succeeded or failed, before any restart logic:

tasks:
  build:
    command: [go, build, .]
    lifecycle:
      onSuccess:
        sh: echo build succeeded | notify-slack
      onFailure:
        command: [./scripts/alert.sh, build failed]

Graph-level hooks (Spec.Lifecycle)

Run when the entire workflow exits. onSuccess fires only on clean internal completion (not on Ctrl+C); onFailure fires when any task fails without restart. Graph hooks use context.Background() since the main context is already cancelled at that point.

lifecycle:
  onSuccess:
    sh: echo all tasks completed
  onFailure:
    sh: ./scripts/send-alert.sh
tasks:
  ...

All hooks are best-effort — failures are logged but do not affect task or graph outcome. JSON schema updated to reflect new types.


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI and others added 2 commits March 20, 2026 21:30
Copilot AI changed the title [WIP] Discuss potential hooks for project Add lifecycle hooks for tasks and the overall workflow graph Mar 20, 2026
Copilot AI requested a review from alexec March 20, 2026 21:36
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.

2 participants