transform

package
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package transform defines the pipeline contract for gitrakz templates: an ordered chain of primitives that reshape a selected timeline into a typed display document. Each primitive reads and writes a shared State; the boss precomputes which State fields each primitive touches so primitives compose without knowing about each other.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownPrimitive = errors.New("unknown transform primitive")

ErrUnknownPrimitive is returned by Registry.Build when a template's transform step names a primitive that was never registered.

Functions

This section is empty.

Types

type Factory

type Factory func(params []byte) (Primitive, error)

Factory builds a primitive from its JSON parameters (a step entry in a template's transform definition). Params is the raw step config.

type Pipeline

type Pipeline struct {
	Steps []Primitive
}

Pipeline is an ordered list of primitives run left to right over one State.

func (Pipeline) Run

func (p Pipeline) Run(ctx context.Context, s *State) error

Run applies every step in order, wrapping the first error with the failing primitive's name so a broken pipeline is diagnosable.

type Primitive

type Primitive interface {
	Name() string
	Apply(ctx context.Context, s *State) error
}

A Primitive is one deterministic (or, for LLM-backed steps, cached) step in a template's transform pipeline. Apply mutates s in place.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry maps a primitive name to its factory. The template engine looks each pipeline step up here, so an unknown step fails loudly instead of silently doing nothing.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) Build

func (r *Registry) Build(name string, params []byte) (Primitive, error)

Build constructs the named primitive, or returns ErrUnknownPrimitive wrapped with the offending name.

func (*Registry) Register

func (r *Registry) Register(name string, f Factory)

Register adds a factory under name, overwriting any previous entry.

type Row

type Row struct {
	Key    string             `json:"key"`
	Values map[string]float64 `json:"values"`
	Labels map[string]string  `json:"labels"`
}

Row is the generic tabular intermediate primitives produce and consume: a grouping key plus named numeric and string values. Example keys in Values: "seconds", "hours", "count", "dollars"; in Labels: "description".

type State

type State struct {
	Timeline types.Timeline
	Sessions []types.Session
	Rows     []Row
	Blocks   blocks.Document
	Form     types.FormValues
}

State is the working state threaded through a pipeline. A primitive mutates the fields its contract names and leaves the rest untouched.

  • Timeline: the selected events (pipeline input).
  • Sessions: work sessions (sessionize writes; downstream reads).
  • Rows: tabular intermediate (group/aggregate/split write; rate reads).
  • Blocks: accumulated display output (terminal primitives append).
  • Form: the run's form values (read-only).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL