From 00f5c1b8211ae7052d4b2402e544ec887a88ed13 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 11 Nov 2026 22:19:39 +0100 Subject: [PATCH] G findings4 mesh-enrolment: the enrolment's reader writes its findings through views.NewStdioHeldWriter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds: design 47 G §639, A-37, A-29 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h --- .../cmd/mesh-enrolment/findings_test.go | 16 +++++++++++++ .../mesh-enrolment/cmd/mesh-enrolment/main.go | 24 ++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 modules/mesh-enrolment/cmd/mesh-enrolment/findings_test.go diff --git a/modules/mesh-enrolment/cmd/mesh-enrolment/findings_test.go b/modules/mesh-enrolment/cmd/mesh-enrolment/findings_test.go new file mode 100644 index 00000000..e178f12d --- /dev/null +++ b/modules/mesh-enrolment/cmd/mesh-enrolment/findings_test.go @@ -0,0 +1,16 @@ +package main + +import "testing" + +// The enrolment's findings are written through the held finding writer of a stdio module (design 47 G §639, A-37): it is made +// over the state findings with the node the runtime sets, and refused without one. +func TestFindingWriter(t *testing.T) { + t.Setenv("MESH_NODE", "n1") + if w, err := newFindingWriter(); err != nil || w == nil { + t.Fatalf("writer = %v, %v; want one", w, err) + } + t.Setenv("MESH_NODE", "") + if _, err := newFindingWriter(); err == nil { + t.Error("a writer without a node was made: its events' subjects name none") + } +} diff --git a/modules/mesh-enrolment/cmd/mesh-enrolment/main.go b/modules/mesh-enrolment/cmd/mesh-enrolment/main.go index 095bff36..8cd07317 100644 --- a/modules/mesh-enrolment/cmd/mesh-enrolment/main.go +++ b/modules/mesh-enrolment/cmd/mesh-enrolment/main.go @@ -13,6 +13,7 @@ import ( "time" "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient" + mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient" stdio "git.novox.be/novox/mesh-sdk/go" "git.novox.be/novox/mesh-sdk/go/views" @@ -120,10 +121,31 @@ const ( AssignmentsTool = assignerModule + ".assigner_read_assignments" ) +// heldWriter is the enrolment's finding writer. +type heldWriter = views.HeldWriter[mcseat.Finding, mcseat.FindingCleared, mcseat.FindingsStated, mcseat.FindingsAskedEvent] + +// newFindingWriter makes the enrolment's held finding writer over its state findings, its node from MESH_NODE (design 47 G §639, A-37). +func newFindingWriter() (*heldWriter, error) { + return views.NewStdioHeldWriter(views.WriterConfig[mcseat.Finding, mcseat.FindingCleared, mcseat.FindingsStated, mcseat.FindingsAskedEvent]{ + Module: Module, State: stdio.State(mcseat.StateFindings), Asked: mcseat.SubjectFindingsAsked, Logf: logf}) +} + // followed is the enrolment's pictures of the assigner's assignments, started at once: its first view asked through // AssignmentsTool, then the assigner's views family; past its bound the finding in the enrolment's own findings. func followed() *views.Reader { - v := &views.Reader{Module: Module, Logf: func(f string, a ...any) { logf("["+Module+"] "+f, a...) }, Findings: views.OwnFindings{}, + // The enrolment's findings go through the held finding writer of a stdio module (design 47 G §639, A-37): the reader + // writes its first-view finding through it, so the keeper's asks and statements hold it. + var findings views.WireWriter + w, err := newFindingWriter() + if err != nil { + logf("[%s] the finding writer cannot be made, so no finding is written: %v", Module, err) + } else { + if err := w.Start(context.Background()); err != nil { + logf("[%s] the finding writer cannot start, its findings are kept in the state alone: %v", Module, err) + } + findings = w + } + v := &views.Reader{Module: Module, Logf: func(f string, a ...any) { logf("["+Module+"] "+f, a...) }, Findings: findings, Acts: meshhandactsclient.Recorder{Ask: stdio.Ask}} v.Follow(assignerModule, assignmentsState, AssignmentsTool) v.Start(context.Background())