Skip to content

Conversation

@adityachoudhari26
Copy link
Contributor

@adityachoudhari26 adityachoudhari26 commented Nov 10, 2025

Summary by CodeRabbit

  • New Features

    • ArgoCD integration for job dispatching, enabling application spec updates.
    • Enhanced release verification with structured metric specs and measurement tracking.
    • Improved job retrieval to include associated release and deployment data for dispatch workflows.
  • Chores

    • Updated and expanded Go module dependencies to support the new integrations and verification features.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 10, 2025

Walkthrough

Adds ArgoCD job dispatch support: new ArgoCDDispatcher, job routing for agent type "argo-cd", store helper to fetch job+release context, go.mod dependency updates, and verification schema restructuring in the SDK.

Changes

Cohort / File(s) Summary
ArgoCD integration & dispatch
apps/workspace-engine/go.mod, apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go, apps/workspace-engine/pkg/workspace/jobdispatch/types.go, apps/workspace-engine/pkg/workspace/releasemanager/deployment/jobs/dispatcher.go
Adds direct Argo CD dependency in go.mod; introduces ArgoCDDispatcher with NewArgoCDDispatcher and DispatchJob that retrieves job+release data, parses ArgoCD config, renders a template to an Application spec, and calls ArgoCD client to update the application. Adds JobAgentTypeArgoCD and routes jobs to the new dispatcher.
Store: job + release retrieval
apps/workspace-engine/pkg/workspace/store/jobs.go
Adds GetWithRelease(id string) (*oapi.JobWithRelease, error) to load a Job and validate/attach its Release, Environment, Deployment, and Resource, returning a composite JobWithRelease.
SDK verification schema changes
packages/workspace-engine-sdk/src/schema.ts
Replaces prior verification models with new schemas: HTTPMetricProvider, alias MetricProvider, ReleaseVerification, VerificationMeasurement, VerificationMetricSpec, and VerificationMetricStatus. Updates Release.verification to use the new type and removes older VerificationAnalysis/VerificationResult.

Sequence Diagram(s)

sequenceDiagram
    participant Router as Dispatcher Router
    participant Caller as Job Trigger
    participant Store as Store
    participant ArgoDisp as ArgoCDDispatcher
    participant Tmpl as Template Engine
    participant ArgoCD as ArgoCD API

    Caller->>Router: DispatchJob(job)
    Router->>Router: inspect job.AgentType
    alt AgentType == "argo-cd"
        Router->>ArgoDisp: DispatchJob(job)
        ArgoDisp->>Store: GetWithRelease(job.ID)
        Store-->>ArgoDisp: JobWithRelease
        ArgoDisp->>ArgoDisp: parseConfig(job)
        ArgoDisp->>Tmpl: Render(cfg.Template, job+release data)
        Tmpl-->>ArgoDisp: renderedSpec
        ArgoDisp->>ArgoCD: NewClient(cfg.serverUrl,cfg.apiKey)
        ArgoCD-->>ArgoDisp: client
        ArgoDisp->>ArgoCD: UpdateSpec(renderedSpec)
        ArgoCD-->>ArgoDisp: success / error
        ArgoDisp-->>Router: result
    else other agent types
        Router-->>Router: existing dispatch flow (e.g., GitHub)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

  • Focus review areas:
    • argocd.go: template rendering edge cases, JSON marshal/unmarshal, error wrapping, and ArgoCD client creation/usage.
    • store/jobs.go: correctness of entity lookups and error cases when composing JobWithRelease.
    • schema.ts: breaking-change impact on consumers and correctness of new schema shapes and references.
    • go.mod: ensure added transitive dependencies do not introduce version conflicts.

Possibly related PRs

Poem

🐰
I hop through code with template and key,
I nudge ArgoCD to set apps free.
Jobs find their release, specs take flight,
Metrics sing softly into the night,
A joyous rabbit cheers: deploys go right!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: init argocd integration' accurately reflects the primary changes in the pull request, which introduce ArgoCD integration capabilities across multiple files including a new ArgoCDDispatcher, job agent type, and schema updates.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch argocd-integration

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 47c261c and 4509070.

📒 Files selected for processing (1)
  • apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: Typecheck
  • GitHub Check: tests
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build-and-push (linux/amd64)
  • GitHub Check: Lint

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 02ec1d6 and 47c261c.

⛔ Files ignored due to path filters (1)
  • apps/workspace-engine/go.sum is excluded by !**/*.sum
📒 Files selected for processing (6)
  • apps/workspace-engine/go.mod (3 hunks)
  • apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go (1 hunks)
  • apps/workspace-engine/pkg/workspace/jobdispatch/types.go (1 hunks)
  • apps/workspace-engine/pkg/workspace/releasemanager/deployment/jobs/dispatcher.go (1 hunks)
  • apps/workspace-engine/pkg/workspace/store/jobs.go (2 hunks)
  • packages/workspace-engine-sdk/src/schema.ts (6 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
apps/workspace-engine/**/*.go

