Skip to content

Conversation

@adityachoudhari26
Copy link
Member

@adityachoudhari26 adityachoudhari26 commented Jan 27, 2026

Summary by CodeRabbit

  • New Features
    • Added in-memory storage and CRUD support for workflows, workflow templates, workflow tasks, and workflow task templates.
  • Bug Fixes / Validation
    • WorkflowStepTemplate now requires an "id" field (schema validation updated).
  • Chores
    • Store now records upserts and deletes for workflow-related entities to improve change tracking.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

Warning

Rate limit exceeded

@adityachoudhari26 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 30 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

OpenAPI and generated Go models now require id for WorkflowStepTemplate (non-nullable). Persistence, repository registry, in-memory store, and Store wiring were extended with workflow-related entities, compaction keys, maps, and four new store wrapper types that record changesets on mutations.

Changes

Cohort / File(s) Summary
OpenAPI Schema & Generated Models
apps/workspace-engine/oapi/openapi.json, apps/workspace-engine/oapi/spec/schemas/workflows.jsonnet, apps/workspace-engine/pkg/oapi/oapi.gen.go
Added required id to WorkflowStepTemplate schema; changed Go field Id from *string (json:"id,omitempty") to string (json:"id"), removing nilability and altering JSON (un)marshalling.
Persistence Layer
apps/workspace-engine/pkg/oapi/persistence.go
Added CompactionKey() implementations for WorkflowTemplate, WorkflowStepTemplate, Workflow, and WorkflowStep.
Repository Registry & InMemoryStore
apps/workspace-engine/pkg/workspace/store/repository/entity_registry.go, apps/workspace-engine/pkg/workspace/store/repository/repo.go
Registered workflow entities in global registry; added in-memory concurrent maps for WorkflowTemplates, WorkflowStepTemplates, Workflows, WorkflowSteps; simplified indexstore.NewStore call site.
Store Wiring
apps/workspace-engine/pkg/workspace/store/store.go
Added four new public Store fields (WorkflowTemplates, WorkflowTaskTemplates, Workflows, WorkflowTasks) and initialized them in New.
Store Wrapper Types
apps/workspace-engine/pkg/workspace/store/workflow_templates.go, .../workflow_task_templates.go, .../workflows.go, .../workflow_tasks.go
New wrapper types exposing Items(), Get(), Upsert(ctx,id,...), and Remove(ctx,id) that delegate to the in-memory repo and record mutations via store.changeset.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client as Client
participant Store as Store (Workflows)
participant Repo as InMemoryRepo
participant CS as Changeset
Client->>Store: Upsert(ctx, id, workflow)
Store->>Repo: repo.Upsert(id, workflow)
Repo-->>Store: ack
Store->>CS: RecordUpsert("workflow", id)
CS-->>Store: ack
Store-->>Client: return

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • jsbroks

Poem

🐰 I hopped through schemas, neat and spry,
IDs added, no more nil to try.
Repos and stores now hum in sync,
Changesets note each upsert blink.
A rabbit cheers for workflows flying high! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 clearly summarizes the main objective: initializing workflow stores. It directly relates to the changeset which adds four new workflow store components (WorkflowTemplates, WorkflowTaskTemplates, Workflows, WorkflowTasks) and their supporting infrastructure.

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


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

🤖 Fix all issues with AI agents
In `@apps/workspace-engine/pkg/workspace/store/workflow_task_templates.go`:
- Around line 29-31: In Upsert, ensure the passed id and workflowTaskTemplate.Id
are consistent before storing: in the WorkflowTaskTemplates.Upsert function,
check the oapi.WorkflowTaskTemplate.Id and if it's empty or differs from the id
parameter, set workflowTaskTemplate.Id = id so the object used with
w.repo.WorkflowTaskTemplates.Set and w.store.changeset.RecordUpsert has a
matching Id; this normalizes stored state and prevents tracking inconsistencies.

In `@apps/workspace-engine/pkg/workspace/store/workflow_templates.go`:
- Around line 29-31: In WorkflowTemplates.Upsert, ensure the provided id and
workflowTemplate.Id stay consistent before calling w.repo.WorkflowTemplates.Set
and w.store.changeset.RecordUpsert: if workflowTemplate.Id is empty, set it to
id; if it is non-empty and differs from id, either return an error or normalize
by overwriting it with id (choose based on project convention), and validate
that the final workflowTemplate.Id is non-empty; update only after this
normalization so repo.WorkflowTemplates.Set(id, workflowTemplate) and
store.changeset.RecordUpsert(workflowTemplate) operate on a consistent object.
🧹 Nitpick comments (6)
apps/workspace-engine/pkg/workspace/store/workflow_tasks.go (2)

