§717 (3), the status view follows the assignments, the wants and the asks by their seats, at the holders the seat-holders view names

The status view's process followed mesh-delivery-assigner's assignments, wants and asks by module name. It now follows them
through views.ProcessReader.FollowSeat with the catalog half's holder function (A-298), its pictures named in the seat form
(mesh-module-assigner_assignments, mesh-wants_wants, mesh-wants_asks); the watchman's stuck key of a want, which names the
holder's real bucket, is read at each use from the holder followed (ProcessReader.HolderBucket), and the tools program,
which reads the wants of the assigner's tool (A-300), names that module's bucket. The process names no module of the
assigner. The bed serves the seats' views at stand-in holders the claimant's seat-holders view names.

Builds: design 47 G §717, A-298, A-300, A-303 (corrected)

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-12 20:38:44 +01:00
parent 43f6b57ab2
commit 29517d702c
16 changed files with 124 additions and 61 deletions
@@ -142,7 +142,7 @@ func TestPrintsTheOpenAsksInTheTableAndTheJSON(t *testing.T) { // 1345/AC2
if err != nil {
t.Fatal(err)
}
m.Apply(view.Entry{Bucket: view.AssignerAsksBucket, Key: key, Value: value})
m.Apply(view.Entry{Bucket: view.AsksBucket, Key: key, Value: value})
dir, err := os.MkdirTemp(os.Getenv("TMPDIR"), "c")
if err != nil {
t.Fatal(err)
@@ -223,7 +223,7 @@ func TestTheAnswerCommandAnswersAnAskNeedingNoProof(t *testing.T) { // 1297/B9b
}
m, w := view.New(viewstate.ViewModule), &putter{puts: map[string][]byte{}}
m.SetWriter(w)
m.Apply(view.Entry{Bucket: view.AssignerAsksBucket, Key: key, Value: value})
m.Apply(view.Entry{Bucket: view.AsksBucket, Key: key, Value: value})
socket := serveWith(t, m)
var out, errOut bytes.Buffer
@@ -266,8 +266,8 @@ func TestTheHoldCommandsListAndAnswerHolds(t *testing.T) {
ans, _ := meshdeliveryclient.EncodeAnswer(meshdeliveryclient.Answer{Option: "keep", Warrant: hold.ID + "@2026-10-25T04:00:00Z", Words: "the operator chose keep"})
m, w := view.New(viewstate.ViewModule), &putter{puts: map[string][]byte{}}
m.SetWriter(w)
m.Apply(view.Entry{Bucket: view.AssignerAsksBucket, Key: key, Value: value})
m.Apply(view.Entry{Bucket: view.AssignerWantsBucket, Key: hkey, Value: held})
m.Apply(view.Entry{Bucket: view.AsksBucket, Key: key, Value: value})
m.Apply(view.Entry{Bucket: view.WantsBucket, Key: hkey, Value: held})
m.Apply(view.Entry{Bucket: view.AnswersBucket, Key: key, Value: ans})
socket := serveWith(t, m)
@@ -7,6 +7,7 @@ import (
"context"
"encoding/json"
"fmt"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
"mesh-delivery-view/internal/view"
"os"
"strings"
@@ -403,6 +404,8 @@ func ownersRead(ask func(key string, body any) (json.RawMessage, error), catalog
assigner := func(tool string) view.StateRead { return view.OwnerRead(ask, view.AssignerModule+"."+tool) }
return view.Reader{State: catalogRead(catalog), CandidatesState: indexer("indexer_read_candidates"),
WantsState: assigner("assigner_read_wants"), DifferencesState: assigner("assigner_read_differences"),
// The wants' real bucket at the module the tools program reads them of (A-300), as the watchman's stuck keys name it.
WantsHeld: view.AssignerModule + "_" + meshwants.StateWants,
HeardState: indexer("indexer_read_heard"),
PredefinedState: indexer("indexer_read_predefined"),
ConfigCandidatesState: indexer("indexer_read_config_candidates"),
@@ -47,8 +47,22 @@ func serveOwners(t *testing.T, ctx context.Context, js jetstream.JetStream, nc *
for _, o := range ownersFollowed {
viewstest.Serve(t, ctx, js, nc, o.owner, o.state, o.tool, "n_"+viewstate.ViewModule)
}
// Design 47 G §717, A-303: the seats' views at their holders, which the seat-holders view of the catalog half's claimant
// names (serveCatalog's claimant): stand-ins named for their seats, so each real bucket is the picture's seat-form name.
for _, o := range []struct{ holder, state string }{{claimantModule, view.AssignmentsState}, {"mesh-wants", "wants"}, {"mesh-wants", "asks"}} {
viewstest.Serve(t, ctx, js, nc, o.holder, o.state, o.holder+"."+o.state, "n_"+viewstate.ViewModule)
}
holders := viewstest.Serve(t, ctx, js, nc, claimantModule, "seat-holders", claimantModule+".seat-holders", "n_"+viewstate.ViewModule)
for seat, holder := range map[string]string{"mesh-module-assigner": claimantModule, "mesh-wants": "mesh-wants"} {
if _, err := holders.Put(ctx, seat, []byte(`{"seat":"`+seat+`","holders":[{"module":"`+holder+`","node":"n"}]}`)); err != nil {
t.Fatal(err)
}
}
}
// claimantModule is the stand-in module claiming mesh-module-assigner in the catalog half the view follows (A-298).
const claimantModule = "mesh-module-assigner"
// catalogHolder is the seat mesh-catalog's holder as the view's process needs it (W16.1): its verb revision answering the
// trunk's newest revision whole, and its event catalog-revision said on the shared events stream at each change, which the
// view's durable consumer hears.
@@ -66,7 +80,10 @@ type catalogHolder struct {
func serveCatalog(t testing.TB, ctx context.Context, js jetstream.JetStream, nc *nats.Conn) *catalogHolder {
t.Helper()
h := &catalogHolder{t: t, js: js, ctx: ctx, rev: 1, entries: map[string]meshcatalog.CatalogEntry{}}
h := &catalogHolder{t: t, js: js, ctx: ctx, rev: 1, entries: map[string]meshcatalog.CatalogEntry{
// the claimant of mesh-module-assigner, whose seat-holders view names the seats' holders (design 47 G §717, A-298)
claimantModule: {Module: claimantModule, ManifestDigest: "sha256:claimant", Manifest: map[string]any{"module": claimantModule,
"claims": []any{map[string]any{"name": "mesh-module-assigner", "scope": "mesh"}}}}}}
events, err := js.Stream(ctx, process.EventsStream)
if err != nil {
t.Fatal(err)
@@ -488,7 +505,7 @@ func TestProcessWholeListsEveryDifference(t *testing.T) { // 1297/B8 AC
go func() { done <- run(runCtx, func(k string) string { return env[k] }, io.Discard) }()
t.Cleanup(func() { stop(); <-done })
kv, err := js.KeyValue(ctx, view.AssignerWantsBucket)
kv, err := js.KeyValue(ctx, view.WantsBucket)
if err != nil {
t.Fatal(err)
}
@@ -563,7 +580,7 @@ func TestProcessWholeWritesTheAnswerToAnAskNeedingNoProof(t *testing.T) { // 129
}
return kv
}
askBucket := bucket(view.AssignerAsksBucket, view.AssignerAsksHistory)
askBucket := bucket(view.AsksBucket, view.AssignerAsksHistory)
viewBucket := bucket(viewstate.BucketsOf(viewstate.ViewModule).Answers, viewstate.ViewAnswersHistory)
bucket(viewstate.ViewModule+"_"+views.MarksState, 1)
teller := bucket(view.AnswersBucket, view.AnswersHistory)
@@ -788,7 +805,7 @@ func TestProcessWholeSaysTheSourceRevisionIsDelivered(t *testing.T) {
t.Fatal(err)
}
kvs := map[string]jetstream.KeyValue{}
for _, name := range []string{view.AssignerWantsBucket, view.HaveBucket, viewstate.BucketsOf(viewstate.ViewModule).Reach} {
for _, name := range []string{view.WantsBucket, view.HaveBucket, viewstate.BucketsOf(viewstate.ViewModule).Reach} {
kv, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: name, History: 5})
if err != nil {
t.Fatal(err)
@@ -818,7 +835,7 @@ func TestProcessWholeSaysTheSourceRevisionIsDelivered(t *testing.T) {
failed, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: fp, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthFailed})
good, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: fp, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
catalog.put(meshcatalog.CatalogEntry{Module: "web", Fp: fp, Manifest: map[string]any{"module": "a"}, Repository: "novox/web", Commit: strings.Repeat("1", 40), Path: meshcatalogclient.RootPath})
if _, err := kvs[view.AssignerWantsBucket].Put(ctx, "want.ace.web", want); err != nil {
if _, err := kvs[view.WantsBucket].Put(ctx, "want.ace.web", want); err != nil {
t.Fatal(err)
}
if _, err := kvs[view.HaveBucket].Put(ctx, "ace.web", failed); err != nil {
@@ -894,7 +911,7 @@ func TestProcessWholeSaysModulesInMotion(t *testing.T) {
t.Fatal(err)
}
kvs := map[string]jetstream.KeyValue{}
for _, name := range []string{view.AssignerWantsBucket, view.HaveBucket, view.StuckBucket} {
for _, name := range []string{view.WantsBucket, view.HaveBucket, view.StuckBucket} {
kv, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: name, History: 5})
if err != nil {
t.Fatal(err)
@@ -933,7 +950,7 @@ func TestProcessWholeSaysModulesInMotion(t *testing.T) {
}
want := func(node, module string) {
v, err := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fpNew, Composed: digest})
put(view.AssignerWantsBucket, "want."+node+"."+module, v, err)
put(view.WantsBucket, "want."+node+"."+module, v, err)
}
have := func(node, module, fp string, phase string, health string, detail string) {
v, err := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: fp, Phase: phase, Health: health, Detail: detail})
@@ -11,7 +11,9 @@ import (
"encoding/json"
"errors"
"fmt"
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
"io"
"log"
"maps"
@@ -154,14 +156,6 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
return err
}
}
open := buckets{js: js, reader: reader}
for _, bucket := range []string{view.HaveBucket, view.AssignmentsBucket, view.PresenceBucket, view.StuckBucket, view.CandidatesBucket, view.AnswersBucket, builds.BuilderBuildsBucket, view.AssignerWantsBucket, view.AssignerAsksBucket, own.Answers, view.TakenBucket, own.Reach} {
go follow(ctx, open, bucket, false, model, logger)
}
// The view's own state reach, as it stood at the start, is what the derivation lays its history over (design 47 G A-225);
// the modules' history is each revision of the catalog half the view takes, in its order (below), and each watched
// branch's source is the seat mesh-delivery's verb source per branch, followed by its source-moved (A-173).
statusBucket := process.AwaitBucket(ctx, js, conn, cred.Module+"_"+views.StatusState, "view_first_views reads nothing and view_first_view_again is not heard", logger.Printf)
// The modules are the catalog half's, per watched branch, through meshcatalogclient's branch follower adopted on the
// reader (design 47 G §532, §614): the registrations' branches, before the first registrations the gate's source's;
// each branch's first view, its status, its hand asks and its event catalog-revision are the reader's. A module's entry
@@ -171,6 +165,25 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
return err
}
branches.Logf = logger.Printf
// The seats mesh-module-assigner's assignments and mesh-wants' wants and asks, each followed at the holder the
// seat-holders view of the catalog half's claimant names, and as it moves (design 47 G §717, A-298, A-300): each a picture
// in the seat form, its first view the holder's tool named for the state; no code names their holder.
holders := branches.SeatHolders(ctx)
for _, s := range []struct{ seat, state string }{{mma.Seat, view.AssignmentsState}, {meshwants.Seat, meshwants.StateWants}, {meshwants.Seat, meshwants.StateAsks}} {
if _, err := reader.FollowSeat(s.seat, s.state, holders); err != nil {
return err
}
}
// The watchman's stuck keys name the wants' real bucket at their holder (A-303 (corrected)).
model.SetWantsHolder(func() string { return reader.HolderBucket(meshwants.Seat, meshwants.StateWants) })
open := buckets{js: js, reader: reader}
for _, bucket := range []string{view.HaveBucket, view.AssignmentsBucket, view.PresenceBucket, view.StuckBucket, view.CandidatesBucket, view.AnswersBucket, builds.BuilderBuildsBucket, view.WantsBucket, view.AsksBucket, own.Answers, view.TakenBucket, own.Reach} {
go follow(ctx, open, bucket, false, model, logger)
}
// The view's own state reach, as it stood at the start, is what the derivation lays its history over (design 47 G A-225);
// the modules' history is each revision of the catalog half the view takes, in its order (below), and each watched
// branch's source is the seat mesh-delivery's verb source per branch, followed by its source-moved (A-173).
statusBucket := process.AwaitBucket(ctx, js, conn, cred.Module+"_"+views.StatusState, "view_first_views reads nothing and view_first_view_again is not heard", logger.Printf)
sources := &branchSources{ctx: ctx, reader: reader, call: calls.Call, model: model, logger: logger}
modules := &catalogModules{ctx: ctx, branches: branches, sources: sources, model: model, logger: logger, applied: map[string]bool{}}
branches.Changed = modules.changed
@@ -269,11 +282,6 @@ type ReachedEvent struct {
// owner's first-view or read tool (as the view's consumes or invokes names it) and views family (its events on the shared events stream); the
// view's tools ask the other six through the owners' read tools on each call.
var ownersFollowed = []struct{ owner, state, tool string }{
// The seats mesh-module-assigner's assignments and mesh-wants' wants and asks, each first viewed by the tool named for its
// state (design 47 G §717, A-300).
{view.AssignerModule, view.AssignmentsState, view.AssignerModule + "." + view.AssignmentsState},
{view.AssignerModule, "wants", view.AssignerModule + ".wants"},
{view.AssignerModule, "asks", view.AssignerModule + ".asks"},
{view.IndexerModule, "candidates", view.IndexerModule + ".indexer_read_candidates"},
{view.IndexerModule, "taken", view.IndexerModule + ".indexer_read_taken"},
{view.TellerModule, view.AnswersState, view.TellerModule + ".teller_read_answers"},
@@ -289,6 +297,9 @@ func (b buckets) KeyValue(ctx context.Context, bucket string) (jetstream.KeyValu
if p := b.reader.Picture(bucket); p != nil {
return p, nil
}
if kv, err := b.reader.KeyValue(ctx, bucket); err == nil { // a seat's view, by its picture's name (§717)
return kv, nil
}
return b.js.KeyValue(ctx, bucket)
}
+1 -1
View File
@@ -65,6 +65,6 @@ require (
git.novox.be/novox/mesh-contracts/identity-and-access/go/seats/meshvault v0.0.0-00010101000000-000000000000 // indirect
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/containerimageregistryclient v0.0.0-00010101000000-000000000000 // indirect
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/containerimageregistry v0.0.0-00010101000000-000000000000 // indirect
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants v0.0.0-00010101000000-000000000000 // indirect
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/ociartifactregistry v0.0.0-00010101000000-000000000000 // indirect
)
@@ -60,7 +60,7 @@ func holdAsk(t *testing.T) (Entry, oc.Ask) {
if err != nil {
t.Fatal(err)
}
return Entry{Bucket: AssignerAsksBucket, Key: key, Value: v, At: t0}, a
return Entry{Bucket: AsksBucket, Key: key, Value: v, At: t0}, a
}
func TestAnAskNeedingNoProofIsOpenInTheViewWithItsOptions(t *testing.T) { // 1297/B9
@@ -108,7 +108,7 @@ func TestTheViewWritesItsAnswerUnderTheAsksViewKey(t *testing.T) { // 1297/B9a A
if len(w.deleted) != 0 {
t.Fatalf("deleted %v while the ask stands", w.deleted)
}
fill(m, Entry{Bucket: AssignerAsksBucket, Key: e.Key, Deleted: true, At: t0})
fill(m, Entry{Bucket: AsksBucket, Key: e.Key, Deleted: true, At: t0})
if !slices.Equal(w.deleted, []string{e.Key + ".view"}) {
t.Errorf("deleted %v once the ask left asks, want %s.view", w.deleted, e.Key)
}
@@ -46,7 +46,7 @@ func TestAnAskWithNoAnswerIsListedAndAnAnsweredOneIsNot(t *testing.T) { // 1345/
if got := m.Snapshot().Asks; len(got) != 1 {
t.Errorf("asks after the answer was taken away = %+v", got)
}
fill(m, Entry{Bucket: AssignerAsksBucket, Key: e.Key, Deleted: true})
fill(m, Entry{Bucket: AsksBucket, Key: e.Key, Deleted: true})
if got := m.Snapshot().Asks; len(got) != 0 {
t.Errorf("a withdrawn ask is listed: %+v", got)
}
@@ -75,9 +75,9 @@ func TestAnAnswerHeardBeforeItsAskStillHidesTheAsk(t *testing.T) {
func TestAnUnreadableAskIsNamedAndNotListed(t *testing.T) { // never dropped silently
m := New(viewstate.ViewModule)
e, _ := holdAsk(t)
fill(m, Entry{Bucket: AssignerAsksBucket, Key: e.Key, Value: []byte("{"), At: t0})
fill(m, Entry{Bucket: AsksBucket, Key: e.Key, Value: []byte("{"), At: t0})
s := m.Snapshot()
if len(s.Asks) != 0 || len(s.Unreadable) != 1 || s.Unreadable[0].Bucket != AssignerAsksBucket {
if len(s.Asks) != 0 || len(s.Unreadable) != 1 || s.Unreadable[0].Bucket != AsksBucket {
t.Errorf("snapshot = %+v", s)
}
}
@@ -21,7 +21,7 @@ func heldE(t *testing.T, module, fp, node, words string) Entry {
if err != nil {
t.Fatal(err)
}
return Entry{Bucket: AssignerWantsBucket, Key: key, Value: v, At: t0}
return Entry{Bucket: WantsBucket, Key: key, Value: v, At: t0}
}
func answered(t *testing.T, key, id, option string) Entry {
@@ -3,7 +3,9 @@ package view
import (
"fmt"
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk"
"git.novox.be/novox/mesh-sdk/go/keys"
)
@@ -33,11 +35,13 @@ const (
PredefinedListKey = "list"
IndexerConfigCandidatesState = "config-candidates"
// The assigner's states.
AssignmentsState = "assignments"
AssignmentsBucket = AssignerModule + "_" + AssignmentsState
AssignerWantsBucket = AssignerModule + "_wants"
AssignerAsksBucket = AssignerModule + "_asks"
// The seats mesh-module-assigner's and mesh-wants' views the process follows, its pictures named in the seat form
// `<seat>_<state>` (design 47 G §717, A-303): no module is named. Where a name must be the holder's real bucket (the
// watchman's stuck key) the process reads it from the holder it follows (views.ProcessReader.HolderBucket).
AssignmentsState = "assignments"
AssignmentsBucket = mma.Seat + "_" + AssignmentsState
WantsBucket = meshwants.Seat + "_" + meshwants.StateWants
AsksBucket = meshwants.Seat + "_" + meshwants.StateAsks
// SourceBucket names, in the model's entries, each watched branch's source as the seat mesh-delivery's verb source answers
// it, keyed by the escaped branch (design 47 G §507, A-173): never a bucket the view reads. The teller's state answers as
@@ -29,7 +29,7 @@ func ReachHistory(bucket string) string { return bucket + "#history" }
// reachBuckets are the watches the derivation waits for before it writes or says anything, so a start does not write a reach
// derived from half its inputs; the view's own reach first, which a restart lays the derivation over (A-225).
func (m *Model) reachBuckets() []string {
return []string{ModulesBucket, AssignerWantsBucket, HaveBucket, TakenBucket, ReachHistory(ModulesBucket), m.own.Reach}
return []string{ModulesBucket, WantsBucket, HaveBucket, TakenBucket, ReachHistory(ModulesBucket), m.own.Reach}
}
// ReachWrite is a reach value to write under its key in the view's state reach.
@@ -53,6 +53,7 @@ type Reader struct {
CandidatesState StateRead // the indexer's candidates
WantsState StateRead // the assigner's wants and holds
WantsHeld string // the wants' real bucket at the module WantsState reads, which the watchman's stuck keys name
DifferencesState StateRead // the assigner's differences
HavesState StateRead // the node-engine's haves
ReachState StateRead // the view's own reach (ADR 0556)
@@ -125,7 +126,7 @@ func ControlRecord(s StateRead, name, key string) (any, error) {
// Status is the view's derivation of status at now (status.go).
func (r Reader) Status(now time.Time) Status {
return DeriveStatus(StatusRead{Conditions: r.ConditionsState, Attempts: r.AttemptsState, Presence: r.PresenceState,
Stuck: r.StuckState, Wants: r.WantsState, Haves: r.HavesState}, now)
Stuck: r.StuckState, Wants: r.WantsState, Haves: r.HavesState, WantsHeld: r.WantsHeld}, now)
}
// ReachReadTool reads the view's reach: per repository, how far each module reached and the reached head (ADR 0556).
@@ -42,6 +42,9 @@ const HealsWithin = 7 * 24 * time.Hour
// StatusRead is the five buckets status reads, as a tool reads them.
type StatusRead struct {
Conditions, Attempts, Presence, Stuck, Wants, Haves StateRead
// WantsHeld is the real bucket of the wants at their holder, which the watchman's stuck keys name (design 47 G A-303);
// "" reads no want as stuck.
WantsHeld string
}
// Status is the view's answer to status.
@@ -178,7 +181,7 @@ func DeriveStatus(r StatusRead, now time.Time) Status {
}
}
words, stopped := "", false
if sk, err := meshwatchdogsclient.StuckKey(AssignerWantsBucket, wk); err == nil && serr == nil {
if sk, err := meshwatchdogsclient.StuckKey(r.WantsHeld, wk); err == nil && serr == nil && r.WantsHeld != "" {
if s, err := meshwatchdogsclient.DecodeStuck(stuck[sk]); err == nil && !s.Moved {
words, stopped = s.Waited, true
}
@@ -255,6 +255,7 @@ type Model struct {
chosen map[string]viewstate.ViewAnswer // the answers the view wrote, by ask key
writer Writer
backlog *Backlog
wantsHolder func() string // the real bucket of mesh-wants' wants at its holder (SetWantsHolder)
answers map[string]string // by key: the router id of the asking the teller's answer is for ("" when unreadable)
answerOf map[string]meshdeliveryclient.Answer // by key: the teller's answer whole, when readable (holds.go)
holds map[string]heldEntry // the assigner's holds, by held key (holds.go)
@@ -596,7 +597,7 @@ func (m *Model) apply(e Entry) {
} else {
delete(m.modBranch, e.Key)
}
case AssignerAsksBucket:
case AsksBucket:
if e.Deleted {
delete(m.aasks, e.Key)
// The view's answer outlives no ask: once the ask has left asks, the view deletes its answer (design 47 G §717).
@@ -619,7 +620,7 @@ func (m *Model) apply(e Entry) {
if a, err := viewstate.DecodeViewAnswer(e.Value); err == nil {
m.chosen[askKey] = a
}
case AssignerWantsBucket:
case WantsBucket:
if m.applyHeld(e) {
return
}
@@ -724,6 +725,22 @@ func (m *Model) Snapshot() Snapshot {
}
// SetBacklog gives the model the seats' workers to read the backlog of asks from.
// wantsHeld is the real bucket of mesh-wants' wants at the holder followed now, "" for none.
func (m *Model) wantsHeld() string {
if m.wantsHolder == nil {
return ""
}
return m.wantsHolder()
}
// SetWantsHolder sets where the model reads the real bucket of the seat mesh-wants' wants at its holder, which the watchman's
// stuck keys name (design 47 G A-303): "" while no holder is followed, when no want reads as stuck.
func (m *Model) SetWantsHolder(bucket func() string) {
m.mu.Lock()
defer m.mu.Unlock()
m.wantsHolder = bucket
}
func (m *Model) SetBacklog(b *Backlog) {
m.mu.Lock()
defer m.mu.Unlock()
@@ -841,12 +858,12 @@ func (m *Model) snapshot() Snapshot {
}
for key, a := range m.aasks {
if a.err != "" {
unreadable = append(unreadable, UnreadableRow{Bucket: AssignerAsksBucket, Key: key, Error: a.err})
unreadable = append(unreadable, UnreadableRow{Bucket: AsksBucket, Key: key, Error: a.err})
}
}
for key, w := range m.wants {
if w.err != "" {
unreadable = append(unreadable, UnreadableRow{Bucket: AssignerWantsBucket, Key: key, Error: w.err})
unreadable = append(unreadable, UnreadableRow{Bucket: WantsBucket, Key: key, Error: w.err})
}
}
sort.Slice(offline, func(i, j int) bool {
@@ -1252,7 +1269,7 @@ func (m *Model) motionNow(e Entry) []MotionEvent {
}
var hk string
switch e.Bucket {
case AssignerWantsBucket:
case WantsBucket:
node, module, err := meshwantsclient.ParseWantKey(e.Key)
if err != nil {
return nil
@@ -1265,7 +1282,7 @@ func (m *Model) motionNow(e Entry) []MotionEvent {
hk = e.Key
case StuckBucket:
st, ok := m.stuck[e.Key]
if !ok || st.err != "" || st.value.Bucket != AssignerWantsBucket {
if held := m.wantsHeld(); !ok || st.err != "" || held == "" || st.value.Bucket != held {
return nil
}
node, module, err := meshwantsclient.ParseWantKey(st.value.Key)
@@ -1282,7 +1299,7 @@ func (m *Model) motionNow(e Entry) []MotionEvent {
// motionReady says whether the view has read what stands in the buckets motion is derived from (the wants, the haves and the
// watchman's stuck keys): before, a want read ahead of its have would be said moving though the node runs it.
func (m *Model) motionReady() bool {
for _, b := range []string{AssignerWantsBucket, HaveBucket, StuckBucket} {
for _, b := range []string{WantsBucket, HaveBucket, StuckBucket} {
if !m.initial[b] {
return false
}
@@ -1372,7 +1389,11 @@ func (m *Model) stuckWant(_ meshwantsclient.Want, node, module string) (string,
if err != nil {
return "", false
}
sk, err := meshwatchdogsclient.StuckKey(AssignerWantsBucket, wk)
held := m.wantsHeld()
if held == "" {
return "", false
}
sk, err := meshwatchdogsclient.StuckKey(held, wk)
if err != nil {
return "", false
}
@@ -300,15 +300,18 @@ func statusDerivesEachPartFromItsBucket(t *testing.T) {
b, _ := meshwatchdogsclient.EncodeStuck(meshwatchdogsclient.Stuck{Bucket: bucket, Key: key, Waited: waited, Since: t0, Moved: moved})
return string(b)
}
stuckWant, _ := meshwatchdogsclient.StuckKey(AssignerWantsBucket, "want.b.web")
// The watchman names the wants' real bucket at their holder, as the read is told (A-303 (corrected)).
const held = "the-assigner_wants"
stuckWant, _ := meshwatchdogsclient.StuckKey(held, "want.b.web")
fin := t0.Add(time.Minute)
r := StatusRead{
Conditions: states(map[string]string{
"machine.b.silent": enc(mcseat.ConditionsByKeyValue{Key: "machine.b.silent", Severity: mcc.Warning, Summary: "b silent", Raised: t0}),
"core.doctor.self-check": enc(mcseat.ConditionsByKeyValue{Key: "core.doctor.self-check", Severity: mcc.Urgent, Summary: "no run", Raised: t0.Add(time.Minute)}),
}),
Presence: states(map[string]string{"a": presence(true), "b": presence(false)}),
Stuck: states(map[string]string{stuckWant: stuckOf(AssignerWantsBucket, "want.b.web", "b to run web", false),
Presence: states(map[string]string{"a": presence(true), "b": presence(false)}),
WantsHeld: held,
Stuck: states(map[string]string{stuckWant: stuckOf(held, "want.b.web", "b to run web", false),
"x.moved": stuckOf("x", "moved", "y", true)}),
Wants: states(map[string]string{"want.a.web": want(fp2), "want.a.mail": want(fp1), "want.b.web": want(fp2), "want.a.db": want(fp3)}),
Haves: states(map[string]string{"a.web": have(fp1, nodeengineclient.PhaseRunning, nodeengineclient.HealthOK, ""), "a.mail": have(fp1, nodeengineclient.PhaseRunning, nodeengineclient.HealthOK, ""),
@@ -36,7 +36,7 @@ func wantE(t *testing.T, node, module string, w meshwantsclient.Want) Entry {
if err != nil {
t.Fatal(err)
}
return Entry{Bucket: AssignerWantsBucket, Key: key, Value: v, At: t0}
return Entry{Bucket: WantsBucket, Key: key, Value: v, At: t0}
}
func haveFP(t *testing.T, node, module, fp string, health string) Entry {
@@ -115,7 +115,7 @@ func TestEveryWantIsARowAgainstItsHave(t *testing.T) {
t.Errorf("a pending row shows both: %+v", r)
}
// a want taken away leaves the list
fill(m, Entry{Bucket: AssignerWantsBucket, Key: "want.novox.web", Deleted: true})
fill(m, Entry{Bucket: WantsBucket, Key: "want.novox.web", Deleted: true})
if n := len(m.Snapshot().Wants); n != 5 {
t.Errorf("wants = %d after a delete, want 5", n)
}
@@ -306,7 +306,7 @@ func TestADottedModuleNameIsFoundAndKept(t *testing.T) {
func motionLog(m *Model) *[]MotionEvent {
var said []MotionEvent
m.SetMotionEvent(func(e MotionEvent) error { said = append(said, e); return nil })
for _, b := range []string{AssignerWantsBucket, HaveBucket, StuckBucket} {
for _, b := range []string{WantsBucket, HaveBucket, StuckBucket} {
m.Initial(b)
}
return &said
@@ -390,8 +390,10 @@ func TestAWantTheWatchmanSaysStoppedMovingIsSaidStuckPastItsBound(t *testing.T)
m := New(viewstate.ViewModule)
said := motionLog(m)
fill(m, wantE(t, "ace", "web", meshwantsclient.Want{Fp: fpNew}), haveFP(t, "ace", "web", fpOld, nodeengineclient.HealthOK))
sk, _ := meshwatchdogsclient.StuckKey(AssignerWantsBucket, "want.ace.web")
v, err := meshwatchdogsclient.EncodeStuck(meshwatchdogsclient.Stuck{Bucket: AssignerWantsBucket, Key: "want.ace.web", Waited: "the node agent of ace to run web", Since: t0})
// The watchman names the wants' real bucket at their holder, which the model reads from the holder followed (A-303 (corrected)).
m.SetWantsHolder(func() string { return "acme-assigner_wants" })
sk, _ := meshwatchdogsclient.StuckKey("acme-assigner_wants", "want.ace.web")
v, err := meshwatchdogsclient.EncodeStuck(meshwatchdogsclient.Stuck{Bucket: "acme-assigner_wants", Key: "want.ace.web", Waited: "the node agent of ace to run web", Since: t0})
if err != nil {
t.Fatal(err)
}
@@ -417,7 +419,7 @@ func TestMotionIsSaidOnlyOnceTheBucketsHaveBeenRead(t *testing.T) {
var said []MotionEvent
m.SetMotionEvent(func(e MotionEvent) error { said = append(said, e); return nil })
fill(m, wantE(t, "ace", "web", meshwantsclient.Want{Fp: fpNew}), wantE(t, "ace", "mail", meshwantsclient.Want{Fp: fpNew}))
m.Initial(AssignerWantsBucket)
m.Initial(WantsBucket)
fill(m, haveFP(t, "ace", "web", fpNew, nodeengineclient.HealthOK), haveFP(t, "ace", "mail", fpOld, nodeengineclient.HealthOK))
m.Initial(HaveBucket)
if len(said) != 0 {
+3 -5
View File
@@ -246,13 +246,11 @@ func TestManifestIsTakenAndReadsOnly(t *testing.T) { // 1134/AC7
}
followed := map[string]string{view.CandidatesBucket: view.IndexerModule + ".views.candidates",
view.TakenBucket: view.IndexerModule + ".views.taken", view.AssignmentsBucket: "seat:mesh-module-assigner.views.assignments",
view.AssignerWantsBucket: "seat:mesh-wants.views.wants", view.AssignerAsksBucket: "seat:mesh-wants.views.asks",
view.WantsBucket: "seat:mesh-wants.views.wants", view.AsksBucket: "seat:mesh-wants.views.asks",
view.AnswersBucket: view.TellerModule + ".views.answers"}
for bucket, family := range followed {
module, state, _ := strings.Cut(family, ".views.")
if strings.HasPrefix(module, "seat:") { // a seat's view, said by its holder (design 47 G §717)
module = view.AssignerModule
}
// a seat's view, said by its holder, is named in the seat form `<seat>_<state>` (design 47 G §717, A-303)
module, state, _ := strings.Cut(strings.TrimPrefix(family, "seat:"), ".views.")
if bucket != module+"_"+state {
t.Errorf("the bucket %s is not the state %s of %s", bucket, state, module)
}