📄 CodeRabbit inference engine (apps/workspace-engine/CLAUDE.md)

apps/workspace-engine/**/*.go: Do not add extraneous inline comments that state the obvious
Do not add comments that simply restate what the code does
Do not add comments for standard Go patterns (e.g., noting WaitGroup or semaphore usage)
Write comments that explain why, document complex logic/algorithms, provide non-obvious context, include TODO/FIXME, and document exported functions/types/methods

Files:

  • apps/workspace-engine/pkg/workspace/jobdispatch/types.go
  • apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go
  • apps/workspace-engine/pkg/workspace/releasemanager/deployment/jobs/dispatcher.go
  • apps/workspace-engine/pkg/workspace/store/jobs.go
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Use TypeScript with explicit types (prefer interfaces for public APIs)
Import styles: Use named imports, group imports by source (std lib > external > internal)
Consistent type imports: import type { Type } from "module"
Prefer async/await over raw promises
Handle errors explicitly (use try/catch and typed error responses)

Files:

  • packages/workspace-engine-sdk/src/schema.ts

⚙️ CodeRabbit configuration file

**/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

Files:

  • packages/workspace-engine-sdk/src/schema.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (CLAUDE.md)

Formatting: Prettier is used with @ctrlplane/prettier-config

Files:

  • packages/workspace-engine-sdk/src/schema.ts
🧠 Learnings (6)
📓 Common learnings
Learnt from: adityachoudhari26
Repo: ctrlplanedev/ctrlplane PR: 637
File: packages/events/src/kafka/client.ts:10-16
Timestamp: 2025-08-01T04:41:41.345Z
Learning: User adityachoudhari26 prefers not to add null safety checks for required environment variables when they are guaranteed to be present in their deployment configuration, similar to their preference for simplicity over defensive programming in test code.
Learnt from: adityachoudhari26
Repo: ctrlplanedev/ctrlplane PR: 601
File: e2e/tests/api/policies/retry-policy.spec.ts:23-24
Timestamp: 2025-06-24T23:52:50.732Z
Learning: The user adityachoudhari26 prefers not to add null safety checks or defensive programming in test code, particularly in e2e tests, as they prioritize simplicity and focus on the main functionality being tested rather than comprehensive error handling within the test itself.
📚 Learning: 2025-08-12T18:13:54.630Z
Learnt from: CR
Repo: ctrlplanedev/ctrlplane PR: 0
File: apps/workspace-engine/CLAUDE.md:0-0
Timestamp: 2025-08-12T18:13:54.630Z
Learning: Applies to apps/workspace-engine/pkg/model/selector/types.go : Add the new condition type to pkg/model/selector/types.go

Applied to files:

  • apps/workspace-engine/pkg/workspace/jobdispatch/types.go
📚 Learning: 2025-08-12T18:13:54.630Z
Learnt from: CR
Repo: ctrlplanedev/ctrlplane PR: 0
File: apps/workspace-engine/CLAUDE.md:0-0
Timestamp: 2025-08-12T18:13:54.630Z
Learning: Applies to apps/workspace-engine/**/*.go : Write comments that explain why, document complex logic/algorithms, provide non-obvious context, include TODO/FIXME, and document exported functions/types/methods

Applied to files:

  • apps/workspace-engine/go.mod
📚 Learning: 2025-08-12T18:13:54.630Z
Learnt from: CR
Repo: ctrlplanedev/ctrlplane PR: 0
File: apps/workspace-engine/CLAUDE.md:0-0
Timestamp: 2025-08-12T18:13:54.630Z
Learning: Applies to apps/workspace-engine/**/*.go : Do not add comments for standard Go patterns (e.g., noting WaitGroup or semaphore usage)

Applied to files:

  • apps/workspace-engine/go.mod
📚 Learning: 2025-08-12T18:13:54.630Z
Learnt from: CR
Repo: ctrlplanedev/ctrlplane PR: 0
File: apps/workspace-engine/CLAUDE.md:0-0
Timestamp: 2025-08-12T18:13:54.630Z
Learning: Applies to apps/workspace-engine/**/*.go : Do not add extraneous inline comments that state the obvious

Applied to files:

  • apps/workspace-engine/go.mod
📚 Learning: 2025-08-12T18:13:54.630Z
Learnt from: CR
Repo: ctrlplanedev/ctrlplane PR: 0
File: apps/workspace-engine/CLAUDE.md:0-0
Timestamp: 2025-08-12T18:13:54.630Z
Learning: Applies to apps/workspace-engine/**/*.go : Do not add comments that simply restate what the code does

Applied to files:

  • apps/workspace-engine/go.mod
🧬 Code graph analysis (4)
apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go (2)
apps/workspace-engine/pkg/oapi/oapi.gen.go (2)
  • JobAgentConfig (76-76)
  • Id (75-75)
