GATE-5: the delivery record follows its pipeline to the machines

The record a merge call opened takes the runner's pipeline-started,
pipeline-ended, wait-held and wait-ended, the assigner's wanted and
pipeline-wanted and the node-engine seat's running, read by its key, and
ends on pipeline-wanted (running: every tier runs; tier-late: failed) or
failed on a pipeline that did not pass.

Builds: design 47 H §738 (G §141 to §147); H-A-29, H-A-75, H-A-89 (1) to (5)

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
2026-11-20 03:33:56 +01:00
parent 2f471edc0f
commit 57984e9b98
8 changed files with 511 additions and 12 deletions
@@ -18,7 +18,10 @@ import (
"sync"
"time"
nodeengine "git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
runner "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
wants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein"
stdio "git.novox.be/novox/mesh-sdk/go"
)
@@ -45,7 +48,9 @@ type stepFamily struct {
// Event is the event's name after its owner; the node is the token after it when NodeScoped.
Event string
NodeScoped bool
Decode func(body json.RawMessage, at time.Time) ([]StepOutcome, error)
// Kind is the event's name on its owner's seat, with no subject tokens: what Follow is told it is.
Kind string
Decode func(body json.RawMessage, at time.Time) ([]StepOutcome, error)
}
// The step events on main the record is built from. A family is added here, with its `consumes` line, when its owner
@@ -54,13 +59,34 @@ var stepFamilies = []stepFamily{
// An entry taken in (the holder of the seat mesh-catalog's own `take-in.taken`, ADR 0633 §1): the merges a source
// revision took in. Its owner is the one the manifest consumes it from.
family(takein.TakeInTakenEvent, decodeTakenIn),
// The record follows its pipeline to the machines (design 47 H §738, H-A-29, H-A-75, H-A-89; recordpipeline.go): the
// runner's pipeline-started, pipeline-ended, wait-held and wait-ended on <branch>.<source>, the assigner's wanted on
// <node>.<module> and pipeline-wanted on <branch>.<source>, and the node-engine seat's running on <node>.<module>.
seatFamily(runner.EventPipelineStarted, 2, false, decodePipelineStarted),
seatFamily(runner.EventPipelineEnded, 2, false, decodePipelineEnded),
seatFamily(runner.EventWaitHeld, 2, false, decodeWait),
seatFamily(runner.EventWaitEnded, 2, false, decodeWait),
seatFamily(wants.EventWanted, 2, false, decodeWanted),
seatFamily(wants.EventPipelineWanted, 2, false, decodePipelineWanted),
seatFamily(nodeengine.EventRunning, 2, true, decodeRunning),
}
// seatFamily is a step family of a seat's event its manifest consumes with each token of its subject a wildcard
// (`<seat>.<event>.*.*`); of a node's event, the node is the first token after the event.
func seatFamily(event string, tokens int, nodeScoped bool, decode func(json.RawMessage, time.Time) ([]StepOutcome, error)) stepFamily {
f := family(event+strings.Repeat(".*", tokens), decode)
f.Kind = event
if nodeScoped {
f.Event, f.NodeScoped = event, true
}
return f
}
// family is a step family of an event as the manifest consumes it: `<owner>.<event>`.
func family(event string, decode func(json.RawMessage, time.Time) ([]StepOutcome, error)) stepFamily {
pattern := declared(event)
owner, _, _ := strings.Cut(pattern, ".")
return stepFamily{Pattern: pattern, Owner: owner, Event: event, Decode: decode}
return stepFamily{Pattern: pattern, Owner: owner, Event: event, Kind: event, Decode: decode}
}
// consumed is what the gate's manifest consumes (its own manifest): every event it follows is one of them.
@@ -115,6 +141,9 @@ type StepConsumer struct {
Logf func(format string, a ...any)
// Taken writes a take-in.taken into the record of its source revision (takenin.go).
Taken func(body json.RawMessage) error
// Follow writes an event of the record's pipeline families into the record of its source revision, told the event's
// kind (recordpipeline.go).
Follow func(kind string, body json.RawMessage) error
mu sync.Mutex
// heard counts, per family, the events applied, refused and the last applied, since this owner started.
@@ -179,6 +208,10 @@ func (c *StepConsumer) Hear(e stdio.Envelope) error {
if err := c.Taken(e.Body); err != nil {
return fmt.Errorf("the record of %s is not opened yet: %w", e.Key, err)
}
} else if f.Event != takein.TakeInTakenEvent && c.Follow != nil {
if err := c.Follow(f.Kind, e.Body); err != nil {
return fmt.Errorf("the record of %s is not written yet: %w", e.Key, err)
}
}
id := e.Headers["x-event-id"]
for _, o := range outcomes {
@@ -216,7 +249,7 @@ func ownerRefusal(f stepFamily, e stdio.Envelope) string {
// apply writes an outcome into every record that holds it, by its merge commits or by its entry: an open record, or one
// that ended without the node the outcome comes from (a node away that wakes adds its outcomes, and is no longer shown
// away). An open record whose present nodes then all run their entries ends.
// away). It ends no record: the assigner's pipeline-wanted does (design 47 H §738, H-A-89 (4)).
func (c *StepConsumer) apply(o StepOutcome, event string) error {
records, err := c.Records.Kept()
if err != nil {
@@ -238,9 +271,6 @@ func (c *StepConsumer) apply(o StepOutcome, event string) error {
return err
}
}
if _, err := c.Records.EndIfRun(r); err != nil {
return err
}
}
return nil
}
@@ -64,7 +64,8 @@ func main() {
h.Records.Changed = h.recordChanged
h.Forge = seatGit{ask: stdio.Ask}
h.Catalog = seatCatalog{ask: stdio.Ask}
h.Consumer = &StepConsumer{Records: h.Records, Families: stepFamilies, Now: h.Now, Logf: logf, Taken: h.TakenIn}
h.Consumer = &StepConsumer{Records: h.Records, Families: stepFamilies, Now: h.Now, Logf: logf, Taken: h.TakenIn,
Follow: h.Follow}
// The gate's one held writer of its own findings (design 47 G A-39, A-37, A-40): made at once, started once the runtime serves.
fw, err := NewFindingWriter()
if err != nil {
@@ -117,10 +117,14 @@ func TestItClaimsTheDeliverySeatAndFollowsWhatItHandles(t *testing.T) {
}
// The names move (milestone 47/G): the families heard from another module are its manifest's consumes, and no Go
// source of the gate names those modules.
if !slices.Contains(m.Consumes, owedEndedEvent) || owedEndedEvent == "" || len(stepFamilies) != 1 ||
!slices.Contains(m.Consumes, stepFamilies[0].Pattern) || stepFamilies[0].Owner+"."+stepFamilies[0].Event != stepFamilies[0].Pattern {
if !slices.Contains(m.Consumes, owedEndedEvent) || owedEndedEvent == "" || len(stepFamilies) != 8 {
t.Fatalf("owed.ended is %q and the step families %+v, not the manifest's consumes %v", owedEndedEvent, stepFamilies, m.Consumes)
}
for _, f := range stepFamilies {
if f.Pattern == "" || !slices.Contains(m.Consumes, f.Pattern) || !strings.HasPrefix(f.Pattern, f.Owner+"."+f.Kind) {
t.Errorf("the step family %+v is not one the manifest consumes %v", f, m.Consumes)
}
}
sources, _ := filepath.Glob("*.go")
for _, f := range sources {
if strings.HasSuffix(f, "_test.go") {
@@ -527,11 +527,28 @@ func (rs *Records) Open(o RecordOpening) (r *Record, opened bool, err error) {
// ByKey is the record of a source revision, read by its key `<branch>.<source>` (H-A-29); nil when none is kept.
func (rs *Records) ByKey(branch string, source int64) (*Record, error) {
inst, err := RecordInstance(recordMilestone(branch, source))
return rs.ByMilestone(recordMilestone(branch, source))
}
// ByMilestone is the record of a key `<branch>.<source>` (a pipeline's key of its source revision, H-A-89 (5)): the one
// the gate keeps as it writes it when it holds it, so a write through it is seen by every reader, else read from the
// ledger; nil when none is kept.
func (rs *Records) ByMilestone(milestone string) (*Record, error) {
inst, err := RecordInstance(milestone)
if err != nil {
return nil, err
}
return rs.Read(inst)
rs.mu.Lock()
held := rs.held[inst]
rs.mu.Unlock()
if held != nil {
return held, nil
}
r, err := rs.Read(inst)
if r != nil {
rs.keep(r)
}
return r, err
}
// sayOpened says record-opened on record-opened.<call>, so the session that called waits on its own call (§737). Said under
@@ -0,0 +1,308 @@
package main
// A delivery record follows its pipeline to the machines (design 47 H §738; G §141 to §147; H-A-29, H-A-75, H-A-89).
// The record a merge call opened (§737), read by its key `<branch>.<source>`, takes the runner's `pipeline-started` and
// `pipeline-ended` of its source revision and of the pipelines a package's publish starts from it (§747), the runner's
// `wait-held` and `wait-ended`, the assigner's `wanted` and `pipeline-wanted`, and the node-engine seat's `running`
// (consumer.go), on the gate's own durable consumer:
//
// - `pipeline-started`: each mover is an entry (module, fingerprint, no node);
// - `pipeline-ended`: each mover's step result is one outcome of its entry, its step the result's step, its outcome the
// result's own word, its why the result's (H-A-89 (1)); a pipeline that did not pass ends the record failed, naming
// the pipeline's why (H-A-89 (3));
// - `wait-held`: the waiting step's outcome is held, with what it waits on; `wait-ended` writes over it the wait's how
// (H-A-89 (2));
// - `wanted`: each want is an entry (module, fingerprint, node) with the outcome wanted, and the trace's from and to are
// the lowest and the highest assignment graph revision of the record's wants; a removed want writes nothing
// (H-A-89 (5));
// - `running`: a healthy running is the running-healthy outcome of every entry it is (consumer.go apply), and ends
// nothing (H-A-89 (4));
// - `pipeline-wanted`: `running` ends the record, every tier's movers running on every present placing machine;
// `tier-late` ends it failed, naming the movers and machines not running (H-A-75, H-A-89 (4); §751).
//
// A pipeline of a run on request delivers nothing, so its events write nothing. An event of a source revision with no
// record (a seed's or a start's, H-A-47), or of a record ended, writes nothing; each write is safe to repeat.
import (
"bytes"
"encoding/json"
"fmt"
"sort"
"strconv"
"strings"
"time"
nodeengine "git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
runner "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
wants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
)
// WhyFailed opens the why of a record that ended failed (H-A-89 (3), (4)).
const WhyFailed = "failed: "
// strictly reads an event's body in its owner's form, refusing a field it does not know.
func strictly(body json.RawMessage, into any) error {
dec := json.NewDecoder(bytes.NewReader(body))
dec.DisallowUnknownFields()
return dec.Decode(into)
}
func decodePipelineStarted(body json.RawMessage, _ time.Time) ([]StepOutcome, error) {
var p runner.PipelineStartedEvent
if err := strictly(body, &p); err != nil {
return nil, err
}
return nil, namesSource(p.Branch, p.Source, p.Run)
}
func decodePipelineEnded(body json.RawMessage, _ time.Time) ([]StepOutcome, error) {
var p runner.PipelineEndedEvent
if err := strictly(body, &p); err != nil {
return nil, err
}
return nil, namesSource(p.Branch, p.Source, p.Run)
}
func decodeWait(body json.RawMessage, _ time.Time) ([]StepOutcome, error) {
var w runner.WaitHeldEvent
if err := strictly(body, &w); err != nil {
return nil, err
}
if w.Step == "" {
return nil, fmt.Errorf("a wait names no step")
}
return nil, namesSource(w.Branch, w.Source, w.Run)
}
func decodeWanted(body json.RawMessage, _ time.Time) ([]StepOutcome, error) {
var w wants.WantedEvent
if err := strictly(body, &w); err != nil {
return nil, err
}
if w.Module == "" || w.Node == "" {
return nil, fmt.Errorf("a wanted names no module or node")
}
return nil, nil
}
func decodePipelineWanted(body json.RawMessage, _ time.Time) ([]StepOutcome, error) {
var p wants.PipelineWantedEvent
if err := strictly(body, &p); err != nil {
return nil, err
}
if p.Outcome != wants.PipelineWantedOutcomeRunning && p.Outcome != wants.PipelineWantedOutcomeTierLate {
return nil, fmt.Errorf("a pipeline-wanted says the outcome %q", p.Outcome)
}
return nil, namesSource(p.Branch, p.Source, "")
}
// decodeRunning is a healthy running's outcome, running-healthy, of the entry it is on its node (the subject's, which the
// consumer checks against the node it came from); a running unhealthy or stopped writes nothing.
func decodeRunning(body json.RawMessage, at time.Time) ([]StepOutcome, error) {
var r nodeengine.RunningEvent
if err := strictly(body, &r); err != nil {
return nil, err
}
if r.Module == "" {
return nil, fmt.Errorf("a running names no module")
}
if r.Stopped || r.Fingerprint == "" || r.Healthy != nil && !*r.Healthy {
return nil, nil
}
return []StepOutcome{{Module: r.Module, Fingerprint: r.Fingerprint, Step: StepRunning,
Outcome: OutcomeRunning, At: at}}, nil
}
// namesSource refuses an event of a pipeline that names no branch or source revision, unless it is a run on request's.
func namesSource(branch string, source int64, run string) error {
if run == "" && (branch == "" || source < 1) {
return fmt.Errorf("it names no branch or source revision")
}
return nil
}
// Follow writes one event of the record's pipeline families into the record of its source revision. Called with an
// event its family decoded; an error only when the record could not be read or written, so the event is offered again.
func (h *Holder) Follow(event string, body json.RawMessage) error {
if h.Records == nil {
return nil
}
switch event {
case runner.EventPipelineStarted:
var p runner.PipelineStartedEvent
if err := json.Unmarshal(body, &p); err != nil || p.Run != "" {
return nil
}
return h.pipelineStarted(p)
case runner.EventPipelineEnded:
var p runner.PipelineEndedEvent
if err := json.Unmarshal(body, &p); err != nil || p.Run != "" {
return nil
}
return h.pipelineEnded(p)
case runner.EventWaitHeld, runner.EventWaitEnded:
var w runner.WaitHeldEvent
if err := json.Unmarshal(body, &w); err != nil || w.Run != "" {
return nil
}
return h.wait(w, event == runner.EventWaitEnded)
case wants.EventWanted:
var w wants.WantedEvent
if err := json.Unmarshal(body, &w); err != nil || w.Removed || w.Pipeline == "" {
return nil
}
return h.wantWritten(w)
case wants.EventPipelineWanted:
var p wants.PipelineWantedEvent
if err := json.Unmarshal(body, &p); err != nil {
return nil
}
return h.pipelineWanted(p)
}
return nil
}
// openRecord is the record of a source revision while it is open, or nil.
func (h *Holder) openRecord(branch string, source int64) (*Record, error) {
r, err := h.Records.ByKey(branch, source)
if err != nil {
return nil, fmt.Errorf("the record of %s at %d cannot be read: %w", branch, source, err)
}
if r == nil || r.Ended != nil {
return nil, nil
}
return r, nil
}
func (h *Holder) pipelineStarted(p runner.PipelineStartedEvent) error {
r, err := h.openRecord(p.Branch, p.Source)
if err != nil || r == nil {
return err
}
for _, m := range p.Movers {
if m.Module == "" {
continue
}
if err := h.Records.AddEntry(r, RecordEntry{Module: m.Module, Fingerprint: m.Fingerprint}); err != nil {
return err
}
}
return nil
}
func (h *Holder) pipelineEnded(p runner.PipelineEndedEvent) error {
r, err := h.openRecord(p.Branch, p.Source)
if err != nil || r == nil {
return err
}
at := h.Now().UTC()
if p.Ended != nil {
at = p.Ended.UTC()
}
for _, m := range p.Movers {
if m.Module == "" {
continue
}
if err := h.Records.AddEntry(r, RecordEntry{Module: m.Module, Fingerprint: m.Fingerprint}); err != nil {
return err
}
for _, s := range m.Steps {
if s.Step == "" || s.Outcome == "" {
continue
}
when := at
if s.Ended != nil {
when = s.Ended.UTC()
}
if _, err := h.Records.Outcome(r, RecordOutcome{Module: m.Module, Fingerprint: m.Fingerprint, Step: s.Step,
Outcome: s.Outcome, Why: s.Why, At: when}); err != nil {
return err
}
}
}
if p.Outcome == runner.PipelineEndedOutcomePassed {
return nil
}
why := strings.TrimSpace(p.Why)
if why == "" {
why = "the pipeline " + p.Pipeline + " ended " + p.Outcome
}
return h.Records.End(r, WhyFailed+why, "")
}
func (h *Holder) wait(w runner.WaitHeldEvent, ended bool) error {
r, err := h.openRecord(w.Branch, w.Source)
if err != nil || r == nil {
return err
}
o := RecordOutcome{Module: w.Module, Fingerprint: w.Fingerprint, Step: w.Step, Outcome: OutcomeHeld, Why: w.On,
At: w.Since.UTC()}
if w.Who != "" {
o.Why += " (" + w.Who + ")"
}
if ended {
if w.How == "" {
h.logf("[mesh-delivery] a wait-ended of %s says no how, so the record %s keeps its wait", w.Pipeline, r.Instance)
return nil
}
o.Outcome, o.At = w.How, h.Now().UTC()
}
_, err = h.Records.Outcome(r, o)
return err
}
func (h *Holder) wantWritten(w wants.WantedEvent) error {
milestone, _, _ := strings.Cut(w.Pipeline, ".published.")
r, err := h.Records.ByMilestone(milestone)
if err != nil {
return fmt.Errorf("the record of the pipeline %s cannot be read: %w", w.Pipeline, err)
}
if r == nil || r.Ended != nil {
return nil
}
if err := h.Records.AddEntry(r, RecordEntry{Module: w.Module, Fingerprint: w.Fp, Node: w.Node}); err != nil {
return err
}
at := h.Now().UTC()
if w.At != nil {
at = w.At.UTC()
}
if _, err := h.Records.Outcome(r, RecordOutcome{Module: w.Module, Fingerprint: w.Fp, Node: w.Node, Step: StepWanted,
Outcome: OutcomeWanted, At: at}); err != nil {
return err
}
var t RecordTrace
if r.Trace != nil {
t = *r.Trace
}
rev := strconv.FormatInt(w.Revision, 10)
if from, err := strconv.ParseInt(t.From, 10, 64); err != nil || w.Revision < from {
t.From = rev
}
if to, err := strconv.ParseInt(t.To, 10, 64); err != nil || w.Revision > to {
t.To = rev
}
return h.Records.SetTrace(r, t)
}
func (h *Holder) pipelineWanted(p wants.PipelineWantedEvent) error {
r, err := h.openRecord(p.Branch, p.Source)
if err != nil || r == nil {
return err
}
if p.Outcome == wants.PipelineWantedOutcomeRunning {
return h.Records.End(r, WhyAllRun, "")
}
var late []string
for _, n := range p.NotRunning {
machines := append([]string(nil), n.Machines...)
sort.Strings(machines)
late = append(late, n.Module+" on "+strings.Join(machines, ", "))
}
sort.Strings(late)
why := "a tier is late"
if len(late) > 0 {
why += ": not running " + strings.Join(late, "; ")
}
return h.Records.End(r, WhyFailed+why, "")
}
@@ -0,0 +1,130 @@
package main
import (
"encoding/json"
"strings"
"testing"
"time"
stdio "git.novox.be/novox/mesh-sdk/go"
)
// pipelineBed is a gate with one record open, of main at source revision 1, and its consumer.
func pipelineBed(t *testing.T) (*Holder, *StepConsumer, *Record, *[]string) {
t.Helper()
now := time.Date(2026, 11, 20, 3, 0, 0, 0, time.UTC)
var ended []string
h := &Holder{Now: func() time.Time { return now }}
h.Records = &Records{Ledger: newLedgerFake(t), Now: h.Now, Say: func(subject string, body any, id string) error {
if strings.Contains(subject, ".record-ended") {
ended = append(ended, id)
}
return nil
}}
if _, _, err := h.Records.Open(opening("main", 1, map[string]string{"novox/app@5": strings.Repeat("a", 40)})); err != nil {
t.Fatal(err)
}
if _, err := h.Records.Kept(); err != nil { // the records as the gate keeps them, read once
t.Fatal(err)
}
r, err := h.Records.ByKey("main", 1)
if err != nil || r == nil {
t.Fatalf("the record is %v (%v)", r, err)
}
c := &StepConsumer{Records: h.Records, Families: stepFamilies, Now: h.Now, Taken: h.TakenIn, Follow: h.Follow}
return h, c, r, &ended
}
func hear(t *testing.T, c *StepConsumer, key, node, body string) {
t.Helper()
if !c.Takes(key) {
t.Fatalf("the consumer takes no %s", key)
}
if err := c.Hear(stdio.Envelope{Key: key, Node: node, Body: json.RawMessage(body)}); err != nil {
t.Fatalf("%s: %v", key, err)
}
}
// GATE-5/AC (design 47 H §738, H-A-89): the record follows its pipeline to the machines: pipeline-started's movers are
// entries, a wait is held then ended with its how, pipeline-ended's step results are outcomes, each want is an entry with
// wanted and moves the trace's from and to, a healthy running is running-healthy and ends nothing, and pipeline-wanted
// running ends the record; a run on request's events and a removed want write nothing.
func TestARecordFollowsItsPipelineToTheMachines(t *testing.T) {
h, c, r, ended := pipelineBed(t)
hear(t, c, "mesh-pipeline-runner.pipeline-started.main.1", "",
`{"v":1,"branch":"main","source":1,"pipeline":"main.1","call":"0000000000000001","movers":[{"module":"app","commit":"c","fingerprint":"f","repository":"novox/app","tier":1}]}`)
hear(t, c, "mesh-pipeline-runner.pipeline-started.main.1", "",
`{"v":1,"branch":"main","source":1,"pipeline":"main.1","run":"r1","movers":[{"module":"other","commit":"c","fingerprint":"g","repository":"novox/o","tier":1}]}`)
if _, ok := r.Entries[EntryKey("app", "f", "")]; !ok || len(r.Entries) != 1 {
t.Fatalf("entries %v: the mover is one, a run's none", r.Entries)
}
hear(t, c, "mesh-pipeline-runner.wait-held.main.1", "",
`{"v":1,"branch":"main","source":1,"pipeline":"main.1","module":"app","fingerprint":"f","step":"approval","on":"person","who":"the operator","since":"2026-11-20T03:01:00Z"}`)
held := r.Outcomes[OutcomeKey("app", "f", "", "approval")]
if held.Outcome != OutcomeHeld || held.Why != "person (the operator)" {
t.Fatalf("the wait is %+v", held)
}
hear(t, c, "mesh-pipeline-runner.wait-ended.main.1", "",
`{"v":1,"branch":"main","source":1,"pipeline":"main.1","module":"app","fingerprint":"f","step":"approval","on":"person","how":"answered","since":"2026-11-20T03:01:00Z"}`)
if o := r.Outcomes[OutcomeKey("app", "f", "", "approval")]; o.Outcome != "answered" {
t.Fatalf("the wait ended as %+v", o)
}
hear(t, c, "mesh-pipeline-runner.pipeline-ended.main.1", "",
`{"v":1,"branch":"main","source":1,"pipeline":"main.1","outcome":"passed","movers":[{"module":"app","fingerprint":"f","tier":1,"steps":[{"step":"build","status":"required","outcome":"passed"},{"step":"review","status":"optional","outcome":"nothing to run","why":"no reviewer"}]}]}`)
if o := r.Outcomes[OutcomeKey("app", "f", "", "review")]; o.Outcome != "nothing to run" || o.Why != "no reviewer" ||
r.Outcomes[OutcomeKey("app", "f", "", "build")].Outcome != "passed" || r.Ended != nil {
t.Fatalf("the steps are %+v and the record ended %+v", r.Outcomes, r.Ended)
}
for _, w := range []string{
`{"v":1,"node":"ace","module":"app","fp":"f","pipeline":"main.1","source":1,"revision":12}`,
`{"v":1,"node":"g14","module":"app","fp":"f","pipeline":"main.1","source":1,"revision":11}`,
`{"v":1,"node":"novox","module":"app","fp":"f","pipeline":"main.1","source":1,"revision":30,"removed":true}`,
} {
hear(t, c, "mesh-wants.wanted.x.app", "", w)
}
if r.Trace == nil || r.Trace.From != "11" || r.Trace.To != "12" {
t.Fatalf("the trace is %+v: from 11 to 12, a removed want moves nothing", r.Trace)
}
if o := r.Outcomes[OutcomeKey("app", "f", "ace", StepWanted)]; o.Outcome != OutcomeWanted {
t.Fatalf("the want on ace is %+v", o)
}
if _, ok := r.Entries[EntryKey("app", "f", "novox")]; ok {
t.Fatal("a removed want is an entry")
}
hear(t, c, "node-engine.running.ace.app", "ace", `{"v":1,"at":"2026-11-20T03:05:00Z","module":"app","node":"ace","fingerprint":"f","healthy":true}`)
hear(t, c, "node-engine.running.g14.app", "g14", `{"v":1,"at":"2026-11-20T03:05:00Z","module":"app","node":"g14","fingerprint":"f","healthy":true}`)
if o := r.Outcomes[OutcomeKey("app", "f", "g14", StepRunning)]; o.Outcome != OutcomeRunning || r.Ended != nil || len(*ended) != 0 {
t.Fatalf("running is %+v and the record ended %+v: running ends nothing", o, r.Ended)
}
hear(t, c, "mesh-wants.pipeline-wanted.main.1", "", `{"v":1,"pipeline":"main.1","branch":"main","source":1,"outcome":"running"}`)
if r.Ended == nil || r.Ended.Why != WhyAllRun || len(*ended) != 1 {
t.Fatalf("the record ended %+v, said %v", r.Ended, *ended)
}
if got, _ := h.Records.ByKey("main", 1); got != r {
t.Fatal("the record read by its key is not the one the gate keeps")
}
}
// GATE-5/AC (design 47 H §738, §751; H-A-75, H-A-89 (3), (4)): a pipeline-ended not passed ends the record failed naming
// the pipeline's why, and pipeline-wanted tier-late ends it failed naming the movers and machines not running.
func TestARecordEndsFailedOnAPipelineNotPassedOrATierLate(t *testing.T) {
for _, tc := range []struct{ name, key, body, why string }{
{"pipeline failed", "mesh-pipeline-runner.pipeline-ended.main.1",
`{"v":1,"branch":"main","source":1,"pipeline":"main.1","outcome":"failed","why":"build failed","movers":[{"module":"app","fingerprint":"f","tier":1,"steps":[{"step":"build","status":"required","outcome":"failed"}]}]}`,
"failed: build failed"},
{"pipeline cancelled, no why", "mesh-pipeline-runner.pipeline-ended.main.1",
`{"v":1,"branch":"main","source":1,"pipeline":"main.1","outcome":"cancelled","movers":[]}`,
"failed: the pipeline main.1 ended cancelled"},
{"tier late", "mesh-wants.pipeline-wanted.main.1",
`{"v":1,"pipeline":"main.1","branch":"main","source":1,"outcome":"tier-late","not-running":[{"module":"app","machines":["g14","ace"]}]}`,
"failed: a tier is late: not running app on ace, g14"},
} {
t.Run(tc.name, func(t *testing.T) {
_, c, r, ended := pipelineBed(t)
hear(t, c, tc.key, "", tc.body)
if r.Ended == nil || r.Ended.Why != tc.why || len(*ended) != 1 {
t.Fatalf("the record ended %+v, said %v; want %q", r.Ended, *ended, tc.why)
}
})
}
}
+3 -1
View File
@@ -3,6 +3,7 @@ module mesh-delivery-gate
go 1.26.0
require (
git.novox.be/novox/mesh-contracts/go/seats/nodeengine v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient v0.0.0-00010101000000-000000000000
@@ -10,6 +11,8 @@ require (
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view/viewstate v0.0.0-00010101000000-000000000000
@@ -37,7 +40,6 @@ require (
git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient v0.0.0-00010101000000-000000000000 // indirect
git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient v0.0.0-00010101000000-000000000000 // indirect
git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner v0.0.0-00010101000000-000000000000 // indirect
git.novox.be/novox/mesh-contracts/go/seats/nodeengine v0.0.0-00010101000000-000000000000 // indirect
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/containerimageregistryclient v0.0.0-00010101000000-000000000000 // indirect
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient v0.0.0-00010101000000-000000000000 // indirect
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/containerimageregistry v0.0.0-00010101000000-000000000000 // indirect
+7
View File
@@ -20,6 +20,13 @@
"git.merge-called.*",
"mesh-delivery-forge-bridge.forge.*.*.*.head-moved",
"mesh-delivery-indexer.take-in.taken",
"mesh-pipeline-runner.pipeline-started.*.*",
"mesh-pipeline-runner.pipeline-ended.*.*",
"mesh-pipeline-runner.wait-held.*.*",
"mesh-pipeline-runner.wait-ended.*.*",
"mesh-wants.wanted.*.*",
"mesh-wants.pipeline-wanted.*.*",
"node-engine.running.*.*",
"mesh-catalog.registration-changed",
"mesh-conditions.findings-asked"
],