Versions in this module Expand all Collapse all v0 v0.1.0 Nov 5, 2026 Changes in this version + const MaxFreezeReason + const MaxHistory + const MaxRoutes + var CPUThrottled = Measure + var CPUUsed = Measure + var ErrActorRequired = errors.New("vis: a change needs an actor") + var ErrConflict = errors.New("vis: conflicting change") + var ErrDefaultLayer = errors.New("vis: the default layer is set in code") + var ErrEmptyChange = errors.New("vis: a change needs at least one knob") + var ErrFrozen = errors.New("vis: automated changes are frozen") + var ErrLeaseRequired = errors.New("vis: fleet, agent and rule values need a lease") + var ErrNotAllowed = errors.New("vis: writer not allowed") + var ErrOutOfRange = errors.New("vis: value out of range") + var ErrStarted = errors.New("vis: Start already ran: the default instance starts once per process") + var ErrUnknownKnob = errors.New("vis: unknown knob") + var ErrUnknownLease = errors.New("vis: unknown or ended lease") + var ErrUnknownRule = errors.New("vis: unknown rule") + var GCCPU = Measure + var Goroutines = Measure + var ProfileKinds = []string + var SchedP99 = Measure + func DeclareDuration(k *Duration, name string, opts ...Option) + func DeclareGauge(g *Gauge, name string, opts ...Option) + func DeclareInt(k *Int, name string, opts ...Option) + func DeclareLatency(l *Latency, name string, opts ...Option) + func DeclareLogLevel(k *LogLevel, name string, opts ...Option) + func HTTP(h http.Handler, opts ...HTTPOption) http.Handler + func ParseTokens(s string) (map[string]Grant, error) + func Probe(ctx context.Context, name string) (done func()) + func Start(ctx context.Context, opts ...StartOption) error + func Stop() + func UnwrappedReads() map[string]uint64 + func WithSnapshot(ctx context.Context, c *Config) context.Context + type Action interface + func Reset() Action + func SetTo[T ~int | ~int64](v T) Action + func StepPercent(p float64) Action + type Breakdown struct + Paths []PathStats + Probes []ProbeStats + Route string + type Bucket struct + Errors int64 + P50 time.Duration + P95 time.Duration + P99 time.Duration + Refused int64 + Requests int64 + Start time.Time + type Change struct + By Writer + For time.Duration + Knob string + Reason string + Value int64 + type Config struct + func SnapshotFrom(ctx context.Context) (*Config, bool) + type Confounder struct + Kind string + Layer string + What string + type Cost interface + type DeclaredRule struct + func NewRule(r RuleSpec) *DeclaredRule + func (r *DeclaredRule) Name() string + type Difference struct + SetBy map[string]string + Values map[string]string + What string + type Duration struct + func NewDuration(name string, opts ...Option) Duration + func (k Duration) Bind(fn func(d time.Duration)) + func (k Duration) BindIn(in *Instance, fn func(d time.Duration)) + func (k Duration) From(ctx context.Context) time.Duration + func (k Duration) Get(c *Config) time.Duration + func (k Duration) Name() string + func (k Duration) Now() time.Duration + func (k Duration) Range() (lo, hi time.Duration) + func (k Duration) SetDefault(v time.Duration) error + type Effect struct + Change uint64 + Knob string + Layer Layer + Lease uint64 + Value int64 + type Entry struct + By Writer + Change uint64 + Kept bool + Layer Layer + Lease uint64 + Left time.Duration + Then int64 + Value int64 + type Event struct + At time.Time + Fields map[string]any + Kind string + type FleetMember struct + CPULimit float64 + CPUUsed float64 + Died string + Frozen bool + Gossiped time.Duration + Held []Held + LastAgo time.Duration + LastChange string + Lost []Held + MemKill time.Duration + MemLimit uint64 + MemUsed uint64 + Pressures []Pressure + Restarted time.Duration + Restarts int + SLOs []MemberSLO + Silent bool + SilentWhy string + Throttled float64 + type FleetReport struct + At time.Time + Common []string + Covers string + Differ []Difference + Members []FleetMember + Missing []string + SLOs []FleetSLO + StandOut []StandOut + type FleetSLO struct + Met bool + Objective time.Duration + P99 time.Duration + Partial string + Requests int64 + Route string + type FreezeState struct + By Writer + Epoch uint64 + Frozen bool + On string + Reason string + Since time.Time + type Gauge struct + func NewGauge(name string, opts ...Option) *Gauge + func (g *Gauge) Measure() Measure + func (g *Gauge) Name() string + func (g *Gauge) Set(v float64) + type GaugeFunc struct + func NewGaugeFunc(name string, read func() float64, opts ...Option) *GaugeFunc + func (g *GaugeFunc) Measure() Measure + func (g *GaugeFunc) Name() string + type Grant struct + Act bool + Writer Writer + type HTTPOption func(*httpOptions) + func RouteName(fn func(*http.Request) string) HTTPOption + type Held struct + Age time.Duration + Back bool + By string + EndsIn time.Duration + Knob string + Unkept bool + Value string + type Impact struct + After map[string]float64 + At time.Time + Before map[string]float64 + Change uint64 + Changes []string + Confounded []string + ConfoundedBy []Confounder + Done bool + Effects []Moved + MeasuredAt time.Time + Memory string + Rest *Rest + Settle time.Duration + Summary string + Warming bool + type Info struct + About string + Default int64 + Env string + FromEnv bool + HasSpecial bool + Max int64 + Min int64 + Name string + Pull []Kind + Saves []Resource + Special int64 + SpecialName string + Type string + Unit string + Uses []Resource + func Knobs() []Info + func Lookup(name string) (Info, bool) + func (i Info) Format(v int64) string + func (i Info) Parse(s string) (int64, error) + type Instance struct + func DefaultInstance() *Instance + func NewInstance(opts ...InstanceOption) *Instance + func (in *Instance) Apply(tx Tx) (Record, error) + func (in *Instance) Breakdown(route string, window time.Duration) Breakdown + func (in *Instance) Clear(knob string, l Layer, by Writer, reason string) (Effect, error) + func (in *Instance) Fleet(ctx context.Context) FleetReport + func (in *Instance) Forget(by Writer, name, reason string) error + func (in *Instance) Freeze(by Writer, reason string) error + func (in *Instance) FreezeState() FreezeState + func (in *Instance) HTTP(h http.Handler, opts ...HTTPOption) http.Handler + func (in *Instance) History(n int) []Event + func (in *Instance) Impact(change uint64) (Impact, bool) + func (in *Instance) Levers(r Resource) []Lever + func (in *Instance) MCP(opts ...MCPOption) http.Handler + func (in *Instance) Members() []Member + func (in *Instance) Pressures() []Pressure + func (in *Instance) Preview(tx Tx) (Record, error) + func (in *Instance) Profile(ctx context.Context, kind string, d time.Duration) (ProfileReport, error) + func (in *Instance) Revert(leaseID uint64, by Writer, reason string) (Record, error) + func (in *Instance) Route(route string, window time.Duration) RouteStats + func (in *Instance) RouteHistory(route string) []Bucket + func (in *Instance) Routes(window time.Duration) []RouteStats + func (in *Instance) Rules() []RuleState + func (in *Instance) RunRule(ctx context.Context, r RuleSpec) + func (in *Instance) RunRules(ctx context.Context) + func (in *Instance) Runtime(window time.Duration) RuntimeStats + func (in *Instance) SLOs() []SLOStatus + func (in *Instance) Serve(ctx context.Context, opts ...ServeOption) (Served, error) + func (in *Instance) Service() string + func (in *Instance) Set(c Change) (Effect, error) + func (in *Instance) SetRule(name string, enabled bool, by Writer, reason string) error + func (in *Instance) Signal(name, unit, about string, read func() float64) Measure + func (in *Instance) Signals() []SignalValue + func (in *Instance) Snapshot() *Config + func (in *Instance) Stack(knob string) ([]Entry, error) + func (in *Instance) StartRequest(ctx context.Context) (context.Context, func(route string, status int)) + func (in *Instance) Stop() + func (in *Instance) Stories(n int, viewer Writer) []Story + func (in *Instance) UI(opts ...UIOption) http.Handler + func (in *Instance) Unfreeze(by Writer, reason string) error + func (in *Instance) WaitImpact(ctx context.Context, change uint64) (Impact, error) + func (in *Instance) Warnings() []string + type InstanceOption func(*Instance) + func InstanceName(name string) InstanceOption + func SLO(route string, p99 time.Duration) InstanceOption + func Service(name string) InstanceOption + func WithLogger(l *slog.Logger) InstanceOption + type Int struct + func NewInt(name string, opts ...Option) Int + func (k Int) Bind(fn func(n int)) + func (k Int) BindIn(in *Instance, fn func(n int)) + func (k Int) From(ctx context.Context) int + func (k Int) Get(c *Config) int + func (k Int) Name() string + func (k Int) Now() int + func (k Int) Range() (lo, hi int) + func (k Int) SetDefault(v int) error + type Kind int + const Agent + const Fleet + const Human + const Rule + func (k Kind) String() string + type Knob interface + type Latency struct + func NewLatency(name string, opts ...Option) *Latency + func (l *Latency) Measure() Measure + func (l *Latency) Name() string + func (l *Latency) Set(d time.Duration) + type Layer int + const AgentLayer + const DefaultLayer + const FleetLayer + const PinLayer + const RuleLayer + func (l Layer) String() string + type Level interface + func Fixed[T time.Duration | float64 | int](v T) Level + type Lever struct + About string + Knob string + Observed string + People bool + Position float64 + Value string + type LogLevel struct + func NewLogLevel(name string, opts ...Option) LogLevel + func (k LogLevel) Bind(fn func(l slog.Level)) + func (k LogLevel) BindIn(in *Instance, fn func(l slog.Level)) + func (k LogLevel) Get(c *Config) slog.Level + func (k LogLevel) Level() slog.Level + func (k LogLevel) Name() string + func (k LogLevel) Now() slog.Level + func (k LogLevel) Range() (lo, hi slog.Level) + func (k LogLevel) SetDefault(v slog.Level) error + type MCPOption func(*mcpOptions) + func Tokens(t map[string]Grant) MCPOption + type Measure struct + Name string + Read func(*Instance) float64 + Resource Resource + Unit string + func RouteP99(route string) Measure + type Member struct + Addr string + Build string + ID string + Name string + Quiet time.Duration + Self bool + Service string + State string + type MemberSLO struct + Met bool + P99 time.Duration + Requests int64 + Route string + type Moved struct + From float64 + Name string + To float64 + Unit string + Worse bool + func (e Moved) String() string + type Objective struct + func NewSLO(route string, t Target) Objective + func (o Objective) P99() time.Duration + func (o Objective) Route() string + type Option func(*decl) + func About(s string) Option + func Default[T ~int | ~int64](v T) Option + func Env(key string) Option + func Pull(kinds ...Kind) Option + func Range[T ~int | ~int64](min, max T) Option + func Saves(cs ...Cost) Option + func Special[T ~int | ~int64](v T, name string) Option + func Unit(u string) Option + func Uses(cs ...Cost) Option + type PathStats struct + Errors int64 + P50 time.Duration + P99 time.Duration + Probes []string + Requests int64 + Share float64 + type Pressure struct + Levers []Lever + Resource Resource + Why string + type ProbeStats struct + P50 time.Duration + P99 time.Duration + Probe string + Requests int64 + Share float64 + type ProfileLine struct + Callers []string + Each float64 + Events int64 + Function string + Share float64 + Value float64 + Via string + Where string + type ProfileReport struct + Kind string + Seconds float64 + Summary string + Top []ProfileLine + Total float64 + Unit string + Vis float64 + type Record struct + Change uint64 + Effects []Effect + Lease uint64 + Replaced []Replaced + type Removal struct + Knob string + Layer Layer + type Replaced struct + By Writer + Knob string + Left time.Duration + Value int64 + type Resource string + const CPU + const Memory + type Rest struct + After map[string]float64 + AfterOf []string + Before map[string]float64 + Changed []string + Gossiped []string + Members []string + type RouteStats struct + Errors int64 + P50 time.Duration + P95 time.Duration + P99 time.Duration + Refused int64 + Requests int64 + Route string + type RuleSpec struct + Cooldown time.Duration + Deadband Level + Do Action + Every time.Duration + For time.Duration + Knob Knob + Lease time.Duration + MaxDrift int64 + Name string + Objective Measure + Over Level + Shadow bool + Stall int + Step int64 + Watch Measure + type RuleState struct + Action string + Aside string + Err string + Knob string + Limit float64 + Moves string + Name string + Signal float64 + SignalName string + Stalls int + State string + Stopped string + Unit string + Warning string + type RuntimeStats struct + CPULimit float64 + CPUUsed float64 + GCCPU float64 + GOMAXPROCS int + GoMemLimit uint64 + Goroutines int + HeapGoal uint64 + HeapGrowth float64 + HeapLive uint64 + HeapRatio float64 + MemFrom string + MemGrowth float64 + MemLimit uint64 + MemLimitBy string + MemUsed uint64 + OOMKills uint64 + Over time.Duration + SchedP50 time.Duration + SchedP99 time.Duration + Throttled float64 + ThrottledTime time.Duration + type SLOStatus struct + Met bool + Minute time.Duration + Now time.Duration + P99 time.Duration + Requests int64 + Route string + Warning string + type ServeOption func(*serveOptions) + func ClusterKey(key string) ServeOption + func FleetWait(d time.Duration) ServeOption + func MCPAt(addr string, opts ...MCPOption) ServeOption + func PeerAdvertise(addr string) ServeOption + func PeerAt(addr string) ServeOption + func PeerDialer(dial func(ctx context.Context, network, addr string) (net.Conn, error)) ServeOption + func PeerListener(ln net.Listener) ServeOption + func Seeds(addrs ...string) ServeOption + func StateDir(dir string) ServeOption + func UIAt(addr string, opts ...UIOption) ServeOption + type Served struct + MCP string + UI string + type SignalValue struct + About string + Err string + Name string + Unit string + Value float64 + type StandOut struct + Look string + Member string + Why string + type StartOption interface + type Step struct + By int64 + Knob string + type Story struct + After string + Alert bool + At time.Time + Body string + Confounded []string + Effects []Moved + ID string + Kind string + Knob string + Lease uint64 + Mark string + Title string + TitleParts []TitlePart + Until time.Time + Who string + Why string + type Target struct + func P99(d time.Duration) Target + type TitlePart struct + Kind string + Text string + type Tx struct + By Writer + Clear []Removal + For time.Duration + Keep bool + Reason string + Set []Write + Step []Step + type UIOption func(*uiOptions) + func UIHosts(hosts ...string) UIOption + func UIUser(id string) UIOption + type Write struct + Knob string + Value int64 + type Writer struct + ID string + Kind Kind + func (w Writer) String() string