ADR-0002: Processing Pipeline Architecture
- Status: Proposed
- Date: 2026-01-01
- Deciders: Morphir Maintainers
- Technical Story: Define a functional processing pipeline for Morphir Go.
Context
Morphir Go needs a consistent way to process IR across commands such as validate,
build, analyze, and generate. The Morphir IR is the central AST, with decorators
as extensible sidecar metadata. Other ASTs may flow through the pipeline
(e.g., Elm ASTs). Today there is no pipeline implementation in pkg/pipeline,
and the CLI implements behavior command-by-command.
We need:
- Composable, testable processing steps.
- Clear separation of I/O from core logic.
- Structured diagnostics and JSON output for automation.
- Alignment with Morphir's functional programming principles.
- A VEntry abstraction (files, documents, nodes, folders, archives) with metadata.
- A mountable virtual filesystem with precedence and read-only/read-write zones.
- Targets (build/test/clean) and tasks that can execute intrinsic actions and external commands.
Decision
We will implement a functional pipeline framework in pkg/pipeline with:
- Pure step functions that accept immutable context and input and return output plus structured results (diagnostics, artifacts, errors).
- Ordered pipeline composition that executes steps sequentially and short-circuits on error while retaining collected outputs.
- Structured results that can be encoded to JSON for CLI
--jsonoutput. - Explicit I/O boundaries: I/O lives in CLI or tooling layers, not in pipeline steps.
- VEntry and VFS abstractions to represent inputs/outputs and mounted workspace/config environments.
- Targets and tasks to orchestrate pipelines and support external commands.
Consequences
- CLI commands become thin wrappers that assemble pipelines and render results.
- Step implementations are isolated and unit-testable.
- Diagnostics are consistent across commands.
- Future extensions (caching, parallelism) can be added without changing step semantics.
Alternatives Considered
- Ad-hoc command logic per CLI command.
- Rejected due to duplication and inconsistent diagnostics.
- Pipeline with side-effecting steps.
- Rejected due to poorer testability and misalignment with functional goals.
- External workflow engine.
- Rejected as too heavy for the current scope.
Implementation Notes
pkg/pipelinewill host core types and composition helpers.pkg/toolingwill provide step implementations (validation, reports, etc.).pkg/vfs(or similar) will define VEntry and virtual filesystem types.cmd/morphirwill assemble pipelines and route outputs to stdout/stderr.