Skip to content

self-development: distill recurring conventions from PR review feedback#786

Open
kelos-bot[bot] wants to merge 2 commits intomainfrom
kelos-config-update-latest
Open

self-development: distill recurring conventions from PR review feedback#786
kelos-bot[bot] wants to merge 2 commits intomainfrom
kelos-config-update-latest

Conversation

@kelos-bot
Copy link
Copy Markdown

@kelos-bot kelos-bot Bot commented Mar 24, 2026

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Distills six recurring conventions from recent PR review feedback and propagates them across AGENTS.md, the shared and worker AgentConfigs, and the reviewer prompts. All changes are backed by specific PR review findings — no speculative rules.

1. Never use os.Getenv() for secrets as Go flag defaults

  • Evidence: PR Remove token-refresher sidecar, generate tokens in-process #971 — P1 security findings in cmd/kelos-webhook-server/main.go and cmd/ghproxy/main.go where os.Getenv("GITHUB_TOKEN") was used as flag.StringVar default, leaking the secret in --help output.
  • Applied to: AGENTS.md, agentconfig.yaml, kelos-workers.yaml, kelos-reviewer.yaml (new security checklist item).

2. Fail fast on invalid configuration

  • Evidence: PR Remove token-refresher sidecar, generate tokens in-process #971 — multiple P1/P2 findings where invalid GitHub App credentials, missing token resolvers, or failed token refreshes caused silent degradation (unauthenticated requests, skipped reporting) instead of erroring out.
  • Applied to: AGENTS.md, agentconfig.yaml, kelos-workers.yaml, kelos-reviewer.yaml (new correctness checklist item).

3. Keep API surfaces minimal

  • Evidence: PR feat(api): Add generic webhook source for arbitrary event-driven task spawning #902 — repeated maintainer feedback on the generic webhook API: "API is hard to fix, so I'd like to find the best way to design it" / "Can we defer these fields for now?" / "Let's make the minimal API for this PR."
  • Applied to: AGENTS.md, agentconfig.yaml, kelos-workers.yaml, kelos-api-reviewer.yaml (new compatibility checklist item).

4. API changes must preserve backward compatibility for existing manifests (new)

  • Evidence: PR feat: add bodyPattern and excludeBodyPatterns regex filters for GitHub webhooks #1058 — three distinct findings on the same PR:
    • Greptile P1: "Breaking schema change: BodyContains scalar → array" — existing in-cluster resources with bodyContains: "/kelos" (scalar) would fail Kubernetes structural-schema validation after the CRD update; the repo itself had at least 9 YAMLs in self-development/ and examples/ still using the old scalar form.
    • Maintainer (gjkim42) asked twice: "Is this backward-compatible? Does setting +kubebuilder:validation:MinLength=1 allow empty BodyPattern?" and "I just want to make sure that the existing YAMLs that don't have bodyPattern (because it's a newly introduced field) can be applied. can we just remove minLength here?"
    • Agreed resolution thread: add new fields and mark the old one +deprecated rather than remove it ("Why don't we add BodyPattern and ExcludeBodyPatterns and mark BodyContains deprecated here so that I can remove BodyContains later?").
  • This is distinct from "Keep API surfaces minimal" — minimal API is about scope of new additions; backward compatibility is about preserving existing manifests across CRD updates.
  • Applied to: AGENTS.md, agentconfig.yaml, kelos-workers.yaml, kelos-api-reviewer.yaml (two new bullets under "API compatibility and evolution": one on validation tightening / kind changes, one on sweeping stale YAMLs).

