Skip to content

Conversation

@adityachoudhari26
Copy link
Member

@adityachoudhari26 adityachoudhari26 commented Feb 2, 2026

Summary by CodeRabbit

  • New Features

    • Workflow templates with string/number/boolean inputs and step templates
    • Create workflows from templates and track multi-step execution with persistence
    • Automatic workflow progression/reconciliation triggered on job success
    • Event-driven handling for workflow and workflow-template creation
  • Tests

    • New end-to-end workflow test coverage and test helpers/options for workflows

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

Adds workflow event handling and job-success orchestration: new event types and handlers for workflow/template creation, a pluggable WorkflowActionOrchestrator invoked on job success, a WorkflowManagerAction that reconciles workflows, workspace integration of workflow components, store additions, and new tests and test helpers.

Changes

Cohort / File(s) Summary
Event Types & Registry
apps/workspace-engine/pkg/events/handler/handler.go, apps/workspace-engine/pkg/events/events.go
Adds WorkflowTemplateCreate and WorkflowCreate event types and wires their handlers into the event registry.
Workflow Event Handlers
apps/workspace-engine/pkg/events/handler/workflows/workflows.go
Adds HandleWorkflowTemplateCreated (upsert template) and HandleWorkflowCreated (create workflow) handlers that unmarshal RawEvent data and call workspace APIs.
Job Handler Hook
apps/workspace-engine/pkg/events/handler/jobs/jobs.go
Invokes WorkflowActionOrchestrator.OnJobSuccess when a job transitions to Successful; logs returned errors.
Action Orchestration
apps/workspace-engine/pkg/workspace/workflowmanager/workflow_orchestrator.go, apps/workspace-engine/pkg/workspace/workflowmanager/action.go
Introduces WorkflowActionOrchestrator, WorkflowAction interface, ActionTriggerJobSuccess, and WorkflowManagerAction that looks up workflow/step and calls Manager.ReconcileWorkflow on job success.
Workspace Integration
apps/workspace-engine/pkg/workspace/workspace.go
Wires workflow manager and action orchestrator into Workspace, adds accessors for workflow manager, orchestrator, templates, steps, and stores.
Store API
apps/workspace-engine/pkg/workspace/store/workflows.go
Adds GetByTemplateID(templateID string) map[string]*oapi.Workflow to filter workflows by template ID.
Test infra & factories
apps/workspace-engine/test/integration/creators/workflow.go, apps/workspace-engine/test/integration/opts.go
Adds workflow test creators and builder option APIs for templates, inputs, and step templates (note: opts.go shows duplicated Workflow Options block in the patch).
End-to-end tests
apps/workspace-engine/test/e2e/engine_workflow_test.go
Adds comprehensive e2e tests exercising single-step, multi-step, multi-input, and concurrent workflow scenarios via simulated events and state assertions.

Sequence Diagram

sequenceDiagram
    actor Job
    participant JobHandler as "Job Handler"
    participant Orchestrator as "WorkflowActionOrchestrator"
    participant Action as "WorkflowManagerAction"
    participant Store as "Store"
    participant Manager as "Workflow Manager"

    Job->>JobHandler: status change -> Successful
    JobHandler->>JobHandler: process status change
    JobHandler->>Orchestrator: OnJobSuccess(ctx, job)
    Orchestrator->>Action: Execute(ctx, ActionTriggerJobSuccess, job)
    Action->>Store: Get WorkflowStep by job.WorkflowStepId
    Store-->>Action: WorkflowStep
    Action->>Store: Get Workflow by workflowStep.WorkflowId
    Store-->>Action: Workflow
    Action->>Manager: ReconcileWorkflow(ctx, workflow)
    Manager->>Store: update/read workflow state
    Store-->>Manager: ack
    Manager-->>Action: result
    Action-->>Orchestrator: result
    Orchestrator-->>JobHandler: done
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 I hopped through events, ears alert and bright,
Templates sewn and workflows set to flight,
Jobs succeed — I nudge the orchestrator's tune,
Managers reconcile beneath the moon,
Hooray — new hops make the system light! 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.94% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The PR title 'init' is too vague and generic; it does not convey meaningful information about the changeset's primary purpose of implementing workflow creation, event handling, and end-to-end testing. Rename the title to something more descriptive, such as 'Add workflow creation and event handling infrastructure' or 'Implement workflow templates, actions, and E2E tests'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 init-workflow-e2e

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist.


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

