Documentation
¶
Overview ¶
Package contract defines what factorymeter writes out, and generates the reference docs and the JSON Schema from the definitions in code.
The contract has three layers. Records (pkg/record) are what is kept. Metrics (pkg/line) are what is measured. The report in this file is what is written out. Inside one version fields are only ever added, and a metric id never changes meaning.
Index ¶
- Constants
- Variables
- func Files() (map[string][]byte, error)
- func JSON(v any) ([]byte, error)
- func MetricsMarkdown() string
- func RecordsMarkdown() string
- func ReportMarkdown() string
- func ReportSchema() map[string]any
- func RulesMarkdown() string
- func Schema(v any, id, title, description string) map[string]any
- type Catalog
- type Coverage
- type Evidence
- type Field
- type Item
- type KindDoc
- type Period
- type Point
- type Recommendation
- type Record
- type RepoCoverage
- type Report
- type Series
- type Slice
- type SourceCoverage
- type Station
- type Tool
- type TrackerCoverage
- type UnitDoc
- type Verdict
- type Window
Constants ¶
const ( StatusMeasured = "measured" StatusPartial = "partial" StatusNotConnected = "not_connected" )
Station statuses.
const ( TrendBetter = "better" TrendWorse = "worse" TrendFlat = "flat" TrendUnknown = "unknown" )
Trends.
const ( ConfidenceHigh = "high" ConfidenceMedium = "medium" ConfidenceLow = "low" )
Confidence levels.
const Dir = "docs/reference"
Dir is where the generated reference files live in the repository.
const SchemaFile = "factorymeter-v1.schema.json"
SchemaFile is the name of the JSON Schema of the report.
const SchemaID = "https://raw.githubusercontent.com/marshal-org/factorymeter/main/" + Dir + "/" + SchemaFile
SchemaID is the id the JSON Schema of the report carries.
const Version = "factorymeter/v1"
Version marks every report.
Variables ¶
var HowRecommended = []string{ "A rule is a fixed test on the numbers of the report. It fires or it does not. Nothing is guessed and no model is asked.", fmt.Sprintf("A station is compared with itself, not with other companies: with its own best %d weeks in a row inside the window of the report. A stretch counts only when at least %d items left the station in it. A window of %d weeks or less has no best weeks, and the gain is not sized.", line.BestWeeks, line.MinSample, line.BestWeeks), "Hours freed a week is the waiting that goes away if the station gets back to that pace. It is waiting time of changes, not working time of people. A rule that cannot size its gain leaves it empty. A gain of 0 means no stretch of the window did better.", "The order is: the constraint first, then the largest hours freed, then the rest in the order of this page.", fmt.Sprintf("Confidence is how much data stands behind the numbers: high from %d items, medium from %d, low below that. For a sized gain it is the smaller of the items in the window and the items in the best weeks. A rule that counts what stands in a queue is always high.", line.HighSample, line.MediumSample), "Every recommendation carries its evidence: each number the rule read, the number it was compared with, and a sentence that says both.", "A rule about a queue names up to 5 items to look at first, the one that has stood longest first. A summary names none.", "A rule id never changes meaning. A rule whose test has to change gets a new id.", }
HowRecommended says how every recommendation is made, whatever the rule.
var Records = []Record{ {record.KindTicket, "An issue on GitHub, Linear or Jira. Tickets feed the spec station.", record.Ticket{}}, {record.KindChange, "A pull request. Changes feed the code, review and merge stations, and tie CI runs and deploys to the line.", record.Change{}}, {record.KindCIRun, "One attempt of one CI workflow on one commit. Runs on a commit of a change feed the ci station.", record.CIRun{}}, {record.KindDeploy, "One deployment to an environment, or one published release. Deploys feed the verify and release stations.", record.Deploy{}}, {record.KindLink, "A tie between two records: a change that closes a ticket, or a change that reverts another.", record.Link{}}, }
Records lists the record kinds in the order the docs print them.
var Rules = []string{ "A definition says \"the period\". For the value of a metric that is the whole window of the report, 13 weeks unless asked otherwise. For one point of its history it is one week.", "A station's numbers are counted when they happen, not when the change merges. A wait counts in the period it ended, and work in the period the item left the station. A change that waited four weeks for review and got it this week counts this week, at the review station, whether or not it has merged yet.", "The numbers about the whole line are measured over the changes merged in the period.", "Queue numbers are not measured over a period. They are the state at the end of it.", fmt.Sprintf("A median, a percentile or a share drawn from fewer than %d items is still reported, and marked thin. No trend is called on a thin value.", line.MinSample), "Every time is wall-clock time. Nights and weekends count, because the work waits through them.", "Changes by automation, such as dependency bumps and release bots, are reported as their own class and are left out of every number about the whole line.", "A metric id never changes meaning. When a definition has to change, the metric gets a new id and the old one stays or is removed in a new contract version.", }
Rules hold for every metric. They are stated once here instead of in each definition.
Functions ¶
func JSON ¶
JSON writes v the way every generated file is written: indented, with a final newline and without escaping the characters HTML cares about.
func MetricsMarkdown ¶
func MetricsMarkdown() string
MetricsMarkdown renders the metric registry as a reference page.
func RecordsMarkdown ¶
func RecordsMarkdown() string
RecordsMarkdown renders the record layout as a reference page.
func ReportMarkdown ¶
func ReportMarkdown() string
ReportMarkdown renders the layout of the report as a reference page.
func ReportSchema ¶
ReportSchema is the JSON Schema of the report.
func RulesMarkdown ¶
func RulesMarkdown() string
RulesMarkdown renders the recommendation rules as a reference page.
Types ¶
type Catalog ¶
type Catalog struct {
Schema string `json:"schema"`
Kinds []KindDoc `json:"kinds"`
Units []UnitDoc `json:"units"`
Rules []string `json:"rules"`
Stations []line.Station `json:"stations"`
Metrics []line.Metric `json:"metrics"`
// RecommendationRules are the rules behind "where to invest". The plain
// name was taken by the rules of the metrics.
RecommendationRules []line.Rule `json:"recommendation_rules"`
}
Catalog is the metric registry as a program reads it.
type Coverage ¶
type Coverage struct {
Repos []RepoCoverage `json:"repos" doc:"One entry per repository in the store. Empty in a summary."`
Sources []SourceCoverage `json:"sources" doc:"One entry per kind of record."`
Trackers []TrackerCoverage `` /* 151-byte string literal not displayed */
}
Coverage says what stands behind the report.
type Evidence ¶
type Evidence struct {
Metric string `json:"metric" doc:"The metric id." pattern:"^[a-z]+[.][a-z][a-z0-9_]*([.][a-z][a-z0-9_]*)?$"`
Slice Slice `json:"slice" doc:"The part of the line the number is about."`
Value *float64 `json:"value" doc:"The value the rule read."`
Versus *float64 `` /* 162-byte string literal not displayed */
Text string `json:"text" doc:"The number in words."`
}
Evidence is one number behind a recommendation.
type Item ¶
type Item struct {
Kind string `json:"kind" doc:"What the item is." enum:"ticket,change"`
Key string `json:"key" doc:"The name people use for it, such as owner/repo#12."`
URL string `json:"url" doc:"Link to it on the source."`
Title string `json:"title" doc:"Its title."`
Class string `json:"class" doc:"Who wrote it. Empty for a ticket." enum:"agent,human,automation,"`
Hours float64 `json:"hours" doc:"How long it has stood in the queue, in hours."`
}
Item is one ticket or change a report points at.
type Period ¶
type Period struct {
From time.Time `json:"from" doc:"Start, inclusive."`
To time.Time `json:"to" doc:"End, exclusive."`
}
Period is one span of time.
type Point ¶
type Point struct {
Value *float64 `json:"value" doc:"The value in the period. Null when nothing was counted."`
N int `json:"n" doc:"How many items the value is drawn from."`
}
Point is one period of a series.
type Recommendation ¶
type Recommendation struct {
Rule string `json:"rule" doc:"The id of the rule that fired, such as review.queue-growing. Rule ids are stable."`
Station string `json:"station" doc:"The station the recommendation is about."`
Title string `json:"title" doc:"What to do, in one line."`
Why string `json:"why" doc:"The reasoning in a sentence or two."`
Evidence []Evidence `json:"evidence" doc:"The numbers the rule read."`
HoursFreed *float64 `` /* 172-byte string literal not displayed */
Confidence string `json:"confidence" doc:"How much data stands behind the recommendation." enum:"high,medium,low"`
PlayURL string `json:"play_url" doc:"Link to the playbook page that describes the practice. Empty when there is none."`
Items []Item `json:"items" doc:"The items to look at first. Empty in a summary."`
}
Recommendation is one thing to do, with the numbers that led to it.
type RepoCoverage ¶
type RepoCoverage struct {
Repo string `json:"repo" doc:"The repository, as owner/name."`
Private bool `json:"private" doc:"True for a private repository."`
From time.Time `json:"from" doc:"How far back the store holds this repository."`
SyncedAt time.Time `json:"synced_at" doc:"When the repository was last synced."`
Changes int `json:"changes" doc:"Changes in the store for this repository."`
}
RepoCoverage is one repository in the store.
type Report ¶
type Report struct {
Schema string `json:"schema" doc:"Always factorymeter/v1." enum:"factorymeter/v1"`
GeneratedAt time.Time `json:"generated_at" doc:"When the report was computed."`
Tool Tool `json:"tool" doc:"The program that wrote the report."`
Target string `json:"target" doc:"The owner or owner/repo that was measured. Empty in a summary."`
Summary bool `json:"summary" doc:"True when every name, title and link was left out, so the file holds station numbers only."`
Window Window `json:"window" doc:"The time the report covers."`
Coverage Coverage `json:"coverage" doc:"What was loaded and what is missing."`
Verdict Verdict `json:"verdict" doc:"The one-sentence answer."`
Stations []Station `json:"stations" doc:"The seven stations of the line, in order."`
Metrics []Series `json:"metrics" doc:"Every number, each with its weekly history."`
Recommendations []Recommendation `json:"recommendations" doc:"Where to invest, most valuable first."`
Limits []string `json:"limits" doc:"What the reader should know before trusting a number."`
}
Report is one run of "factorymeter report" as JSON.
type Series ¶
type Series struct {
Metric string `` /* 135-byte string literal not displayed */
Slice Slice `json:"slice" doc:"The part of the line the series is about."`
Unit string `json:"unit" doc:"What the values count." enum:"per_week,hours,share,count,lines"`
Value *float64 `json:"value" doc:"The value over the window. Null when nothing was counted."`
N int `json:"n" doc:"How many items the value is drawn from."`
Thin bool `json:"thin" doc:"True when the value is drawn from fewer items than the metric's minimum sample."`
Previous *float64 `` /* 130-byte string literal not displayed */
PreviousN int `json:"previous_n" doc:"How many items the previous value is drawn from."`
Change *float64 `` /* 247-byte string literal not displayed */
Trend string `` /* 274-byte string literal not displayed */
Points []Point `json:"points" doc:"One value per period of the window's periods, oldest first."`
}
Series is one metric for one slice: its value over the window, the value it is compared with, and its history.
type Slice ¶
type Slice struct {
Class string `json:"class" doc:"Who wrote the changes. Empty for all of them." enum:"agent,human,automation,"`
Agent string `json:"agent" doc:"The id of one agent in the signature registry. Empty for all."`
Repo string `json:"repo" doc:"One repository. Empty for all."`
}
Slice says which part of the line a series is about. Every field empty means the whole line.
type SourceCoverage ¶
type SourceCoverage struct {
Kind string `json:"kind" doc:"The kind of record." enum:"ticket,change,ci_run,deploy"`
Source string `json:"source" doc:"Where the records come from, such as github. Empty when nothing is connected."`
Records int `json:"records" doc:"How many records of this kind the window holds."`
Note string `` /* 133-byte string literal not displayed */
}
SourceCoverage is one kind of record in the store.
type Station ¶
type Station struct {
ID string `json:"id" doc:"The station id." enum:"spec,code,ci,verify,review,merge,release"`
Name string `json:"name" doc:"The station name."`
Status string `json:"status" doc:"Whether the station could be measured." enum:"measured,partial,not_connected"`
Missing string `json:"missing" doc:"What to connect to measure the station fully. Empty when nothing is missing."`
Constraint bool `json:"constraint" doc:"True for the one station named the constraint."`
Oldest []Item `json:"oldest" doc:"The items that have stood longest in the station's queue, oldest first. Empty in a summary."`
}
Station is one station of the line in a report.
type Tool ¶
type Tool struct {
Name string `json:"name" doc:"Always factorymeter."`
Version string `json:"version" doc:"The version of the program."`
RegistryVersion string `json:"registry_version" doc:"The version of the agent signature registry used to tell agents from people."`
RecordSchema int `json:"record_schema" doc:"The version of the record layout in the store the report was read from."`
}
Tool names the program and the rule files behind a report.
type TrackerCoverage ¶ added in v0.5.0
type TrackerCoverage struct {
Source string `json:"source" doc:"The ticket system." enum:"linear,jira"`
Name string `json:"name" doc:"The URL key of the Linear workspace, or the host of the Jira site. Empty in a summary."`
SyncedAt time.Time `json:"synced_at" doc:"When it was last synced. The zero time while its first sync has not finished."`
Tickets int `json:"tickets" doc:"Its tickets in the store, in the window or not."`
Linked int `` /* 177-byte string literal not displayed */
Keys []string `` /* 197-byte string literal not displayed */
}
TrackerCoverage is one ticket system that is not a repository.
type Verdict ¶
type Verdict struct {
Headline string `json:"headline" doc:"One sentence that names the constraint and how it is moving."`
Constraint string `json:"constraint" doc:"The id of the constraint station. Empty when too few changes merged to name one."`
Detail string `json:"detail" doc:"One or two sentences of evidence behind the headline."`
}
Verdict is the answer on top of the page.
type Window ¶
type Window struct {
Since time.Time `json:"since" doc:"Start of the window the values are computed over."`
Until time.Time `json:"until" doc:"End of the window."`
PeriodDays int `json:"period_days" doc:"Length of one period of a history, in days. 7 unless asked otherwise."`
Periods []Period `json:"periods" doc:"The periods of every history, oldest first. They can reach further back than the window."`
Previous *Period `` /* 155-byte string literal not displayed */
}
Window is the time a report covers.