Skip to content

feat(plugin): add validators and custom step types (C069)#285

Merged
pocky merged 1 commit intomainfrom
issue/280-c069-plugin-extensibility--validators--c
Mar 29, 2026
Merged

feat(plugin): add validators and custom step types (C069)#285
pocky merged 1 commit intomainfrom
issue/280-c069-plugin-extensibility--validators--c

Conversation

@pocky
Copy link
Copy Markdown
Contributor

@pocky pocky commented Mar 29, 2026

Summary

  • Adds two new plugin capability types: workflow validators (enforce custom validation rules during awf validate) and custom step types (execute new step kinds defined by plugins)
  • Introduces ValidatorService and StepTypeService gRPC services with corresponding domain ports (WorkflowValidatorProvider, StepTypeProvider) so third-party plugins can extend the workflow engine without touching core code
  • Adds --skip-plugins and --validator-timeout CLI flags to awf run and awf validate, and new --step-types / --validators flags to awf plugin list for capability inspection
  • Ships two production-quality example plugins (awf-plugin-database, awf-plugin-security-validator) demonstrating both capabilities end-to-end

Changes

Protocol Buffers

  • proto/plugin/v1/plugin.proto: Add ValidatorService and StepTypeService with RegisterStepType, ValidateStepConfig, ValidateWorkflow RPC methods
  • proto/plugin/v1/plugin.pb.go: Regenerated protobuf types
  • proto/plugin/v1/plugin_grpc.pb.go: Regenerated gRPC stubs
  • proto/plugin/v1/plugin_test.go: Tests for new proto messages

Domain

  • internal/domain/ports/plugin_validator.go: New WorkflowValidatorProvider and StepTypeProvider port interfaces
  • internal/domain/ports/plugin_validator_test.go: Tests for port interfaces and error types
  • internal/domain/workflow/step.go: Add Config map[string]any field for plugin step configuration
  • internal/domain/workflow/context.go: Extend execution context with plugin step data
  • internal/domain/workflow/conversation.go: Minor additions for plugin step support
  • internal/domain/workflow/workflow.go: Register StepTypeChecker for plugin-defined step type validation
  • internal/domain/pluginmodel/info.go: Add StepTypes []string field to PluginInfo
  • internal/domain/pluginmodel/manifest.go: Update CapabilityStepTypes (breaking rename from CapabilityCommands)

Application

  • internal/application/execution_service.go: Invoke validator plugins during workflow loading; route plugin step types to their provider at execution time
  • internal/application/service.go: Wire ValidatorProvider and StepTypeProvider into the service; expose SetValidatorProvider / SetStepTypeProvider setters

Infrastructure — Plugin Manager

  • internal/infrastructure/pluginmgr/grpc_validator.go: gRPC adapter implementing WorkflowValidatorProvider via ValidatorService RPC
  • internal/infrastructure/pluginmgr/grpc_step_type.go: gRPC adapter implementing StepTypeProvider via StepTypeService RPC
  • internal/infrastructure/pluginmgr/rpc_manager.go: Register and expose validator/step-type adapters per plugin; populate StepTypes on PluginInfo; multi-directory plugin discovery
  • internal/infrastructure/pluginmgr/loader.go: Set Type field on loaded plugins

Infrastructure — Repository

  • internal/infrastructure/repository/yaml_mapper.go: Map config: block from YAML step to Step.Config
  • internal/infrastructure/repository/yaml_types.go: Add Config field to yamlStep

CLI

  • internal/interfaces/cli/run.go: Wire --skip-plugins and --validator-timeout flags; register validator/step-type providers into ExecutionService
  • internal/interfaces/cli/validate.go: Wire --skip-plugins into validation path
  • internal/interfaces/cli/plugin_cmd.go: Add --step-types and --validators flags to awf plugin list; display capability columns
  • internal/interfaces/cli/plugins.go: Update plugin list rendering to support new capability columns
  • internal/interfaces/cli/config.go: Restrict AWF_PLUGINS_PATH env var to exclusive override

CLI UI

  • internal/interfaces/cli/ui/output.go: Add PrintStepTypes and PrintValidators table renderers