apps/workspace-engine/pkg/workspace/store/jobs.go (1)
  • Jobs (17-20)
apps/workspace-engine/pkg/workspace/releasemanager/deployment/jobs/dispatcher.go (2)
apps/workspace-engine/pkg/workspace/jobdispatch/types.go (1)
  • JobAgentTypeArgoCD (7-7)
apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go (1)
  • NewArgoCDDispatcher (28-32)
apps/workspace-engine/pkg/workspace/store/jobs.go (5)
apps/workspace-engine/pkg/oapi/oapi.gen.go (8)
  • JobWithRelease (356-362)
  • ReleaseId (79-79)
  • ReleaseTarget (495-499)
  • Job (310-322)
  • Release (485-492)
  • Environment (222-229)
  • Deployment (146-155)
  • Resource (540-554)
apps/workspace-engine/pkg/workspace/store/releases.go (1)
  • Releases (16-19)
apps/workspace-engine/pkg/workspace/store/environments.go (1)
  • Environments (18-21)
apps/workspace-engine/pkg/workspace/store/deployments.go (1)
  • Deployments (24-27)
apps/workspace-engine/pkg/workspace/store/resources.go (1)
  • Resources (21-24)
packages/workspace-engine-sdk/src/schema.ts (3)
apps/api/src/types/openapi.ts (1)
  • components (631-1175)
apps/web/app/api/openapi.ts (1)
  • components (283-599)
packages/workspace-engine-sdk/src/index.ts (1)
  • components (7-7)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: workspace-engine-tests
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build-and-push (linux/amd64)
  • GitHub Check: tests
  • GitHub Check: build (linux/amd64)
  • GitHub Check: Typecheck
  • GitHub Check: Lint

Comment on lines +34 to +52
func (d *ArgoCDDispatcher) parseConfig(job *oapi.Job) (argoCDAgentConfig, error) {
var parsed argoCDAgentConfig
rawCfg, err := json.Marshal(job.JobAgentConfig)
if err != nil {
return argoCDAgentConfig{}, err
}
if err := json.Unmarshal(rawCfg, &parsed); err != nil {
return argoCDAgentConfig{}, err
}
if parsed.ServerUrl == "" {
return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: serverUrl")
}
if parsed.ApiKey == "" {
return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: apiKey")
}
if parsed.Template == "" {
return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: template")
}
return parsed, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Require the ArgoCD application name.

UpdateSpec sends Name: &cfg.Application; if the config omits application, we end up handing ArgoCD an empty string and the API rejects the request. Please fail fast in parseConfig the same way we already do for serverUrl, apiKey, and template.

 	if parsed.Template == "" {
 		return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: template")
 	}
+	if parsed.Application == "" {
+		return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: application")
+	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func (d *ArgoCDDispatcher) parseConfig(job *oapi.Job) (argoCDAgentConfig, error) {
var parsed argoCDAgentConfig
rawCfg, err := json.Marshal(job.JobAgentConfig)
if err != nil {
return argoCDAgentConfig{}, err
}
if err := json.Unmarshal(rawCfg, &parsed); err != nil {
return argoCDAgentConfig{}, err
}
if parsed.ServerUrl == "" {
return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: serverUrl")
}
if parsed.ApiKey == "" {
return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: apiKey")
}
if parsed.Template == "" {
return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: template")
}
return parsed, nil
func (d *ArgoCDDispatcher) parseConfig(job *oapi.Job) (argoCDAgentConfig, error) {
var parsed argoCDAgentConfig
rawCfg, err := json.Marshal(job.JobAgentConfig)
if err != nil {
return argoCDAgentConfig{}, err
}
if err := json.Unmarshal(rawCfg, &parsed); err != nil {
return argoCDAgentConfig{}, err
}
if parsed.ServerUrl == "" {
return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: serverUrl")
}
if parsed.ApiKey == "" {
return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: apiKey")
}
if parsed.Template == "" {
return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: template")
}
if parsed.Application == "" {
return argoCDAgentConfig{}, fmt.Errorf("missing required ArgoCD job config: application")
}
return parsed, nil
}
🤖 Prompt for AI Agents
In apps/workspace-engine/pkg/workspace/jobdispatch/argocd.go around lines 34 to
52, parseConfig currently validates serverUrl, apiKey, and template but does not
validate the ArgoCD application name; add a check that parsed.Application is not
empty and return an error such as fmt.Errorf("missing required ArgoCD job
config: application") so we fail fast before calling UpdateSpec (which sets
Name: &cfg.Application) and avoid sending an empty name to the ArgoCD API.

@adityachoudhari26 adityachoudhari26 merged commit 6463016 into main Nov 10, 2025
10 checks passed
@adityachoudhari26 adityachoudhari26 deleted the argocd-integration branch November 10, 2025 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants