Skip to content

Activity Contracts for Workflow Orchestrator#360

Merged
hjmeesho merged 1 commit intodevelopfrom
feat/WO-activity-contracts
Mar 30, 2026
Merged

Activity Contracts for Workflow Orchestrator#360
hjmeesho merged 1 commit intodevelopfrom
feat/WO-activity-contracts

Conversation

@hjmeesho
Copy link
Copy Markdown
Contributor

@hjmeesho hjmeesho commented Mar 30, 2026

What type of PR is this?

  • 🍕 Feature
  • 🐛 Bug Fix
  • ⚙️ Config Change
  • 📄 Template Change
  • 📝 CHANGELOG/README Update
  • 🎨 Linting
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🔁 Version Bump
  • ⏩ Revert

Description

PR Description
Adding a small Go Project which is used by workflow-orchestrator and activities.

Added tests

  • 👍 Yes
  • 🙅 No
  • 🙋 Need Help!

Key Requirement Doc

  • H0
  • H1
  • H2
  • KRD is not required for this change

Why is KRD not required?
Just model changes, which needs to be released

Downstream Impact

  • No downstream impact

Additional Information

Updated by ReadyToReviewBot for @hjmeesho · Edit form

@readytoreview
Copy link
Copy Markdown

readytoreview bot commented Mar 30, 2026

PR Validation Passed

PR description validation passed

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Walkthrough

A new activity contracts Go package is introduced, defining shared types for the activity system including global output mappings, standardized activity inputs and outputs, and a common activity function signature. Module configuration is established for the new package.

Changes

Cohort / File(s) Summary
Activity Contract Types
core/activity-contracts/activity/activity.go
Introduces GlobalActivityOutputs map type for tracking prior action outputs; defines ActivityInput struct with action metadata, parameters, execution identifiers, and version info; defines ActivityOutput struct with result map and error field; declares ActivityFunc function type signature accepting context, global outputs, and activity input.
Module Configuration
core/activity-contracts/go.mod
Establishes new Go module github.com/Meesho/BharatMLStack/core/activity-contracts with toolchain version 1.25.6.
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Dynamic Configuration Validation ✅ Passed No dynamic configuration files matching application-dyn-*.yml pattern were modified in this PR.

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


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

Copy link
Copy Markdown

@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.

🧹 Nitpick comments (1)
core/activity-contracts/activity/activity.go (1)

22-27: Clarify precedence between ActivityOutput.Error and returned error.

Lines 22-27 currently expose two error channels. Please define one canonical behavior to avoid inconsistent handling across activities and orchestrator paths.

Proposed contract clarification
 type ActivityOutput struct {
 	Result map[string]interface{} `json:"result,omitempty"`
-	Error  string                 `json:"error,omitempty"`
+	// Error is for domain/business failures that should be serialized in workflow state.
+	// Runtime/infrastructure failures should be returned from ActivityFunc as a non-nil error.
+	Error  string                 `json:"error,omitempty"`
 }
 
 // ActivityFunc is the function signature that every registered activity must implement.
+// Return non-nil error only for runtime/execution failures.
 type ActivityFunc func(ctx context.Context, globalOutputs GlobalActivityOutputs, input ActivityInput) (ActivityOutput, error)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@core/activity-contracts/activity/activity.go` around lines 22 - 27, Define a
single canonical error precedence: treat the error value returned by
ActivityFunc as authoritative for control flow and orchestration, and treat
ActivityOutput.Error only as an optional, informational field for result
payloads; update all callers (the orchestrator and any executor) to check the
returned error from ActivityFunc first and only inspect ActivityOutput.Error if
the returned error is nil, and update comments/docs on the ActivityOutput struct
and the ActivityFunc type to state this precedence so implementers know to
return an error for control/failure and only set ActivityOutput.Error for
non-fatal, descriptive result information.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@core/activity-contracts/activity/activity.go`:
- Around line 22-27: Define a single canonical error precedence: treat the error
value returned by ActivityFunc as authoritative for control flow and
orchestration, and treat ActivityOutput.Error only as an optional, informational
field for result payloads; update all callers (the orchestrator and any
executor) to check the returned error from ActivityFunc first and only inspect
ActivityOutput.Error if the returned error is nil, and update comments/docs on
the ActivityOutput struct and the ActivityFunc type to state this precedence so
implementers know to return an error for control/failure and only set
ActivityOutput.Error for non-fatal, descriptive result information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0ede72fd-5da4-4b1a-a91d-848215d0bebd

📥 Commits

Reviewing files that changed from the base of the PR and between 719e1f6 and 49a82de.

📒 Files selected for processing (2)
  • core/activity-contracts/activity/activity.go
  • core/activity-contracts/go.mod

@hjmeesho hjmeesho merged commit 4cf17af into develop Mar 30, 2026
10 checks passed
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