Add taskTemplates to TaskSpawner for per-item pipeline spawning#721
Open
kelos-bot[bot] wants to merge 6 commits intomainfrom
Open
Add taskTemplates to TaskSpawner for per-item pipeline spawning#721kelos-bot[bot] wants to merge 6 commits intomainfrom
kelos-bot[bot] wants to merge 6 commits intomainfrom
Conversation
There was a problem hiding this comment.
6 issues found across 16 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_test.go">
<violation number="1" location="cmd/kelos-spawner/main_test.go:2456">
P2: The partial-recovery test should assert the exact expected task names, not only the total count, to reliably validate pipeline recovery semantics.</violation>
</file>
<file name="api/v1alpha1/taskspawner_types.go">
<violation number="1" location="api/v1alpha1/taskspawner_types.go:370">
P2: Constrain `taskTemplates[].name` to DNS-safe characters before using it in generated Task names.</violation>
<violation number="2" location="api/v1alpha1/taskspawner_types.go:396">
P1: Require at least one pipeline step when `taskTemplates` is set; an empty list can fall into single-task mode and dereference a nil `taskTemplate`.</violation>
</file>
<file name="internal/manifests/install-crd.yaml">
<violation number="1" location="internal/manifests/install-crd.yaml:1835">
P1: The one-of CEL rule allows `taskTemplates: []`, which leaves both modes effectively unset and can trigger a nil-pointer dereference in the spawner.</violation>
</file>
<file name="cmd/kelos-spawner/main.go">
<violation number="1" location="cmd/kelos-spawner/main.go:276">
P1: Using the first step as a sentinel for new item detection prevents partial pipeline recovery. If the spawner crashes after creating the first step, the remaining steps are never recovered.</violation>
<violation number="2" location="cmd/kelos-spawner/main.go:338">
P1: The `stepsToCreate` variable uses the total number of templates instead of counting only the missing steps, which causes the `maxTotalTasks` budget calculation to overestimate the required budget during partial pipeline recovery. This can permanently deadlock the spawner.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Collaborator
|
/kelos pick-up |
Author
|
🤖 Kelos Task Status Task |
Author
|
🤖 Kelos Agent @gjkim42 /kelos needs-input All review feedback has been addressed in the latest commits:
Ready for re-review. |
Collaborator
|
rebase on origin/main |
Author
|
🤖 Kelos Task Status Task |
babb98b to
993b240
Compare
Author
|
🤖 Kelos Task Status Task |
Add support for multi-step pipeline spawning in TaskSpawner. When
taskTemplates is set, each discovered work item spawns N tasks (one per
step) with automatic dependency wiring. Step names in dependsOn are
translated to fully-qualified task names ({spawner}-{itemID}-{stepName}).
Key changes:
- Add NamedTaskTemplate struct with Name field that embeds TaskTemplate
- Add TaskTemplates field to TaskSpawnerSpec alongside existing TaskTemplate
- Make TaskTemplate a pointer (optional) with CEL mutual exclusivity rule
- Add CEL validation for unique step names and valid dependsOn references
- Spawner creates N tasks per item in pipeline mode with pipeline-item label
- maxConcurrency counts pipeline instances (not individual tasks)
- maxTotalTasks counts individual tasks for resource budgeting
- Add TotalPipelinesCreated to TaskSpawnerStatus
- Add 8 unit tests covering pipeline creation, dependency translation,
concurrency, budget, labels, independent step fields, and partial recovery
- Add pipeline example under examples/09-taskspawner-pipeline/
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reuse the pipelineMode variable already computed earlier instead of recomputing it as isPipelineMode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address review feedback: - Fix partial pipeline recovery: check all steps for missing tasks instead of using only the first step as a sentinel. This ensures that if the spawner crashes mid-pipeline, remaining steps are created on the next cycle. - Fix maxTotalTasks budget calculation to count only missing steps instead of total templates, preventing deadlock during partial recovery. - Add MinItems=1 validation on taskTemplates to prevent empty list from bypassing mutual exclusivity and causing nil-pointer dereference. - Add DNS-safe pattern constraint on step names to ensure generated task names are valid Kubernetes resource names. - Improve partial recovery test to assert exact expected task names. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use taskSpawnerWorkspaceRef helper in CLI printer so pipeline-mode TaskSpawners display the workspace name instead of generic source - Move missingStepsPerItem map allocation inside pipelineMode branch Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The rebase on main introduced a new integration test that used TaskTemplate as a value type, but the PR changed it to a pointer. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace toSet() (unavailable in K8s 1.31) with exists_one() for unique step name validation. Add MaxItems/MaxLength constraints to taskTemplates, dependsOn, and step names to keep CEL rule cost within budget. Replace nested map().exists() with simpler exists() to reduce estimated cost. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
993b240 to
978fdb3
Compare
Author
|
🤖 Kelos Agent @gjkim42 /kelos needs-input Rebased on origin/main and fixed CEL validation rules that were incompatible with K8s 1.31:
All previous review feedback was already addressed. Ready for re-review. |
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.
/kind feature
What this PR does / why we need it:
Adds
taskTemplates(plural) toTaskSpawnerSpecso that each discovered work item can spawn a pipeline of Tasks with automatic dependency wiring and result passing between steps.Previously, TaskSpawner could only create one Task per work item via the singular
taskTemplatefield. This forced users to either cram everything into one monolithic prompt or set up multiple independent TaskSpawners with fragile label-based gating conventions.With
taskTemplates, a spawner can define a multi-step pipeline (e.g., plan → implement → test → open-pr) where each step'sdependsOnreferences sibling step names. The spawner translates these to fully-qualified task names at creation time:Key design decisions (per maintainer feedback on #710):
taskTemplate(singular) preserved alongsidetaskTemplatesfor backward compatibilityWhat changes are included:
NamedTaskTemplatestruct withNamefield embeddingTaskTemplate;TaskSpawnerSpec.TaskTemplatesfield;TaskTemplatechanged to pointer (optional);TotalPipelinesCreatedin statusexists_one), valid dependsOn refs, no self-references, workspaceRef check for GitHub/Jira sources; MaxItems/MaxLength constraints for CEL cost budget{spawner}-{itemID}-{stepName}naming;kelos.dev/pipeline-itemlabel;maxConcurrencycounts pipeline instances;maxTotalTaskscounts individual tasks; partial pipeline recovery creates only missing stepsexamples/09-taskspawner-pipeline/with 3-step pipeline YAML and READMEWhich issue(s) this PR is related to:
Fixes #710
Special notes for your reviewer:
TaskTemplatechanged from value to pointer type — all existing test files updated to use&kelosv1alpha1.TaskTemplate{}taskTemplateandtaskTemplatesviataskSpawnerWorkspaceRef()helperexists_one()instead oftoSet()for K8s 1.31 compatibility, withMaxItems=10/MaxLength=63constraints to stay within cost budget^[a-z0-9]([-a-z0-9]*[a-z0-9])?$Does this PR introduce a user-facing change?