Conversation
Add a top-level `triggers` block to workflow config for cron-based scheduled workflows using standard 5-field cron syntax. Each firing creates a synthetic work item that flows through the normal workflow state machine. - Add TriggerConfig type and validation for cron expressions and state names - Implement startScheduler/stopScheduler using robfig/cron/v3 - Add injectScheduledIssue for creating synthetic work items with dedup based on active/queued status - Skip issue-provider calls (fetchIssueComments, isIssueClosed) for synthetic items since they have no real issue - Preserve scheduled trigger's CurrentStep in startQueuedItems - Automatic skip in --once mode and when at concurrency limit Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds cron-based scheduled triggers to the workflow engine by introducing a top-level triggers config block and wiring a UTC cron scheduler into the daemon to enqueue synthetic work items that run through the normal state machine.
Changes:
- Add
triggersto workflow config + validation (5-field cron parsing shared with runtime scheduler). - Start/stop a
robfig/cron/v3scheduler in the daemon (skipped in--oncemode) and inject synthetic scheduled work items. - Skip issue-provider calls for synthetic items and preserve
CurrentStepwhen starting queued items.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/workflow/config.go | Adds TriggerConfig and triggers to workflow YAML schema. |
| internal/workflow/validate.go | Validates trigger schedule syntax + referenced state; exports shared cron parser spec. |
| internal/workflow/validate_test.go | Adds unit + integration tests for trigger validation. |
| internal/daemon/daemon.go | Introduces daemon scheduler lifecycle and registers cron entries per repo workflow config. |
| internal/daemon/polling.go | Injects synthetic scheduled work items, preserves CurrentStep on queued start, and skips “closed issue” checks for synthetic items. |
| internal/daemon/coding.go | Skips fetching issue comments for synthetic scheduled work items. |
| internal/daemon/actions_test.go | Adds tests for scheduled injection/dedup/max-concurrent and synthetic skip behaviors. |
| docs/workflow.html | Documents the new triggers block semantics and examples. |
| go.mod / go.sum | Adds github.com/robfig/cron/v3. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+1445
to
+1446
| require an existing session or branch (like | ||
| <code>ai.summarize</code>) will fail on synthetic work items. |
- stopScheduler now waits (up to 5s) for in-flight jobs via the context returned by cron.Stop(), and clears the scheduler field - Scope scheduled issue IDs by repoPath to avoid collisions when multiple repos share the same state name - Use UnixNano for higher-resolution uniqueness in issue IDs - Scope hasActiveScheduledItem dedup by repoPath so triggers in different repos don't block each other - Move robfig/cron/v3 from indirect to direct require in go.mod Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
triggersblock to workflow config for cron-based scheduled workflows (standard 5-field cron syntax)startScheduler/stopSchedulerusingrobfig/cron/v3with automatic skip in--oncemodeNote: The
ai.summarizeaction has been extracted into #432.Test plan
TestInjectScheduledIssue_EnqueuesWorkItem— verifies synthetic work item creationTestInjectScheduledIssue_RespectsMaxConcurrent— verifies concurrency limit enforcementTestInjectScheduledIssue_SkipsWhilePreviousActive— verifies dedup logicTestInjectScheduledIssue_AllowedAfterPreviousCompletes— verifies re-enqueue after terminalTestInjectScheduledIssue_SkippedWhenConfigSavePaused— verifies safety checkTestFetchIssueComments_SkipsSyntheticItems— verifies synthetic skipTestIsIssueClosed_ReturnsFalseForSyntheticItems— verifies synthetic skipTestStartQueuedItems_PreservesScheduledCurrentStep— verifies trigger state is preservedTestStartQueuedItems_DefaultsToStartState— verifies normal items still use start stateTestStartScheduler_SkippedInOnceMode— verifies no-op in single-shot modeTestStartScheduler_RegistersTriggers— verifies cron entries are registeredTestValidateTriggers— table-driven validation of trigger configsTestValidate_WithValidTrigger/TestValidate_WithInvalidTrigger— end-to-end validationgo test -p=1 -count=1 ./...passesFixes #419
🤖 Generated with Claude Code