9-41: Add Go doc comments for exported WorkflowTasks APIs.

Please add GoDoc for NewWorkflowTasks, WorkflowTasks, and the exported methods to satisfy workspace-engine guidelines.

📌 Example GoDoc additions
+// NewWorkflowTasks constructs a workflow-task store backed by the in-memory repository.
 func NewWorkflowTasks(store *Store) *WorkflowTasks {
 	return &WorkflowTasks{
 		repo:  store.repo,
 		store: store,
 	}
 }

+// WorkflowTasks provides accessors and change-tracking for workflow tasks.
 type WorkflowTasks struct {
 	repo  *repository.InMemoryStore
 	store *Store
 }
As per coding guidelines, please document exported functions/types/methods.

29-31: Normalize Upsert to use entity's Id field consistently.

The method stores entities using the caller-supplied id parameter but RecordUpsert tracks changes using workflowTask.Id (via CompactionKey). If these diverge, the in-memory map key and persistence key become inconsistent. Align the map key with the entity's Id to ensure consistency between in-memory and persistence layers.

🔧 Suggested normalization
 func (w *WorkflowTasks) Upsert(ctx context.Context, id string, workflowTask *oapi.WorkflowTask) {
+	if workflowTask != nil && workflowTask.Id != "" {
+		id = workflowTask.Id
+	}
 	w.repo.WorkflowTasks.Set(id, workflowTask)
 	w.store.changeset.RecordUpsert(workflowTask)
 }
apps/workspace-engine/pkg/workspace/store/workflows.go (2)

9-41: Add Go doc comments for exported Workflows APIs.

Please add GoDoc for NewWorkflows, Workflows, and the exported methods to satisfy workspace-engine guidelines.

📌 Example GoDoc additions
+// NewWorkflows constructs a workflow store backed by the in-memory repository.
 func NewWorkflows(store *Store) *Workflows {
 	return &Workflows{
 		repo:  store.repo,
 		store: store,
 	}
 }

+// Workflows provides accessors and change-tracking for workflows.
 type Workflows struct {
 	repo  *repository.InMemoryStore
 	store *Store
 }
As per coding guidelines, please document exported functions/types/methods.

29-31: Normalize upsert key to workflow.Id to prevent in-memory and persistence key drift.

Set(id, workflow) uses the caller-supplied id parameter, while RecordUpsert(workflow) uses workflow.CompactionKey() which returns workflow.Id. If these diverge, the in-memory cache key and persistence entity key will mismatch. Normalize to use workflow.Id consistently:

🔧 Suggested fix
 func (w *Workflows) Upsert(ctx context.Context, id string, workflow *oapi.Workflow) {
+	if workflow != nil && workflow.Id != "" {
+		id = workflow.Id
+	}
 	w.repo.Workflows.Set(id, workflow)
 	w.store.changeset.RecordUpsert(workflow)
 }
apps/workspace-engine/pkg/workspace/store/workflow_task_templates.go (1)

9-19: Add Go doc comments for exported symbols.

Constructor and type are exported but undocumented. As per coding guidelines, please add Go doc comments for NewWorkflowTaskTemplates and WorkflowTaskTemplates (and ideally its exported methods) to satisfy the workspace-engine docs requirement.

As per coding guidelines, please document exported functions/types/methods.

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

9-19: Add Go doc comments for exported symbols.

Constructor and type are exported but undocumented. As per coding guidelines, please add Go doc comments for NewWorkflowTemplates and WorkflowTemplates (and ideally its exported methods) to satisfy the workspace-engine docs requirement.

As per coding guidelines, please document exported functions/types/methods.

