Skip to content

feat: generic redesign with Store[T], typed builders, and dual type params#16

Merged
jasoet merged 21 commits intomainfrom
feat/generic-redesign
Mar 27, 2026
Merged

feat: generic redesign with Store[T], typed builders, and dual type params#16
jasoet merged 21 commits intomainfrom
feat/generic-redesign

Conversation

@jasoet
Copy link
Copy Markdown
Owner

@jasoet jasoet commented Mar 27, 2026

Summary

  • New workflow/store/ package — generic Store[T], RawStore, Codec[T], TypedStore[T] replacing the metadata-coupled workflow/artifacts/ for new code. Includes LocalStore, S3Store, InstrumentedStore (OTel), KeyBuilder.
  • Dual type params on orchestration typesPipelineInput[I, O], ParallelInput[I, O], LoopInput[I, O] now carry both input and output types for compile-time I/O pairing.
  • Shared DAG typesDAGNode[I, O], DAGInput[I, O], DAGOutput[O] in workflow/ with cycle detection validation.
  • Generic container packageGenericBuilder[I, O], generic workflow entry points, typed operations (SubmitTypedWorkflow[I], SubmitAndWaitTyped[O]), generic WorkflowSource[I] templates. Backward compatible — existing APIs preserved alongside new generic ones.
  • Generic function packageWorkflowBuilder[I, O] and LoopBuilder[I, O] fully generic, workflow wrappers simplified (helpers.go deleted), patterns updated.
  • Datasync store migrationJob[T, U].ArtifactConfigJob[T, U].Store store.RawStore.

Test plan

  • All 22 packages pass task test:unit (zero failures)
  • task lint passes
  • task fmt produces no changes
  • Integration tests with container engine (task test:integration)
  • Verify downstream datasync consumers compile with store field change

jasoet added 21 commits March 27, 2026 12:53
Full architecture plan to make go-wf fully generic with compile-time
type safety across workflow core, container, function, and store packages.
23-task phased plan: store → core types → container → function → datasync → cleanup.
Each phase compiles and tests independently.
Port S3 storage from workflow/artifacts/s3.go to the new RawStore
interface with simplified key-based API and no metadata dependency.
Includes integration test using testcontainers with rustfs/MinIO.
Wrap RawStore with OpenTelemetry instrumentation following the same
pattern as workflow/artifacts/otel.go. Zero overhead when OTel config
is not present in context.
…types

Add phantom type parameter O TaskOutput to PipelineInput, ParallelInput,
LoopInput, and ParameterizedLoopInput for compile-time I/O type pairing.
Add generic DAG types (DAGNode, DAGInput, DAGOutput, NodeResult) to the
workflow core package with DFS-based cycle detection validation ported
from function/payload. These are type definitions only — no execution
logic, keeping container/function concerns separate.
Add function/types.go and function/types_extended.go with type aliases
pointing to function/payload, allowing callers to use function.FunctionExecutionInput
directly. Update worker.go to use the local aliases. Mark Pipeline/Parallel
input/output types in payload as deprecated in favor of generic workflow types.
… access

Re-export ContainerExecutionInput, ContainerExecutionOutput, WaitStrategyConfig,
and all extended types (DAGNode, DAGWorkflowInput, etc.) from the container
package root via type aliases pointing to container/payload. This allows
consumers to use container.ContainerExecutionInput instead of the longer
container/payload.ContainerExecutionInput path.
Make WorkflowBuilder and LoopBuilder generic with [I TaskInput, O TaskOutput]
type parameters. Add NewFunctionBuilder, NewFunctionLoopBuilder convenience
constructors. Update patterns to use generic types (Tasks instead of Functions).
Update all tests and examples accordingly.
… builder

Add GenericBuilder[I, O] type that works with any TaskInput/TaskOutput types.
Keep existing WorkflowBuilder for backward compatibility with container-specific
workflows. Add BuildGenericPipeline and BuildGenericParallel methods that produce
workflow.PipelineInput and workflow.ParallelInput generic types.
…nd parallel

Add GenericContainerPipelineWorkflow and GenericParallelContainersWorkflow
that accept generic workflow.PipelineInput/ParallelInput types directly,
eliminating the need for type conversion. Keep legacy wrappers for backward
compatibility.
Add SubmitTypedWorkflow and SubmitAndWaitTyped generic functions that provide
compile-time type safety for workflow submission, eliminating the need for
interface{} type switches. Keep legacy SubmitWorkflow and SubmitAndWait for
backward compatibility.
…ates

Add GenericSource[I] interface, GenericSourceFunc[I] adapter, and
TaskInputSource[I] wrapper alongside the existing container-specific
WorkflowSource interface. This enables templates and sources to work
with any TaskInput type in the generic builder.
…irectly

Workflow functions now accept generic workflow.PipelineInput[I,O],
ParallelInput[I,O], LoopInput[I,O] directly instead of function-specific
payload types. Delete helpers.go since conversion functions are no longer
needed. Update all workflow tests accordingly.
…types

Update integration tests to use workflow.PipelineInput[I,O],
ParallelInput[I,O], LoopInput[I,O], and ParameterizedLoopInput[I,O]
directly instead of the deprecated payload-specific types. Mark
Pipeline/Parallel input/output types in payload as deprecated.
…wStore

Replace workflow/artifacts dependency with workflow/store in datasync
package. Job.ArtifactConfig becomes Job.Store (store.RawStore) and
builder.WithArtifactConfig becomes builder.WithStore.
- Add statusFailed constant in container/operations.go (goconst)
- Remove unused parallelMode field from GenericBuilder (unused)
- Fix gofumpt formatting for long function signatures
- Add nolint directives for intentional error ignoring (errcheck)
- Update INSTRUCTION.md: add workflow/store/ to key paths, document
  generic store, dual type parameters, and generic builder alternatives
@jasoet jasoet merged commit abb1212 into main Mar 27, 2026
2 checks passed
@jasoet jasoet deleted the feat/generic-redesign branch March 27, 2026 23:38
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.

1 participant