From 4d2f1ea1f3734f0f87bdeac1af1ae3e5ea023519 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 27 Nov 2026 03:51:43 +0100 Subject: [PATCH] GT1 fix: a wanted with no want-revision keeps the held revision; rows for a repeated wanted and an again pipeline's running MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes review r1 part 4 items 2 and 3 (H-A-865, AC-832g, AC-824m). Builds: design 47 H2b ยง832 5. --- .../cmd/mesh-delivery-gate/recordpipeline.go | 12 ++++++++-- .../mesh-delivery-gate/recordpipeline_test.go | 23 ++++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordpipeline.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordpipeline.go index 9ae1e21d0..62427903c 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordpipeline.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordpipeline.go @@ -326,12 +326,20 @@ func (h *Holder) wantWritten(w wants.WantedEvent) error { if r == nil || r.Ended != nil { return nil } + // A body with no want-revision is the earlier form: it is applied and leaves the held revision as it is (H-A-865). + held := w.WantRevision for _, e := range r.Entries { - if e.Module == w.Module && e.Node == w.Node && w.WantRevision > 0 && e.WantRevision > w.WantRevision { + if e.Module != w.Module || e.Node != w.Node { + continue + } + if w.WantRevision > 0 && e.WantRevision > w.WantRevision { return nil } + if w.WantRevision == 0 && e.WantRevision > held { + held = e.WantRevision + } } - if err := h.Records.AddEntry(r, RecordEntry{Module: w.Module, Fingerprint: w.Fp, Node: w.Node, WantRevision: w.WantRevision}); err != nil { + if err := h.Records.AddEntry(r, RecordEntry{Module: w.Module, Fingerprint: w.Fp, Node: w.Node, WantRevision: held}); err != nil { return err } at := h.Now().UTC() diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordpipeline_test.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordpipeline_test.go index 0d19c3b84..b4e654c44 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordpipeline_test.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/recordpipeline_test.go @@ -118,12 +118,33 @@ func TestARecordFollowsItsPipelineToTheMachines(t *testing.T) { if _, ok := r.Entries[EntryKey("app", "f2", "ace")]; ok { t.Fatal("a want at want-revision 8, below the 9 held, is an entry") } + // A wanted of the earlier form (no want-revision) leaves the held 9 as it is, so a wanted at 8 changes nothing still + // (H-A-865); and a body said again under a new id adds no ledger operation (1984/AC-832g). + ledger := h.Records.Ledger.(*ledgerFake) + hear(t, c, "mesh-wants.wanted.x.app", "", `{"v":1,"node":"ace","module":"app","fp":"f","pipeline":"main.1","source":1,"revision":12}`) + hear(t, c, "mesh-wants.wanted.x.app", "", `{"v":1,"node":"ace","module":"app","fp":"f3","pipeline":"main.1","source":1,"revision":12,"want-revision":8}`) + if e := r.Entries[EntryKey("app", "f", "ace")]; e.WantRevision != 9 { + t.Fatalf("the entry is %+v: a wanted with no want-revision keeps the 9 held", e) + } + if _, ok := r.Entries[EntryKey("app", "f3", "ace")]; ok { + t.Fatal("a want at want-revision 8 is an entry after a wanted of the earlier form") + } + before := len(ledger.history) + again := `{"v":1,"node":"ace","module":"app","fp":"f","pipeline":"main.1","source":1,"revision":12,"want-revision":9}` + for _, id := range []string{"id-1", "id-2"} { + if err := c.Hear(stdio.Envelope{Key: "mesh-wants.wanted.x.app", Body: json.RawMessage(again), Headers: map[string]string{"Nats-Msg-Id": id}}); err != nil { + t.Fatal(err) + } + } + if len(ledger.history) != before { + t.Fatalf("a repeated wanted wrote %v", ledger.history[before:]) + } 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"}`) + hear(t, c, "mesh-wants.pipeline-wanted.main.1", "", `{"v":1,"pipeline":"main.1.again.2","branch":"main","source":1,"outcome":"running"}`) // an again pipeline's, on its source's subject (AC-824m) if r.Ended == nil || r.Ended.Why != WhyAllRun || len(*ended) != 1 { t.Fatalf("the record ended %+v, said %v", r.Ended, *ended) }