Support immediate re-triggering of completed tasks via TriggerComment#452
Merged
Support immediate re-triggering of completed tasks via TriggerComment#452
Conversation
b6d383d to
357de85
Compare
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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>
3f10c31 to
fb0fae0
Compare
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>
fb0fae0 to
6052977
Compare
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
TriggerCommentis configured and a completed (Succeeded/Failed) task exists, the spawner now compares the latest trigger comment's timestamp against the task'sCompletionTime. If the trigger comment is newer, the completed task is deleted and a new one is created.TriggerCommentis configured and a matching comment is found after task completion.Key changes
internal/source/source.go: AddedTriggerTimefield toWorkItemto carry the latest trigger comment timestamp from source to spawner.internal/source/github.go: AddedCreatedAttogithubComment, refactoredfetchCommentsto return structured comments (preserving timestamps), addedlatestTriggerTimehelper andconcatCommentBodiesutility.cmd/axon-spawner/main.go: Updated dedup logic — when a completed task exists and the trigger comment is newer thanCompletionTime, 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 newerTestRunCycleWithSource_RetriggerSkippedWhenTriggerBeforeCompletion— verifies no retrigger when trigger is older than completionTestRunCycleWithSource_RetriggerFailedTask— verifies retrigger works for failed tasks tooTestRunCycleWithSource_RetriggerSkippedWithoutTriggerComment— verifies no retrigger when TriggerComment not configuredTestRunCycleWithSource_RetriggerSkippedForRunningTask— verifies running tasks are never retriggeredTestRunCycleWithSource_RetriggerRespectsMaxConcurrency— verifies maxConcurrency is still enforced after retriggerTestLatestTriggerTime— unit tests for the timestamp extraction helperTestDiscoverSetsTriggerTime— integration test verifying TriggerTime is set on WorkItemTestDiscoverTriggerTimeZeroWithoutTriggerComment— verifies TriggerTime is zero when not configuredmake 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
Refactors
Written for commit 6052977. Summary will update on new commits.