Decouple Task activity from source discovery#834
Open
kelos-bot[bot] wants to merge 2 commits intomainfrom
Open
Decouple Task activity from source discovery#834kelos-bot[bot] wants to merge 2 commits intomainfrom
kelos-bot[bot] wants to merge 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
1 issue found across 3 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:226">
P1: This adds a second concurrent reporting loop for the same tasks, which can race with the existing poll-cycle reporting and emit duplicate GitHub comment API calls.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Remove the Task watch from the main spawner reconciler that triggered full source discovery (GitHub/Jira API calls) on every Task phase change, deletion timestamp change, or delete event. Add a separate lightweight task-activity controller that watches Task events and only recomputes status.activeTasks and runs per-Task GitHub reporting when enabled, without calling source discovery. The next GitHub/Jira item is only considered on the next scheduled poll. This eliminates 100% of GitHub/Jira requests caused by Task-driven rediscovery, which could amount to thousands of unnecessary API calls per hour in busy environments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…oller The poll cycle's runReportingCycle and handleTaskActivity both called ReportTaskStatus on the same tasks concurrently, which could produce duplicate GitHub comment API calls. Move reporting exclusively into the task-activity controller path, which is triggered by Task phase changes, and remove the now-dead runReportingCycle function. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3ed3a9a to
89d4ade
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.
What type of PR is this?
/kind feature
What this PR does / why we need it:
Phase 1 of #794: Decouples Task activity (phase changes, deletion) from source discovery in the spawner reconciler.
Before: Every Task phase change, deletion timestamp change, or delete event triggered a full reconcile cycle that called
source.Discover()— making GitHub/Jira API calls even though no new work items could appear from Task activity alone.After: Task events are handled by a separate lightweight
task-activitycontroller that only:status.activeTasksReporting is handled exclusively by the task-activity controller to avoid racing with the poll-cycle goroutine. The next scheduled poll picks up freed concurrency slots. This eliminates 100% of external API requests caused by Task-driven rediscovery.
Fixes #794
Special notes for your reviewer:
taskPredicateandrequestsForTaskmethods moved fromspawnerReconcilertotaskActivityReconcilerwith identical logicstatus.totalDiscovered,status.totalTasksCreated, andstatus.lastDiscoveryTimeremain poll-cycle-only fields as specified in the issuerunOnce) and moved exclusively intohandleTaskActivityto eliminate the race condition where both paths could callReportTaskStatusconcurrently on the same tasksDoes this PR introduce a user-facing change?