Plugin SDK

  • pkg/plugin/sdk/validator.go: SDK helpers for implementing ValidatorProvider in plugin binaries
  • pkg/plugin/sdk/step_type.go: SDK helpers for implementing StepTypeProvider in plugin binaries
  • pkg/plugin/sdk/grpc_plugin.go: Register validator and step-type gRPC servers in Serve()

Interpolation

  • pkg/interpolation/resolver.go: Expose step Config map to template resolver

Example Plugins

  • examples/plugins/awf-plugin-database/: New plugin implementing SQL query step type with connection pooling
  • examples/plugins/awf-plugin-security-validator/: New plugin implementing validator that blocks hardcoded secrets and dangerous commands
  • examples/plugins/awf-plugin-echo/main.go, main_test.go, README.md, plugin.yaml: Simplified to use BasePlugin defaults (remove redundant Name/Version overrides)

Tests

  • internal/application/service_plugin_step_type_test.go: Tests for step-type routing in ExecutionService
  • internal/application/service_plugin_validator_test.go: Tests for validator invocation in ExecutionService
  • internal/infrastructure/pluginmgr/grpc_step_type_test.go: Unit tests for gRPC step-type adapter
  • internal/infrastructure/pluginmgr/grpc_validator_test.go: Unit tests for gRPC validator adapter
  • internal/infrastructure/pluginmgr/rpc_manager_test.go: Updated for multi-directory discovery and new capability queries
  • internal/infrastructure/repository/yaml_mapper_config_test.go: Tests for Config field YAML mapping
  • internal/infrastructure/repository/yaml_types_config_test.go: Tests for yamlStep.Config parsing
  • internal/interfaces/cli/run_plugin_provider_wiring_test.go: Tests verifying validator/step-type providers are wired into the run command
  • internal/interfaces/cli/run_skip_plugins_test.go: Tests for --skip-plugins behaviour
  • internal/interfaces/cli/validate_skip_plugins_test.go: Tests for --skip-plugins in validate command
  • internal/interfaces/cli/arch_lint_config_test.go: Architecture lint rules for new packages
  • internal/interfaces/cli/plugin_cmd_test.go, plugins_test.go, plugins_internal_test.go, ui/output_test.go: Updated for new flags and renderers
  • internal/domain/workflow/step_config_test.go, step_type_checker_test.go, workflow_plugins_test.go: New domain-level tests
  • internal/domain/workflow/context_test.go, conversation_test.go: Extended tests
  • pkg/plugin/sdk/validator_test.go, step_type_test.go: SDK unit tests
  • examples/plugins/awf-plugin-database/main_test.go, awf-plugin-security-validator/main_test.go: Example plugin unit tests
  • pkg/interpolation/resolver_data_test.go: Tests for Config map exposure
  • internal/testutil/fixtures/fixtures_test.go: Updated fixture tests
  • tests/integration/plugins/plugin_test.go, plugin_validation_manifest_test.go: Updated integration tests

Documentation & Config

  • docs/user-guide/plugins.md: Document validator and step-type plugin capabilities with SDK usage examples
  • docs/user-guide/workflow-syntax.md: Document config: block on plugin step types
  • docs/user-guide/commands.md: Document --skip-plugins, --validator-timeout, --step-types, --validators flags
  • CHANGELOG.md: Entry for C069
  • README.md, docs/README.md: Update feature list
  • tests/fixtures/plugins/valid-full/plugin.yaml: Update fixture for renamed capability_step_types

Test plan

  • go test ./internal/... ./pkg/... ./examples/... — all unit tests pass
  • Build and install the security-validator example plugin, run awf validate on a workflow containing hardcoded secrets, confirm validation errors are reported
  • Define a custom step type in the database plugin, reference it in a workflow YAML with a config: block, run awf run and confirm the plugin step executes
  • Run awf plugin list --step-types --validators and confirm capability columns populate for loaded plugins; run with --skip-plugins and confirm plugins are bypassed

Closes #280


Generated with awf commit workflow