5. Docs must match implementation, not aspiration

  • Evidence:
    • PR docs: Document GenericWebhook TaskSpawner source #1035 (kelos-bot[bot] P1): docs claimed HMAC signature validation per source, but the GenericSource branch in internal/webhook/handler.go never reads <SOURCE>_WEBHOOK_SECRET, inspects X-Hub-Signature-256, or calls validateHMACSignature — giving users a false sense of security.
    • PR API: Add Workspace.spec.setupCommand for pre-agent setup #1056 (kelos-bot[bot] P2): doc note claimed PodOverrides.Env entries reusing reserved names are dropped so the built-in always wins, but the actual filter only drops collisions against names already populated on mainContainer.Env.
  • Applied to: AGENTS.md, agentconfig.yaml, kelos-workers.yaml, kelos-reviewer.yaml (new "Documentation accuracy" checklist subsection).

6. TaskSpawner conventions

  • Evidence: PR self-development: add kelos-api-reviewer TaskSpawner #965 — three distinct corrections from maintainer (gjkim42): use webhook-based triggers over poll-based; handle empty {{.Branch}} for issue events; design issue_comment prompts for both issue and PR contexts. PR Add API contract validation example (example 12) #974 — P2: "Remove the manual PR branch checkout instruction; Kelos already handles PR branch checkout automatically."
  • Applied to: agentconfig.yaml, kelos-workers.yaml. README template-variable table corrected from "Usually PR head branch" to "PR head branch; empty for issue events".

Also fixes the kelos-reviewer TaskSpawner branch field to use the safe {{with index . "Branch"}}{{.}}{{else}}main{{end}} fallback form instead of bare {{.Branch}}. Flagged P2 by Greptile in this PR's prior review (#786): the spawner listens on issue_comment, so a /kelos review triggered on a plain issue would land on whatever default state Kelos falls back to rather than main.

Which issue(s) this PR is related to:

N/A

Special notes for your reviewer:

This PR was rebased onto current main. All changes are documentation/configuration; no runtime code changes.

Does this PR introduce a user-facing change?

NONE

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.

No issues found across 4 files

@kelos-bot kelos-bot Bot changed the title Add pre-push verification and cross-surface update conventions Add deploy-dev sync, controller migration, and release note conventions Mar 28, 2026
kelos-bot Bot pushed a commit that referenced this pull request Mar 29, 2026
Add three new agent conventions from recent PR review feedback:

1. Per-TaskSpawner configuration should be CRD fields, not controller
   flags (PR #838 - gjkim42 review)
2. CRD API backward compatibility - never rename JSON field tags
   (PR #838 - P1 review finding)
3. Gate optional CRDs behind Helm values flags (PR #821 - PodMonitoring
   broke installs on clusters without monitoring.googleapis.com)

Also includes previously proposed conventions from PR #786:
- Consistent guidance across surfaces
- Provider-agnostic API design
- Idiomatic Helm values
- Deploy-dev workflow sync
- Controller-driven migration
- Release note user action requirements

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@kelos-bot kelos-bot Bot force-pushed the kelos-config-update-latest branch from bcdeef3 to 7ade17e Compare March 29, 2026 18:06
@kelos-bot kelos-bot Bot changed the title Add deploy-dev sync, controller migration, and release note conventions Add CRD design, API compatibility, and Helm gating conventions Mar 29, 2026
@gjkim42
Copy link
Copy Markdown
Collaborator

gjkim42 commented Mar 30, 2026

/kelos pick-up
rebase on origin/main

@kelos-bot
Copy link
Copy Markdown
Author

kelos-bot Bot commented Mar 30, 2026

🤖 Kelos Task Status

Task kelos-pr-responder-786 has succeeded. ✅

@kelos-bot kelos-bot Bot added kind/cleanup and removed needs-kind Indicates an issue or PR lacks a kind/* label labels Mar 30, 2026
@kelos-bot
Copy link
Copy Markdown
Author

kelos-bot Bot commented Mar 30, 2026

🤖 Kelos Agent @gjkim42

/kelos needs-input

Rebased on origin/main (was already up to date). Added kind/cleanup label to fix check-pr-labels CI check. Updated PR body formatting.

The only failing CI check is comment-label — this is a repo-level permissions issue (kelos-bot[bot] lacks write access), not related to this PR. All core checks (build, test, verify, e2e, integration) passed on the current commit.

Ready for re-review.

@kelos-bot kelos-bot Bot force-pushed the kelos-config-update-latest branch from 7ade17e to 782ce1c Compare March 30, 2026 18:13
@kelos-bot kelos-bot Bot changed the title Add CRD design, API compatibility, and Helm gating conventions Add Helm CRD escaping, Docker pinning, and Go safety conventions Mar 30, 2026
@kelos-bot kelos-bot Bot changed the title Add Helm CRD escaping, Docker pinning, and Go safety conventions Add test synchronization, RBAC, and Go safety conventions Apr 1, 2026
@kelos-bot kelos-bot Bot changed the title Add test synchronization, RBAC, and Go safety conventions Sync worker agent conventions and broaden K8s comparison rule Apr 2, 2026
@kelos-bot kelos-bot Bot force-pushed the kelos-config-update-latest branch from 0871329 to 6379545 Compare April 3, 2026 18:15
@kelos-bot kelos-bot Bot changed the title Sync worker agent conventions and broaden K8s comparison rule Add new agent conventions from PR review feedback and sync worker agent Apr 3, 2026
@kelos-bot kelos-bot Bot changed the title Add new agent conventions from PR review feedback and sync worker agent Propagate conventions to all agents and add new rules from PR reviews Apr 4, 2026
@kelos-bot kelos-bot Bot force-pushed the kelos-config-update-latest branch from 6f6241c to 41ed5c4 Compare April 7, 2026 18:06
@kelos-bot kelos-bot Bot changed the title Propagate conventions to all agents and add new rules from PR reviews Add consistent parallel paths convention and fix workers prompt bug Apr 7, 2026
@kelos-bot kelos-bot Bot force-pushed the kelos-config-update-latest branch from 41ed5c4 to 5f6baa8 Compare April 8, 2026 18:08
@kelos-bot kelos-bot Bot changed the title Add consistent parallel paths convention and fix workers prompt bug Add testing conventions, parallel paths, and fix agent prompt bugs Apr 8, 2026
@kelos-bot kelos-bot Bot force-pushed the kelos-config-update-latest branch from 5f6baa8 to 675ac75 Compare April 9, 2026 18:12
@kelos-bot kelos-bot Bot changed the title Add testing conventions, parallel paths, and fix agent prompt bugs Add API surface convention, sync agent configs, and fix prompt bugs Apr 9, 2026
@kelos-bot kelos-bot Bot force-pushed the kelos-config-update-latest branch from eb7fce3 to f472430 Compare April 12, 2026 18:10
@kelos-bot kelos-bot Bot changed the title Add API surface convention, sync agent configs, and fix prompt bugs Add secret-in-flag-defaults convention and clarify Branch template variable Apr 12, 2026
kelos-bot Bot pushed a commit that referenced this pull request Apr 14, 2026
…eedback

Adds conventions learned from recent PR reviews:

1. Fail fast on invalid configuration (PR #971): three P1 and four P2
   issues flagged silent degradation when credentials or config were
   invalid, falling back to unauthenticated requests instead of
   erroring.

2. No manual PR branch checkout in TaskSpawner prompts (PR #974): Kelos
   already checks out the PR branch automatically; manual checkout
   instructions are redundant and confusing.

Also carries forward the previously proposed changes from PR #786:
- os.Getenv() secret-in-flag-defaults convention (PR #971)
- TaskSpawner creation conventions (PR #965)
- Branch template variable documentation fix (PR #965)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@kelos-bot kelos-bot Bot force-pushed the kelos-config-update-latest branch from 1d88c65 to 0d360ce Compare April 14, 2026 18:07
@kelos-bot kelos-bot Bot changed the title Add secret-in-flag-defaults convention and clarify Branch template variable Add fail-fast convention, no-manual-checkout rule, and secret-in-flag-defaults Apr 14, 2026
@kelos-bot kelos-bot Bot changed the title Add fail-fast convention, no-manual-checkout rule, and secret-in-flag-defaults Add fail-fast, no-manual-checkout, secret-flag-default, and docs-accuracy conventions Apr 30, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Greptile Summary

This PR propagates five conventions distilled from recent PR review feedback — secrets in flag defaults, fail-fast configuration, minimal API surfaces, backward-compatible manifests, and documentation accuracy — across AGENTS.md, the shared and worker AgentConfigs, and the reviewer prompts. It also corrects the kelos-reviewer TaskSpawner branch template to the safe {{with index . "Branch"}}{{.}}{{else}}main{{end}} fallback form, resolving the prior P2 finding.

Confidence Score: 5/5

Safe to merge — documentation/configuration only, no runtime code changes, with one minor P2 style inconsistency.

All findings are P2 style suggestions; no P0/P1 issues found. The changes are purely documentation and configuration with a well-scoped, evidence-backed set of convention additions.

self-development/agentconfig.yaml and self-development/kelos-workers.yaml have a minor mismatch between the documented branch-fallback example and the canonical form used in the spawner YAMLs.

Important Files Changed

Filename Overview
AGENTS.md Adds five new coding-convention bullets (secrets in flags, fail-fast config, minimal API, backward-compat manifests, docs accuracy); straightforward documentation update.
self-development/README.md Single-line fix: corrects the {{.Branch}} description from "Usually PR head branch or push branch" to "PR head branch; empty for issue events".
self-development/agentconfig.yaml Propagates all five conventions to the shared dev-agent config; documented branch-fallback form ({{if .Branch}}) is inconsistent with the canonical form ({{with index . "Branch"}}) used in the actual spawner YAMLs.
self-development/kelos-workers.yaml Adds all five conventions to the worker agent config; same branch-fallback form inconsistency as agentconfig.yaml; also adds previously-missing Kubernetes resource-comparison rule.
self-development/kelos-reviewer.yaml Adds correctness/security/doc-accuracy checklist items to the reviewer prompt; branch field updated to the safe {{with index . "Branch"}}{{.}}{{else}}main{{end}} fallback form, resolving the prior P2 finding.
self-development/kelos-api-reviewer.yaml Adds three new API-design checklist bullets (minimal surface, backward-compat, stale manifests); clean addition with no issues.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[PR Review Feedback\nPRs #965 #971 #902 #974 #1035 #1056] --> B[Five Conventions Distilled]

    B --> C1[1. No os.Getenv secrets\nas flag defaults]
    B --> C2[2. Fail fast on\ninvalid config]
    B --> C3[3. Minimal API surfaces]
    B --> C4[4. Docs match\nimplementation]
    B --> C5[5. TaskSpawner\nconventions]

    C1 --> D1[AGENTS.md]
    C2 --> D1
    C3 --> D1
    C4 --> D1

    C1 --> D2[agentconfig.yaml]
    C2 --> D2
    C3 --> D2
    C4 --> D2
    C5 --> D2

    C1 --> D3[kelos-workers.yaml]
    C2 --> D3
    C3 --> D3
    C4 --> D3
    C5 --> D3

    C3 --> D4[kelos-api-reviewer.yaml\nnew compatibility checklist]

    C1 --> D5[kelos-reviewer.yaml\nsecurity + doc-accuracy checklist]
    C2 --> D5
    C4 --> D5

    C5 --> D6[kelos-reviewer.yaml\nbranch: with index Branch main]

    D6 --> E[Resolves prior P2 finding\nfrom PR #786 review]
Loading
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
self-development/agentconfig.yaml:41
**Documented convention form differs from canonical implementation**

The convention here prescribes `{{if .Branch}}{{.Branch}}{{else}}main{{end}}`, but `kelos-reviewer.yaml` and `kelos-api-reviewer.yaml` both use `{{with index . "Branch"}}{{.}}{{else}}main{{end}}`. Both are functionally equivalent for map access in Go templates, but the same inconsistency exists in `kelos-workers.yaml` line 40. Given that this PR introduces the "Docs must match implementation" rule, the documented example should match the canonical form actually deployed.

```suggestion
      - The `{{.Branch}}` template variable is empty for issue-only events; use `{{with index . "Branch"}}{{.}}{{else}}main{{end}}` when it may be empty
```

### Issue 2 of 2
self-development/kelos-workers.yaml:40
**Documented convention form differs from canonical implementation**

Same issue as `agentconfig.yaml` line 41 — the prescribed form `{{if .Branch}}{{.Branch}}{{else}}main{{end}}` does not match the `{{with index . "Branch"}}{{.}}{{else}}main{{end}}` form used in `kelos-reviewer.yaml` and `kelos-api-reviewer.yaml`. The convention text and the deployed examples should agree.

```suggestion
      - The `{{.Branch}}` template variable is empty for issue-only events; use `{{with index . "Branch"}}{{.}}{{else}}main{{end}}` when it may be empty
```

Reviews (3): Last reviewed commit: "self-development: add API backward-compa..." | Re-trigger Greptile

Adds five conventions distilled from recent PR reviews and applies them
across AGENTS.md, the shared and worker AgentConfigs, and the reviewer
prompts.

1. Never use os.Getenv() for secrets as Go flag defaults (PR #971)
   — flag prints defaults in --help output, leaking secret values.

2. Fail fast on invalid configuration (PR #971) — do not silently fall
   back to unauthenticated/degraded behavior when credentials or config
   are missing.

3. Keep API surfaces minimal (PR #902) — only fields immediately needed,
   no speculative additions; API is hard to change once shipped.

4. Docs must match implementation, not aspiration (PRs #1035, #1056) —
   describe only what the code actually does; verify enforcement before
   documenting a contract.

5. TaskSpawner conventions (PRs #965, #974):
   - Prefer webhook-based triggers over poll-based.
   - {{.Branch}} is empty for issue-only events; use the
     {{if .Branch}}{{.Branch}}{{else}}main{{end}} fallback form.
   - issue_comment fires for both issues and PRs; design prompts to
     detect and handle both contexts.
   - Do not include manual PR branch checkout instructions — Kelos
     checks out the PR branch automatically.

Also fixes the kelos-reviewer TaskSpawner branch field to use the safe
fallback form (was using bare {{.Branch}}, which is empty for issue
events; flagged P2 in PR #786 review).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kelos-bot kelos-bot Bot force-pushed the kelos-config-update-latest branch from 7aff731 to 6a74ec3 Compare May 1, 2026 18:09
@kelos-bot kelos-bot Bot changed the title Add fail-fast, no-manual-checkout, secret-flag-default, and docs-accuracy conventions self-development: distill recurring conventions from PR review feedback May 1, 2026
PR #1058 surfaced a recurring API-change pattern not covered by the
existing "Keep API surfaces minimal" rule:

- A scalar -> array kind change on an existing CRD field (BodyContains)
  was flagged P1 because existing in-cluster resources would fail
  structural-schema validation; the repo itself had ~9 stale YAMLs
  in self-development/ and examples/ still using the old scalar form.
- The maintainer asked twice about backward compatibility on a newly
  added BodyPattern field, and required removing
  +kubebuilder:validation:MinLength=1 because it would reject existing
  YAMLs that don't yet have the field.
- The agreed migration path was to add new fields and mark the old one
  +deprecated rather than remove it.

Adds the convention to AGENTS.md (and CLAUDE.md via symlink), to the
shared agentconfig.yaml and kelos-workers.yaml, and to the
kelos-api-reviewer prompt as an explicit checklist item under "API
compatibility and evolution".

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai Bot commented May 2, 2026

You're iterating quickly on this pull request. To help protect your rate limits, cubic has paused automatic reviews on new pushes for now—when you're ready for another review, comment @cubic-dev-ai review.

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.

1 participant