Skip to content

Conversation

@jumski
Copy link
Contributor

@jumski jumski commented Jan 5, 2026

Add conditional execution infrastructure to pgflow

This PR adds support for conditional step execution in pgflow with a new "skip" infrastructure. The implementation includes:

  • New step configuration options:

    • condition_pattern: JSONB pattern for @> containment check
    • when_unmet: What to do when condition is not met (options: 'fail', 'skip', 'skip-cascade')
    • when_failed: What to do when handler fails after retries (options: 'fail', 'skip', 'skip-cascade')
  • New step status and tracking:

    • Added 'skipped' status to step states
    • New columns: skip_reason, skipped_at to track why and when a step was skipped
    • Skip reasons include: 'condition_unmet', 'handler_failed', 'dependency_skipped'
  • Cascade functionality:

    • New cascade_skip_steps function to skip a step and all its downstream dependents
    • Respects the dependency graph when skipping steps
    • Updates run counters and broadcasts step:skipped events
  • Comprehensive test coverage:

    • Tests for parameter validation
    • Tests for cascading skips through multiple dependency levels
    • Tests for event payload format and ordering

This feature enables more flexible workflows where steps can be conditionally executed based on runtime data.

@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2026

🦋 Changeset detected

Latest commit: 736e5b4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@pgflow/core Patch
@pgflow/dsl Patch
pgflow Patch
@pgflow/client Patch
@pgflow/edge-worker Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor Author

jumski commented Jan 5, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@nx-cloud
Copy link

nx-cloud bot commented Jan 5, 2026

View your CI Pipeline Execution ↗ for commit 736e5b4

Command Status Duration Result
nx run edge-worker:test:integration ✅ Succeeded 5m 19s View ↗
nx run client:e2e ✅ Succeeded 2m 51s View ↗
nx affected -t verify-exports --base=origin/mai... ✅ Succeeded 3s View ↗
nx affected -t build --configuration=production... ✅ Succeeded 4s View ↗
nx affected -t lint typecheck test --parallel -... ✅ Succeeded 1m 51s View ↗
nx run core:pgtap ✅ Succeeded 1m 48s View ↗
nx run edge-worker:e2e ✅ Succeeded 40s View ↗
nx run cli:e2e ✅ Succeeded 6s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-23 11:06:35 UTC

- Add skip_type column and cascade_skip_steps() function
- Add condition evaluation in start_ready_steps
- Add whenFailed option for error handling after retries
- Add ifNot negative condition pattern
- Add ContainmentPattern<T> and StepMeta types for type-safe DSL
- Add condition fields to FlowShape for auto-compilation
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