Documentation
¶
Overview ¶
Package main demonstrates the forge package for signed, governed KPI computation.
This example shows the three composable layers of go-codex:
- Layer 1: Validated domain models — codex.Codec[T] with Refine constraints.
- Layer 2 (not shown here): API endpoints — api/rest or api/events builders.
- Layer 3: KPI pipelines — forge.Function[In,Out] with governance + computation graph.
The domain is Overall Equipment Efficiency (OEE), a standard manufacturing KPI:
OEE = Availability × Performance × Quality
Availability measures uptime: how much of the planned production time was running. Performance measures speed: how close to the ideal cycle time the equipment ran. Quality measures correctness: the fraction of units produced without defects.
The example demonstrates:
- Domain codecs with validate.RangeFloat constraints.
- forge.MeasuredCodec for attaching provenance to values crossing system boundaries.
- Minimal pipeline definition — only name + version + codecs + compute fn.
- Governed pipeline definition — same but with FunctionOpt governance metadata.
- Single-input functions: gradeCalc, availabilityOnlyOEE.
- Multi-input functions via struct codecs (codex.Struct): availabilityCalc, performanceCalc.
- Sum-type composition: OEEIn assembles validated Availability+Performance+Quality outputs.
- Cross-input validation: codec-level RefineFunc (preferred) and WithRefinement (pipeline-level).
- forge.Compose: chaining Function[A,B] + Function[B,Out] → Function[A,Out].
10. Structured errors (forge.InputError, RefinementError, ApplyError) via errors.As. 11. stats.PipelineObserver injected via Registry.WithObserver for Apply telemetry. 12. forge.Registry + render/pipeline YAML spec output.