From 12b48debe928aaf2f2d08f798a9bfe9de5e99830 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 05:18:13 +0100 Subject: [PATCH] T-119: the teller says one widening per mover; record-opened is no longer heard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The teller reads pipeline-ended's H1 form, saying each mover's widening once for its module, watched branch and commit; its hearing of record-opened, whose forge-made record H §763 retires, goes with its consume in the manifest. Builds: design 47 H H-A-119, H-A-72, H-A-51, §763 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../cmd/mesh-delivery-teller/main.go | 6 +- .../cmd/mesh-delivery-teller/widens.go | 76 ++++++++----------- .../cmd/mesh-delivery-teller/widens_test.go | 23 +++--- modules/mesh-delivery-teller/manifest_test.go | 2 +- modules/mesh-delivery-teller/module.json | 1 - 5 files changed, 49 insertions(+), 59 deletions(-) diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/main.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/main.go index 01f8b1c9..9fa18d8d 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/main.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/main.go @@ -94,13 +94,11 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro if err := hub.Handle(registrationChangedSubject, widens.HearRegistration); err != nil { return fmt.Errorf("hearing %s: %w", registrationChangedSubject, err) } - // A merge named a recovery and a merge made at the forge are told on every channel (design 47 G §81, §170, §514). + // A merge named a recovery is told on every channel (design 47 G §81, §514); a merge made at the forge is no record of its + // own (H §763, H-A-119). if err := hub.Handle(recoveryMergedSubject, widens.HearRecovery); err != nil { return fmt.Errorf("hearing %s: %w", recoveryMergedSubject, err) } - if err := hub.Handle(recordOpenedSubject, widens.HearRecordOpened); err != nil { - return fmt.Errorf("hearing %s: %w", recordOpenedSubject, err) - } // Hear the warrants first, so none that comes while the asks are read is missed. if err := client.Listen(t.Answer, t.Said); err != nil { return fmt.Errorf("hearing the router's warrants: %w", err) diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/widens.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/widens.go index 636e490b..2a2e928d 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/widens.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/widens.go @@ -15,10 +15,10 @@ import ( "git.novox.be/novox/mesh-sdk/go/keys" ) -// What the teller says of a widening (design 47 G §71, §335, §522): the runner says each pipeline's end as pipeline-ended, -// its field `widens` naming what the change widens, and the teller tells the operator on every channel through the seat -// operator-channel's verb notify (§514), one message per pipeline-ended that carries any, once per module, watched branch -// and commit. It keeps, in its state widens-said, one key per module and watched branch holding the last commit it said, +// What the teller says of a widening (design 47 G §71, §335, §522; H §746, H-A-119): the runner says each pipeline's end as +// pipeline-ended, each mover's field `widens` naming what its change widens, and the teller tells the operator on every +// channel through the seat operator-channel's verb notify (§514), one message per mover that carries any, once per module, +// watched branch and commit. It keeps, in its state widens-said, one key per module and watched branch holding the last commit it said, // replaced by the next and deleted when registration-changed says the branch is no longer watched. const ( @@ -36,7 +36,6 @@ const ( pipelineEndedSubject = "mesh.seat." + mpr.Seat + ".event." + mpr.EventPipelineEnded + ".>" registrationChangedSubject = meshcatalog.SubjectRegistrationChanged recoveryMergedSubject = meshdelivery.SubjectRecoveryMerged - recordOpenedSubject = meshdelivery.SubjectRecordOpened ) // widensState is the state widens-said as the teller keeps it. @@ -69,41 +68,52 @@ func commit7(commit string) string { return commit } -// widensWords is the message of a pipeline's end: one line per entry, in the operator's words (design 47 G §522). -func widensWords(p mpr.PipelineEnded) string { - lines := make([]string, 0, len(p.Widens)) - for _, w := range p.Widens { - lines = append(lines, fmt.Sprintf("Widening: %s %s on %s widens %s %s.", p.Module, commit7(p.Commit), p.Branch, w.What, w.Name)) +// widensWords is the message of a mover's widening at its pipeline's end: one line per entry, in the operator's words +// (design 47 G §522). +func widensWords(branch string, m mpr.MoverEnded) string { + lines := make([]string, 0, len(m.Widens)) + for _, w := range m.Widens { + lines = append(lines, fmt.Sprintf("Widening: %s %s on %s widens %s %s.", m.Module, commit7(m.Commit), branch, w.What, w.Name)) } return strings.Join(lines, "\n") } -// Said tells the operator the widening of a pipeline's end on every channel, once for its module, watched branch and -// commit, and keeps the commit; an end with no widening, or one whose commit is the last said, says nothing. +// Said tells the operator each mover's widening of a pipeline's end on every channel (H-A-119), once for its module, watched +// branch and commit, and keeps the commit; a mover with no widening, or whose commit is the last said, says nothing. func (w *Widens) Said(p mpr.PipelineEnded) error { - if len(p.Widens) == 0 || p.Commit == "" { + var errs []error + for _, m := range p.Movers { + if err := w.saidMover(p.Branch, m); err != nil { + errs = append(errs, err) + } + } + return errors.Join(errs...) +} + +// saidMover tells one mover's widening once and keeps its commit. +func (w *Widens) saidMover(branch string, m mpr.MoverEnded) error { + if len(m.Widens) == 0 || m.Commit == "" { return nil } - key := widensKey(p.Module, p.Branch) + key := widensKey(m.Module, branch) e, err := w.State.Get(key) if err != nil { - return fmt.Errorf("the commit last said for %s on %s cannot be read: %w", p.Module, p.Branch, err) + return fmt.Errorf("the commit last said for %s on %s cannot be read: %w", m.Module, branch, err) } - if e != nil && strings.Trim(string(e.Value), `"`) == p.Commit { + if e != nil && strings.Trim(string(e.Value), `"`) == m.Commit { return nil } - words := widensWords(p) // The message's key holds the commit, so a say that is made again after a failure to keep it replaces the message. - if err := w.tell("widens."+key+"."+commit7(p.Commit), p.Module, words); err != nil { - return fmt.Errorf("the widening of %s %s on %s is not told: %w", p.Module, commit7(p.Commit), p.Branch, err) + if err := w.tell("widens."+key+"."+commit7(m.Commit), m.Module, widensWords(branch, m)); err != nil { + return fmt.Errorf("the widening of %s %s on %s is not told: %w", m.Module, commit7(m.Commit), branch, err) } if e == nil { - _, err = w.State.Create(key, p.Commit) + _, err = w.State.Create(key, m.Commit) } else { - _, err = w.State.Update(key, p.Commit, e.Revision) + _, err = w.State.Update(key, m.Commit, e.Revision) } if err != nil { - return fmt.Errorf("the widening of %s %s on %s is told but not kept: %w", p.Module, commit7(p.Commit), p.Branch, err) + return fmt.Errorf("the widening of %s %s on %s is told but not kept: %w", m.Module, commit7(m.Commit), branch, err) } return nil } @@ -194,12 +204,6 @@ func recoveryWords(ev meshdelivery.RecoveryMergedEvent) string { return fmt.Sprintf("Recovery merged: %s %s on %s, named by %s: %s.", ev.Module, commit7(ev.Commit), ev.Branch, ev.By, ev.Why) } -// forgeMadeWords is the message of a record opened for a merge made at the forge (design 47 G §522, §170). -func forgeMadeWords(ev meshdelivery.RecordOpenedEvent) string { - return fmt.Sprintf("Merged at the forge, not through the mesh: %s pull request #%d at %s on %s; delivered like any merge.", - ev.Repository, ev.Pull, commit7(ev.Commit), ev.Branch) -} - // tell says words on every channel under key; a message of the same key is the same message. func (w *Widens) tell(key, subject, words string) error { _, err := w.Call(notifyKey, map[string]any{"key": key, "subject": subject, "severity": "warning", "summary": words, @@ -217,19 +221,3 @@ func (w *Widens) HearRecovery(m jetstream.Msg) { } w.finish(m, w.tell("recovery."+ev.Repository+"."+commit7(ev.Commit), ev.Repository, recoveryWords(ev))) } - -// HearRecordOpened is the handler of record-opened: it tells a record opened for a merge made at the forge on every channel -// (design 47 G §170, §514); any other record is left to the watchman. -func (w *Widens) HearRecordOpened(m jetstream.Msg) { - var ev meshdelivery.RecordOpenedEvent - if err := json.Unmarshal(m.Data(), &ev); err != nil { - w.logf("%s is not a record's opening and is left: %v", m.Subject(), err) - _ = m.Ack() - return - } - if !ev.ForgeMade { - _ = m.Ack() - return - } - w.finish(m, w.tell("forge-made."+ev.Record, ev.Repository, forgeMadeWords(ev))) -} diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/widens_test.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/widens_test.go index c4474d83..8d2f4072 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/widens_test.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/widens_test.go @@ -61,11 +61,16 @@ func (c *calls) call(key string, body any) (json.RawMessage, error) { } func widenEnd(commit string, what ...string) mpr.PipelineEnded { - p := mpr.PipelineEnded{Module: "nats", Branch: "main", Commit: commit} + return mpr.PipelineEnded{Branch: "main", Movers: []mpr.MoverEnded{widenMover("nats", commit, what...)}} +} + +// widenMover is a mover at its pipeline's end, its commit and its widens (H-A-119). +func widenMover(module, commit string, what ...string) mpr.MoverEnded { + m := mpr.MoverEnded{Module: module, Commit: commit} for _, w := range what { - p.Widens = append(p.Widens, mpr.Widening{What: w, Name: "name-of-" + strings.ReplaceAll(w, " ", "-")}) + m.Widens = append(m.Widens, mpr.Widening{What: w, Name: "name-of-" + strings.ReplaceAll(w, " ", "-")}) } - return p + return m } // Design 47 G §71, §335, §522 (TL1): a pipeline's widening is said once on every channel, in the operator's words. @@ -82,6 +87,10 @@ func TestAWideningIsSaidOnceOnEveryChannelAndKept(t *testing.T) { {"the same end again says nothing", end, 1}, {"an end with no widening says nothing", widenEnd("fffffffffffffffffffffffffffffffffffffff"), 1}, {"the next commit says one more", widenEnd("89abcdef0123456789abcdef0123456789abcdef", "credential"), 2}, + // H-A-119: one message per mover that widens, each mover once for its commit. + {"two movers say one message for the one not said yet", mpr.PipelineEnded{Branch: "main", Movers: []mpr.MoverEnded{ + widenMover("nats", "89abcdef0123456789abcdef0123456789abcdef", "credential"), + widenMover("mesh-sdk", "0123456789abcdef0123456789abcdef01234567", "acting rule")}}, 3}, } for _, s := range steps { if err := w.Said(s.end); err != nil { @@ -175,8 +184,8 @@ func TestAPipelineEndedIsAcknowledgedOnlyWhenTold(t *testing.T) { } } -// Design 47 G §81, §170, §522 (TL2, TL3): a recovery and a merge made at the forge are told on every channel in the operator's -// words, with their fields filled; a record opened the ordinary way is told nothing. +// Design 47 G §81, §522 (TL2): a recovery is told on every channel in the operator's words, with its fields filled; a merge +// made at the forge is no record of its own (H §763, H-A-119). func TestARecoveryAndAForgeMadeMergeAreToldInTheOperatorsWords(t *testing.T) { commit := "0123456789abcdef0123456789abcdef01234567" for _, tc := range []struct { @@ -187,10 +196,6 @@ func TestARecoveryAndAForgeMadeMergeAreToldInTheOperatorsWords(t *testing.T) { {"a recovery", `{"v":1,"repository":"novox/mesh-sdk","module":"mesh-sdk","branch":"main","commit":"` + commit + `","why":"the live delivery was broken","by":"jochen"}`, func(w *Widens, m *fakeMsg) { w.HearRecovery(m) }, "recovery.novox/mesh-sdk.0123456", "Recovery merged: mesh-sdk 0123456 on main, named by jochen: the live delivery was broken."}, - {"a forge-made record", `{"record":"mesh-tools-35","milestone":"47/G","forge-made":true,"repository":"novox/mesh-tools","pull":35,"commit":"` + commit + `","branch":"main"}`, - func(w *Widens, m *fakeMsg) { w.HearRecordOpened(m) }, "forge-made.mesh-tools-35", - "Merged at the forge, not through the mesh: novox/mesh-tools pull request #35 at 0123456 on main; delivered like any merge."}, - {"an ordinary record", `{"record":"47-G","milestone":"47/G"}`, func(w *Widens, m *fakeMsg) { w.HearRecordOpened(m) }, "", ""}, } { c := &calls{} w := &Widens{State: &widensMem{memStore{entries: map[string]*stdio.StateEntry{}}}, Call: c.call} diff --git a/modules/mesh-delivery-teller/manifest_test.go b/modules/mesh-delivery-teller/manifest_test.go index d66fc752..47fa14f5 100644 --- a/modules/mesh-delivery-teller/manifest_test.go +++ b/modules/mesh-delivery-teller/manifest_test.go @@ -112,7 +112,7 @@ func TestManifestDeclarations(t *testing.T) { // 1240/AC1 } // design 47 G §335 (TL1): the widening of a pipeline end is told through the seat operator-channel and kept in widens-said. // design 47 G §387: the keeper's ask for the findings is heard, and the finding stream is declared (§383). - if want := []string{"mesh-conditions.findings-asked", "seat:mesh-wants.views.asks", "seat:mesh-delivery-view.views.answers", "seat:mesh-module-assigner.views.seat-holders", "mesh-catalog.catalog-revision", "mesh-delivery.source-moved", "mesh-catalog.registration-changed", "mesh-pipeline-runner.pipeline-ended", "mesh-delivery.recovery-merged", "mesh-delivery.record-opened", "mesh-broker.recreated", "mesh-broker.dropped"}; !reflect.DeepEqual(m.Consumes, want) { + if want := []string{"mesh-conditions.findings-asked", "seat:mesh-wants.views.asks", "seat:mesh-delivery-view.views.answers", "seat:mesh-module-assigner.views.seat-holders", "mesh-catalog.catalog-revision", "mesh-delivery.source-moved", "mesh-catalog.registration-changed", "mesh-pipeline-runner.pipeline-ended", "mesh-delivery.recovery-merged", "mesh-broker.recreated", "mesh-broker.dropped"}; !reflect.DeepEqual(m.Consumes, want) { t.Errorf("consumes = %v, want %v", m.Consumes, want) } if want := []string{"operator-channel"}; !reflect.DeepEqual(sorted(m.Uses), want) { diff --git a/modules/mesh-delivery-teller/module.json b/modules/mesh-delivery-teller/module.json index f515d14a..ab2c2678 100644 --- a/modules/mesh-delivery-teller/module.json +++ b/modules/mesh-delivery-teller/module.json @@ -29,7 +29,6 @@ "mesh-catalog.registration-changed", "mesh-pipeline-runner.pipeline-ended", "mesh-delivery.recovery-merged", - "mesh-delivery.record-opened", "mesh-broker.recreated", "mesh-broker.dropped" ],