From 1477497ef244f8ef182e24500a6ca26f6a817086 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 5 Nov 2026 14:51:55 +0100 Subject: [PATCH] Watchman: the hand acts through the seat's client, its findings through the conditions client's writer, the owners' states followed from the shared events stream, seat names from the contracts; contract import paths follow the domain folders (D-12..D-22 Watchman part; issue 1966) Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i --- .../cmd/mesh-delivery-watchman-tools/main.go | 4 ++-- .../cmd/mesh-delivery-watchman/consumes.go | 4 ++-- .../cmd/mesh-delivery-watchman/integration_test.go | 4 ++-- .../cmd/mesh-delivery-watchman/main.go | 11 ++++++----- .../cmd/mesh-delivery-watchman/main_test.go | 2 +- modules/mesh-delivery-watchman/go.mod | 2 ++ 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman-tools/main.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman-tools/main.go index 269c8121..0ce55f26 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman-tools/main.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman-tools/main.go @@ -12,8 +12,8 @@ import ( "strings" "time" + "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient" stdio "git.novox.be/novox/mesh-sdk/go" - "git.novox.be/novox/mesh-sdk/go/handacts" "git.novox.be/novox/mesh-sdk/go/views" "mesh-delivery-watchman/internal/socket" @@ -164,7 +164,7 @@ func Tools(states func(string) state, ask func(socket.Ask) (json.RawMessage, err Description: "The watchman's findings (novox/hq ADR 0564 ยง2): each thing it observes wrong now, .., with its " + "severity, subject, evidence and the row that observed it; the condition keeper raises and clears the conditions from " + "them. Give key for one, prefix to narrow. Read-only."}, - }, views.StatusTools(watch.Observer, ToolFirstViews, ToolFirstViewAgain, stdio.State(views.StatusState), handacts.Recorder{Ask: stdio.Ask}, time.Now)...) + }, views.StatusTools(watch.Observer, ToolFirstViews, ToolFirstViewAgain, stdio.State(views.StatusState), meshhandactsclient.Recorder{Ask: stdio.Ask}, time.Now)...) } func main() { diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/consumes.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/consumes.go index 52bd98d8..bb1263ab 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/consumes.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/consumes.go @@ -3,12 +3,12 @@ package main import ( "context" "encoding/json" + "git.novox.be/novox/mesh-contracts/go/seats/meshbroker" "strings" "sync" "github.com/nats-io/nats.go/jetstream" - "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/delivery" "git.novox.be/novox/mesh-sdk/go/membership" "git.novox.be/novox/mesh-sdk/go/process" @@ -121,5 +121,5 @@ func hearConsumed(ctx context.Context, js jetstream.JetStream, cred process.Acco // brokerSubject is a subject the bus module's created or refused arrives on: the seat mesh-broker's, where only its holder // publishes. The bus module's own stream is its history for its tool, never heard here. func brokerSubject(subject string) bool { - return strings.HasPrefix(subject, "mesh.seat."+catalogue.BrokerSeat+".event.") + return strings.HasPrefix(subject, "mesh.seat."+meshbroker.Seat+".event.") } diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go index c509bf7a..86d96c09 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go @@ -62,8 +62,8 @@ accounts { // families (DLV-M5, ADR 0615): the watchman (n1) follows both, never their buckets. func serveOwners(t *testing.T, ctx context.Context, js jetstream.JetStream, nc *nats.Conn) { t.Helper() - viewstest.Serve(t, ctx, js, nc, delivery.AssignerModule, wantsState, delivery.AssignerModule+".assigner_read_wants", assignerViews, "n1_"+delivery.WatchmanModule) - viewstest.Serve(t, ctx, js, nc, delivery.IndexerModule, modulesState, delivery.IndexerModule+".indexer_read_modules", indexerViews, "n1_"+delivery.WatchmanModule) + viewstest.Serve(t, ctx, js, nc, delivery.AssignerModule, wantsState, delivery.AssignerModule+".assigner_read_wants", "n1_"+delivery.WatchmanModule) + viewstest.Serve(t, ctx, js, nc, delivery.IndexerModule, modulesState, delivery.IndexerModule+".indexer_read_modules", "n1_"+delivery.WatchmanModule) } // TestWatchmanWhole starts the program the way the node does (its entry, run, with its environment and a broker file) diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go index 2ef14b0a..59b36ae6 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go @@ -10,6 +10,7 @@ import ( "encoding/json" "errors" "fmt" + sdkfindings "git.novox.be/novox/mesh-delivery/sdk/findings" "io" "log" "os" @@ -189,8 +190,6 @@ const ( wantsState = "wants" modulesState = "modules" // The owners' views families, as their manifests' `streams` name them. - indexerViews = "indexer-views" - assignerViews = "assigner-views" ) // run is the program: it returns when ctx ends or the bus cannot be used. @@ -236,12 +235,14 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro } defer calls.Close() reader := &views.ProcessReader{Module: delivery.WatchmanModule, Call: calls.Call, Logf: logger.Printf, - Findings: func() jetstream.KeyValue { return kvs.findings }} - wants, err := reader.Follow(delivery.AssignerModule, wantsState, delivery.AssignerModule+".assigner_read_wants", assignerViews) + Findings: func() views.FindingWriter { + return sdkfindings.Writer(ctx, func() jetstream.KeyValue { return kvs.findings }) + }} + wants, err := reader.Follow(delivery.AssignerModule, wantsState, delivery.AssignerModule+".assigner_read_wants") if err != nil { return err } - modules, err := reader.Follow(delivery.IndexerModule, modulesState, delivery.IndexerModule+".indexer_read_modules", indexerViews) + modules, err := reader.Follow(delivery.IndexerModule, modulesState, delivery.IndexerModule+".indexer_read_modules") if err != nil { return err } diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main_test.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main_test.go index f711e98e..68e97fca 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main_test.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main_test.go @@ -86,7 +86,7 @@ func TestRunNeedsItsCredential(t *testing.T) { // 1135/AC6 return json.Marshal(views.Answer{V: views.Version, Owner: delivery.AssignerModule, State: wantsState, Revision: 3, Created: written, At: written.Add(time.Hour), Values: map[string]json.RawMessage{"ace.mail": json.RawMessage(`{}`)}, Written: map[string]time.Time{"ace.mail": written}}) }} - p, err := r.Follow(delivery.AssignerModule, wantsState, delivery.AssignerModule+".assigner_read_wants", assignerViews) + p, err := r.Follow(delivery.AssignerModule, wantsState, delivery.AssignerModule+".assigner_read_wants") if err != nil { t.Fatal(err) } diff --git a/modules/mesh-delivery-watchman/go.mod b/modules/mesh-delivery-watchman/go.mod index db19c48d..71b2126f 100644 --- a/modules/mesh-delivery-watchman/go.mod +++ b/modules/mesh-delivery-watchman/go.mod @@ -3,6 +3,8 @@ module mesh-delivery-watchman go 1.26.0 require ( + git.novox.be/novox/mesh-contracts/go/seats/meshbroker v0.0.0-00010101000000-000000000000 + git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261104174359-05b3e2e1b94f github.com/nats-io/nats-server/v2 v2.11.17 github.com/nats-io/nats.go v1.54.0