Implement workflow compiler plugin with code analysis and modification features#8
Conversation
…ntation - Created build.gradle for the Ballerina workflow module, including tasks for updating TOML files and committing changes. - Implemented placeholder function `getInfo` in functions.bal for the workflow module. - Added unit tests for the `getInfo` function in test.bal. - Introduced Checkstyle configuration in build-config/checkstyle/build.gradle for code quality checks. - Created Ballerina.toml and CompilerPlugin.toml files for package metadata and compiler plugin configuration. - Established a multi-project Gradle setup with separate modules for workflow-native, workflow-compiler-plugin, and their tests. - Developed the WorkflowCompilerPlugin class with initialization logic for the compiler plugin. - Implemented a native Java class WorkflowNative with a placeholder method for native functionality. - Added Gradle wrapper files for consistent build environment setup. - Configured dependencies and publishing settings for the workflow module and its components. - Included SpotBugs and Checkstyle configurations to maintain code quality across the project. - Created an exclusion file for SpotBugs to ignore specific patterns and test files.
…n features - Add WorkflowCodeAnalyzer for validating @process and @activity function signatures. - Introduce WorkflowCodeModifier to transform workflow process functions and register them. - Create WorkflowCompilerPlugin to integrate the analyzer and modifier into the compilation process. - Define WorkflowConstants for shared constants used across the plugin. - Implement WorkflowModifierContext to hold information about process modifications. - Develop WorkflowSourceModifier to handle AST transformations for process functions. - Add WorkflowValidatorTask for validating function signatures based on workflow semantics. - Create ModuleUtils for managing workflow module information. - Enhance ProcessRegistry to track activities associated with processes. - Implement native functions in WorkflowNative for registering processes and retrieving registered workflows. - Add functionality to clear the registry for testing purposes.
There was a problem hiding this comment.
Pull request overview
Introduces initial “workflow” module scaffolding including a Ballerina compiler plugin, native runtime stubs, Gradle build infrastructure, and CI workflows to enable basic workflow/process/activity registration and validation.
Changes:
- Added Java-native runtime + registries and Ballerina APIs/annotations for workflow orchestration and registry introspection.
- Added compiler plugin analyzer/modifier to validate
@Process/@Activitysignatures and rewrite activity calls / inject process registration. - Added Gradle multi-module build setup, wrapper, and CI workflows (PR build, release publish, Trivy, GraalVM checks).
Reviewed changes
Copilot reviewed 60 out of 63 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| spotbugs-exclude.xml | SpotBugs suppressions for the new modules. |
| settings.gradle | Defines multi-project Gradle structure and plugin management. |
| native/src/main/java/io/ballerina/stdlib/workflow/utils/TypesUtil.java | Ballerina↔Java type conversion helpers. |
| native/src/main/java/io/ballerina/stdlib/workflow/runtime/nativeimpl/WorkflowNative.java | Native entrypoints backing Ballerina workflow functions. |
| native/src/main/java/io/ballerina/stdlib/workflow/runtime/WorkflowRuntime.java | Placeholder workflow runtime/executor and API stubs. |
| native/src/main/java/io/ballerina/stdlib/workflow/registry/ProcessRegistry.java | In-memory process registry + process metadata. |
| native/src/main/java/io/ballerina/stdlib/workflow/registry/ActivityRegistry.java | In-memory activity registry. |
| native/src/main/java/io/ballerina/stdlib/workflow/ModuleUtils.java | Captures module reference for native record creation. |
| native/build.gradle | Native module build configuration and deps (incl. Temporal). |
| gradlew.bat | Gradle wrapper script (Windows). |
| gradlew | Gradle wrapper script (POSIX). |
| gradle/wrapper/gradle-wrapper.properties | Gradle wrapper distribution configuration. |
| gradle/wrapper/gradle-wrapper.jar | Gradle wrapper binary. |
| gradle.properties | Centralized version + plugin property definitions. |
| compiler-plugin/src/main/java/io/ballerina/stdlib/workflow/compiler/WorkflowValidatorTask.java | Compiler-plugin validation of @Process/@Activity signatures. |
| compiler-plugin/src/main/java/io/ballerina/stdlib/workflow/compiler/WorkflowSourceModifier.java | AST rewrite for activity calls + inject process registration. |
| compiler-plugin/src/main/java/io/ballerina/stdlib/workflow/compiler/WorkflowModifierContext.java | Tracks process/activity info per document. |
| compiler-plugin/src/main/java/io/ballerina/stdlib/workflow/compiler/WorkflowConstants.java | Shared constants and diagnostic messages/codes. |
| compiler-plugin/src/main/java/io/ballerina/stdlib/workflow/compiler/WorkflowCompilerPlugin.java | Compiler plugin entrypoint wiring analyzer + modifier. |
| compiler-plugin/src/main/java/io/ballerina/stdlib/workflow/compiler/WorkflowCodeModifier.java | Registers analysis/modification tasks for transformations. |
| compiler-plugin/src/main/java/io/ballerina/stdlib/workflow/compiler/WorkflowCodeAnalyzer.java | Registers validation task. |
| compiler-plugin/src/main/java/io/ballerina/stdlib/workflow/compiler/ProcessFunctionInfo.java | Stores per-process activity call metadata. |
| compiler-plugin/src/main/java/io/ballerina/stdlib/workflow/compiler/ProcessFunctionAnalysisTask.java | Collects @Process and referenced @Activity calls. |
| compiler-plugin/spotbugs-exclude.xml | SpotBugs suppressions specific to compiler plugin. |
| compiler-plugin/build.gradle | Compiler plugin build configuration. |
| compiler-plugin-tests/src/test/resources/testng.xml | TestNG suite configuration for plugin tests. |
| compiler-plugin-tests/src/test/resources/ballerina_sources/valid_process_with_context/main.bal | Sample validating Context usage in @Process. |
| compiler-plugin-tests/src/test/resources/ballerina_sources/valid_process_with_context/Ballerina.toml | Sample package metadata for Context test. |
| compiler-plugin-tests/src/test/resources/ballerina_sources/valid_process_with_activities/main.bal | Sample with activities invoked from process. |
| compiler-plugin-tests/src/test/resources/ballerina_sources/valid_process_with_activities/Ballerina.toml | Sample package metadata for activity test. |
| compiler-plugin-tests/src/test/resources/ballerina_sources/process_no_activities/main.bal | Sample process without activities. |
| compiler-plugin-tests/src/test/resources/ballerina_sources/process_no_activities/Ballerina.toml | Sample package metadata for no-activity test. |
| compiler-plugin-tests/src/test/resources/ballerina_sources/multiple_processes/main.bal | Sample package with multiple processes + shared activities. |
| compiler-plugin-tests/src/test/resources/ballerina_sources/multiple_processes/Ballerina.toml | Sample package metadata for multi-process test. |
| compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_activity_return/main.bal | Negative sample for invalid activity return type. |
| compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_activity_return/Ballerina.toml | Sample package metadata for invalid return test. |
| compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_activity_param/main.bal | Negative sample for invalid activity param type. |
| compiler-plugin-tests/src/test/resources/ballerina_sources/invalid_activity_param/Ballerina.toml | Sample package metadata for invalid param test. |
| compiler-plugin-tests/src/test/java/io/ballerina/stdlib/workflow/compiler/WorkflowCompilerPluginTest.java | Test harness for plugin validation and modification. |
| compiler-plugin-tests/build.gradle | Test module build config incl. JaCoCo/TestNG. |
| codecov.yml | Codecov reporting configuration. |
| changelog.md | Initial changelog stub. |
| build.gradle | Root Gradle configuration + build/release orchestration. |
| build-config/resources/CompilerPlugin.toml | Template for generating module CompilerPlugin.toml. |
| build-config/resources/Ballerina.toml | Template for generating module Ballerina.toml. |
| build-config/checkstyle/build.gradle | Downloads shared WSO2 checkstyle rules. |
| ballerina/types.bal | Public workflow types (Context, registry records). |
| ballerina/tests/test.bal | Ballerina-level tests for registry functions. |
| ballerina/functions.bal | Public workflow functions (native interop wrappers). |
| ballerina/build.gradle | Ballerina package build/publish configuration + TOML generation. |
| ballerina/annotations.bal | Defines @Process and @Activity annotations. |
| ballerina/README.md | Minimal module README. |
| ballerina/CompilerPlugin.toml | Module compiler plugin config (generated artifact path). |
| ballerina/Ballerina.toml | Module package metadata + native dependency. |
| .gitignore | Ignore rules updated for Gradle/IDE/Ballerina artifacts. |
| .github/workflows/trivy-scan.yml | Scheduled/manual Trivy scanning workflow. |
| .github/workflows/pull-request.yml | PR validation workflow configuration. |
| .github/workflows/publish-release.yml | Release publish workflow wiring. |
| .github/workflows/central-publish.yml | Central publish workflow wiring. |
| .github/workflows/build-with-bal-test-graalvm.yml | GraalVM compatibility workflow wiring. |
| .github/workflows/build-timestamped-master.yml | Main branch build workflow wiring. |
| .github/CODEOWNERS | Repository ownership rules. |
| .gitattributes | Enforces LF endings for Java sources. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 66 out of 69 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…rgument transformation in workflow source modifier
…rgument transformation in workflow source modifier
Co-authored-by: Dulmina Renuke <[email protected]>
| * Validates @Process function signature according to Agent.md semantics. | ||
| * <ul> | ||
| * <li>Optional first parameter: workflow:Context</li> | ||
| * <li>Required input parameter: subtype of anydata</li> |
There was a problem hiding this comment.
Why this is required?. It's a valid case that the workflow does not require any input, right?
There was a problem hiding this comment.
We can't derive the correlation without an input. In one of the discussions, we decided to drop the no-correlation concept.
Fixes #ballerina-platform/ballerina-library#8449
This pull request introduces the initial setup for the Ballerina Workflow module, including core workflow APIs, annotations, configuration, and CI/CD automation. The changes establish the foundation for workflow orchestration, registration, and activity execution, along with supporting infrastructure for building, testing, and publishing the module.
Module Implementation and APIs:
callActivity,startProcess,sendEvent,registerProcess,getRegisteredWorkflows, andclearRegistryfunctions infunctions.balfor workflow orchestration and management.@Processand@Activityannotations inannotations.balto mark workflow process and activity functions.README.mddescribing the purpose of the workflow library.Configuration and Build System:
Ballerina.tomlandCompilerPlugin.tomlfor package metadata and compiler plugin configuration. [1] [2]build.gradleto automate building, testing, and publishing the module, including updating TOML files and handling dependencies.Testing:
tests/test.balto verify process and activity registration, registry introspection, and clearing functionality.CI/CD and Repository Management:
.gitattributesto enforce LF line endings for Java files..github/CODEOWNERSto specify repository owners.