Merge branch 'fix/47-G-shared-runs-watchman' into fix/47-G-shared-runs

This commit is contained in:
2026-11-17 13:14:44 +01:00
3 changed files with 36 additions and 3 deletions
@@ -357,6 +357,30 @@ func TestWatchmanWhole(t *testing.T) { // 1135/AC8
until("the step stands again", func() bool { return finding(stepFinding) })
sayStep("step-ended", time.Now().UTC())
until("the step's end clears it", func() bool { return !finding(stepFinding) })
// A step the runner's stands named at the start (seeded through the seat verb) and that no progress follows is
// `pipeline-stands`; the approval waiting on a person is owed none.
seeded := func(step string) string {
return watch.FindingKey(watch.ScopeDelivery, watch.StepFindingID(seededPipeline+"/"+step+"/"), watch.KindPipelineStands)
}
until("the seeded composition step with no progress", func() bool { return finding(seeded("composition")) })
if finding(seeded("approval")) {
t.Error("a step waiting on a person raised pipeline-stands")
}
// A test step whose run's ask ended with no step-ended of its own stands five minutes (here the short bound) after that end.
const runAsk = "run-ask-2"
old := time.Now().UTC().Add(-time.Minute) // started longer ago than the short bound: it stands at once
testStep, _ := json.Marshal(meshpipelinerunner.StepEvent{Pipeline: "main.6.web", Branch: "main", Module: "web", Commit: "c2", At: &old,
Result: meshpipelinerunner.StepResult{Step: "unit", Artifact: "web:program", Ask: "t-ask", Outcome: meshpipelinerunner.StepResultOutcomeRunning,
Shared: []meshpipelinerunner.Shared{{Run: "r2", Ask: runAsk}}}})
if _, err := js.Publish(ctx, "mesh.seat.mesh-pipeline-runner.event.step-started.web.main.c2", testStep); err != nil {
t.Fatal(err)
}
testFinding := watch.FindingKey(watch.ScopeDelivery, watch.StepFindingID("main.6.web/unit/web:program"), watch.KindPipelineStands)
until("the test step standing since its old start", func() bool { return finding(testFinding) })
sayAsk(t, ctx, js, "step-ended", runAsk)
until("the end of the run's ask begins the clock again, so the finding is cleared", func() bool { return !finding(testFinding) })
until("the test step whose run ended with no end of its own, one bound after that end", func() bool { return finding(testFinding) })
// A-274: the finding is said under the watchman's binding finding-events.
until("a finding-written under the binding finding-events", func() bool {
st, err := js.Stream(ctx, "WATCHMAN_FINDINGS")
@@ -631,6 +655,9 @@ const (
testWantsBucket = testAssigner + "_" + meshwants.StateWants
)
// seededPipeline is the pipeline the stand-in runner's stands names.
const seededPipeline = "main.5.web"
// serveCatalogHalf answers the catalog half's first views (design 47 G §614): the gate's one source branch, the stand-in
// registered on it, and its trunk revision whose entry claims mesh-module-assigner.
func serveCatalogHalf(t *testing.T, nc *nats.Conn) {
@@ -643,7 +670,13 @@ func serveCatalogHalf(t *testing.T, nc *nats.Conn) {
Entries: []meshcatalog.CatalogEntry{{Module: testAssigner, ManifestDigest: "d1", Manifest: map[string]any{"module": testAssigner,
"claims": []any{map[string]any{"name": "mesh-module-assigner", "scope": "mesh"}}}}}}
registrations := meshcatalog.RegistrationsAnswer{Registrations: []meshcatalog.Registration{{Module: testAssigner, Version: 1, Branches: []string{"release"}}}}
for subject, handle := range map[string]nats.MsgHandler{"mesh.seat.mesh-catalog.call.revision": respond(revision),
// The runner's stands (design 47 G §731, A-469p), which the watchman seeds its open steps from at its start: a composition step
// waiting on the assigner, a test step reading a run, and an approval waiting on a person.
stands := meshpipelinerunner.StandsAnswer{Stands: []meshpipelinerunner.Wait{
{Pipeline: seededPipeline, Step: "composition", Ask: "seeded-ask", Module: "web", Branch: "main", Since: time.Now().UTC(), V: 1},
{Pipeline: seededPipeline, Step: "approval", On: meshpipelinerunner.WaitOnPerson, Module: "web", Branch: "main", Since: time.Now().UTC(), V: 1}}}
for subject, handle := range map[string]nats.MsgHandler{"mesh.seat.mesh-pipeline-runner.call.stands": respond(stands),
"mesh.seat.mesh-catalog.call.revision": respond(revision),
"mesh.seat.mesh-catalog.call.registrations": respond(registrations), "mesh.seat.mesh-delivery.call.source": respond(map[string]any{"branches": []string{"release"}})} {
for _, s := range []string{subject, subject + ".>"} {
sub, err := nc.Subscribe(s, handle)
@@ -69,7 +69,7 @@ func (w *Watchman) timeHead(branch string) {
Headline: "A change has started no pipeline",
Explanation: "The head of the watched branch " + branch + " (source revision " + fmt.Sprint(h.revision) + ") moved " +
HeadBound.String() + " ago or more and the pipeline runner has said no pipeline started for it.",
Needs: "the runner to start the pipeline (its pipeline_stands and list tools say where it is)"}
Needs: "the runner to start the pipeline (its verbs mesh-pipeline-runner.stands and mesh-pipeline-runner.list say where it is)"}
left := HeadBound - w.now().Sub(h.at)
if left > 0 {
w.signal(headRow, id, left, signalDue{Do: dueFind, Finding: f})
@@ -190,7 +190,7 @@ func (w *Watchman) timeStep(key string) {
Headline: "A pipeline step has stopped saying it lives",
Explanation: "The step " + name + " started and has not ended, and neither it nor the run it reads has said its progress for " +
w.progressBound.String() + " or more" + last + ".",
Needs: "the part that runs it to say its progress, or the step ended (the runner's pipeline_stands and runner_cancel tools)"}
Needs: "the part that runs it to say its progress, or the step ended (the runner's verbs mesh-pipeline-runner.stands and mesh-pipeline-runner.cancel)"}
if left := w.progressBound - w.now().Sub(s.at); left > 0 {
w.signal(stepRow, id, left, signalDue{Do: dueFind, Finding: f})
return