From 6f2e27f59bb23263dfe3230d0d65950401d23ac0 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 5 Nov 2026 16:48:00 +0100 Subject: [PATCH] =?UTF-8?q?mesh-hand-acts=20and=20mesh-healers=20take=20th?= =?UTF-8?q?e=20hand-act=20names=20and=20the=20act=20from=20the=20seat=20me?= =?UTF-8?q?sh-hand-acts=20and=20its=20client,=20not=20mesh-sdk's=20handact?= =?UTF-8?q?s=20(B5l;=20ADR=200634=20=C2=A74;=20issue=201966)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i --- .../mesh-hand-acts/cmd/mesh-hand-acts/acts.go | 39 ++++++++++--------- .../cmd/mesh-hand-acts/acts_test.go | 2 +- modules/mesh-hand-acts/go.mod | 2 + .../mesh-healers/cmd/mesh-healers/healers.go | 4 +- .../cmd/mesh-healers/healers_test.go | 6 +-- .../mesh-healers/cmd/mesh-healers/tools.go | 7 ++-- .../mesh-healers/cmd/mesh-healers/wanted.go | 6 +-- modules/mesh-healers/go.mod | 2 + 8 files changed, 37 insertions(+), 31 deletions(-) diff --git a/modules/mesh-hand-acts/cmd/mesh-hand-acts/acts.go b/modules/mesh-hand-acts/cmd/mesh-hand-acts/acts.go index 6d83505f0..063987624 100644 --- a/modules/mesh-hand-acts/cmd/mesh-hand-acts/acts.go +++ b/modules/mesh-hand-acts/cmd/mesh-hand-acts/acts.go @@ -24,35 +24,36 @@ import ( "sync/atomic" "time" + handactsclient "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient" + handacts "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshhandacts" occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient" oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel" - "git.novox.be/novox/mesh-sdk/go/handacts" ) -// The seat, the log, the states and the event, as mesh-sdk's handacts names them. +// The seat, the log, the states and the event, as the seat mesh-hand-acts's contract names them. const ( - Module = handacts.Module + Module = "mesh-hand-acts" Seat = handacts.Seat - ActsLog = handacts.ActsLog - WarrantsState = handacts.WarrantsState + ActsLog = handacts.StateActs + WarrantsState = handacts.StateWarrants // RouterRecords is the router's record of every ask, `.` (ADR 0259): the warrant is read there. RouterRecords = "messenger.asks" - RecordedEvent = handacts.EventRecorded + RecordedEvent = handacts.EventActRecorded // RecordedSubject is where the seat says it: a seat's events are on mesh.seat..event., which its // consumers hear (catalogue.SeatSays). RecordedSubject = "mesh.seat." + Seat + ".event." + RecordedEvent - VerbRecord = handacts.VerbRecord - VerbDrill = handacts.VerbDrill - VerbWarrant = handacts.VerbWarrant - CauseDrill = handacts.CauseDrill - CauseOperatorAnswer = handacts.CauseOperatorAnswer + VerbRecord = handactsclient.VerbRecord + VerbDrill = handactsclient.VerbDrill + VerbWarrant = handactsclient.VerbWarrant + CauseDrill = handactsclient.CauseDrill + CauseOperatorAnswer = handactsclient.CauseOperatorAnswer ) // RepeatedWithin is how far back a cause counts as repeated (S15). const RepeatedWithin = 14 * 24 * time.Hour -// Act is one entry of the log: mesh-sdk's handacts.Act, the controller's HandAct unchanged. +// Act is one entry of the log: the seat's Act. type Act = handacts.Act // Store is the bus's buckets and this module's log as it reaches them, through its runtime. Create writes a key only @@ -130,7 +131,7 @@ func (l *Log) HandAct(by, verb, what, why, cause, condition string) (Recorded, e ", which no healer is wanted for. Nothing was recorded") } at := l.Now().UTC() - act := Act{ID: actKey(at), At: at, By: by, Verb: verb, Args: []string{what}, Why: why, Cause: cause, + act := Act{ID: actKey(at), At: at, By: by, Verb: verb, Arguments: []string{what}, Why: why, Cause: cause, Condition: strings.TrimSpace(condition)} if err := l.record(act); err != nil { return Recorded{}, err @@ -219,10 +220,10 @@ func (l *Log) Warranted(caller, asker, ask string) (Recorded, error) { } at := l.Now().UTC() act := Act{ID: "warrant-" + asker + "-" + ask, At: warranted.UTC(), Verb: VerbWarrant, - Args: []string{fmt.Sprintf("the operator chose %s on %s's ask %s", w.Label, asker, ask)}, - Why: fmt.Sprintf("%s (ask %s of %s)", occ.Says(*w), ask, asker), - By: fmt.Sprintf("the %s, as %s identity %s", w.By.Who, w.By.Kind, w.By.Identity), - Cause: CauseOperatorAnswer, Via: via(*w), Ask: ask, Proofs: w.Proofs, + Arguments: []string{fmt.Sprintf("the operator chose %s on %s's ask %s", w.Label, asker, ask)}, + Why: fmt.Sprintf("%s (ask %s of %s)", occ.Says(*w), ask, asker), + By: fmt.Sprintf("the %s, as %s identity %s", w.By.Who, w.By.Kind, w.By.Identity), + Cause: CauseOperatorAnswer, Via: via(*w), Ask: ask, Proofs: w.Proofs, RequestedBy: asker + ", recorded at the word of " + caller, Outcome: "chosen; what " + asker + " did with it is in its own record"} if claimed == nil { @@ -297,7 +298,7 @@ func (l *Log) HandActs(days int, cause, who string) Listing { out.Kept[ActsLog] = kept } for _, a := range all { - if now.Sub(a.At) <= RepeatedWithin && a.Repair() { + if now.Sub(a.At) <= RepeatedWithin && handactsclient.Repair(a) { out.Repeated[a.Cause]++ } if a.At.Before(since) || (cause != "" && a.Cause != cause) || (who != "" && !strings.Contains(a.By, who)) { @@ -329,7 +330,7 @@ func (l *Log) read(since time.Time) ([]Act, int, error) { if json.Unmarshal(raw, &a) != nil || a.At.Before(since) { continue } - a.Log = handacts.LogSeat + a.Log = handacts.Seat out = append(out, a) } return out, len(entries), nil diff --git a/modules/mesh-hand-acts/cmd/mesh-hand-acts/acts_test.go b/modules/mesh-hand-acts/cmd/mesh-hand-acts/acts_test.go index b95c2d568..9f5d2bb8c 100644 --- a/modules/mesh-hand-acts/cmd/mesh-hand-acts/acts_test.go +++ b/modules/mesh-hand-acts/cmd/mesh-hand-acts/acts_test.go @@ -171,7 +171,7 @@ func TestHandActRecordsWhatTheProvenCallerDid(t *testing.T) { raw, _, _ := store.Last(ActsLog, keys[0]) _ = json.Unmarshal(raw, &kept) if kept.By != tc.by || kept.Verb != tc.wantVerb || kept.Cause != tc.wantCause || kept.Condition != "bus.x.missing" || - kept.Args[0] != tc.what || kept.Log != "" { + kept.Arguments[0] != tc.what || kept.Log != "" { t.Errorf("%s: kept %+v", tc.name, kept) } } diff --git a/modules/mesh-hand-acts/go.mod b/modules/mesh-hand-acts/go.mod index 360e7a04b..143b09769 100644 --- a/modules/mesh-hand-acts/go.mod +++ b/modules/mesh-hand-acts/go.mod @@ -3,6 +3,8 @@ module mesh-hand-acts go 1.26.0 require ( + git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshhandacts 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-contracts/operator-and-conversation/go/clients/operatorchannelclient v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261104174359-05b3e2e1b94f diff --git a/modules/mesh-healers/cmd/mesh-healers/healers.go b/modules/mesh-healers/cmd/mesh-healers/healers.go index 4fc0c11e5..e7e335db1 100644 --- a/modules/mesh-healers/cmd/mesh-healers/healers.go +++ b/modules/mesh-healers/cmd/mesh-healers/healers.go @@ -26,9 +26,9 @@ import ( "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient" meshconditions "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" + handacts "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshhandacts" meshhealers "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshhealers" stdio "git.novox.be/novox/mesh-sdk/go" - "git.novox.be/novox/mesh-sdk/go/handacts" ) // Module and Seat are this module and the seat it holds once for the mesh. @@ -47,7 +47,7 @@ const ( // ActedSubject is where the seat says it, which its consumers hear (catalogue.SeatSays). ActedSubject = "mesh.seat." + Seat + ".event." + ActedEvent // RecordedEvent is the hand-act log's seat event, each act recorded there (ADR 0565 ยง11). - RecordedEvent = handacts.Seat + "." + handacts.EventRecorded + RecordedEvent = handacts.Seat + "." + handacts.EventActRecorded // The events it hears: the keeper's, on the seat mesh-conditions. RaisedEvent = "mesh-conditions.condition-raised" ChangedEvent = "mesh-conditions.condition-changed" diff --git a/modules/mesh-healers/cmd/mesh-healers/healers_test.go b/modules/mesh-healers/cmd/mesh-healers/healers_test.go index 2322abbf6..d7e5d68fd 100644 --- a/modules/mesh-healers/cmd/mesh-healers/healers_test.go +++ b/modules/mesh-healers/cmd/mesh-healers/healers_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "git.novox.be/novox/mesh-sdk/go/handacts" + handacts "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshhandacts" ) type memStore struct { @@ -426,7 +426,7 @@ func TestTheVerbsAndReads(t *testing.T) { args map[string]any log, err string }{ - {"into the seat", false, map[string]any{"what": "stopped records", "why": "does it raise"}, handacts.LogSeat, ""}, + {"into the seat", false, map[string]any{"what": "stopped records", "why": "does it raise"}, handacts.Seat, ""}, {"no holder: refused, the controller's not asked", true, map[string]any{"what": "stopped records", "why": "x"}, "", "nothing was recorded"}, {"says nothing", false, map[string]any{}, "", "says what"}, } @@ -455,7 +455,7 @@ func TestTheVerbsAndReads(t *testing.T) { } case err != nil || got.(map[string]any)["log"] != d.log: t.Errorf("drill %s: %v, %v", d.name, got, err) - case d.log == handacts.LogSeat && !strings.Contains(asked[0], `"verb":"hand-act drill"`): + case d.log == handacts.Seat && !strings.Contains(asked[0], `"verb":"hand-act drill"`): t.Errorf("drill %s asked %v", d.name, asked) } for _, k := range asked { diff --git a/modules/mesh-healers/cmd/mesh-healers/tools.go b/modules/mesh-healers/cmd/mesh-healers/tools.go index e5f1dc25b..fc0d92273 100644 --- a/modules/mesh-healers/cmd/mesh-healers/tools.go +++ b/modules/mesh-healers/cmd/mesh-healers/tools.go @@ -12,8 +12,9 @@ import ( "strings" "time" + handactsclient "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient" + handacts "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshhandacts" stdio "git.novox.be/novox/mesh-sdk/go" - "git.novox.be/novox/mesh-sdk/go/handacts" ) // Verbs are the seat's verbs, as the manifest claims them. @@ -92,7 +93,7 @@ func (h *Healers) Drill(what, why, condition string) (any, error) { if h.Ask == nil { return nil, errors.New("the hand-act log cannot be reached from here: nothing was recorded") } - body := map[string]any{"what": what, "why": why, "verb": handacts.VerbDrill} + body := map[string]any{"what": what, "why": why, "verb": handactsclient.VerbDrill} if condition != "" { body["condition"] = condition } @@ -100,7 +101,7 @@ func (h *Healers) Drill(what, why, condition string) (any, error) { if err != nil { return nil, fmt.Errorf("%s.hand-act refused the drill, so nothing was recorded: %w", handacts.Seat, err) } - return map[string]any{"log": handacts.LogSeat, "answer": answer}, nil + return map[string]any{"log": handacts.Seat, "answer": answer}, nil } // Heal is the verb heal: one condition judged now by its healer. diff --git a/modules/mesh-healers/cmd/mesh-healers/wanted.go b/modules/mesh-healers/cmd/mesh-healers/wanted.go index 2b83a20af..cbee1a0e3 100644 --- a/modules/mesh-healers/cmd/mesh-healers/wanted.go +++ b/modules/mesh-healers/cmd/mesh-healers/wanted.go @@ -16,13 +16,13 @@ import ( "strings" "time" - "git.novox.be/novox/mesh-sdk/go/handacts" + handacts "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshhandacts" ) // Within is how far back a repeated cause counts. const Within = 14 * 24 * time.Hour -// HandAct is what S15 reads of one act of the hand-act log (mesh-sdk handacts.Act). +// HandAct is what S15 reads of one act of the hand-act log (the seat mesh-hand-acts's Act). type HandAct struct { ID string `json:"id"` At time.Time `json:"at"` @@ -85,7 +85,7 @@ func (h *Healers) ActRecorded(body []byte) { if h.acts == nil { h.acts = map[string]HandAct{} } - h.acts[handacts.LogSeat+":"+a.ID] = a + h.acts[handacts.Seat+":"+a.ID] = a h.mu.Unlock() h.Wanted() } diff --git a/modules/mesh-healers/go.mod b/modules/mesh-healers/go.mod index 0b3c16026..77d768cb1 100644 --- a/modules/mesh-healers/go.mod +++ b/modules/mesh-healers/go.mod @@ -3,6 +3,7 @@ module mesh-healers go 1.26.0 require ( + git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshhandacts v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261104174359-05b3e2e1b94f github.com/nats-io/nats.go v1.54.0 ) @@ -24,3 +25,4 @@ require ( require git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient v0.0.0-00010101000000-000000000000 require git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions v0.0.0-00010101000000-000000000000 require git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshhealers v0.0.0-00010101000000-000000000000 +require git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient v0.0.0-00010101000000-000000000000