🤖 Fix all issues with AI agents
In `@apps/workspace-engine/test/integration/opts.go`:
- Around line 1420-1427: WithWorkflowBooleanInput builds a boolean input via
c.NewBooleanWorkflowInput(wft.Id) and applies WorkflowInputOption callbacks but
never attaches the created input to the workflow template, so it should be
appended to wft.Inputs; update the function (WithWorkflowBooleanInput) to call
option(ws, input) for each option and then add the resulting input to wft.Inputs
(ensuring the type matches the slice element type on
oapi.WorkflowTemplate.Inputs) so the input is preserved in the template.
🧹 Nitpick comments (7)
apps/workspace-engine/pkg/workspace/store/workflows.go (1)

29-37: Add an exported doc comment for GetByTemplateID.

This method is exported; please add a brief doc comment that conveys intent (e.g., template-scoped lookup for workflow orchestration).

💡 Suggested doc comment
+// GetByTemplateID returns workflows keyed by ID for a given template, enabling template-scoped lookups.
 func (w *Workflows) GetByTemplateID(templateID string) map[string]*oapi.Workflow {

As per coding guidelines, “Write comments that explain why, document complex logic/algorithms, provide non-obvious context, include TODO/FIXME, and document exported functions/types/methods.”

apps/workspace-engine/pkg/events/handler/workflows/workflows.go (1)

11-38: Add doc comments for exported workflow handlers.

Both handlers are exported and should have concise doc comments explaining their intent/usage.

💡 Suggested doc comments
+// HandleWorkflowTemplateCreated upserts a workflow template from an incoming event payload.
 func HandleWorkflowTemplateCreated(
@@
+// HandleWorkflowCreated creates a workflow instance from an incoming event payload.
 func HandleWorkflowCreated(

As per coding guidelines, “Write comments that explain why, document complex logic/algorithms, provide non-obvious context, include TODO/FIXME, and document exported functions/types/methods.”

apps/workspace-engine/pkg/workspace/workflowmanager/action.go (1)

10-42: Add doc comments for exported WorkflowManagerAction APIs.

Please add brief doc comments for the exported type and its public methods to comply with workspace-engine documentation expectations.

💡 Suggested doc comments
+// WorkflowManagerAction reconciles workflows in response to workflow-related triggers.
 type WorkflowManagerAction struct {
@@
+// NewWorkflowManagerAction constructs a workflow manager action with the given store and manager.
 func NewWorkflowManagerAction(store *store.Store, manager *Manager) *WorkflowManagerAction {
@@
+// Execute runs the action for supported triggers (e.g., job success).
 func (w *WorkflowManagerAction) Execute(ctx context.Context, trigger ActionTrigger, job *oapi.Job) error {

As per coding guidelines, “Write comments that explain why, document complex logic/algorithms, provide non-obvious context, include TODO/FIXME, and document exported functions/types/methods.”

apps/workspace-engine/pkg/workspace/workflowmanager/workflow_orchestrator.go (1)

9-44: Add doc comments for the exported workflow orchestration API.
These new exported types/functions are undocumented; please add brief Go doc comments for the public surface.

As per coding guidelines: Write comments that explain why, document complex logic/algorithms, provide non-obvious context, include TODO/FIXME, and document exported functions/types/methods.

apps/workspace-engine/pkg/workspace/workspace.go (1)

80-82: Document the new exported workflow accessors.
Please add brief Go doc comments for the newly added Workflow* accessors to align with the workspace-engine comment guideline.

As per coding guidelines: Write comments that explain why, document complex logic/algorithms, provide non-obvious context, include TODO/FIXME, and document exported functions/types/methods.

Also applies to: 100-102, 184-198

apps/workspace-engine/test/integration/creators/workflow.go (1)

10-69: Add doc comments to the new workflow test creators.
These exported helpers should have brief Go doc comments for discoverability.

As per coding guidelines: Write comments that explain why, document complex logic/algorithms, provide non-obvious context, include TODO/FIXME, and document exported functions/types/methods.

apps/workspace-engine/test/integration/opts.go (1)

1329-1354: Document the new workflow option types/helpers.
Please add brief Go doc comments to the newly exported Workflow* option types and helpers.

As per coding guidelines: Write comments that explain why, document complex logic/algorithms, provide non-obvious context, include TODO/FIXME, and document exported functions/types/methods.

Also applies to: 1356-1461, 1463-1485

@adityachoudhari26 adityachoudhari26 changed the title init chore: workflows working e2e Feb 3, 2026
@adityachoudhari26 adityachoudhari26 merged commit b749288 into main Feb 3, 2026
8 checks passed
@adityachoudhari26 adityachoudhari26 deleted the init-workflow-e2e branch February 3, 2026 18:40
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.

1 participant