Skip to content

Support immediate re-triggering of completed tasks via TriggerComment#452

Open
axon-agent[bot] wants to merge 2 commits intomainfrom
axon-task-432
Open

Support immediate re-triggering of completed tasks via TriggerComment#452
axon-agent[bot] wants to merge 2 commits intomainfrom
axon-task-432

Conversation

@axon-agent
Copy link

@axon-agent axon-agent bot commented Feb 26, 2026

Summary

  • When TriggerComment is configured and a completed (Succeeded/Failed) task exists, the spawner now compares the latest trigger comment's timestamp against the task's CompletionTime. If the trigger comment is newer, the completed task is deleted and a new one is created.
  • This allows users to re-trigger work immediately by posting a new trigger comment, without waiting for TTL cleanup.
  • Label-based flows and Cron sources are unaffected — retrigger only activates when TriggerComment is configured and a matching comment is found after task completion.

Key changes

  1. internal/source/source.go: Added TriggerTime field to WorkItem to carry the latest trigger comment timestamp from source to spawner.
  2. internal/source/github.go: Added CreatedAt to githubComment, refactored fetchComments to return structured comments (preserving timestamps), added latestTriggerTime helper and concatCommentBodies utility.
  3. cmd/axon-spawner/main.go: Updated dedup logic — when a completed task exists and the trigger comment is newer than CompletionTime, delete the old task and allow recreation. Existing concurrency and budget limits are still respected.

Test plan

  • TestRunCycleWithSource_RetriggerCompletedTask — verifies completed task is deleted and new one created when trigger is newer
  • TestRunCycleWithSource_RetriggerSkippedWhenTriggerBeforeCompletion — verifies no retrigger when trigger is older than completion
  • TestRunCycleWithSource_RetriggerFailedTask — verifies retrigger works for failed tasks too
  • TestRunCycleWithSource_RetriggerSkippedWithoutTriggerComment — verifies no retrigger when TriggerComment not configured
  • TestRunCycleWithSource_RetriggerSkippedForRunningTask — verifies running tasks are never retriggered
  • TestRunCycleWithSource_RetriggerRespectsMaxConcurrency — verifies maxConcurrency is still enforced after retrigger
  • TestLatestTriggerTime — unit tests for the timestamp extraction helper
  • TestDiscoverSetsTriggerTime — integration test verifying TriggerTime is set on WorkItem
  • TestDiscoverTriggerTimeZeroWithoutTriggerComment — verifies TriggerTime is zero when not configured
  • All existing tests pass (make test, make verify)

Fixes #432

🤖 Generated with Claude Code


Summary by cubic

Enable immediate re-triggering of completed tasks via TriggerComment. Satisfies axon-task-432 by recreating a task when a newer trigger comment is posted.

  • New Features

    • Spawner compares WorkItem.TriggerTime to Task.CompletionTime; if the trigger is newer and the task is Succeeded/Failed, delete and recreate. Respects maxConcurrency and maxTotalTasks; running tasks are never retriggered. If creation is blocked, the item is picked up as new on the next cycle.
    • GitHub source captures comment timestamps (CreatedAt), computes the latest matching trigger, and sets WorkItem.TriggerTime.
    • Label-only and Cron-based flows are unchanged; retriggering activates only when TriggerComment is configured.
  • Refactors

    • fetchComments now returns structured comments with timestamps; added latestTriggerTime helper and concatCommentBodies to keep existing comment filtering behavior.

Written for commit b6d383d. Summary will update on new commits.

When TriggerComment is configured and a completed task exists for a
discovered work item, the spawner now compares the latest trigger
comment timestamp against the task's CompletionTime. If the trigger
comment is newer, the completed task is deleted and a new one is
created, allowing users to re-trigger work without waiting for TTL
cleanup.

Changes:
- Add TriggerTime field to WorkItem to carry trigger comment timestamp
- Add CreatedAt to githubComment struct to parse GitHub API timestamps
- Refactor fetchComments to return structured comments (with timestamps)
- Add latestTriggerTime helper to find the most recent trigger comment
- Update spawner dedup logic to delete and recreate completed tasks
  when a newer trigger comment is found
- Add comprehensive tests for retrigger behavior

Fixes #432

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

When retrigger deletes a completed task but creation is later blocked
by maxConcurrency or maxTotalTasks, the item will be picked up as new
on the next poll cycle. Document this behavior in a code comment and
clean up the verbose test comment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support immediate re-triggering of completed tasks before TTL cleanup

1 participant