Skip to content

Migrate self-development to webhook-based TaskSpawners#883

Open
gjkim42 wants to merge 1 commit intomainfrom
use-webhook
Open

Migrate self-development to webhook-based TaskSpawners#883
gjkim42 wants to merge 1 commit intomainfrom
use-webhook

Conversation

@gjkim42
Copy link
Copy Markdown
Collaborator

@gjkim42 gjkim42 commented Apr 1, 2026

/kind feature

What type of PR is this?

What this PR does / why we need it:

  • Migrates the self-development GitHub issue and pull request TaskSpawners from polling sources to githubWebhook
  • Updates the affected prompts so they re-check live GitHub state instead of relying on polling-only template fields
  • Documents webhook setup and the no-backfill behavior in self-development/README.md
  • Adds a regression test to keep the migrated manifests on webhook-based triggers

Which issue(s) this PR is related to:

N/A

Special notes for your reviewer:

  • Existing matching issues and PRs will not backfill after deploy; they need a fresh comment, review, or relabel event to retrigger
  • The migration keeps the cron-based self-development spawners unchanged

Does this PR introduce a user-facing change?

Migrated the self-development GitHub issue and pull request TaskSpawner examples to webhook-driven triggers and documented the required webhook setup and retrigger behavior.

Summary by cubic

Migrates self-development TaskSpawners from polling (githubIssues/githubPullRequests) to webhook-based githubWebhook for faster, event-driven execution and more accurate context. Updates prompts to re-check live GitHub state and adds a regression test and docs for webhook setup.

  • New Features

    • All self-development manifests now use githubWebhook with filters on issues, issue_comment, and pull_request_review (stop using githubIssues/githubPullRequests)
    • Prompts re-read current issue/PR state with gh, include webhook metadata, and use predictable branch names for review/respond/squash flows
    • README documents webhook setup, event subscriptions, new template variables, and runtime validation behavior
    • Regression test (internal/examples/self_development_test.go) enforces webhook usage and expected events/filters
    • Cron-based spawners are unchanged
  • Migration

    • Enable the GitHub webhook server and expose /webhook/github; create github-webhook-secret with WEBHOOK_SECRET
    • Configure the repo webhook to deliver issues, issue_comment, and pull_request_review
    • No backfill: existing matching issues/PRs won’t spawn until a new comment, relabel, or review event occurs
    • If adapting to another repo, update spec.when.githubWebhook.repository and any author filters

Written for commit 777e419. Summary will update on new commits.

@github-actions github-actions bot added kind/feature Categorizes issue or PR as related to a new feature needs-triage needs-priority needs-actor release-note labels Apr 1, 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.

5 issues found across 9 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="self-development/kelos-pr-responder.yaml">

<violation number="1" location="self-development/kelos-pr-responder.yaml:94">
P2: Remove manual `git checkout` from the task prompt; Kelos should rely on its automatic PR branch checkout instead.