Comment on lines 29 to 31
func (w *WorkflowTaskTemplates) Upsert(ctx context.Context, id string, workflowTaskTemplate *oapi.WorkflowTaskTemplate) {
w.repo.WorkflowTaskTemplates.Set(id, workflowTaskTemplate)
w.store.changeset.RecordUpsert(workflowTaskTemplate)
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

Enforce idworkflowTaskTemplate.Id consistency in Upsert.

With WorkflowTaskTemplate.Id now required, storing by id while allowing a mismatched or empty workflowTaskTemplate.Id can create inconsistent state and break change tracking. Normalize or validate before storing.

🛠️ Suggested fix
 func (w *WorkflowTaskTemplates) Upsert(ctx context.Context, id string, workflowTaskTemplate *oapi.WorkflowTaskTemplate) {
+	if workflowTaskTemplate == nil {
+		return
+	}
+	if workflowTaskTemplate.Id != "" && workflowTaskTemplate.Id != id {
+		workflowTaskTemplate.Id = id
+	} else if workflowTaskTemplate.Id == "" {
+		workflowTaskTemplate.Id = id
+	}
 	w.repo.WorkflowTaskTemplates.Set(id, workflowTaskTemplate)
 	w.store.changeset.RecordUpsert(workflowTaskTemplate)
 }
🤖 Prompt for AI Agents
In `@apps/workspace-engine/pkg/workspace/store/workflow_task_templates.go` around
lines 29 - 31, In Upsert, ensure the passed id and workflowTaskTemplate.Id are
consistent before storing: in the WorkflowTaskTemplates.Upsert function, check
the oapi.WorkflowTaskTemplate.Id and if it's empty or differs from the id
parameter, set workflowTaskTemplate.Id = id so the object used with
w.repo.WorkflowTaskTemplates.Set and w.store.changeset.RecordUpsert has a
matching Id; this normalizes stored state and prevents tracking inconsistencies.

Comment on lines 29 to 31
func (w *WorkflowTemplates) Upsert(ctx context.Context, id string, workflowTemplate *oapi.WorkflowTemplate) {
w.repo.WorkflowTemplates.Set(id, workflowTemplate)
w.store.changeset.RecordUpsert(workflowTemplate)
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

Enforce idworkflowTemplate.Id consistency in Upsert.

With WorkflowTemplate.Id required, storing by id while allowing a mismatched or empty workflowTemplate.Id can create inconsistent state and break change tracking. Normalize or validate before storing.

🛠️ Suggested fix
 func (w *WorkflowTemplates) Upsert(ctx context.Context, id string, workflowTemplate *oapi.WorkflowTemplate) {
+	if workflowTemplate == nil {
+		return
+	}
+	if workflowTemplate.Id != "" && workflowTemplate.Id != id {
+		workflowTemplate.Id = id
+	} else if workflowTemplate.Id == "" {
+		workflowTemplate.Id = id
+	}
 	w.repo.WorkflowTemplates.Set(id, workflowTemplate)
 	w.store.changeset.RecordUpsert(workflowTemplate)
 }
📝 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 (w *WorkflowTemplates) Upsert(ctx context.Context, id string, workflowTemplate *oapi.WorkflowTemplate) {
w.repo.WorkflowTemplates.Set(id, workflowTemplate)
w.store.changeset.RecordUpsert(workflowTemplate)
func (w *WorkflowTemplates) Upsert(ctx context.Context, id string, workflowTemplate *oapi.WorkflowTemplate) {
if workflowTemplate == nil {
return
}
if workflowTemplate.Id != "" && workflowTemplate.Id != id {
workflowTemplate.Id = id
} else if workflowTemplate.Id == "" {
workflowTemplate.Id = id
}
w.repo.WorkflowTemplates.Set(id, workflowTemplate)
w.store.changeset.RecordUpsert(workflowTemplate)
}
🤖 Prompt for AI Agents
In `@apps/workspace-engine/pkg/workspace/store/workflow_templates.go` around lines
29 - 31, In WorkflowTemplates.Upsert, ensure the provided id and
workflowTemplate.Id stay consistent before calling w.repo.WorkflowTemplates.Set
and w.store.changeset.RecordUpsert: if workflowTemplate.Id is empty, set it to
id; if it is non-empty and differs from id, either return an error or normalize
by overwriting it with id (choose based on project convention), and validate
that the final workflowTemplate.Id is non-empty; update only after this
normalization so repo.WorkflowTemplates.Set(id, workflowTemplate) and
store.changeset.RecordUpsert(workflowTemplate) operate on a consistent object.

WorkflowTaskTemplate: {
type: 'object',
required: ['name', 'jobAgent'],
required: ['id', 'name', 'jobAgent'],
Copy link
Member

Choose a reason for hiding this comment

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

a template doesn't need an id

Copy link
Member

Choose a reason for hiding this comment

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

follow github patterns, you dont provide an id to the steps

Copy link
Member Author

Choose a reason for hiding this comment

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

after discussion - id is internal, later we will add referenceId which will be "id" in the yaml

@adityachoudhari26 adityachoudhari26 merged commit c5d7b22 into main Jan 27, 2026
9 checks passed
@adityachoudhari26 adityachoudhari26 deleted the init-workflow-store branch January 27, 2026 18:21
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