deploys

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package deploys records deployment markers — a timestamped point ("this shipped then") you overlay on any metric to answer the one question every other analytics tool leaves you guessing: did that deploy move the number? Markers are cheap to record (a git sha + message from CI, or a named release by hand); the impact math lives in impact.go and is the same trends engine the dashboard renders, so the answer is computed, never guessed, and a CI test pins it to the dashboard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Report

func Report(evs []event.Event, deps []Deploy, eventName string, days, window int) map[string]any

Types

type Deploy

type Deploy struct {
	ID      string    `json:"id"`
	SHA     string    `json:"sha,omitempty"`
	Message string    `json:"message,omitempty"`
	Author  string    `json:"author,omitempty"`
	Ref     string    `json:"ref,omitempty"`
	URL     string    `json:"url,omitempty"`
	Source  string    `json:"source,omitempty"` // github | ci | cli | manual
	At      time.Time `json:"at"`               // when it shipped (the marker time)
	Created time.Time `json:"created"`          // when it was recorded here
}

Deploy is one recorded release. Identity is the git SHA when present (so re-recording the same commit upserts instead of duplicating — the cloud syncs every commit on each dashboard load); a marker without a SHA is a distinct manual entry.

type Impact

type Impact struct {
	Deploy
	ShortSHA    string   `json:"short_sha"`
	Before      *float64 `json:"before"`
	After       *float64 `json:"after"`
	DeltaPct    *float64 `json:"delta_pct"`
	Direction   string   `json:"direction"` // regression | improvement | flat | unknown
	Significant bool     `json:"significant"`
}

Impact is one deploy with its measured before/after effect on a metric. Nullable fields use pointers so they serialize as JSON null (not 0) when there isn't enough data — a missing number must never read as "zero change".

func ComputeImpact

func ComputeImpact(series []Point, deps []Deploy, window int, threshold float64) []Impact

ComputeImpact lines each deploy up against a daily metric series and compares the mean of the `window` days AFTER the deploy against the `window` days BEFORE. This is correlation, not proof, so a deploy is only flagged Significant when BOTH windows are fully populated AND the move is at least `threshold` (e.g. 0.25). Returned newest-first.

func Headline

func Headline(impacts []Impact) *Impact

Headline picks the one deploy to lead with: the most recent SIGNIFICANT regression, else the most recent significant change, else nothing. Regressions are the alarm; a recovery is good news but never the headline.

type Point

type Point struct {
	Date  time.Time
	Count int
}

Point is one day of a metric series (mirrors trends.Point; the api/mcp layer converts so this package stays dependency-free and the impact math is a pure, testable leaf).

type Store

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

Store is a small persisted list of deploy markers. Same shape + persistence as the goal / share stores: JSON on disk, atomic tmp+rename, one mutex, List returns a copy.

func Open

func Open(p string) (*Store, error)

Open loads the store from p, or returns an empty store if the file doesn't exist. An empty path means in-memory only (demo mode writes nothing to the visitor's disk).

func (*Store) Delete

func (s *Store) Delete(id string) error

Delete removes a marker by id.

func (*Store) List

func (s *Store) List() []Deploy

List returns all markers newest-first (a copy — never the internal slice).

func (*Store) Record

func (s *Store) Record(d Deploy) (Deploy, error)

Record adds a marker, upserting by SHA: recording the same commit again refreshes its fields (message/url/at) but keeps its id + first-recorded time, so the cloud can safely re-sync every commit on each load without ever creating duplicates.

Jump to

Keyboard shortcuts

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