Flows YAML — internal triggers (task.*, flow.*, pr.merged) #1065

Closed
opened 2026-05-10 15:38:50 +00:00 by claude-desktop · 0 comments
Collaborator

User story

As a flow author, I want to react to task.completed, task.failed, task.timed_out, pr.merged, flow.completed, and flow.failed, so that post-dispatch behaviour (dependency cascade, follow-up reviews, retries) lives in flows instead of hardcoded callbacks.

Resolves audit finding §1.1.6 (no async hooks; handleIssueClosed hardcoded; flow runner not the sole dispatcher).

Acceptance criteria

Trigger emission

  • Worker (apps/server/src/background/worker.ts) fires task.completed / task.failed / task.timed_out after each task lifecycle terminal state.
  • Executor fires flow.completed / flow.failed after each run terminal state.
  • Forge handler fires pr.merged after Forgejo confirms merge (post-merge verification, distinct from pull_request.closed).
  • Each emission carries a typed TriggerEvent shape matching the spec (parent ids, repo, issue/pr context).

Trigger consumption

  • YAML on: { task: [completed], pr: [merged], flow: [failed] } matches the new kinds.
  • Loader + executor accept these triggers same as forge events.

Fan-out limit

  • Internal triggers carry a chain-depth counter incremented per re-entry.
  • Depth > 4 → log + drop, do not dispatch (prevents infinite loops, Q5 from spec).

Migration of legacy callbacks

  • handleIssueClosed (currently invoked by injection bundle) is replaced by an issue.closed flow that calls a propagate_dependencies op.
  • TODO at apps/server/src/domain/flows/flow-dispatch.ts:184 is removed.

Tests

  • Worker emits expected triggers on completion / failure / timeout.
  • Re-entry depth cap fires drop + log on the 5th hop.
  • An on: task.completed flow runs after a task finishes.

Out of scope

  • The propagate_dependencies op itself (covered by #flows-7).
  • Cross-repo trigger fan-out.

References

  • Spec: docs/specs/flows-yaml.md §5.2, §12 Q5.
## User story As a flow author, I want to react to `task.completed`, `task.failed`, `task.timed_out`, `pr.merged`, `flow.completed`, and `flow.failed`, so that post-dispatch behaviour (dependency cascade, follow-up reviews, retries) lives in flows instead of hardcoded callbacks. Resolves audit finding §1.1.6 (no async hooks; `handleIssueClosed` hardcoded; flow runner not the sole dispatcher). ## Acceptance criteria ### Trigger emission - [ ] Worker (`apps/server/src/background/worker.ts`) fires `task.completed` / `task.failed` / `task.timed_out` after each task lifecycle terminal state. - [ ] Executor fires `flow.completed` / `flow.failed` after each run terminal state. - [ ] Forge handler fires `pr.merged` after Forgejo confirms merge (post-merge verification, distinct from `pull_request.closed`). - [ ] Each emission carries a typed `TriggerEvent` shape matching the spec (parent ids, repo, issue/pr context). ### Trigger consumption - [ ] YAML `on: { task: [completed], pr: [merged], flow: [failed] }` matches the new kinds. - [ ] Loader + executor accept these triggers same as forge events. ### Fan-out limit - [ ] Internal triggers carry a chain-depth counter incremented per re-entry. - [ ] Depth > 4 → log + drop, do not dispatch (prevents infinite loops, Q5 from spec). ### Migration of legacy callbacks - [ ] `handleIssueClosed` (currently invoked by injection bundle) is replaced by an `issue.closed` flow that calls a `propagate_dependencies` op. - [ ] TODO at `apps/server/src/domain/flows/flow-dispatch.ts:184` is removed. ### Tests - [ ] Worker emits expected triggers on completion / failure / timeout. - [ ] Re-entry depth cap fires drop + log on the 5th hop. - [ ] An `on: task.completed` flow runs after a task finishes. ## Out of scope - The `propagate_dependencies` op itself (covered by #flows-7). - Cross-repo trigger fan-out. ## References - Spec: `docs/specs/flows-yaml.md` §5.2, §12 Q5.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks#1065
No description provided.