Compare commits

...
10 Commits
Author SHA1 Message Date
mesh-tools fb23967de3 Merge pull request 'Design 47 H1: a pipeline ends failed as soon as it can no longer pass; end-again judges it by hand (H-A-163, H-A-164, H-A-171)' (#278) from fix/47-H1-runner-ends-multi-mover into main 2026-11-20 16:51:19 +00:00
jschoubben 07dd8ea842 Design 47 H1: the end names why each mover has no step, its registration or a publish (H-A-171)
The end judgement took every mover with no step as waiting on its
registration; one may wait for the publish of a mover it builds on. The
registration lookup tells them apart, and the why names each with its own
reason.

Builds: design 47 H §746, H-A-163, H-A-171, G A-327
2026-11-20 17:48:10 +01:00
mesh-tools 277c53067e Merge pull request 'Design 47 H1: proof 2, a two-module change along a dependency edge delivered by its pipeline (H §5 step 7)' (#273) from proof/47-H1-two-modules into main 2026-11-20 16:44:51 +00:00
mesh-tools 227f6e68ce Merge pull request 'Design 47 H1: a build with an unpinned package waits for its release (H-A-165)' (#277) from fix/47-H1-builder-waits-package into main 2026-11-20 16:41:47 +00:00
jschoubben 521cbf089e Design 47 H1: the seat mesh-pipeline-runner gains end-again, a hand act judging a pipeline's end once more (H-A-164)
A pipeline the end judgement before H-A-163 left running had no way to end
but a cancel. The runner's process answers end-again, so the end takes its
turn in the queue; runner_end_again asks it. The seat's definition changes:
its Go and TypeScript contracts are generated again.

Builds: design 47 H §746, H-A-163, H-A-164
2026-11-20 17:38:20 +01:00
jschoubben 39a2c6a944 Design 47 H1: a pipeline ends failed once it can no longer pass, a mover waiting on its registration named (H-A-163)
main.20 and main.22 never ended: a mover with no step placed (no registration)
held the end even after a placed mover's required step failed and nothing was
open. It now holds the end only while the pipeline could still pass.

Builds: design 47 H §746, H-A-163, G A-327
2026-11-20 17:38:20 +01:00
jschoubben 577ec05205 Design 47 H1: the runner says a mover waits on its registration when placed from the half or the queue (A-327)
A pipeline placed at its turn in the queue, or once its branch's half was held,
dropped its movers with no registration without a word: main.20 and main.22 sat
running with every step ended and nothing said why (their mover
mesh-delivery-contracts has no registration, so it is never placed and the
pipeline never ends).

Builds: design 47 G A-327, design 47 H §746
2026-11-20 17:38:20 +01:00
jschoubben 744204c5ab Builder: releases heard wake the package wait; its setting package-wait-minutes (H-A-165)
The process tells the builder each version-released it takes in and
gives it the newest release its record keeps, so an unpinned package's
step ask wakes on the event and pins the release; the wait's bound is
the setting package-wait-minutes (default 10), carried as a file under
the state dir like revision-wait-minutes.

Builds: design 47 H H-A-165, H-A-156, H-A-155
2026-11-20 17:37:25 +01:00
jschoubben 0f41b405ba Builder: a step ask naming a package with no pin waits for its release (H-A-165)
An entry keeps a mesh package with no released version unpinned
(H-A-161). Its step ask now waits, in the wait of H-A-155, for the
release of the module holding the package, heard or kept in the
builder's record of releases, and builds with that release as the pin;
past the bound the step fails naming the package and builds nothing.

Builds: design 47 H H-A-165, H-A-155, H-A-161
2026-11-20 17:37:25 +01:00
jschoubben e312999843 Design 47 H1: proof 2, a two-module change along a dependency edge delivered by its pipeline (H §5 step 7) 2026-11-20 17:06:04 +01:00
33 changed files with 524 additions and 33 deletions
@@ -222,6 +222,12 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
return err
}
b.RevisionWait = time.Duration(revisionWait) * time.Minute
// A step ask naming a package with no pin waits for its release (H-A-165); its bound is package-wait-minutes.
packageWait, err := numberFile(getenv("MESH_BUILDER_PACKAGE_WAIT_FILE"), int(build.DefaultPackageWait/time.Minute))
if err != nil {
return err
}
b.PackageWait = time.Duration(packageWait) * time.Minute
waitsBucket := process.AwaitBucket(ctx, js, conn, builds.StateBucket(cred.Module, build.WaitsState), "the toolchain waits are kept in memory only, and builder_waits shows none", logger.Printf)
b.Waits = newWaitsKept(waitsBucket, func(ctx context.Context, event, id string, body any) error {
return emitEvent(context.WithoutCancel(ctx), js, cred, event, id, body)
@@ -236,6 +242,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
return emitSeatEvent(context.WithoutCancel(ctx), js, cred, meshbuilds.SubjectPackagePublished, "package-published-"+p.Module+"-"+p.Version+"-"+p.Artifact, p)
}
b.Reserved = reserved
// A release heard, or the newest the builder's record keeps, pins a package an entry names with none (H-A-165).
reserved.heardReleased = b.VersionReleased
b.NewestReleased = reserved.r.NewestReleased
// The last versions-filled the stream keeps is read at the start (design 47 G §369, §372): a restart does not lose it.
reserved.readFilled(ctx, lastKeptOf(js, cred, logger.Printf), sleeps)
// A state bound later numbers the builds looked at without it.
@@ -44,12 +44,15 @@ type reservations struct {
// built asks a done build's publish (design 47 G A-457a), released ends its item; nil are none.
built func(ctx context.Context, module, version string) error
released func(ctx context.Context, module, version string)
filled atomic.Bool
bounds func() jetstream.KeyValue
found *findings
bound time.Duration
wake func(context.Context)
logf func(string, ...any)
// heardReleased is told each version-released taken in (design 47 H H-A-165): a step ask waiting for a package of the
// module wakes. Nil tells nobody.
heardReleased func(module, version string)
filled atomic.Bool
bounds func() jetstream.KeyValue
found *findings
bound time.Duration
wake func(context.Context)
logf func(string, ...any)
// call asks a seat's verb: the git seat's tag (design 47 G §370).
call toolCaller
// say says package-published on the seat mesh-builds; nil says none.
@@ -252,6 +255,9 @@ func (rv *reservations) heard(ctx context.Context, m jetstream.Msg) bool {
if rv.released != nil {
rv.released(ctx, ev.Module, ev.Version)
}
if rv.heardReleased != nil {
rv.heardReleased(ev.Module, ev.Version)
}
rv.found.clear(ctx, versions.VersionUnreleased, meshconditionsclient.ScopeModule, ev.Module)
default:
return false
@@ -134,10 +134,15 @@ func TestTheCatalogsWordsMoveTheReservations(t *testing.T) {
if err != nil || !strings.Contains(got.Summary, "m:b unpublished") || strings.Contains(got.Summary, "m:a unpublished") || !strings.Contains(got.Summary, "1.4.3") {
t.Fatalf("finding = %+v (%v), want version-unreleased naming m:b of 1.4.3", got, err)
}
var heardReleases []string // H-A-165: a release heard wakes a step ask waiting for a package of the module
rv.heardReleased = func(m, v string) { heardReleases = append(heardReleases, m+" "+v) }
released := &wakeMsg{subject: meshcatalog.SubjectVersionReleased, data: []byte(`{"v":1,"module":"m","version":"1.4.3","source":1,"artifacts":[]}`)}
if !rv.heard(ctx, released) || !released.acked {
t.Fatalf("version-released was not taken in (acked %v)", released.acked)
}
if strings.Join(heardReleases, ", ") != "m 1.4.3" {
t.Errorf("the release heard was told %v, want m 1.4.3 (H-A-165)", heardReleases)
}
if strings.Join(items, ", ") != "asked m 1.4.3, ended m 1.4.3" {
t.Errorf("publish items %v, want the build's end to ask the publish and the release to end it", items)
}
@@ -3,10 +3,13 @@ package build
import (
"context"
"fmt"
"maps"
"slices"
"time"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
)
// **A build waits for its revision; a build with no version is never made** (design 47 H H-A-155, H-A-156; H-A-141): a step
@@ -100,3 +103,108 @@ func (b *Builder) awaitRevision(ctx context.Context, run meshbuilds.StepRun) (ou
}
}
}
// **A package with no pin waits for its release** (design 47 H H-A-165, H-A-161): an entry keeps a mesh package none of
// whose versions is released with an empty version. Its step ask waits, as for its revision, for the release of the module
// that holds the package (the catalog's version-released, VersionReleased), up to PackageWait (the setting
// package-wait-minutes), then builds with that release as the package's pin (v<version>); past the bound the step fails,
// naming the package, and nothing is built.
// DefaultPackageWait is the bound of a step ask's wait for a package's release, its setting package-wait-minutes' default.
const DefaultPackageWait = 10 * time.Minute
func (b *Builder) packageWait() time.Duration {
if b.PackageWait > 0 {
return b.PackageWait
}
return DefaultPackageWait
}
// VersionReleased takes the catalog's version-released of module in: a step ask waiting for a package of it wakes.
func (b *Builder) VersionReleased(module, version string) {
b.init()
b.mu.Lock()
b.releases[module] = version
b.mu.Unlock()
b.pictureMoved()
}
// releaseOf is the pin a package is built against: the release of the module holding it, as Go names it; "" for none yet.
func (b *Builder) releaseOf(ctx context.Context, pkg string) string {
if b.Members == nil {
return ""
}
module, _, found, err := b.Members(ctx, pkg)
if err != nil || !found {
return ""
}
b.mu.Lock()
v := b.releases[module]
b.mu.Unlock()
if v == "" && b.NewestReleased != nil {
if kept, ok, err := b.NewestReleased(ctx, module); err == nil && ok {
v = kept
}
}
if v == "" {
return ""
}
return "v" + v
}
// awaitPins fills each package entry names with no pin from its release, waiting for one; no outcome once every package has
// a pin, failed past the bound, could not run at the builder's stop.
func (b *Builder) awaitPins(ctx context.Context, entry *meshcatalog.CatalogEntry) (outcome, said string) {
var unpinned []string
for p, v := range entry.Packages {
if v == "" {
unpinned = append(unpinned, p)
}
}
if len(unpinned) == 0 {
return "", ""
}
slices.Sort(unpinned)
bound := b.packageWait()
wait, stop := context.WithTimeout(ctx, bound) // a context's bound, no timer (ADR 0437 §8)
defer stop()
pins := map[string]string{}
told := false
for {
b.mu.Lock()
moved := b.moved
b.mu.Unlock()
missing := ""
for _, p := range unpinned {
if pins[p] == "" {
pins[p] = b.releaseOf(ctx, p)
}
if pins[p] == "" && missing == "" {
missing = p
}
}
if missing == "" {
packages := maps.Clone(entry.Packages)
maps.Copy(packages, pins)
entry.Packages = packages
if told {
b.logf("%s at %s: every package it names has a released version: built with %v", entry.Module, entry.Fp, pins)
}
return "", ""
}
notReleased := fmt.Sprintf("package %s has no released version", missing)
if !told {
b.logf("%s at %s: %s yet: the ask waits for its release, at most %s", entry.Module, entry.Fp, notReleased, bound)
told = true
}
select {
case <-moved:
case <-wait.Done():
if ctx.Err() != nil {
return meshbuilds.StepEndedOutcomeCouldNotRun, notReleased + ": the builder stopped before it was"
}
b.logf("%s at %s: %s within %s: the step fails, nothing is built", entry.Module, entry.Fp, notReleased, bound)
return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s within %s", notReleased, bound)
}
}
}
@@ -113,6 +113,11 @@ type Builder struct {
// RevisionWait bounds a step ask's wait for its revision, its setting revision-wait-minutes (H-A-156); DefaultRevisionWait
// when 0.
RevisionWait time.Duration
// PackageWait bounds a step ask's wait for the release of a package its entry names with no pin, its setting
// package-wait-minutes (H-A-165); DefaultPackageWait when 0. NewestReleased reads the newest version the builder's
// record of releases keeps for a module; nil reads none, and only a release heard (VersionReleased) gives a pin.
PackageWait time.Duration
NewestReleased func(ctx context.Context, module string) (version string, found bool, err error)
// Forms answers what each node's engine states it reads (ADR 0618 §2, ADR 0624 §1): present, the nodes whose engine
// answered when last asked, and counted, every node the assignments names, present or away, a node with no statement
// stating nothing (the baseline's first forms). A done key names each artifact in the forms these keep, the oldest in
@@ -157,6 +162,8 @@ type Builder struct {
builds map[string]context.CancelCauseFunc
// moved is closed and made again at each entry the picture takes in or drops: the step asks waiting for a revision wake.
moved chan struct{}
// releases are the versions heard released, by module (VersionReleased): a package with no pin waits for one.
releases map[string]string
}
type planned struct {
@@ -187,6 +194,7 @@ func (b *Builder) init() {
b.hands, b.events = map[string]*handWatch{}, map[string]bool{}
b.builds = map[string]context.CancelCauseFunc{}
b.moved = make(chan struct{})
b.releases = map[string]string{}
})
}
@@ -63,6 +63,10 @@ func (b *Builder) buildEntry(ctx context.Context, e meshbuilds.BuildEntry) (outc
if entry.Module != e.Module || (e.Commit != "" && entry.Commit != e.Commit) {
return meshbuilds.StepEndedOutcomeCouldNotRun, fmt.Sprintf("the entry of %s at %s is of %s at %s", e.Module, e.Fingerprint, entry.Module, entry.Commit)
}
// A package the entry names with no pin is built against its release, waited for (H-A-165).
if outcome, said := b.awaitPins(ctx, &entry); outcome != "" {
return outcome, said
}
key, err := builds.BuilderBuildKey(entry.Module, entry.Fp)
if err != nil {
return meshbuilds.StepEndedOutcomeCouldNotRun, err.Error()
@@ -3,7 +3,9 @@ package build
import (
"context"
"errors"
"reflect"
"strings"
"sync"
"sync/atomic"
"testing"
"time"
@@ -11,6 +13,7 @@ import (
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
"git.novox.be/novox/mesh-sdk/go/catalogue"
"mesh-delivery-builder/internal/versions"
@@ -116,6 +119,79 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T)
t.Run("H-A-155: an ask waits for the picture to take its revision in, then builds with its version reserved", aStepAskWaitsForItsRevision)
t.Run("H-A-155: past the bound the ask fails naming its revision, and nothing is built", aStepAskPastItsRevisionBoundFails)
t.Run("H-A-162: a revision held that changes no entry wakes the ask", aRevisionHeldWakesTheAsk)
t.Run("H-A-165: a package with no pin waits for its release and is built with it", aPackageWithNoPinWaitsForItsRelease)
t.Run("H-A-165: past its bound a package with no release fails the step", aPackageWithNoReleaseFailsPastItsBound)
}
// unpinnedRig is a rig whose step entry m names the package x with no version, built by the module contracts.
func unpinnedRig(t *testing.T) (*rig, *fakeReservations) {
var held atomic.Int64
r, res, entry := revisionRig(t, &held, make(chan struct{}, 1))
r.b.Picture = nil // no revision to wait for here
entry.Packages = map[string]string{"git.novox.be/novox/mesh-contracts/go/seats/x": "", "git.novox.be/novox/mesh-sdk/go": "v0.1.20"}
r.b.StepEntry = func(context.Context, string) (meshcatalog.CatalogEntry, error) { return entry, nil }
r.b.Members = func(_ context.Context, pkg string) (string, string, bool, error) {
return "contracts", "contracts:x", pkg == "git.novox.be/novox/mesh-contracts/go/seats/x", nil
}
return r, res
}
func aPackageWithNoPinWaitsForItsRelease(t *testing.T) {
r, _ := unpinnedRig(t)
var once sync.Once
looked := make(chan struct{})
r.b.NewestReleased = func(context.Context, string) (string, bool, error) { // the record holds none yet
once.Do(func() { close(looked) })
return "", false, nil
}
ended := make(chan meshbuilds.StepEnded, 1)
go func() {
ended <- r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "main.9.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Source: 41,
Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}})
}()
select {
case <-looked:
case end := <-ended:
t.Fatalf("the ask ended before the package was released: %+v, asks %+v", end, r.asks.Asks())
case <-time.After(5 * time.Second):
t.Fatal("the ask never looked for the package's release")
}
if _, ok := r.st.vals[r.key]; ok {
t.Fatal("the build was made before the package had a release")
}
r.b.VersionReleased("contracts", "0.1.3")
var end meshbuilds.StepEnded
select {
case end = <-ended:
case <-time.After(5 * time.Second):
t.Fatal("the release did not wake the ask")
}
r.b.Wait()
asks := r.asks.Asks()
if end.Outcome != meshbuilds.StepEndedOutcomePassed || len(asks) == 0 ||
!reflect.DeepEqual(asks[0].Packages, buildstep.PackageVersions{"git.novox.be/novox/mesh-contracts/go/seats/x": "v0.1.3", "git.novox.be/novox/mesh-sdk/go": "v0.1.20"}) {
t.Errorf("end = %+v, asks %+v; want passed, built with x at v0.1.3", end, asks)
}
}
func aPackageWithNoReleaseFailsPastItsBound(t *testing.T) {
r, _ := unpinnedRig(t)
r.b.PackageWait = time.Nanosecond
end := r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "main.9.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Source: 41,
Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}})
r.b.Wait()
if _, built := r.st.vals[r.key]; end.Outcome != meshbuilds.StepEndedOutcomeFailed || built ||
!strings.Contains(end.Said, "package git.novox.be/novox/mesh-contracts/go/seats/x has no released version") {
t.Errorf("end = %+v, built %v; want failed naming the package, nothing built", end, built)
}
// A release the builder's own record keeps gives the pin at once.
r.b.NewestReleased = func(_ context.Context, module string) (string, bool, error) {
return "0.1.2", module == "contracts", nil
}
if end := r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "main.9.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Source: 41,
Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}}); strings.Contains(end.Said, "no released version") {
t.Errorf("a release the record keeps did not pin the package: %+v", end)
}
}
func aRevisionHeldWakesTheAsk(t *testing.T) {
@@ -295,6 +295,23 @@ func (r *Reserver) ReleasedFor(ctx context.Context, module, fingerprint string)
return false, nil
}
// NewestReleased is the newest version the builder's own record of releases keeps for module (design 47 H H-A-165): a
// package with no pin is built against it; false when the record holds none.
func (r *Reserver) NewestReleased(ctx context.Context, module string) (string, bool, error) {
if r.Releases == nil {
return "", false, nil
}
raw, _, found, err := r.Releases.Get(ctx, ReleasedKey(module))
if err != nil || !found {
return "", false, err
}
var rec ReleasedRecord
if json.Unmarshal(raw, &rec) != nil || len(rec.Kept) == 0 {
return "", false, nil
}
return rec.Kept[len(rec.Kept)-1].Version, true, nil
}
// keepRelease adds a release to the module's record, dropping the oldest past ReleasedKept.
func (r *Reserver) keepRelease(ctx context.Context, module, fingerprint, version string) error {
n := r.ReleasedKept
@@ -201,11 +201,13 @@ func TestAReleaseIsRecordedByFingerprintBeforeItsReservationGoes(t *testing.T) {
t.Errorf("reservations left: %v", all)
}
// One key per module holds the last releases, the oldest dropped (A-456b).
newest := ""
for _, fp := range []string{"src2:b1", "src2:b2"} {
n, err := r.Reserve(ctx, "m", "0.1", []string{"m:a"}, Source{Fingerprint: fp})
if err != nil {
t.Fatal(err)
}
newest = n.Version
if _, err := r.Released(ctx, "m", n.Version); err != nil {
t.Fatal(err)
}
@@ -219,6 +221,13 @@ func TestAReleaseIsRecordedByFingerprintBeforeItsReservationGoes(t *testing.T) {
if ok, _ := r.ReleasedFor(ctx, "m", "src2:b2"); !ok {
t.Error("the newest release is not kept")
}
// H-A-165: the newest version the record keeps is the pin of a package with none.
if v, ok, err := r.NewestReleased(ctx, "m"); !ok || err != nil || v != newest {
t.Errorf("newest released of m = %q, %v (%v), want %s", v, ok, err, newest)
}
if _, ok, _ := r.NewestReleased(ctx, "other"); ok {
t.Error("a module never released has a newest release")
}
}
// TestARebuildReservesAboveTheCatalogsHighestWhateverItsStandingNumberWas: design 47 G A-490b — a build again of a done key replaces
@@ -186,9 +186,9 @@ func TestManifestDeclarations(t *testing.T) { // 1607/AC1
m.Streams[2].Name != "mesh-delivery-builder-findings" || !reflect.DeepEqual(m.Streams[2].Events, []string{"finding-written.*", "finding-cleared.*", "findings-stated.*"}) {
t.Errorf("streams = %+v, want waits with wait-held.** and wait-ended.**, 7 days, 16 MiB, the builds' stream (build.ended.**, 7 days, kept last per subject: design 47 G A-181) and the findings' stream", m.Streams)
}
if c, ok := m.Config["toolchain-wait-minutes"]; !ok || c.Default != float64(60) || len(m.Config) != 6 || m.Config["revision-wait-minutes"].Default != float64(2) ||
if c, ok := m.Config["toolchain-wait-minutes"]; !ok || c.Default != float64(60) || len(m.Config) != 7 || m.Config["revision-wait-minutes"].Default != float64(2) || m.Config["package-wait-minutes"].Default != float64(10) ||
m.Config["publish-pause"].Default != float64(30) || m.Config["publish-pause-max"].Default != float64(30) || m.Config["publish-tries"].Default != float64(8) {
t.Errorf("config = %+v, want toolchain-wait-minutes of 60, revision-wait-minutes of 2 (H-A-156), the publish settings 30 s, 30 min and 8 tries (design 47 G §588, §633, A-457a)", m.Config)
t.Errorf("config = %+v, want toolchain-wait-minutes of 60, revision-wait-minutes of 2 (H-A-156), package-wait-minutes of 10 (H-A-165), the publish settings 30 s, 30 min and 8 tries (design 47 G §588, §633, A-457a)", m.Config)
}
// Design 47 G §349: version.numbered is no longer said; old-form-closed on the family version, apart from the builds' ends.
if want := []string{"build.asked-again", "version.old-form-closed"}; !reflect.DeepEqual(m.Emits, want) {
@@ -241,7 +241,7 @@ func TestManifestProcess(t *testing.T) { // 1607/AC1
t.Errorf("process = %v", p)
}
env, _ := p["env"].(map[string]any)
if len(env) != 7 || env["MESH_BUILDER_REVISION_WAIT_FILE"] != "${dir:state}/revision-wait-minutes" || env["MESH_BUILDER_PUBLISH_TRIES_FILE"] != "${dir:state}/publish-tries" || env["MESH_BROKER_FILE"] != "${dir:state}/broker" || env["MESH_BUILDER_TOOLCHAIN_WAIT_FILE"] != "${dir:state}/toolchain-wait-minutes" {
if len(env) != 8 || env["MESH_BUILDER_REVISION_WAIT_FILE"] != "${dir:state}/revision-wait-minutes" || env["MESH_BUILDER_PACKAGE_WAIT_FILE"] != "${dir:state}/package-wait-minutes" || env["MESH_BUILDER_PUBLISH_TRIES_FILE"] != "${dir:state}/publish-tries" || env["MESH_BROKER_FILE"] != "${dir:state}/broker" || env["MESH_BUILDER_TOOLCHAIN_WAIT_FILE"] != "${dir:state}/toolchain-wait-minutes" {
t.Errorf("env = %v, want the broker file and the path of the toolchain wait's file, never the setting itself (design 47 G §672, A-71)", p["env"])
}
for k, v := range env {
+17
View File
@@ -155,6 +155,14 @@
"trusted": false,
"default": 2
},
"package-wait-minutes": {
"type": "number",
"description": "minutes a build step ask waits for the release of a mesh package its entry names with no pin before it fails, building nothing (design 47 H H-A-165).",
"minimum": 1,
"maximum": 120,
"trusted": false,
"default": 10
},
"publish-pause": {
"type": "number",
"description": "seconds before a version's second publish try, doubled per try up to publish-pause-max (design 47 G A-457a).",
@@ -239,6 +247,14 @@
"mode": "0600",
"content": "${config:revision-wait-minutes}"
},
{
"id": "package-wait",
"type": "file",
"path": "${dir:state}/package-wait-minutes",
"owner": "mesh-delivery-builder",
"mode": "0600",
"content": "${config:package-wait-minutes}"
},
{
"id": "publish-pause",
"type": "file",
@@ -286,6 +302,7 @@
"MESH_BROKER_FILE": "${dir:state}/broker",
"MESH_BUILDER_TOOLCHAIN_WAIT_FILE": "${dir:state}/toolchain-wait-minutes",
"MESH_BUILDER_REVISION_WAIT_FILE": "${dir:state}/revision-wait-minutes",
"MESH_BUILDER_PACKAGE_WAIT_FILE": "${dir:state}/package-wait-minutes",
"MESH_BUILDER_PUBLISH_PAUSE_FILE": "${dir:state}/publish-pause",
"MESH_BUILDER_PUBLISH_PAUSE_MAX_FILE": "${dir:state}/publish-pause-max",
"MESH_BUILDER_PUBLISH_TRIES_FILE": "${dir:state}/publish-tries",
@@ -26,6 +26,7 @@ const (
VerbRerun = "rerun"
VerbAccept = "accept"
VerbCancel = "cancel"
VerbEndAgain = "end-again"
VerbPlace = "place"
VerbAskAgain = "ask-again"
VerbTestRuns = "test-runs"
@@ -47,7 +48,7 @@ const (
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
func Verbs() []string {
return []string{VerbRun, VerbStart, VerbShow, VerbList, VerbStands, VerbWhyCarried, VerbKept, VerbReview, VerbRerun, VerbAccept, VerbCancel, VerbPlace, VerbAskAgain, VerbTestRuns, VerbTestRunsDrop}
return []string{VerbRun, VerbStart, VerbShow, VerbList, VerbStands, VerbWhyCarried, VerbKept, VerbReview, VerbRerun, VerbAccept, VerbCancel, VerbEndAgain, VerbPlace, VerbAskAgain, VerbTestRuns, VerbTestRunsDrop}
}
// Events is every event published on the seat's subject: a new copy each call.
@@ -1195,6 +1196,19 @@ type CancelAnswer struct {
Pipeline Pipeline `json:"pipeline"`
}
// EndAgainInput is what end-again takes.
type EndAgainInput struct {
// the pipeline's key
Pipeline string `json:"pipeline"`
// why, written with the caller the runtime proves in the hand-act log
Why string `json:"why"`
}
// EndAgainAnswer is what end-again answers.
type EndAgainAnswer struct {
Pipeline Pipeline `json:"pipeline"`
}
// PlaceInput is what place takes.
type PlaceInput struct {
// the pipeline's key
@@ -119,6 +119,8 @@ func TestFixtures(t *testing.T) {
decode: func(b []byte) (any, error) { var v TestRunsDropAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
{name: "place asks a waiting pipeline ahead of its turn, with why", subject: "", given: "{\"pipeline\":\"main.3590\",\"why\":\"the operator wants the fix out first\"}", wire: "{\"pipeline\":\"main.3590\",\"why\":\"the operator wants the fix out first\"}",
decode: func(b []byte) (any, error) { var v PlaceInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
{name: "end-again asks a running pipeline's end judged once more, with why", subject: "", given: "{\"pipeline\":\"main.20\",\"why\":\"a mover waits on its registration and another failed\"}", wire: "{\"pipeline\":\"main.20\",\"why\":\"a mover waits on its registration and another failed\"}",
decode: func(b []byte) (any, error) { var v EndAgainInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
}
for _, c := range cases {
v, err := c.decode([]byte(c.given))
@@ -336,5 +336,13 @@
"pipeline": "main.3590",
"why": "the operator wants the fix out first"
}
},
{
"name": "end-again asks a running pipeline's end judged once more, with why",
"of": "verb:end-again.input",
"given": {
"pipeline": "main.20",
"why": "a mover waits on its registration and another failed"
}
}
]
@@ -474,6 +474,39 @@
},
"class": "act"
},
{
"name": "end-again",
"description": "A running pipeline's end judged once more, as at a step's end: it ends when it can, failed as soon as it can no longer pass (design 47 H §746, H-A-163, H-A-164). Written in the hand-act log.",
"input": {
"type": "object",
"properties": {
"pipeline": {
"type": "string",
"description": "the pipeline's key"
},
"why": {
"type": "string",
"description": "why, written with the caller the runtime proves in the hand-act log"
}
},
"required": [
"pipeline",
"why"
]
},
"answer": {
"type": "object",
"properties": {
"pipeline": {
"$ref": "#/defs/Pipeline"
}
},
"required": [
"pipeline"
]
},
"class": "act"
},
{
"name": "place",
"description": "A waiting pipeline placed ahead of its turn, its steps asked now; written in the hand-act log (design 47 H §748, H-A-53).",
@@ -16,6 +16,7 @@ export declare const verbs: {
readonly rerun: "rerun";
readonly accept: "accept";
readonly cancel: "cancel";
readonly endAgain: "end-again";
readonly place: "place";
readonly askAgain: "ask-again";
readonly testRuns: "test-runs";
@@ -683,6 +684,19 @@ export interface CancelAnswer {
"pipeline": Pipeline;
}
/** is what end-again takes. */
export interface EndAgainInput {
/** the pipeline's key */
"pipeline": string;
/** why, written with the caller the runtime proves in the hand-act log */
"why": string;
}
/** is what end-again answers. */
export interface EndAgainAnswer {
"pipeline": Pipeline;
}
/** is what place takes. */
export interface PlaceInput {
/** the pipeline's key */
@@ -16,6 +16,7 @@ export const verbs = {
rerun: "rerun",
accept: "accept",
cancel: "cancel",
endAgain: "end-again",
place: "place",
askAgain: "ask-again",
testRuns: "test-runs",
@@ -42,7 +42,7 @@ func TestTools(t *testing.T) {
for _, tl := range UnloggedTools(stdio.State("pipelines"), stdio.Log("step-log"), nil, nil) {
names = append(names, tl.Name)
}
want := "mesh-pipeline-runner.show mesh-pipeline-runner.list mesh-pipeline-runner.stands mesh-pipeline-runner.why-carried mesh-pipeline-runner.kept runner_first_views runner_first_view_again runner_cancel runner_rerun runner_start runner_run runner_accept runner_place runner_ask_again runner_health runner_waiting runner_unlogged runner_unlogged_append"
want := "mesh-pipeline-runner.show mesh-pipeline-runner.list mesh-pipeline-runner.stands mesh-pipeline-runner.why-carried mesh-pipeline-runner.kept runner_first_views runner_first_view_again runner_cancel runner_rerun runner_start runner_run runner_accept runner_place runner_end_again runner_ask_again runner_health runner_waiting runner_unlogged runner_unlogged_append"
if got := strings.Join(names, " "); got != want {
t.Errorf("tools %q, want %q", got, want)
}
@@ -54,6 +54,15 @@ func VerbTools(ask func(key string, body any) (json.RawMessage, error)) []stdio.
}
return whyOf(in.Why)
}),
verbTool[seat.EndAgainInput](ask, "end_again", seat.VerbEndAgain,
"Judge a running pipeline's end once more by the seat verb end-again (design 47 H H-A-163, H-A-164): it ends as at a step's end, failed as soon as it can no longer pass (a mover with no registration named), and says pipeline-ended; one that still cannot end is answered running. The pipeline's key and why; written in the hand-act log. A pipeline not running is refused by the verb.",
obj([]string{"pipeline", "why"}, map[string]any{"pipeline": str, "why": str}),
func(in seat.EndAgainInput) string {
if in.Pipeline == "" {
return "end-again names the pipeline"
}
return whyOf(in.Why)
}),
verbTool[seat.AskAgainInput](ask, "ask_again", seat.VerbAskAgain,
"Ask a declined approval step of a pipeline once more by the seat verb ask-again: the pipeline's key, the mover's module (needed when the pipeline moves several) and why.",
obj([]string{"pipeline", "why"}, map[string]any{"pipeline": str, "module": str, "why": str}),
@@ -32,6 +32,10 @@ func TestVerbTools(t *testing.T) {
{"place", "runner_place", "seat:mesh-pipeline-runner.place", "", map[string]any{"pipeline": "main.6", "why": "urgent"},
seat.PlaceInput{Pipeline: "main.6", Why: "urgent"}},
{"place no why", "runner_place", "", "names why", map[string]any{"pipeline": "main.6"}, nil},
// H-A-164: runner_end_again asks the verb end-again with the pipeline and why.
{"end-again", "runner_end_again", "seat:mesh-pipeline-runner.end-again", "", map[string]any{"pipeline": "main.20", "why": "left running"},
seat.EndAgainInput{Pipeline: "main.20", Why: "left running"}},
{"end-again no why", "runner_end_again", "", "names why", map[string]any{"pipeline": "main.20"}, nil},
{"ask-again no why", "runner_ask_again", "", "names why", map[string]any{"pipeline": "p"}, nil},
} {
t.Run(c.name, func(t *testing.T) {
@@ -152,6 +152,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
Kept: keptReader(ctx, kept), Toolchain: toolchainReader(ctx, toolchains),
Fills: fills, Recovered: kvRecoveries{ctx, recovered}.Has, Holders: rv.Holders.Holders, Ended: hearer.EndedAtPlacing}
hearer.AskSteps = starter.AskSteps
hearer.Unplaced = func(p seat.Pipeline, module string) string { return starter.Unplaced(p, module, rv.Catalog.View) }
hearer.Release = func(key string) {
if _, err := starter.Release(hearer.Store, key, rv.Catalog.View); err != nil {
logger.Printf("the movers of %s waiting for a build are not placed: %v", key, err)
@@ -38,7 +38,7 @@ func answerVerbs(conn *process.Conn, seats *seatlist.Part, v pipeline.Verbs) (fu
return conn.AnswerSeat(seat.Seat, seatlist.Definition(seats.Reader, seat.Seat), writeHandlers(v))
}
// writeHandlers are the seat's write verbs the process answers: run, review, rerun, accept, cancel, start, and ask-again; and
// writeHandlers are the seat's write verbs the process answers: run, review, rerun, accept, cancel, end-again, start, and ask-again; and
// the test runs' verbs test-runs and test-runs-drop (A-469g, A-470i).
func writeHandlers(v pipeline.Verbs) map[string]process.SeatHandler {
return map[string]process.SeatHandler{
@@ -47,6 +47,7 @@ func writeHandlers(v pipeline.Verbs) map[string]process.SeatHandler {
seat.VerbRerun: verbOf(func(c string, in seat.RerunInput) (any, error) { return v.Rerun(c, in) }),
seat.VerbAccept: verbOf(func(c string, in seat.AcceptInput) (any, error) { return v.Accept(c, in) }),
seat.VerbCancel: verbOf(func(c string, in seat.CancelInput) (any, error) { return v.Cancel(c, in) }),
seat.VerbEndAgain: verbOf(func(c string, in seat.EndAgainInput) (any, error) { return v.EndAgain(c, in) }),
seat.VerbPlace: verbOf(func(c string, in seat.PlaceInput) (any, error) { return v.Place(c, in) }),
seat.VerbStart: verbOf(func(c string, in seat.StartInput) (any, error) { return v.Start(c, in) }),
seat.VerbAskAgain: verbOf(func(c string, in seat.AskAgainInput) (any, error) { return v.AskAgain(c, in) }),
@@ -23,7 +23,7 @@ func TestEveryWriteVerbIsServed(t *testing.T) {
got = append(got, v)
}
slices.Sort(got)
want := []string{seat.VerbAccept, seat.VerbAskAgain, seat.VerbCancel, seat.VerbPlace, seat.VerbRerun, seat.VerbReview, seat.VerbStart, seat.VerbRun, seat.VerbTestRuns, seat.VerbTestRunsDrop}
want := []string{seat.VerbAccept, seat.VerbAskAgain, seat.VerbCancel, seat.VerbEndAgain, seat.VerbPlace, seat.VerbRerun, seat.VerbReview, seat.VerbStart, seat.VerbRun, seat.VerbTestRuns, seat.VerbTestRunsDrop}
slices.Sort(want)
if !slices.Equal(got, want) {
t.Errorf("the process answers %v, want %v", got, want)
@@ -366,7 +366,7 @@ func (h *Hearer) endReader(reader RunReader, run string, r Run) error {
if err != nil {
return err
}
ended := endPipeline(&p, now)
ended := endPipeline(&p, now, h.Unplaced)
if _, err := h.Store.Update(reader.Pipeline, p, rev); errors.Is(err, ErrChanged) {
continue
} else if err != nil {
@@ -541,6 +541,28 @@ func (s *Starter) Resume(store Updater, branch string, half Half) (int, error) {
return asked, first
}
// Unplaced says why mover module of p has no step placed (H-A-171): "<module> has no registration" when the registrations
// do not name it (A-327), else "<module> waits on the publish of <package>, …", the packages it awaits not yet published
// as the catalog half of p's branch holds its edges (§746).
func (s *Starter) Unplaced(p seat.Pipeline, module string, view func(branch string) (Half, bool)) string {
if s.Registration == nil {
return module + " has no registration"
}
if _, ok := s.Registration(module); !ok {
return module + " has no registration"
}
var waiting []string
if view != nil {
if half, ok := view(p.Branch); ok {
_, waiting, _ = ready(p, module, half.Entries)
}
}
if len(waiting) == 0 {
return module + " waits on the publish of the movers it builds on"
}
return module + " waits on the publish of " + strings.Join(waiting, ", ")
}
// Registered places, on a registration-changed of reg's module, the steps of that module's mover in every running pipeline
// that moves it with none placed, from the registration (design 47 G §21, §23, A-327): a pipeline started before its module
// had a registration. Each is written by compare-and-set, so it is placed once, its steps asked, and said; a run on request
@@ -610,7 +632,12 @@ func (s *Starter) placeWaiting(store Updater, due func(seat.Pipeline) bool, reg
continue
}
before := len(p.Steps)
asks, _, ended, notAsked := s.placeMovers(&p, reg, half.Entries, now)
asks, unregistered, ended, notAsked := s.placeMovers(&p, reg, half.Entries, now)
// Until its registration arrives, the pipeline says it waits on it (A-327): a mover with no registration has no step,
// and it holds the pipeline's end only while every placed mover's required steps passed (H-A-163, H-A-171).
for _, m := range unregistered {
s.logf("%s: %s has no registration yet: its steps wait on its registration, which places them (A-327)", key, m)
}
if len(p.Steps) == before {
continue
}
@@ -3,6 +3,8 @@ package pipeline
import (
"encoding/json"
"errors"
"fmt"
"slices"
"strings"
"testing"
@@ -280,6 +282,23 @@ func TestAPipelineStartedBeforeItsRegistrationIsPlacedWhenItArrives(t *testing.T
if n != 1 || err != nil || len(p.Steps) == 0 || len(asks.asks) == before {
t.Errorf("the pipeline a runner before this one set aside: placed %d (%v), %d steps, %d asks more, want it started as a newly started one", n, err, len(p.Steps), len(asks.asks)-before)
}
// A-327: a mover with no registration, in a pipeline placed from the half held later (the queue's turn, the half held),
// is said to wait on its registration, so the pipeline that cannot end before it is placed says why.
var logged []string
s.Logf = func(f string, a ...any) { logged = append(logged, fmt.Sprintf(f, a...)) }
held = false
taken = catalog.TakeInTaken{Branch: "next", Source: 8, Entries: []catalog.TakeInEntry{{Module: "app", Commit: "c4", Fingerprint: "src2:dd"}, {Module: "contracts", Commit: "c4", Fingerprint: "src2:ee"}}}
if n, err := s.TakenIn(taken, late); n != 1 || err != nil {
t.Fatalf("the take-in of two movers started %d (%v)", n, err)
}
held, logged = true, nil
if n, err := s.Waiting(store.memStore, "next", late); n != 1 || err != nil {
t.Fatalf("the half of next placed %d (%v), want next.8's registered mover", n, err)
}
if !slices.ContainsFunc(logged, func(l string) bool { return strings.Contains(l, "next.8: contracts has no registration yet") }) {
t.Errorf("placing next.8 said %q, want that contracts waits on its registration (A-327)", logged)
}
}
// R1/AC1 (design 47 H §747): a start names an event, never a sweep. A take-in starts the pipelines of its own entries
@@ -158,6 +158,9 @@ type Hearer struct {
// Turn takes a pipeline's end into the queue, its running key deleted and the next placed (design 47 H §748;
// Starter.Turn); nil takes none.
Turn func(key string)
// Unplaced says why a mover of a pipeline has no step placed, for the why of its end (H-A-171; Starter.Unplaced): it
// waits on its registration or on a publish; nil says only that it has no step placed.
Unplaced func(p seat.Pipeline, module string) string
// Rejoin keys a pipeline running again once its approval is answered and it still runs (H-A-106 (b); Starter.Rejoin);
// nil keys none.
Rejoin func(key string)
@@ -568,16 +571,22 @@ func stepPassed(s seat.StepResult) bool {
// endPipeline ends a pipeline whose every mover is placed and every step ended: passed when every mover's required steps
// passed, were carried or had nothing to run, else failed, naming each required step that held it (ADR 0666 §7, §9;
// design 47 H §746). A failed optional step, and an optional step still waiting, hold nothing. An approval step still
// waiting when a required step did not pass is `not asked` (§26). It says whether the pipeline ended now, its end count one
// higher.
func endPipeline(p *seat.Pipeline, now time.Time) bool {
// design 47 H §746). A mover with no step placed, waiting on its registration (A-327) or on the publish of a mover it
// builds on (§746), holds the end only while the pipeline could still pass: once a placed mover's required step did not
// pass and none is open, it ends failed, the why naming each unplaced mover with the reason unplaced gives (H-A-163,
// H-A-171; nil says only that it has no step placed). A failed optional step, and an optional step still waiting, hold
// nothing. An approval step still waiting when a required step did not pass is `not asked` (§26). It says whether the
// pipeline ended now, its end count one higher.
func endPipeline(p *seat.Pipeline, now time.Time, unplaced func(seat.Pipeline, string) string) bool {
if p.Outcome != seat.PipelineOutcomeRunning {
return false
}
// A mover with no step placed waits on its registration or a publish: it holds the end only while every placed mover's
// required steps passed, since once one failed or could not run the pipeline can no longer pass (H-A-163, H-A-171).
var waiting []string
for _, m := range p.Movers {
if !placed(*p, m.Module) {
return false
waiting = append(waiting, m.Module)
}
}
var held []string
@@ -598,6 +607,9 @@ func endPipeline(p *seat.Pipeline, now time.Time) bool {
held = append(held, strings.TrimSpace(s.Module+" "+s.Artifact+" "+s.Step)+" "+s.Outcome)
}
}
if len(waiting) > 0 && len(held) == 0 {
return false
}
if len(notAsked) > 0 {
if len(held) == 0 {
return false
@@ -611,6 +623,13 @@ func endPipeline(p *seat.Pipeline, now time.Time) bool {
p.Outcome, p.Why = seat.PipelineOutcomePassed, ""
if len(held) > 0 {
p.Outcome, p.Why = seat.PipelineOutcomeFailed, "required steps not passed: "+strings.Join(held, ", ")
for _, m := range waiting {
why := m + " has no step placed"
if unplaced != nil {
why = unplaced(*p, m)
}
p.Why += "; " + why
}
}
for i := range p.Movers {
m := &p.Movers[i]
@@ -622,7 +641,7 @@ func endPipeline(p *seat.Pipeline, now time.Time) bool {
// endPipeline is endPipeline with each mover's widens computed into its value at the end (§71, A-207; H-A-51).
func (h *Hearer) endPipeline(p *seat.Pipeline, now time.Time) bool {
if !endPipeline(p, now) {
if !endPipeline(p, now, h.Unplaced) {
return false
}
if h.Widens != nil {
@@ -8,6 +8,7 @@ import (
"git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient"
oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel"
catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
seat "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"
nodebuildgo "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo"
@@ -291,23 +292,57 @@ func TestApprovalEnds(t *testing.T) {
}
// An optional step still waiting (a code review nobody has given) does not hold a pipeline's end; a required one does
// (design 47 G A-104).
// (design 47 G A-104). A mover with no step placed, waiting on its registration (A-327) or on the publish of a mover it
// builds on (§746), holds the end while every placed mover's required steps passed or one is open, and once a placed one
// did not pass the pipeline ends failed, naming each with its own reason (H-A-163, H-A-171).
func TestAnOptionalStepStillWaitingHoldsNoEnd(t *testing.T) {
now := time.Date(2026, 11, 11, 12, 0, 0, 0, time.UTC)
// lib is registered and awaits core's package, which core's passed build has not published yet; contracts has no
// registration.
starter := &Starter{Registration: func(m string) (catalog.Registration, bool) { return catalog.Registration{Module: m}, m != "contracts" }}
view := func(string) (Half, bool) {
return Half{Entries: map[string]catalog.CatalogEntry{"lib": {Edges: []catalog.Edge{{From: "core:go", To: "lib:program", Kind: 1}}}}}, true
}
unplaced := func(p seat.Pipeline, m string) string { return starter.Unplaced(p, m, view) }
for name, c := range map[string]struct {
review string
ends bool
}{"optional review waiting": {seat.StepResultStatusOptional, true}, "required review waiting": {seat.StepResultStatusRequired, false}} {
p := seat.Pipeline{Outcome: seat.PipelineOutcomeRunning, Steps: []seat.StepResult{
{Step: seat.StepResultStepBuild, Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomePassed},
{Step: seat.StepResultStepReview, Status: c.review, Outcome: seat.StepResultOutcomeWaiting},
{Step: seat.StepResultStepApproval, Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomePassed},
review, build, unit string
waiting []string
ends bool
outcome string
why []string
}{
"optional review waiting": {seat.StepResultStatusOptional, seat.StepResultOutcomePassed, seat.StepResultOutcomePassed, nil, true, seat.PipelineOutcomePassed, nil},
"required review waiting": {seat.StepResultStatusRequired, seat.StepResultOutcomePassed, seat.StepResultOutcomePassed, nil, false, "", nil},
"unregistered mover, the placed one passed": {seat.StepResultStatusOptional, seat.StepResultOutcomePassed, seat.StepResultOutcomePassed, []string{"contracts"}, false, "", nil},
"unregistered mover, the placed one failed": {seat.StepResultStatusOptional, seat.StepResultOutcomeFailed, seat.StepResultOutcomePassed, []string{"contracts"}, true, seat.PipelineOutcomeFailed, []string{"contracts has no registration"}},
"unregistered mover, failed and a step open": {seat.StepResultStatusOptional, seat.StepResultOutcomeFailed, seat.StepResultOutcomeRunning, []string{"contracts"}, false, "", nil},
"unregistered mover, the placed one could not run": {seat.StepResultStatusOptional, seat.StepResultOutcomePassed, seat.StepResultOutcomeCouldNotRun, []string{"contracts"}, true, seat.PipelineOutcomeFailed, []string{"contracts has no registration"}},
"a mover waiting on a publish, the placed one failed": {seat.StepResultStatusOptional, seat.StepResultOutcomeFailed, seat.StepResultOutcomePassed, []string{"contracts", "lib"}, true, seat.PipelineOutcomeFailed,
[]string{"contracts has no registration", "lib waits on the publish of core:go"}},
} {
p := seat.Pipeline{Outcome: seat.PipelineOutcomeRunning, Movers: []seat.Mover{{Module: "app"}, {Module: "core"}}, Steps: []seat.StepResult{
{Step: seat.StepResultStepBuild, Module: "app", Status: seat.StepResultStatusRequired, Outcome: c.build},
{Step: seat.StepResultStepUnit, Module: "app", Status: seat.StepResultStatusRequired, Outcome: c.unit},
{Step: seat.StepResultStepReview, Module: "app", Status: c.review, Outcome: seat.StepResultOutcomeWaiting},
{Step: seat.StepResultStepApproval, Module: "app", Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomePassed},
{Step: seat.StepResultStepBuild, Module: "core", Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomePassed},
}}
if got := endPipeline(&p, now); got != c.ends {
for _, m := range c.waiting {
p.Movers = append(p.Movers, seat.Mover{Module: m})
}
if got := endPipeline(&p, now, unplaced); got != c.ends {
t.Errorf("%s: ended = %v, want %v", name, got, c.ends)
}
if c.ends && p.Outcome != seat.PipelineOutcomePassed {
t.Errorf("%s: outcome %s", name, p.Outcome)
if c.ends && p.Outcome != c.outcome {
t.Errorf("%s: outcome %s, want %s", name, p.Outcome, c.outcome)
}
for _, w := range c.why {
if !strings.Contains(p.Why, w) {
t.Errorf("%s: why %q, want it to name %q", name, p.Why, w)
}
}
if strings.Contains(p.Why, "lib has no registration") {
t.Errorf("%s: why %q names a registered mover as having no registration", name, p.Why)
}
}
}
@@ -244,6 +244,24 @@ func (v Verbs) Cancel(caller string, in seat.CancelInput) (seat.CancelAnswer, er
}
}
// EndAgain judges a running pipeline's end once more by hand, recorded in the hand-act log first (design 47 H §746,
// H-A-163, H-A-164): it ends as at a step's end, failed as soon as it can no longer pass, and says it, taking its turn in
// the queue; one that still cannot end is answered running. A pipeline not running is refused.
func (v Verbs) EndAgain(_ string, in seat.EndAgainInput) (seat.EndAgainAnswer, error) {
p, _, err := v.change(in.Pipeline, seat.EventStepEnded, func() error {
return v.record(seat.VerbEndAgain, "judged the end of the pipeline "+in.Pipeline+" again", in.Why)
}, func(p *seat.Pipeline, _ time.Time) (int, error) {
if p.Outcome != seat.PipelineOutcomeRunning {
return -1, fmt.Errorf("the pipeline %s is %s, not running", in.Pipeline, p.Outcome)
}
return -1, nil
})
if err != nil {
return seat.EndAgainAnswer{}, err
}
return seat.EndAgainAnswer{Pipeline: p}, nil
}
// Rerun asks one step again, recorded in the hand-act log first (§22, §39): the step goes back to running under a new ask,
// the ask saying it is a rerun and the caller the bus proved; a failed pipeline runs again and ends once more with its end
// count one higher (§325), an approval never asked waiting again. A review waits again; an approval is asked again by
@@ -156,6 +156,30 @@ func TestAcceptRerunAndCancelWriteByCompareAndSetAndRecordTheirHandAct(t *testin
t.Errorf("%d hand acts recorded, want accept, rerun, cancel (3): %v", n, *acts)
}
// H-A-163, H-A-164: end-again judges a running pipeline's end once more, a hand act; a pipeline the judgement before
// left running (a mover waiting on its registration, a placed one failed, nothing open) ends failed naming that mover.
if _, err := v.EndAgain("operator", seat.EndAgainInput{Pipeline: pkey, Why: "again"}); err == nil || len(*acts) != 3 {
t.Errorf("end-again of a cancelled pipeline = %v, %d hand acts, want refused and none recorded", err, len(*acts))
}
store["main.20"] = struct {
p seat.Pipeline
rev uint64
}{seat.Pipeline{Pipeline: "main.20", Branch: "main", Source: 20, Outcome: seat.PipelineOutcomeRunning,
Movers: []seat.Mover{{Module: "app"}, {Module: "contracts"}}, Steps: []seat.StepResult{
{Step: seat.StepResultStepBuild, Module: "app", Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomeFailed}}}, 1}
// contracts is named by no registration (H-A-171).
v.Hearer.Unplaced = func(p seat.Pipeline, m string) string { return (&Starter{}).Unplaced(p, m, nil) }
if _, err := v.EndAgain("operator", seat.EndAgainInput{Pipeline: "main.20"}); err == nil {
t.Error("an end-again with no why was taken")
}
e, err := v.EndAgain("operator", seat.EndAgainInput{Pipeline: "main.20", Why: "left running by the judgement before H-A-163"})
if err != nil || e.Pipeline.Outcome != seat.PipelineOutcomeFailed || e.Pipeline.EndCount != 1 || !strings.Contains(e.Pipeline.Why, "contracts has no registration") {
t.Fatalf("end-again = %+v, %v, want main.20 ended failed naming contracts", e.Pipeline, err)
}
if last := (*said)[len(*said)-1]; !strings.HasPrefix(last, "pipeline-ended.") || len(*acts) != 4 || !strings.Contains((*acts)[3], "mesh-pipeline-runner.end-again") {
t.Errorf("end-again said %q and recorded %v, want pipeline-ended and its hand act", last, *acts)
}
// H-A-101 (1): on a pipeline of two movers a verb names the mover's module; one naming none, or a module the pipeline
// does not move, is refused, and the module named picks that mover's step.
two, store2, _, _, _, _ := verbsFixture()
@@ -114,7 +114,7 @@ func TestManifest(t *testing.T) {
{"uses operator-channel", equalSets(m.Uses, []string{"operator-channel"})},
// RN25 (§539): the runner's tools carry the prefix runner_.
{"first-view tools", equalSets(m.Tools, []string{"runner_first_views", "runner_first_view_again", "runner_health", "runner_unlogged", "runner_unlogged_append",
"runner_start", "runner_run", "runner_accept", "runner_ask_again", "runner_place", "runner_waiting",
"runner_start", "runner_run", "runner_accept", "runner_ask_again", "runner_place", "runner_end_again", "runner_waiting",
"runner_test_runs", "runner_test_runs_drop"})},
// A-305 (ADR 0227 rule 8, ADR 0240 rule 2): the process is judged by its unit, as every process of mesh-delivery,
// never by a tool of its own; runner_health stays a tool.
@@ -18,6 +18,7 @@
"rerun",
"accept",
"cancel",
"end-again",
"place",
"ask-again",
"test-runs",
@@ -36,6 +37,7 @@
"runner_accept",
"runner_ask_again",
"runner_place",
"runner_end_again",
"runner_waiting",
"runner_test_runs",
"runner_test_runs_drop"
@@ -3,6 +3,7 @@
// at a commit of the repository that builds it. The indexer reads it so at each trunk merge (its packages state's series
// keys), and the checker so at a delivery group member's head for a package new in the group, so the judge is handed one
// name for each package whoever reads it (mesh-sdk composer.Request.Packages).
// Design 47 H1, proof 2: this comment is the mesh-delivery-sdk half of a two-module change its pipeline delivers.
package packagename
import (