Skip to content

feat: add step.statemachine_transition and step.statemachine_get pipeline steps#163

Merged
intel352 merged 2 commits intomainfrom
feat/step-statemachine-transition
Feb 25, 2026
Merged

feat: add step.statemachine_transition and step.statemachine_get pipeline steps#163
intel352 merged 2 commits intomainfrom
feat/step-statemachine-transition

Conversation

@intel352
Copy link
Contributor

Summary

  • Adds step.statemachine_transition — triggers a named state machine transition from within a pipeline, with template resolution for entity_id, event, and data fields; configurable fail_on_error (default false)
  • Adds step.statemachine_get — reads the current state of a workflow instance, returning current_state and entity_id outputs
  • Registers both steps in plugins/statemachine via StepFactories() and declares them in the manifest's StepTypes

Test plan

  • TestStateMachineTransitionStep_* (13 cases): factory validation, successful transition, templated entity/event, invalid transition with fail_on_error=false and true, data pass-through, missing service, wrong service type, nil app, mock TransitionTrigger interface
  • TestStateMachineGetStep_* (8 cases): factory validation, returns correct state, templated entity_id, state after transition, missing instance, missing service, wrong type, nil app
  • TestStepFactories in statemachine plugin: both step types present
  • TestPluginManifest: manifest declares 2 step types
  • All existing statemachine and module tests continue to pass
go test ./module/... -run TestStateMachine
go test ./plugins/statemachine/...

🤖 Generated with Claude Code

intel352 and others added 2 commits February 25, 2026 00:38
Implements step.build_from_config (Phase 5.1 roadmap) — a pipeline step
that assembles a self-contained Docker image from a workflow config YAML
file, a server binary, and optional plugin binaries.

- Creates a temp build context, copies config + server + plugin binaries
- Generates a Dockerfile with correct ENTRYPOINT/CMD for workflow server
- Executes docker build (and optional docker push) via exec.Command
- exec.Command is injectable for deterministic unit testing
- 17 tests cover factory validation, Dockerfile generation, error paths,
  push flag, plugin inclusion, and build context file layout
- Registers step.build_from_config in plugins/cicd manifest and factory map

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…line steps

Implements two new pipeline steps for interacting with state machine
workflow instances directly from pipeline execution:

- step.statemachine_transition: triggers a named transition on a workflow
  instance, supports data templates, fail_on_error flag, and the
  TransitionTrigger interface for testability via mocks.
- step.statemachine_get: reads the current state of a workflow instance.

Both steps resolve entity_id and data fields from Go templates using the
existing TemplateEngine, look up the named StateMachineEngine by service
name from the app registry, and return structured output (transition_ok,
new_state, current_state, entity_id).

Steps are registered in plugins/statemachine with StepFactories() and
declared in the manifest's StepTypes list.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 25, 2026 06:07
if err != nil {
return fmt.Errorf("create %q: %w", dst, err)
}
defer out.Close()
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds new pipeline steps to interact with the state machine engine from within pipelines, and wires them into the statemachine plugin so they’re discoverable/usable via plugin loading. The PR also introduces and registers an additional CI/CD step (step.build_from_config) that is not currently reflected in the PR’s stated scope.

Changes:

  • Add step.statemachine_transition and step.statemachine_get pipeline steps (with template resolution) plus unit tests.
  • Register the new state machine steps in plugins/statemachine and validate via plugin tests/manifest step type assertions.
  • Add/register step.build_from_config in the CI/CD plugin and add its module implementation + tests.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
plugins/statemachine/plugin.go Declares new step types in manifest and exposes StepFactories() for statemachine steps.
plugins/statemachine/plugin_test.go Adds assertions for manifest step types and verifies step factories exist.
module/pipeline_step_statemachine_transition.go Implements transition-triggering pipeline step with templated inputs + fail_on_error.
module/pipeline_step_statemachine_transition_test.go Unit tests for transition step behavior and error modes.
module/pipeline_step_statemachine_get.go Implements state lookup pipeline step returning current_state/entity_id.
module/pipeline_step_statemachine_get_test.go Unit tests for get step behavior and error cases.
plugins/cicd/plugin.go Adds step.build_from_config to the CI/CD plugin manifest and factories.
plugins/cicd/plugin_test.go Updates expected step list and factory count after plugin load.
module/pipeline_step_build_from_config.go Implements docker build/push step that assembles a build context from config + binaries.
module/pipeline_step_build_from_config_test.go Adds unit tests for factory validation and build context behavior.
Comments suppressed due to low confidence (3)

module/pipeline_step_build_from_config_test.go:451

  • The error from copyDirRecursive(...) is ignored, so this test can silently proceed with an incomplete copy and produce confusing follow-on failures. Please assert copyDirRecursive succeeds (e.g., fail the test immediately on error).
				copyDir := t.TempDir()
				_ = copyDirRecursive(capturedBuildDir, copyDir)
				capturedBuildDir = copyDir
			}

module/pipeline_step_build_from_config_test.go:126

  • Test name has a typo (NoPLugins). Renaming to NoPlugins will keep test naming consistent and easier to search/grep.
func TestBuildFromConfigStep_GenerateDockerfile_NoPLugins(t *testing.T) {

plugins/cicd/plugin.go:48

  • This PR appears to introduce/register step.build_from_config in the CI/CD plugin, but the PR title/description focus on statemachine steps and don’t mention this additional feature. Please update the PR description (and/or split into a separate PR) so reviewers can clearly track the scope and rationale of the CI/CD change.
				StepTypes: []string{
					"step.shell_exec",
					"step.artifact_pull",
					"step.artifact_push",
					"step.docker_build",
					"step.docker_push",
					"step.docker_run",
					"step.scan_sast",
					"step.scan_container",
					"step.scan_deps",
					"step.deploy",
					"step.gate",
					"step.build_ui",
					"step.build_from_config",
				},

}
defer in.Close()

out, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

copyFile() creates files with mode 0600. That means config.yaml in the Docker build context will be root-readable only, and the generated image can fail at runtime when using non-root base images (e.g., distroless:nonroot) because /app/config.yaml won’t be readable. Consider setting a less restrictive mode for the config (e.g., chmod config.yaml after copy, or make copyFile accept a mode) so the runtime user can read it.

Suggested change
out, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
out, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)

Copilot uses AI. Check for mistakes.
@intel352 intel352 merged commit 385b1ff into main Feb 25, 2026
17 of 18 checks passed
@intel352 intel352 deleted the feat/step-statemachine-transition branch February 25, 2026 06:30
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