R1 (§775): a composition ask whose holder is away passes its step, a step of the runner's whole test

The holder of mesh-wants is away while a re-pin asks the composition again:
the put meets no responders, is put again at the kept-call pace (a hundredth
of its default, so 40 s is 400 ms) and lands once the holder is back; the step
then passes with no hand act.

Builds: design 47 H2 §775 (H-A-453 (3): the whole criterion proven at its level)
This commit is contained in:
2026-11-22 03:30:37 +01:00
parent 7cf8ea380e
commit 81ea73a45f
@@ -22,8 +22,10 @@ import (
builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
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"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/buscompose"
"git.novox.be/novox/mesh-sdk/go/busretry"
"git.novox.be/novox/mesh-sdk/go/catalogue"
"git.novox.be/novox/mesh-sdk/go/process"
"git.novox.be/novox/mesh-sdk/go/seatlist"
@@ -53,9 +55,13 @@ func TestTheRunnerPlacesAPipelineAsksItsBuildTakesItsEndAndAnswersAReview(t *tes
t.Run("step log read does not wait for a batch it cannot fill", testStepLogReadDoesNotWaitForABatchItCannotFill)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
reg := catalog.Registration{Module: "app", Branches: []string{"main"}, Origin: "o/app", Policy: catalog.Policy{Steps: catalog.StepStatuses{Review: "optional", Validate: "bypass", Composition: "bypass", Approval: "bypass"}}}
reg := catalog.Registration{Module: "app", Branches: []string{"main"}, Origin: "o/app", Policy: catalog.Policy{Steps: catalog.StepStatuses{Review: "optional", Validate: "bypass", Composition: "required", Approval: "bypass"}}}
// design 47 H2 §790: the stalled bound is the setting stalled-bound, here one minute, read as the node-engine composes it.
t.Setenv(stdio.SettingWord(pipeline.StalledBoundSetting), "1m")
// design 47 H2 §775, H-A-453 (3): the kept-call pace a hundredth of its default (10 ms doubling to 300 ms), so the
// holder away for 40 s at the default pace is away for 400 ms here.
const away = 400 * time.Millisecond
t.Cleanup(busretry.Waits(busretry.Bound, 10*time.Millisecond, 300*time.Millisecond))
// The branch main has no revision yet at the runner's start (none-yet), then revision 1 holding app (A-336), then the
// re-pin revision 5 of the same source moving app to src2:ab (H-A-283), its newest once said.
var revised, repinned atomic.Bool
@@ -124,6 +130,11 @@ func TestTheRunnerPlacesAPipelineAsksItsBuildTakesItsEndAndAnswersAReview(t *tes
}
// A re-pin revision of the pipeline's own source keeps app in it at src2:ab, its steps placed again under new asks, and
// says re-pinned naming the pipeline, the mover and the revision (design 47 H2 §821, H-A-283).
// The holder of mesh-wants is away (§775): no work queue takes its asks, so the composition asked again meets no
// responders and is put again at the kept-call pace.
if _, err := js.UpdateStream(ctx, jetstream.StreamConfig{Name: "ASKS", Subjects: []string{builds.AcceptSubjectStep}, Retention: jetstream.WorkQueuePolicy}); err != nil {
t.Fatal(err)
}
repinned.Store(true)
repin, _ := json.Marshal(catalog.CatalogRevisionEvent{V: 1, Revision: 5, Kind: "trunk", Branch: "main", Source: 3, CallKind: catalog.CatalogRevisionEventCallKindRelease})
if _, err := js.Publish(ctx, catalog.SubjectCatalogRevision("main"), repin); err != nil {
@@ -140,6 +151,24 @@ func TestTheRunnerPlacesAPipelineAsksItsBuildTakesItsEndAndAnswersAReview(t *tes
if build = stepOf(p, seat.StepResultStepBuild); build.Outcome != seat.StepResultOutcomeRunning || build.Ask == "" {
t.Fatalf("the build placed again = %+v", build)
}
// The composition ask meets the holder away, said in the journal once; the holder is back after the away span and the
// ask lands on its work queue, no hand act between (§775).
waitFor(t, ctx, logs, func() bool {
return strings.Contains(logs.String(), "kept call: the seat "+wants.Seat+" does not answer")
})
gone := time.Now()
waitFor(t, ctx, logs, func() bool { return time.Since(gone) >= away })
if _, err := js.UpdateStream(ctx, jetstream.StreamConfig{Name: "ASKS", Subjects: []string{"mesh.seat.*.accept.>"}, Retention: jetstream.WorkQueuePolicy}); err != nil {
t.Fatal(err)
}
composition := stepOf(p, seat.StepResultStepComposition)
if composition.Outcome != seat.StepResultOutcomeRunning || composition.Ask == "" || composition.Fingerprint != "src2:ab" {
t.Fatalf("the composition asked again = %+v", composition)
}
waitFor(t, ctx, logs, func() bool {
m, err := asks.GetLastMsgForSubject(ctx, wants.AcceptSubjectStep)
return err == nil && m.Header.Get(nats.MsgIdHdr) == composition.Ask
})
// Once a step is placed in it, the health no longer names it (§790).
if a := pipeline.Health(kvKept{ctx, pipelines}, noConsumers, p.Started.Add(61*time.Second), bound); strings.Contains(a.Why, key+" (nothing open") {
t.Fatalf("with its build placed, the health still names %s: %+v", key, a)
@@ -176,7 +205,16 @@ func TestTheRunnerPlacesAPipelineAsksItsBuildTakesItsEndAndAnswersAReview(t *tes
return readPipeline(ctx, pipelines, key, &p) && stepOf(p, seat.StepResultStepBuild).Outcome == seat.StepResultOutcomePassed
})
// The holder back says the composition ended passed: the step passes, the pipeline with it.
composed, _ := json.Marshal(wants.StepEnded{ID: composition.Ask, Pipeline: key, Step: wants.StepRunStepComposition, Node: "n1", Outcome: "passed",
Module: "app", Commit: "c1", Fingerprint: "src2:ab"})
if _, err := js.Publish(ctx, wants.SubjectStepEnded("n1"), composed); err != nil {
t.Fatal(err)
}
waitFor(t, ctx, logs, func() bool { return readPipeline(ctx, pipelines, key, &p) && p.Outcome == seat.PipelineOutcomePassed })
if c := stepOf(p, seat.StepResultStepComposition); c.Outcome != seat.StepResultOutcomePassed || c.Ask != composition.Ask {
t.Fatalf("the composition whose holder was away ended %+v, want passed under its ask %s", c, composition.Ask)
}
// Each of the runner's events was heard by its name (§821).
waitFor(t, ctx, logs, func() bool {
return len(heardOf(seat.EventPipelineStarted)) > 0 && len(heardOf(seat.EventStepEnded)) > 0 && len(heardOf(seat.EventPipelineEnded)) > 0