Skip to content

Epic: Composite triggers — AND/OR combinators for multi-condition workflows #805

@geoffjay

Description

@geoffjay

Summary

Implement a composite trigger system that combines multiple trigger strategies with boolean logic (AND/OR). This enables powerful multi-condition workflows — e.g., "fire when a PR has label ready AND review is approved" or "fire on cron schedule OR manual trigger."

Goals

  • Design a combinator architecture wrapping existing TriggerStrategy implementations
  • Implement CompositeStrategy supporting AND (all conditions) and OR (any condition) semantics
  • Add Composite variant to TriggerConfig with nested trigger configurations
  • Handle task merging/correlation for AND conditions across sub-strategies
  • Adapt the runner loop to evaluate composite conditions correctly
  • Wire into the strategy factory, API validation, and CLI

Design Notes

  • OR combinator: Fires when ANY sub-strategy produces tasks. Straightforward — tokio::select! across sub-strategies.
  • AND combinator: Fires when ALL sub-strategies have produced at least one task within a configurable time window. Requires a correlation window and state tracking.
  • AND semantics are significantly more complex — consider a phased approach: OR first, AND later
  • Nested composites should be supported (AND of ORs, etc.) but may be deferred
  • Task merging: when AND fires, the produced task should include context from all sub-conditions
  • This likely requires changes to how WorkflowRunner interacts with strategies, particularly for AND conditions that need to accumulate state

Architectural Considerations

  • The current TriggerStrategy::next_tasks() interface returns when tasks are ready — AND combinators need to buffer partial results
  • Consider a CompositeStrategy that internally manages sub-strategy tasks and only yields when the composite condition is met
  • Template variables should provide access to all sub-trigger contexts (e.g., {{triggers[0].source_id}})
  • Config validation must detect circular references in nested composites

Acceptance Criteria

  • CompositeStrategy implements TriggerStrategy trait
  • OR combinator: fires when any sub-strategy produces tasks
  • AND combinator: fires when all sub-strategies have produced tasks within a time window
  • Composite variant added to TriggerConfig with nested configs
  • Configurable correlation window for AND conditions
  • Strategy factory recursively creates sub-strategies
  • API and CLI support for creating composite workflows
  • Config validation prevents circular references
  • Unit and integration tests for all combinator types
  • Documentation with usage examples

Blocked By

Stack Base

Stack on: feature/autonomous-pipeline — this epic depends on other Phase 6 epics being available for composition but can begin implementation in parallel since it wraps the existing strategy trait.

Key Files

  • crates/orchestrator/src/scheduler/strategy.rs — add CompositeStrategy
  • crates/orchestrator/src/scheduler/types.rs — add Composite variant with nested TriggerConfig
  • crates/orchestrator/src/scheduler/runner.rs — recursive strategy creation
  • crates/orchestrator/src/scheduler/api.rs — validation for nested configs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions