Skip to content

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

Merged
gjkim42 merged 1 commit intomainfrom
axon-task-432
Feb 27, 2026
Merged

Support immediate re-triggering of completed tasks via TriggerComment#452
gjkim42 merged 1 commit 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. Meets axon-task-432 by deleting the completed task and recreating it when a newer trigger comment is posted.

  • New Features

    • Spawner compares WorkItem.TriggerTime to Task.CompletionTime; if newer and the task is Succeeded/Failed, delete and recreate. Only runs when TriggerComment is configured, respects maxConcurrency/maxTotalTasks, and never retriggers running tasks. If creation is blocked, the item is picked up next cycle.
  • Refactors

    • GitHub source now returns structured comments with CreatedAt, adds latestTriggerTime, and uses concatCommentBodies for filters. Added kelos-spawner and source tests (including byte-limit resilience) and updated paths to kelos-spawner.

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

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

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.

2 issues found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="cmd/kelos-spawner/main.go">

<violation number="1" location="cmd/kelos-spawner/main.go:209">
P2: Missing `IsNotFound` handling on Delete: if the task was already cleaned up (e.g., by TTL) between the List and Delete calls, this logs an error and skips recreation for the entire cycle. Handle `IsNotFound` as a success case so the item is still added to `newItems`.</violation>
</file>

<file name="internal/source/github.go">

<violation number="1" location="internal/source/github.go:125">
P2: `latestTriggerTime` operates on comments that were byte-truncated oldest-first by `fetchComments`, so the newest trigger comment — the one that matters for retriggering — may be silently dropped on issues with many or large comments. Consider computing the trigger time from the full comment list before truncation, or fetching comments with `direction=desc` so the newest ones are preserved.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

// Record the timestamp of the most recent trigger comment so the
// spawner can retrigger completed tasks when a new trigger arrives.
if s.TriggerComment != "" {
item.TriggerTime = latestTriggerTime(rawComments, s.TriggerComment)
Copy link

@cubic-dev-ai cubic-dev-ai bot Feb 27, 2026

Choose a reason for hiding this comment

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

P2: latestTriggerTime operates on comments that were byte-truncated oldest-first by fetchComments, so the newest trigger comment — the one that matters for retriggering — may be silently dropped on issues with many or large comments. Consider computing the trigger time from the full comment list before truncation, or fetching comments with direction=desc so the newest ones are preserved.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/source/github.go, line 125:

<comment>`latestTriggerTime` operates on comments that were byte-truncated oldest-first by `fetchComments`, so the newest trigger comment — the one that matters for retriggering — may be silently dropped on issues with many or large comments. Consider computing the trigger time from the full comment list before truncation, or fetching comments with `direction=desc` so the newest ones are preserved.</comment>

<file context>
@@ -113,12 +117,39 @@ func (s *GitHubSource) Discover(ctx context.Context) ([]WorkItem, error) {
+		// Record the timestamp of the most recent trigger comment so the
+		// spawner can retrigger completed tasks when a new trigger arrives.
+		if s.TriggerComment != "" {
+			item.TriggerTime = latestTriggerTime(rawComments, s.TriggerComment)
+		}
+
</file context>
Fix with Cubic

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>
@gjkim42 gjkim42 added priority/important-soon triage-accepted kind/feature Categorizes issue or PR as related to a new feature actor/kelos labels Feb 27, 2026
@github-actions github-actions bot removed needs-triage needs-kind Indicates an issue or PR lacks a kind/* label needs-priority needs-actor labels Feb 27, 2026
@gjkim42 gjkim42 merged commit cfa020f into main Feb 27, 2026
16 of 18 checks passed
@gjkim42 gjkim42 deleted the axon-task-432 branch February 27, 2026 16:38
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