mesh-self-check and mesh-healers give the writer the findings-asked subject of the seat's contract, and the reader the writer itself
Builds: design 47 G A-17, A-16 Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
@@ -161,7 +161,7 @@ func (w *world) fresh() {
|
||||
},
|
||||
}
|
||||
wr, err := views.NewWriter(views.WriterConfig[Finding, FindingCleared, FindingsStated, FindingsAsked]{
|
||||
Module: Module, Node: "ace", State: findingState{w.store}, Observe: w.h.Observe, Now: func() time.Time { return w.now },
|
||||
Module: Module, Node: "ace", Asked: "mesh.seat.mesh-conditions.event.findings-asked", State: findingState{w.store}, Observe: w.h.Observe, Now: func() time.Time { return w.now },
|
||||
Publish: func(_ context.Context, subject string, _ []byte, _ string) error {
|
||||
w.events = append(w.events, subject)
|
||||
return nil
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
meshconditions "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
@@ -58,7 +59,7 @@ func main() {
|
||||
Ask: func(key string, body any) (json.RawMessage, error) { return stdio.Ask(key, body) },
|
||||
Publish: stdio.SeatPublish}
|
||||
w, err := views.NewStdioWriter(views.WriterConfig[Finding, FindingCleared, FindingsStated, FindingsAsked]{
|
||||
Module: Module, State: stdio.State(FindingsState), Observe: h.Observe, Logf: logf})
|
||||
Module: Module, State: stdio.State(FindingsState), Observe: h.Observe, Asked: meshconditions.SubjectFindingsAsked, Logf: logf})
|
||||
if err != nil {
|
||||
logf("%v", err)
|
||||
os.Exit(1)
|
||||
|
||||
@@ -30,7 +30,6 @@ import (
|
||||
"github.com/nats-io/nats.go/jetstream"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/testbus"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
|
||||
type wire struct {
|
||||
@@ -390,7 +389,7 @@ func TestTheHealersWholeHearTheKeeperAndPassOverWhatEnded(t *testing.T) {
|
||||
// The runtime's consumer holds an event until the bundle subscribes: delivered once it hears them.
|
||||
eventually(t, "the healers hearing the keeper's conditions", func() bool { return p.hears(RaisedEvent) && p.hears(ChangedEvent) })
|
||||
// The writer hears the keeper's asks for findings, and states at its start the findings it observes: none.
|
||||
eventually(t, "the writer hearing findings-asked", func() bool { return p.hears(views.FindingsAskedEvent) })
|
||||
eventually(t, "the writer hearing findings-asked", func() bool { return p.hears("mesh-conditions.findings-asked") })
|
||||
if msg, err := stated.NextMsg(10 * time.Second); err != nil || !strings.Contains(string(msg.Data), `"findings":[]`) {
|
||||
t.Errorf("findings-stated at the start: %v", err)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
||||
meshconditions "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
|
||||
@@ -69,7 +70,7 @@ func NewChecker() *Checker {
|
||||
Ask: func(key string, body any) (json.RawMessage, error) { return stdio.Ask(key, body) },
|
||||
Publish: stdio.SeatPublish}
|
||||
w, err := views.NewStdioWriter(views.WriterConfig[Finding, FindingCleared, FindingsStated, FindingsAsked]{
|
||||
Module: Module, State: stdio.State(FindingsState), Observe: c.Observe, Logf: logf})
|
||||
Module: Module, State: stdio.State(FindingsState), Observe: c.Observe, Asked: meshconditions.SubjectFindingsAsked, Logf: logf})
|
||||
if err != nil {
|
||||
logf("%v", err)
|
||||
os.Exit(1)
|
||||
@@ -83,7 +84,7 @@ func NewChecker() *Checker {
|
||||
// its owner's read tool, then followed by the owner's events. A first view unanswered past its bound is a finding of the
|
||||
// self-check's own (first-view-unanswered), written into its state findings.
|
||||
func newViews(w *FindingsWriter) *views.Reader {
|
||||
r := &views.Reader{Module: Module, Logf: logf, Findings: views.WriterFindings{Writer: w}, Acts: meshhandactsclient.Recorder{Ask: stdio.Ask}}
|
||||
r := &views.Reader{Module: Module, Logf: logf, Findings: w, Acts: meshhandactsclient.Recorder{Ask: stdio.Ask}}
|
||||
r.Follow(assignerModule, placing.StateAssignments, AssignmentsTool)
|
||||
r.Follow(assignerModule, placing.StateSeatHolders, SeatHoldersTool)
|
||||
r.Follow(indexerModule, "modules", ModulesTool)
|
||||
|
||||
@@ -127,7 +127,7 @@ func checker(store *memStore, registry ...Probe) (*Checker, *[]string) {
|
||||
return nil
|
||||
}}
|
||||
w, err := views.NewWriter(views.WriterConfig[Finding, FindingCleared, FindingsStated, FindingsAsked]{
|
||||
Module: Module, Node: "novox", State: findingState{store}, Observe: c.Observe, Logf: c.Logf, Now: c.Now,
|
||||
Module: Module, Node: "novox", Asked: "mesh.seat.mesh-conditions.event.findings-asked", State: findingState{store}, Observe: c.Observe, Logf: c.Logf, Now: c.Now,
|
||||
Publish: func(_ context.Context, subject string, _ []byte, _ string) error {
|
||||
store.events = append(store.events, subject)
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user