From 48aa36120db2eb012cb16c9e9abb8b7278282ebe Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 01:07:50 +0100 Subject: [PATCH] A3: an answered validate or composition ask is one journal line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The journal said a step's end only when it failed to say it, so an ask's answer could not be followed by reading the journal. The assigner writes "answered " where the step's end is said, the one place a validate or composition ask is answered. Builds: design 47 H2 §792 --- .../mesh-delivery-assigner/compositionstep.go | 2 ++ .../compositionstep_test.go | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep.go index 04615205f..6bf171b15 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep.go @@ -183,6 +183,8 @@ func (c *compositionSteps) sayEnd(id string, run meshwants.StepRun, started *tim return } c.settle(id, true) // the ask's end is said: its pulled messages leave the seat's work queue (§777) + // One journal line per ask answered, in the one place it is answered (design 47 H2 §792). + c.logf("answered %s %s %s %s %s", id, run.Pipeline, run.Module, step, o.Outcome) if c.ended != nil { c.ended(id, run, ended) } diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep_test.go index edf0d478f..d38980356 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep_test.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "errors" + "fmt" "slices" "strings" "sync" @@ -137,7 +138,14 @@ func TestTheCompositionStepIsTakenAndItsEndSaid(t *testing.T) { said := newSaidEvents() at := time.Date(2026, 11, 12, 9, 0, 0, 0, time.UTC) var asked meshwants.StepRun - c := &compositionSteps{node: "n1", say: said.say, now: func() time.Time { return at }, logf: t.Logf, + var lines []string + var linesMu sync.Mutex + logf := func(f string, a ...any) { + linesMu.Lock() + lines = append(lines, fmt.Sprintf(f, a...)) + linesMu.Unlock() + } + c := &compositionSteps{node: "n1", say: said.say, now: func() time.Time { return at }, logf: logf, run: func(_ context.Context, id string, run meshwants.StepRun) stepOutcome { asked = run return stepOutcome{Outcome: meshwants.StepEndedOutcomeFailed, Said: "a and b own /etc/x", Warnings: []string{"n3 asleep"}, @@ -175,6 +183,13 @@ func TestTheCompositionStepIsTakenAndItsEndSaid(t *testing.T) { len(end.Shared) != 1 || end.Shared[0] != (meshwants.Shared{Machine: "n1", Run: "main=2e4.n1", Ask: "run-1"}) { // §723, §729 t.Fatalf("step-ended %+v", end) } + // Design 47 H2 §792: the ask answered is one journal line, said where its end is said. + linesMu.Lock() + answered := slices.DeleteFunc(slices.Clone(lines), func(l string) bool { return !strings.HasPrefix(l, "answered ") }) + linesMu.Unlock() + if !slices.Equal(answered, []string{"answered ask-1 main.4.m m composition failed"}) { + t.Errorf("the journal says %q, want one answered line", answered) + } // Design 47 H2 §777, §775 (H-A-381, H-A-401, H-A-404): the asks of the seat's work queue, taken once by id, said ask-taken at // the pull, in progress while they run, acknowledged once their end is said, and ended by the seat's drop. t.Run("work queue", queueCases)