(Based on your team's feedback about avoiding manual git checkout steps in Kelos prompts/tasks.) [FEEDBACK_USED]</violation>
</file>

<file name="self-development/kelos-reviewer.yaml">

<violation number="1" location="self-development/kelos-reviewer.yaml:109">
P2: Remove the manual `git checkout` step from the reviewer prompt. Kelos already checks out the PR branch automatically, so this extra checkout is unnecessary and can make the workflow more brittle.

(Based on your team's feedback about avoiding manual git checkout steps in Kelos agent prompts/tasks.) [FEEDBACK_USED]</violation>
</file>

<file name="self-development/kelos-workers.yaml">

<violation number="1" location="self-development/kelos-workers.yaml:134">
P1: The prompt uses the issue number as the PR selector in `gh pr edit`, which can edit/fail against the wrong PR in the issue workflow.</violation>
</file>

<file name="self-development/kelos-squash-commits.yaml">

<violation number="1" location="self-development/kelos-squash-commits.yaml:76">
P2: Remove the manual `git checkout` step; Kelos already checks out the PR branch for these tasks.

(Based on your team's feedback about not including manual git checkout steps in Kelos prompts.) [FEEDBACK_USED]</violation>

<violation number="2" location="self-development/kelos-squash-commits.yaml:110">
P1: The completion comment command matches the webhook trigger substring, so the bot can retrigger itself in a loop.

(Based on your team's feedback about ensuring automation does not loop or over-consume tokens.) [FEEDBACK_USED]</violation>
</file>

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

- 5a. Make only the incremental changes needed to address review feedback or remaining issues. Preserve existing work.
- 6a. Commit and push your changes to origin kelos-task-{{.Number}}.
- 7a. /review the PR to verify your changes address the feedback. If changes are needed, make them, run `make verify` and `make test`, commit and push, then /review again. Repeat until the review passes.
- 8a. Update the PR title and description to reflect the final diff. The PR body MUST contain a standard closing keyword reference on its own line (e.g., `Fixes #{{.Number}}` or `Closes #{{.Number}}`). Do not embed the issue number in natural language. Ensure the PR has labels "generated-by-kelos" and "ok-to-test" (use `gh pr edit {{.Number}} --add-label generated-by-kelos --add-label ok-to-test` if missing).
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 1, 2026

Choose a reason for hiding this comment

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

P1: The prompt uses the issue number as the PR selector in gh pr edit, which can edit/fail against the wrong PR in the issue workflow.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At self-development/kelos-workers.yaml, line 134:

<comment>The prompt uses the issue number as the PR selector in `gh pr edit`, which can edit/fail against the wrong PR in the issue workflow.</comment>

<file context>
@@ -93,34 +105,46 @@ spec:
+      - 5a. Make only the incremental changes needed to address review feedback or remaining issues. Preserve existing work.
+      - 6a. Commit and push your changes to origin kelos-task-{{.Number}}.
+      - 7a. /review the PR to verify your changes address the feedback. If changes are needed, make them, run `make verify` and `make test`, commit and push, then /review again. Repeat until the review passes.
+      - 8a. Update the PR title and description to reflect the final diff. The PR body MUST contain a standard closing keyword reference on its own line (e.g., `Fixes #{{.Number}}` or `Closes #{{.Number}}`). Do not embed the issue number in natural language. Ensure the PR has labels "generated-by-kelos" and "ok-to-test" (use `gh pr edit {{.Number}} --add-label generated-by-kelos --add-label ok-to-test` if missing).
+      - 9a. After pushing, actively check CI status with `gh pr checks`. If any checks fail, investigate the failures, fix them, commit and push, then check again. Do not request review until CI passes.
 
</file context>
Suggested change
- 8a. Update the PR title and description to reflect the final diff. The PR body MUST contain a standard closing keyword reference on its own line (e.g., `Fixes #{{.Number}}` or `Closes #{{.Number}}`). Do not embed the issue number in natural language. Ensure the PR has labels "generated-by-kelos" and "ok-to-test" (use `gh pr edit {{.Number}} --add-label generated-by-kelos --add-label ok-to-test` if missing).
- 8a. Update the PR title and description to reflect the final diff. The PR body MUST contain a standard closing keyword reference on its own line (e.g., `Fixes #{{.Number}}` or `Closes #{{.Number}}`). Do not embed the issue number in natural language. Ensure the PR has labels "generated-by-kelos" and "ok-to-test" (use `gh pr edit --add-label generated-by-kelos --add-label ok-to-test` if missing).
Fix with Cubic

- Run: `gh issue edit <issue-number> --add-label kelos/needs-input`

8. Post a comment on PR #{{.Number}} whose first line is `/kelos squash-commits-done` to signal completion.
9. Post a comment on PR #{{.Number}} whose first line is `/kelos squash-commits-done` to signal completion.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 1, 2026

Choose a reason for hiding this comment

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

P1: The completion comment command matches the webhook trigger substring, so the bot can retrigger itself in a loop.

(Based on your team's feedback about ensuring automation does not loop or over-consume tokens.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At self-development/kelos-squash-commits.yaml, line 110:

<comment>The completion comment command matches the webhook trigger substring, so the bot can retrigger itself in a loop.

(Based on your team's feedback about ensuring automation does not loop or over-consume tokens.) </comment>

<file context>
@@ -44,56 +47,67 @@ spec:
          - Run: `gh issue edit <issue-number> --add-label kelos/needs-input`
 
-      8. Post a comment on PR #{{.Number}} whose first line is `/kelos squash-commits-done` to signal completion.
+      9. Post a comment on PR #{{.Number}} whose first line is `/kelos squash-commits-done` to signal completion.
 
       Important:
</file context>
Suggested change
9. Post a comment on PR #{{.Number}} whose first line is `/kelos squash-commits-done` to signal completion.
9. Post a comment on PR #{{.Number}} whose first line is `/kelos squash-done` to signal completion.
Fix with Cubic

if git remote get-url upstream >/dev/null 2>&1; then
git fetch upstream main
git fetch origin "$BRANCH":"$BRANCH" 2>/dev/null || true
git checkout "$BRANCH"
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 1, 2026

Choose a reason for hiding this comment

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

P2: Remove manual git checkout from the task prompt; Kelos should rely on its automatic PR branch checkout instead.

(Based on your team's feedback about avoiding manual git checkout steps in Kelos prompts/tasks.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At self-development/kelos-pr-responder.yaml, line 94:

<comment>Remove manual `git checkout` from the task prompt; Kelos should rely on its automatic PR branch checkout instead.

(Based on your team's feedback about avoiding manual git checkout steps in Kelos prompts/tasks.) </comment>

<file context>
@@ -49,47 +60,54 @@ spec:
         if git remote get-url upstream >/dev/null 2>&1; then
           git fetch upstream main
+          git fetch origin "$BRANCH":"$BRANCH" 2>/dev/null || true
+          git checkout "$BRANCH"
           git rebase upstream/main
         else
</file context>
Fix with Cubic

git fetch --unshallow || true
git fetch origin main
git fetch origin "$BRANCH":"$BRANCH" 2>/dev/null || true
git checkout "$BRANCH"
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 1, 2026

Choose a reason for hiding this comment

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

P2: Remove the manual git checkout step from the reviewer prompt. Kelos already checks out the PR branch automatically, so this extra checkout is unnecessary and can make the workflow more brittle.

(Based on your team's feedback about avoiding manual git checkout steps in Kelos agent prompts/tasks.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At self-development/kelos-reviewer.yaml, line 109:

<comment>Remove the manual `git checkout` step from the reviewer prompt. Kelos already checks out the PR branch automatically, so this extra checkout is unnecessary and can make the workflow more brittle.

(Based on your team's feedback about avoiding manual git checkout steps in Kelos agent prompts/tasks.) </comment>

<file context>
@@ -79,39 +81,47 @@ spec:
         git fetch --unshallow || true
         git fetch origin main
+        git fetch origin "$BRANCH":"$BRANCH" 2>/dev/null || true
+        git checkout "$BRANCH"
         ```
 
</file context>
Fix with Cubic

git fetch origin main
git checkout {{.Branch}}
git fetch origin "$BRANCH":"$BRANCH" 2>/dev/null || true
git checkout "$BRANCH"
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 1, 2026

Choose a reason for hiding this comment

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

P2: Remove the manual git checkout step; Kelos already checks out the PR branch for these tasks.

(Based on your team's feedback about not including manual git checkout steps in Kelos prompts.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At self-development/kelos-squash-commits.yaml, line 76:

<comment>Remove the manual `git checkout` step; Kelos already checks out the PR branch for these tasks.

(Based on your team's feedback about not including manual git checkout steps in Kelos prompts.) </comment>

<file context>
@@ -44,56 +47,67 @@ spec:
          git fetch origin main
-         git checkout {{.Branch}}
+         git fetch origin "$BRANCH":"$BRANCH" 2>/dev/null || true
+         git checkout "$BRANCH"
          ```
 
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature needs-actor needs-priority needs-triage release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant