Skip to content

Decouple Task activity from source discovery#834

Open
kelos-bot[bot] wants to merge 2 commits intomainfrom
kelos-task-794
Open

Decouple Task activity from source discovery#834
kelos-bot[bot] wants to merge 2 commits intomainfrom
kelos-task-794

Conversation

@kelos-bot
Copy link
Copy Markdown

@kelos-bot kelos-bot bot commented Mar 28, 2026

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-activity controller that only:

  1. Recomputes and updates status.activeTasks
  2. Runs per-Task GitHub reporting when enabled
  3. Never calls source discovery

Reporting 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:

  • The taskPredicate and requestsForTask methods moved from spawnerReconciler to taskActivityReconciler with identical logic
  • status.totalDiscovered, status.totalTasksCreated, and status.lastDiscoveryTime remain poll-cycle-only fields as specified in the issue
  • Reporting was removed from the poll cycle (runOnce) and moved exclusively into handleTaskActivity to eliminate the race condition where both paths could call ReportTaskStatus concurrently on the same tasks
  • Phase 2 (lazy-fetch GitHub details) is planned as a follow-up

Does this PR introduce a user-facing change?

Reduce unnecessary GitHub/Jira API traffic by decoupling Task activity from source discovery in the spawner

@kelos-bot kelos-bot bot added the kind/feature Categorizes issue or PR as related to a new feature label Mar 28, 2026
@github-actions github-actions bot removed the needs-kind Indicates an issue or PR lacks a kind/* label label Mar 28, 2026
Copy link
Copy Markdown

@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.

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.

gjkim42 and others added 2 commits March 28, 2026 17:23
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>
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.

Reduce TaskSpawner GitHub API traffic by decoupling polling from Task events and lazily fetching details

1 participant