GT2: a delivery record keeps its delivery time; gate_times judges it

The head entry keeps merge-called from its opening and the pipeline's phases
from its end; a record whose every mover runs ends with delivery-time (from
merge-called to the last running of its movers) and class (core when a mover's
catalog entry, read once at its entry's opening, says core). gate_times answers
each class's budget (budget-core 10m, budget-leaf 3m), the last seven days'
median and worst, and every delivery over its budget with its longest phase.

Builds: design 47 H2 §810, §785; H-A-394
This commit is contained in:
2026-11-22 00:30:48 +01:00
parent 41610e903f
commit 607a1d76ea
12 changed files with 391 additions and 24 deletions
@@ -376,6 +376,9 @@ func (r *runtime) answer(m rpcMessage) {
return toolAnswer(map[string]any{"repository": repository, "branch": branch, "head": head}), nil
case "seat:mesh-hand-acts.hand-act":
return toolAnswer(map[string]any{"id": "hand-act-1"}), nil
case "seat:" + meshcatalog.Seat + "." + meshcatalog.VerbEntry:
// A mover's catalog entry, read once for its class (design 47 H2 §810): this test's modules are leaves.
return toolAnswer(map[string]any{"entry": map[string]any{"manifest": map[string]any{}}}), nil
case "gitea.gitea_note_append", "gitea.gitea_delivery_view", "gitea.gitea_commit_status", "gitea.gitea_merge_pull_request",
"gitea.gitea_add_comment":
return toolAnswer(map[string]any{}), nil
@@ -60,7 +60,8 @@ func main() {
}
h.init()
h.SaySeat = stdio.SeatPublish
h.Records = &Records{Ledger: sdkLedger{}, Now: h.Now, Retention: h.recordRetention, Say: stdio.SeatPublish, Logf: logf, TooLarge: h.recordTooLarge}
h.Records = &Records{Ledger: sdkLedger{}, Now: h.Now, Retention: h.recordRetention, Say: stdio.SeatPublish, Logf: logf, TooLarge: h.recordTooLarge,
Class: seatCatalog{ask: stdio.Ask}.Class}
h.Records.Changed = h.recordChanged
h.Forge = seatGit{ask: stdio.Ask}
h.Catalog = seatCatalog{ask: stdio.Ask}
@@ -186,7 +186,7 @@ func TestItClaimsTheDeliverySeatAndFollowsWhatItHandles(t *testing.T) {
}
// It calls no controller verb and no forge verb: the forge's reads and writes are the bridge's (ADR 0437 §8; design 47 §592).
// It uses no operator-channel: its stalled conditions went, the watchman's record-open the one signal (H-A-48).
want := []string{"seat:git.branch", "seat:mesh-catalog.registrations", "seat:mesh-hand-acts.hand-act", WantsEntryVerb, EngineCompositionVerb}
want := []string{"seat:git.branch", "seat:mesh-catalog.entry", "seat:mesh-catalog.registrations", "seat:mesh-hand-acts.hand-act", WantsEntryVerb, EngineCompositionVerb}
if len(m.Uses) != 0 {
t.Fatalf("uses %v", m.Uses)
}
@@ -16,6 +16,7 @@ import (
"time"
"git.novox.be/novox/mesh-sdk/go/buscalls"
catalogue "git.novox.be/novox/mesh-sdk/go/catalogue"
)
// TypeMover is the ledger type of a mover's entry.
@@ -26,7 +27,7 @@ const MoversIndex = "movers"
// The operations of a mover's entry; the manifest's type mover declares exactly these (record_test.go).
const (
OpMover = "mover" // set-fields: its record's key, its module, its pipeline and its version
OpMover = "mover" // set-fields: its record's key, its module, its class, its pipeline and its version
// OpEntry and OpOutcome write its entries and outcomes as they did on the whole record.
)
@@ -49,10 +50,12 @@ type Mover struct {
Sequence uint64 `json:"-"`
// Record is its record's key, `<branch>.<source>`, the index's field.
Record string `json:"record"`
Module string `json:"module"`
Pipeline string `json:"pipeline,omitempty"`
Version string `json:"version,omitempty"`
Record string `json:"record"`
Module string `json:"module"`
Pipeline string `json:"pipeline,omitempty"`
Version string `json:"version,omitempty"`
// Class is the module's class as its catalog entry said it when the entry opened (core or leaf, H-A-394 (2)).
Class string `json:"class,omitempty"`
Entries map[string]RecordEntry `json:"entries,omitempty"`
Outcomes map[string]RecordOutcome `json:"outcomes,omitempty"`
}
@@ -140,7 +143,7 @@ func (r *Record) join(ms []*Mover) {
func (r *Record) Movers() map[string]*Mover { return r.movers }
// mover is the record's entry of module, opened in the ledger when it has none, and counted on the head entry.
func (rs *Records) mover(r *Record, module string) (*Mover, error) {
func (rs *Records) mover(r *Record, module, fingerprint string) (*Mover, error) {
if m := r.movers[module]; m != nil {
return m, nil
}
@@ -148,8 +151,16 @@ func (rs *Records) mover(r *Record, module string) (*Mover, error) {
if err != nil {
return nil, err
}
m := &Mover{Instance: inst, Record: r.Milestone, Module: module}
seq, err := rs.Ledger.Apply(inst, OpMover, map[string]any{"record": r.Milestone, "module": module})
class := catalogue.ClassLeaf
if rs.Class != nil && fingerprint != "" {
c, err := rs.Class(fingerprint)
if err != nil {
return nil, fmt.Errorf("the class of %s at %s cannot be read from its catalog entry, so its entry is not opened: %w", module, fingerprint, err)
}
class = firstOf(c, catalogue.ClassLeaf)
}
m := &Mover{Instance: inst, Record: r.Milestone, Module: module, Class: class}
seq, err := rs.Ledger.Apply(inst, OpMover, map[string]any{"record": r.Milestone, "module": module, "class": class})
if err != nil {
return nil, err
}
@@ -167,8 +178,8 @@ func (rs *Records) mover(r *Record, module string) (*Mover, error) {
}
// SetMover writes a mover's pipeline and version, unless its entry holds them already.
func (rs *Records) SetMover(r *Record, module, pipeline, version string) error {
m, err := rs.mover(r, module)
func (rs *Records) SetMover(r *Record, module, fingerprint, pipeline, version string) error {
m, err := rs.mover(r, module, fingerprint)
if err != nil {
return err
}
@@ -180,7 +191,7 @@ func (rs *Records) SetMover(r *Record, module, pipeline, version string) error {
if err := rs.fits(m.Instance, next); err != nil {
return err
}
seq, err := rs.Ledger.Apply(m.Instance, OpMover, map[string]any{"record": r.Milestone, "module": module,
seq, err := rs.Ledger.Apply(m.Instance, OpMover, map[string]any{"record": r.Milestone, "module": module, "class": m.Class,
"pipeline": next.Pipeline, "version": next.Version})
if err != nil {
return err
@@ -22,6 +22,7 @@ import (
"time"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery"
runner "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/buscalls"
)
@@ -58,7 +59,7 @@ const (
)
// RecordOperations are a record's operations, in the order the manifest's type allows them.
var RecordOperations = []string{OpOpen, OpGroup, OpTrace, OpMovers, OpAway, OpBack, OpAct, OpEnd}
var RecordOperations = []string{OpOpen, OpGroup, OpTrace, OpMovers, OpPhases, OpAway, OpBack, OpAct, OpEnd}
// HeldOperations are the month's list's operations.
var HeldOperations = []string{OpHold, OpDrop}
@@ -102,6 +103,12 @@ type Record struct {
// MoverCount is the count of its movers, each with an entry of its own (design 47 H2 §809); Entries and Outcomes above
// are joined from those entries when read.
MoverCount int `json:"movers,omitempty"`
// MergeCalled is the merge-called event's own time, from the record's opening; DeliveryTime (a duration) and Class are
// written at its end, Phases at its pipeline's end (design 47 H2 §810, §785; H-A-394).
MergeCalled time.Time `json:"merge-called,omitzero"`
DeliveryTime string `json:"delivery-time,omitempty"`
Class string `json:"class,omitempty"`
Phases *runner.PipelineEndedPhases `json:"phases,omitempty"`
movers map[string]*Mover
}
@@ -368,6 +375,9 @@ type Records struct {
// Changed is told of every change of a record that owes the forge an act (A-39): a step's outcome applied, the record
// ended (owedacts.go); nil owes none.
Changed func(r *Record, c RecordChange)
// Class reads a mover's class from its catalog entry by its fingerprint (design 47 H2 §810; H-A-394 (2)), once, when its
// entry opens; nil reads none, every mover a leaf.
Class func(fingerprint string) (string, error)
// TooLarge raises (raised) or clears record-too-large for an entry (§809); nil raises none.
TooLarge func(instance string, bytes int, raised bool)
@@ -533,8 +543,12 @@ func (rs *Records) Open(o RecordOpening) (r *Record, opened bool, err error) {
if err != nil {
return nil, false, err
}
called := o.Trace.At.UTC()
if o.Trace.At.IsZero() {
called = now
}
body := map[string]any{"milestone": milestone, "branch": o.Branch, "source": o.Source, "call": o.Call, "heads": o.Heads,
"opened": now, "form": RecordForm}
"opened": now, "form": RecordForm, "merge-called": called}
if _, err := rs.Ledger.Apply(inst, OpOpen, body); err != nil {
return nil, false, err
}
@@ -724,7 +738,7 @@ func (rs *Records) Outcome(r *Record, o RecordOutcome) (applied bool, err error)
if had, ok := r.Outcomes[o.Key]; ok && (had.Event != "" && had.Event == o.Event || sameOutcome(had, o)) {
return false, nil
}
m, err := rs.mover(r, o.Module)
m, err := rs.mover(r, o.Module, o.Fingerprint)
if err != nil {
return false, err
}
@@ -755,7 +769,7 @@ func (rs *Records) AddEntry(r *Record, e RecordEntry) error {
if had, ok := r.Entries[e.Key]; ok && had == e {
return nil
}
m, err := rs.mover(r, e.Module)
m, err := rs.mover(r, e.Module, e.Fingerprint)
if err != nil {
return err
}
@@ -17,6 +17,8 @@ import (
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/buscalls"
"git.novox.be/novox/mesh-sdk/go/catalogue"
runner "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
)
// ledgerFake plays the tool runner's ledger for the gate's `records`, from the types the manifest declares: each operation
@@ -214,7 +216,7 @@ func TestTheDeliveryRecordIsALedgerInstanceKeyedByItsSourceRevision(t *testing.T
if err := rs.AddEntry(r, RecordEntry{Module: module, Fingerprint: "src2:f" + module}); err != nil {
t.Fatal(err)
}
if err := rs.SetMover(r, module, "main.90", "0.1.7"); err != nil {
if err := rs.SetMover(r, module, "src2:f"+module, "main.90", "0.1.7"); err != nil {
t.Fatal(err)
}
for _, node := range []string{"ace", "g14", "novox", "shanks"} {
@@ -251,6 +253,52 @@ func TestTheDeliveryRecordIsALedgerInstanceKeyedByItsSourceRevision(t *testing.T
}
})
// A record keeps its delivery time and class; gate_times judges them against the budgets (design 47 H2 §810; H-A-394).
t.Run("a core record ended 11 minutes after merge-called is over its budget", func(t *testing.T) {
now := at
rs := &Records{Ledger: newLedgerFake(t), Now: func() time.Time { return now }, Class: func(fp string) (string, error) {
if fp == "src2:core" {
return catalogue.ClassCore, nil
}
return "", nil
}}
h := &Holder{Records: rs, Now: func() time.Time { return now }}
for i, c := range []struct {
fp string
took time.Duration
}{{"src2:core", 11 * time.Minute}, {"src2:leaf", 2 * time.Minute}, {"src2:core", 4 * time.Minute}} {
o := opening("main", int64(200+i), heads)
o.Trace.At = now
r, _, err := rs.Open(o)
if err != nil {
t.Fatal(err)
}
if err := rs.AddEntry(r, RecordEntry{Module: "m" + c.fp, Fingerprint: c.fp}); err != nil {
t.Fatal(err)
}
p := now.Add(time.Minute)
if err := rs.SetPhases(r, &runner.PipelineEndedPhases{Taken: &now, Placed: &p, Build: &runner.PipelineEndedPhasesBuild{Start: &p, End: ptrTime(p.Add(7 * time.Minute))}}); err != nil {
t.Fatal(err)
}
if _, err := rs.Outcome(r, RecordOutcome{Module: "m" + c.fp, Fingerprint: c.fp, Node: "ace", Step: "running", Outcome: OutcomeRunning, At: now.Add(c.took)}); err != nil {
t.Fatal(err)
}
now = now.Add(c.took)
if err := rs.End(r, WhyAllRun, ""); err != nil {
t.Fatal(err)
}
if r.DeliveryTime != c.took.String() {
t.Fatalf("record %d keeps %q, want %s", i, r.DeliveryTime, c.took)
}
}
times, err := h.Times()
core, leaf := times[catalogue.ClassCore], times[catalogue.ClassLeaf]
if err != nil || core.Budget != "10m0s" || core.Deliveries != 2 || len(core.Over) != 1 || core.Over[0].DeliveryTime != "11m0s" ||
core.Over[0].Longest != "build" || core.Worst != "11m0s" || leaf.Deliveries != 1 || len(leaf.Over) != 0 {
t.Fatalf("gate_times %+v %v", times, err)
}
})
t.Run("an instance per source revision, a path the tool runner takes", func(t *testing.T) {
a, err := RecordInstance(recordMilestone("feat/x", 7))
if err != nil {
@@ -1007,3 +1055,5 @@ func (o *ownersFake) Running(node, module string) (string, string, error) {
func opening(branch string, source int64, heads map[string]string) RecordOpening {
return RecordOpening{Branch: branch, Source: source, Call: fmt.Sprintf("%016x", source), Heads: heads}
}
func ptrTime(t time.Time) *time.Time { return &t }
@@ -132,11 +132,23 @@ func (rs *Records) End(r *Record, why, by string) error {
func (rs *Records) end(r *Record, why, by string) error {
e := RecordEnded{At: rs.now(), Why: why, By: by, Away: awayList(r)}
seq, err := rs.Ledger.Apply(r.Instance, OpEnd, map[string]any{"ended": e})
body := map[string]any{"ended": e}
var took time.Duration
var class string
if why == WhyAllRun {
// Every mover runs: the record keeps its delivery time and class (design 47 H2 §810).
if took, class = timesAtEnd(r); took > 0 {
body["delivery-time"], body["class"] = took.String(), class
}
}
seq, err := rs.Ledger.Apply(r.Instance, OpEnd, body)
if err != nil {
return err
}
r.Ended, r.Sequence = &e, seq
if took > 0 {
r.DeliveryTime, r.Class = took.String(), class
}
rs.clearTooLarge(r)
rs.keep(r)
if rs.Changed != nil {
@@ -186,7 +186,7 @@ func (h *Holder) pipelineStarted(p runner.PipelineStartedEvent) error {
if err := h.Records.AddEntry(r, RecordEntry{Module: m.Module, Fingerprint: m.Fingerprint}); err != nil {
return err
}
if err := h.Records.SetMover(r, m.Module, p.Pipeline, m.Version); err != nil {
if err := h.Records.SetMover(r, m.Module, m.Fingerprint, p.Pipeline, m.Version); err != nil {
return err
}
}
@@ -209,7 +209,7 @@ func (h *Holder) pipelineEnded(p runner.PipelineEndedEvent) error {
if err := h.Records.AddEntry(r, RecordEntry{Module: m.Module, Fingerprint: m.Fingerprint}); err != nil {
return err
}
if err := h.Records.SetMover(r, m.Module, p.Pipeline, m.Version); err != nil {
if err := h.Records.SetMover(r, m.Module, m.Fingerprint, p.Pipeline, m.Version); err != nil {
return err
}
for _, s := range m.Steps {
@@ -226,6 +226,9 @@ func (h *Holder) pipelineEnded(p runner.PipelineEndedEvent) error {
}
}
}
if err := h.Records.SetPhases(r, p.Phases); err != nil {
return err
}
if p.Outcome == runner.PipelineEndedOutcomePassed {
return nil
}
@@ -195,6 +195,16 @@ func recordTools(h *Holder, acts handActs) []stdio.Tool {
}
return h.Records.RecordOf(strArg(a, "instance"), strArg(a, "milestone"))
}},
{Name: "gate_times",
Description: "Delivery times against their budgets (design 47 H2 §810; ADR 0282 §6): for the classes core and leaf, the " +
"budget (the settings budget-core and budget-leaf), the last seven days' median and worst delivery time from " +
"merge-called to the last running of its movers, and every delivery over its budget, newest first, with its longest phase.",
Run: func(map[string]any) (any, error) {
if h.Records == nil {
return none()
}
return h.Times()
}},
{Name: "gate_records",
Description: "Every delivery record kept, oldest first: its milestone, when it opened and ended, its entries, " +
"outcomes, nodes away and pins, its size against the bus's value limit, and while open what it waits for; and " +
@@ -30,6 +30,30 @@ type Registered interface {
// seatCatalog reads the seat mesh-catalog through the tool runner.
type seatCatalog struct{ ask asking }
// Class is the class of the module at fingerprint, as its catalog entry's manifest says it (design 47 H2 §810;
// H-A-394 (2)): the seat mesh-catalog's entry; a manifest with no class is a leaf.
func (s seatCatalog) Class(fingerprint string) (string, error) {
raw, err := s.ask("seat:"+meshcatalog.Seat+"."+meshcatalog.VerbEntry, meshcatalog.EntryInput{Fingerprint: fingerprint})
if err != nil {
return "", err
}
answer, said, ok := answerOf(raw)
if !ok {
return "", fmt.Errorf("entry refused: %s", lastLine(said))
}
var a struct {
Entry struct {
Manifest struct {
Class string `json:"class"`
} `json:"manifest"`
} `json:"entry"`
}
if err := json.Unmarshal(answer, &a); err != nil {
return "", fmt.Errorf("the answer of entry is not readable: %w", err)
}
return a.Entry.Manifest.Class, nil
}
// Registrations reads every registration, a module's and a source-only one alike (design 47 H2 §815), page by page from
// the cursor each page answers (§779, §806), so a registration past the first 768 KB is watched too.
func (s seatCatalog) Registrations() (meshcatalog.RegistrationsAnswer, error) {
@@ -0,0 +1,196 @@
package main
// A delivery record keeps its delivery time (design 47 H2 §810; ADR 0282 §1, §6, §7; ADR 0304; H-A-394): the head entry
// keeps `merge-called` from its opening, the pipeline's `phases` (§785) from its end, and at its end the record's
// `delivery-time`, from `merge-called` to the last `running` of its movers, and its `class`: core when it moves a module
// whose manifest's class (the catalog entry the gate read at the mover's opening) says core, else leaf. gate_times
// answers each class's budget, the last seven days' median and worst, and every delivery over its budget with its
// longest phase; the self-check's probe judges them, the gate raises nothing.
import (
"fmt"
"sort"
"time"
stdio "git.novox.be/novox/mesh-sdk/go"
catalogue "git.novox.be/novox/mesh-sdk/go/catalogue"
runner "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
)
// OpPhases writes the pipeline's phases on the head entry (set-fields phases).
const OpPhases = "phases"
// The budgets' settings and their defaults (ADR 0282, ADR 0304).
const (
BudgetCoreSetting = "budget-core"
BudgetLeafSetting = "budget-leaf"
DefaultBudgetCore = 10 * time.Minute
DefaultBudgetLeaf = 3 * time.Minute
)
// timesWindow is how far back gate_times reads (§810: the last seven days).
const timesWindow = 7 * 24 * time.Hour
// Budgets are the two classes' budgets, read with the one settings reader; a value that is no duration is said and the
// default kept.
func (h *Holder) Budgets() map[string]time.Duration {
out := map[string]time.Duration{}
for class, s := range map[string]struct {
key string
def time.Duration
}{catalogue.ClassCore: {BudgetCoreSetting, DefaultBudgetCore}, catalogue.ClassLeaf: {BudgetLeafSetting, DefaultBudgetLeaf}} {
d, err := stdio.SettingDuration(s.key, s.def)
if err != nil {
h.logf("[mesh-delivery] the setting %s: %v; %s is kept", s.key, err, s.def)
d = s.def
}
out[class] = d
}
return out
}
// SetPhases writes the pipeline's phases on the record's head entry, unless it holds them already.
func (rs *Records) SetPhases(r *Record, p *runner.PipelineEndedPhases) error {
if p == nil {
return nil
}
next := *r
next.Phases = p
if err := rs.fits(r.Instance, next.head()); err != nil {
return err
}
seq, err := rs.Ledger.Apply(r.Instance, OpPhases, map[string]any{"phases": p})
if err != nil {
return err
}
r.Phases, r.Sequence = p, seq
rs.fitted(r.Instance)
return nil
}
// timesAtEnd are the delivery time and the class of a record whose every mover runs: from merge-called to the last running
// of its movers; core when one of its movers is core. No delivery time without merge-called or a running.
func timesAtEnd(r *Record) (time.Duration, string) {
class := catalogue.ClassLeaf
var last time.Time
for _, m := range r.movers {
if m.Class == catalogue.ClassCore {
class = catalogue.ClassCore
}
for _, at := range m.Running() {
if at.After(last) {
last = at
}
}
}
if r.MergeCalled.IsZero() || last.IsZero() || last.Before(r.MergeCalled) {
return 0, class
}
return last.Sub(r.MergeCalled), class
}
// longestPhase is the record's longest phase of §785 and its length: the take-in, the placing, each step kind's span.
func longestPhase(p *runner.PipelineEndedPhases, mergeCalled time.Time) (string, time.Duration) {
if p == nil {
return "", 0
}
type span struct {
name string
start, end *time.Time
}
mc := mergeCalled
spans := []span{{"take-in", &mc, p.Taken}, {"placing", p.Taken, p.Placed}}
add := func(name string, start, end *time.Time) { spans = append(spans, span{name, start, end}) }
if b := p.Build; b != nil {
add("build", b.Start, b.End)
}
if b := p.Lint; b != nil {
add("lint", b.Start, b.End)
}
if b := p.Unit; b != nil {
add("unit", b.Start, b.End)
}
if b := p.Integration; b != nil {
add("integration", b.Start, b.End)
}
if b := p.Validate; b != nil {
add("validate", b.Start, b.End)
}
if b := p.Composition; b != nil {
add("composition", b.Start, b.End)
}
name, longest := "", time.Duration(0)
for _, s := range spans {
if s.start == nil || s.end == nil || s.start.IsZero() {
continue
}
if d := s.end.Sub(*s.start); d > longest {
name, longest = s.name, d
}
}
return name, longest
}
// TimesOver is one delivery over its class's budget, with its longest phase.
type TimesOver struct {
Record string `json:"record"`
Milestone string `json:"milestone"`
Ended string `json:"ended"`
DeliveryTime string `json:"delivery-time"`
Longest string `json:"longest-phase,omitempty"`
LongestTime string `json:"longest-phase-time,omitempty"`
}
// ClassTimes are one class's times over the last seven days.
type ClassTimes struct {
Budget string `json:"budget"`
Deliveries int `json:"deliveries"`
Median string `json:"median,omitempty"`
Worst string `json:"worst,omitempty"`
Over []TimesOver `json:"over"`
}
// Times is gate_times: each class's budget, the last seven days' median and worst, and every delivery over its budget,
// newest first, with its longest phase (§810; ADR 0282 §6).
func (h *Holder) Times() (map[string]ClassTimes, error) {
kept, err := h.keptRecords()
if err != nil {
return nil, err
}
budgets, now := h.Budgets(), h.Now().UTC()
by := map[string][]*Record{}
for _, r := range kept {
if r.Ended == nil || r.DeliveryTime == "" || now.Sub(r.Ended.At) > timesWindow {
continue
}
by[firstOf(r.Class, catalogue.ClassLeaf)] = append(by[firstOf(r.Class, catalogue.ClassLeaf)], r)
}
out := map[string]ClassTimes{}
for class, budget := range budgets {
rs := by[class]
ct := ClassTimes{Budget: budget.String(), Deliveries: len(rs), Over: []TimesOver{}}
var ds []time.Duration
sort.Slice(rs, func(i, j int) bool { return rs[i].Ended.At.After(rs[j].Ended.At) })
for _, r := range rs {
d, err := time.ParseDuration(r.DeliveryTime)
if err != nil {
return nil, fmt.Errorf("the record %s keeps a delivery time %q that is no duration", r.Instance, r.DeliveryTime)
}
ds = append(ds, d)
if d > budget {
o := TimesOver{Record: r.Instance, Milestone: r.Milestone, Ended: r.Ended.At.Format(time.RFC3339), DeliveryTime: d.String()}
if name, l := longestPhase(r.Phases, r.MergeCalled); name != "" {
o.Longest, o.LongestTime = name, l.String()
}
ct.Over = append(ct.Over, o)
}
}
if len(ds) > 0 {
sort.Slice(ds, func(i, j int) bool { return ds[i] < ds[j] })
ct.Median, ct.Worst = ds[len(ds)/2].String(), ds[len(ds)-1].String()
}
out[class] = ct
}
return out, nil
}
+46 -3
View File
@@ -128,6 +128,18 @@
},
"movers": {
"type": "integer"
},
"merge-called": {
"type": "string"
},
"delivery-time": {
"type": "string"
},
"class": {
"type": "string"
},
"phases": {
"type": "object"
}
},
"operations": [
@@ -141,7 +153,8 @@
"call",
"heads",
"opened",
"form"
"form",
"merge-called"
],
"sequence": true
},
@@ -170,6 +183,14 @@
],
"sequence": true
},
{
"name": "phases",
"effect": "set-fields",
"fields": [
"phases"
],
"sequence": true
},
{
"name": "away",
"effect": "set-entry",
@@ -208,7 +229,9 @@
"name": "end",
"effect": "set-fields",
"fields": [
"ended"
"ended",
"delivery-time",
"class"
],
"sequence": true
}
@@ -252,6 +275,9 @@
},
"event": {
"type": "string"
},
"class": {
"type": "string"
}
},
"operations": [
@@ -261,6 +287,7 @@
"fields": [
"record",
"module",
"class",
"pipeline",
"version"
],
@@ -369,6 +396,7 @@
},
"invokes": [
"seat:git.branch",
"seat:mesh-catalog.entry",
"seat:mesh-catalog.registrations",
"seat:mesh-hand-acts.hand-act",
"seat:mesh-wants.entry",
@@ -396,7 +424,8 @@
"gate_source",
"gate_source_again",
"gate_source_seed",
"gate_source_start"
"gate_source_start",
"gate_times"
],
"config": {
"record-retention": {
@@ -413,6 +442,20 @@
"minimum": 1,
"trusted": false,
"default": 10
},
"budget-core": {
"type": "string",
"description": "The budget of a delivery that moves a core module, from merge-called to the last running of its movers, as a duration such as 10m (ADR 0282; design 47 H2 §810): gate_times names every delivery over it, and the self-check raises over-budget for it.",
"trusted": false,
"runtime": true,
"default": "10m"
},
"budget-leaf": {
"type": "string",
"description": "The budget of a delivery that moves only leaf modules, as a duration such as 3m (ADR 0304; design 47 H2 §810).",
"trusted": false,
"runtime": true,
"default": "3m"
}
},
"resources": [