- `CHANGELOG.md`: Document C069 plugin extensibility feature
- `README.md`: Update feature list with validator and step type capabilities
- `docs/README.md`: Update docs index for new plugin capabilities
- `docs/user-guide/commands.md`: Add --skip-plugins and --validator-timeout flag docs
- `docs/user-guide/plugins.md`: Add validator and step_type plugin authoring guide
- `docs/user-guide/workflow-syntax.md`: Add custom step type syntax documentation
- `examples/plugins/awf-plugin-database/Makefile`: Add build targets for database plugin
- `examples/plugins/awf-plugin-database/README.md`: Document database plugin example
- `examples/plugins/awf-plugin-database/main.go`: Implement database step type plugin
- `examples/plugins/awf-plugin-database/main_test.go`: Add tests for database plugin
- `examples/plugins/awf-plugin-database/plugin.yaml`: Add database plugin manifest
- `examples/plugins/awf-plugin-echo/README.md`: Update echo plugin docs for BasePlugin pattern
- `examples/plugins/awf-plugin-echo/main.go`: Remove redundant Name/Version method overrides
- `examples/plugins/awf-plugin-echo/main_test.go`: Fix tests to initialize BasePlugin fields
- `examples/plugins/awf-plugin-echo/plugin.yaml`: Update manifest with step_types capability
- `examples/plugins/awf-plugin-security-validator/Makefile`: Add build targets for security plugin
- `examples/plugins/awf-plugin-security-validator/README.md`: Document security validator plugin
- `examples/plugins/awf-plugin-security-validator/main.go`: Implement security validator plugin
- `examples/plugins/awf-plugin-security-validator/main_test.go`: Add tests for security validator
- `examples/plugins/awf-plugin-security-validator/plugin.yaml`: Add security validator manifest
- `internal/application/execution_service.go`: Wire step type provider for custom step execution
- `internal/application/plugin_operation_test.go`: Update test for renamed capability field
- `internal/application/service.go`: Inject validator and step type providers into service
- `internal/application/service_plugin_step_type_test.go`: Add tests for step type provider wiring
- `internal/application/service_plugin_validator_test.go`: Add tests for validator provider wiring
- `internal/domain/pluginmodel/info.go`: Add StepTypes field to PluginInfo
- `internal/domain/pluginmodel/manifest.go`: Rename CapabilityCommands to CapabilityStepTypes
- `internal/domain/pluginmodel/manifest_test.go`: Update manifest tests for renamed capability
- `internal/domain/ports/plugin_validator.go`: Add WorkflowValidatorProvider port interface
- `internal/domain/ports/plugin_validator_test.go`: Add tests for validator port interface
- `internal/domain/workflow/context.go`: Add plugin step type data to execution context
- `internal/domain/workflow/context_test.go`: Add context tests for plugin step type data
- `internal/domain/workflow/conversation.go`: Add step type awareness to conversation steps
- `internal/domain/workflow/conversation_test.go`: Add conversation step type tests
- `internal/domain/workflow/doc.go`: Update package documentation
- `internal/domain/workflow/step.go`: Add Config field and step type checker support
- `internal/domain/workflow/step_agent_test.go`: Update step tests for Config field
- `internal/domain/workflow/step_command_test.go`: Update command step tests
- `internal/domain/workflow/step_config_test.go`: Add tests for step Config field parsing
- `internal/domain/workflow/step_loop_test.go`: Update loop step tests
- `internal/domain/workflow/step_message_test.go`: Update message step tests
- `internal/domain/workflow/step_script_file_test.go`: Update script file step tests
- `internal/domain/workflow/step_type_checker_test.go`: Add StepTypeChecker function tests
- `internal/domain/workflow/workflow.go`: Add plugin alias resolution and step type validation
- `internal/domain/workflow/workflow_plugins_test.go`: Add plugin alias functionality tests
- `internal/domain/workflow/workflow_test.go`: Update workflow tests for new fields
- `internal/domain/workflow/workflow_validate_test.go`: Update validation tests
- `internal/infrastructure/pluginmgr/grpc_step_type.go`: Add gRPC step type adapter
- `internal/infrastructure/pluginmgr/grpc_step_type_test.go`: Add gRPC step type adapter tests
- `internal/infrastructure/pluginmgr/grpc_validator.go`: Add gRPC validator adapter
- `internal/infrastructure/pluginmgr/grpc_validator_test.go`: Add gRPC validator adapter tests
- `internal/infrastructure/pluginmgr/loader.go`: Set Type field on loaded plugins
- `internal/infrastructure/pluginmgr/loader_test.go`: Update loader tests
- `internal/infrastructure/pluginmgr/manifest_parser_test.go`: Update manifest parser tests
- `internal/infrastructure/pluginmgr/rpc_manager.go`: Add multi-directory discovery and step type querying
- `internal/infrastructure/pluginmgr/rpc_manager_test.go`: Update RPC manager tests for new capabilities
- `internal/infrastructure/repository/yaml_mapper.go`: Add Config field mapping for custom steps
- `internal/infrastructure/repository/yaml_mapper_config_test.go`: Add Config mapping tests
- `internal/infrastructure/repository/yaml_repository.go`: Update repository for config field
- `internal/infrastructure/repository/yaml_types.go`: Add Config field to YAML step type
- `internal/infrastructure/repository/yaml_types_config_test.go`: Add YAML config type tests
- `internal/interfaces/cli/arch_lint_config_test.go`: Add arch lint tests for new provider wiring
- `internal/interfaces/cli/config.go`: Make AWF_PLUGINS_PATH exclusive for test isolation
- `internal/interfaces/cli/plugin_cmd.go`: Add step type and validator display to plugin list
- `internal/interfaces/cli/plugin_cmd_test.go`: Update plugin command tests
- `internal/interfaces/cli/plugins.go`: Update plugin list output for new capabilities
- `internal/interfaces/cli/plugins_internal_test.go`: Update internal plugin tests
- `internal/interfaces/cli/plugins_test.go`: Update plugin list tests
- `internal/interfaces/cli/run.go`: Wire validator and step type providers in run command
- `internal/interfaces/cli/run_plugin_provider_wiring_test.go`: Add provider wiring tests
- `internal/interfaces/cli/run_skip_plugins_test.go`: Add --skip-plugins flag tests
- `internal/interfaces/cli/ui/output.go`: Add step type and validator output rendering
- `internal/interfaces/cli/ui/output_test.go`: Add output rendering tests
- `internal/interfaces/cli/validate.go`: Add --skip-plugins and --validator-timeout flags
- `internal/interfaces/cli/validate_skip_plugins_test.go`: Add skip plugins validation tests
- `internal/testutil/fixtures/fixtures_test.go`: Update fixture tests
- `pkg/interpolation/resolver.go`: Add plugin step type data resolution
- `pkg/interpolation/resolver_data_test.go`: Add resolver data tests
- `pkg/plugin/sdk/grpc_plugin.go`: Register validator and step type services in SDK
- `pkg/plugin/sdk/step_type.go`: Add StepTypeHandler SDK interface and helpers
- `pkg/plugin/sdk/step_type_test.go`: Add step type SDK tests
- `pkg/plugin/sdk/validator.go`: Add ValidatorHandler SDK interface and helpers
- `pkg/plugin/sdk/validator_test.go`: Add validator SDK tests
- `proto/plugin/v1/plugin.pb.go`: Add ValidatorService and StepTypeService protobuf messages
- `proto/plugin/v1/plugin.proto`: Define ValidatorService and StepTypeService gRPC services
- `proto/plugin/v1/plugin_grpc.pb.go`: Add generated gRPC service stubs
- `proto/plugin/v1/plugin_test.go`: Add proto tests for new services
- `tests/fixtures/plugins/valid-full/plugin.yaml`: Update fixture for renamed capability field
- `tests/integration/plugins/plugin_test.go`: Update plugin integration tests
- `tests/integration/plugins/plugin_validation_manifest_test.go`: Update manifest validation tests

Closes #280
@pocky pocky marked this pull request as ready for review March 29, 2026 21:10
@pocky pocky merged commit 4160dcf into main Mar 29, 2026
5 checks passed
@pocky pocky deleted the issue/280-c069-plugin-extensibility--validators--c branch March 29, 2026 21:10
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.

C069: Plugin Extensibility — Validators & Custom Step Types

1 participant