From 2559c205bbc04fa6aa60af46ce605de000964913 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 16 Nov 2026 18:00:04 +0100 Subject: [PATCH] approval: the first views run before any seat list is read (novox 2026-11-16 deadlock) Cause: startRead looked only in the definitions the runner holds. The seat list is itself read through the seat mesh-catalog, so before the catalog half is ready the runner holds none, and every first view it waits on (its own and another runner's, from any account) was refused with "marks not read yet" for ever. Quick fix: let the one account that stalled through (calledByModule). Thorough fix (chosen): the foundation's bootstrapped definitions answer for the seats they name wherever the held list lacks them, so a first view runs whoever asks; an act of the same seat and a seat no definition names stay held. Test: TestTheFirstViewsRunBeforeAnySeatListIsRead (fails without run.go change). Builds: design 47 G A-387, A-388, A-433 --- go/approval/approval_test.go | 27 +++++++++++++++++++++++++++ go/approval/run.go | 27 ++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/go/approval/approval_test.go b/go/approval/approval_test.go index f53bdc1c..5aa055ed 100644 --- a/go/approval/approval_test.go +++ b/go/approval/approval_test.go @@ -194,3 +194,30 @@ func TestAnUnreadCatalogHalfLetsItsOwnReadsThrough(t *testing.T) { t.Errorf("the module's own seat call in its own runtime: ran %v (%v), want it run", ran, err) } } + +// The deadlock of novox 2026-11-16: the seat list is read through the seat mesh-catalog, so while the catalog half is unread +// the runner holds no definitions, and the first views it waits on (its own and another runner's) were refused for ever. The +// foundation's bootstrapped definitions answer for them, from whichever account asks. +func TestTheFirstViewsRunBeforeAnySeatListIsRead(t *testing.T) { + g := New(Deps{Node: "n1", Runner: "node-tools", Catalog: unread{defs: map[string]seatdef.Definition{}}, + Wait: func(time.Duration) error { return errors.New("still unread") }, Logf: func(string, ...any) {}}) + for _, tc := range []struct { + seat, name, caller string + runs bool + }{ + {"mesh-catalog", "revision", "n1.node-tools", true}, + {"mesh-catalog", "revision", "n2.node-tools", true}, + {"mesh-catalog", "registrations", "person.operator", true}, + {"mesh-catalog", "entry", "n1.node-tools", true}, + {"mesh-catalog", "seat-definitions", "n1.node-tools", true}, + {"git", "merge-pull", "n1.node-tools", false}, + {"unheld", "list", "n1.node-tools", false}, + } { + ran := false + _, err := g.Run(Call{Address: tc.seat + "." + tc.name, Module: "mesh-delivery-indexer", Seat: tc.seat, Name: tc.name, + Fingerprint: "fp1", Caller: tc.caller}, func() (any, error) { ran = true; return "ok", nil }) + if ran != tc.runs || (err == nil) != tc.runs { + t.Errorf("%s.%s by %s: ran %v (%v), want %v", tc.seat, tc.name, tc.caller, ran, err, tc.runs) + } + } +} diff --git a/go/approval/run.go b/go/approval/run.go index afaacf4f..2deb1171 100644 --- a/go/approval/run.go +++ b/go/approval/run.go @@ -5,9 +5,11 @@ import ( "fmt" "slices" "strings" + "sync" "git.novox.be/novox/mesh-sdk/go/operatorask" "git.novox.be/novox/mesh-sdk/go/seatdef" + "git.novox.be/novox/mesh-sdk/go/seatlist" ) // Run is a call through the gate (ยง20): an unmarked call runs; a marked one runs only on the operator's approval of that @@ -84,7 +86,13 @@ func (g *Gate) startRead(c Call) bool { } def, ok := g.d.Catalog.Definitions()[c.Seat] if !ok { - return false + // The seat list is itself read through the seat mesh-catalog, so before its first view the held definitions are + // none: the foundation's bootstrapped definitions answer for the seats they name (the first view of the catalog half + // must run before the catalog half is ready: novox 2026-11-16, the indexer's mesh-catalog.revision refused for 20 minutes). + def, ok = bootstrapped(c.Seat) + if !ok { + return false + } } i := slices.IndexFunc(def.Verbs, func(v seatdef.Verb) bool { return v.Name == c.Name }) return i >= 0 && def.Verbs[i].Class == seatdef.ClassRead && !def.Verbs[i].NeedsApproval @@ -229,3 +237,20 @@ func errText(err error) string { } return err.Error() } + +var ( + bootOnce sync.Once + boot map[string]seatdef.Definition +) + +// bootstrapped is the foundation's definition of a seat, which every runner knows before any seat list is read. +func bootstrapped(seat string) (seatdef.Definition, bool) { + bootOnce.Do(func() { + boot = map[string]seatdef.Definition{} + for _, d := range seatlist.Bootstrapped() { + boot[d.Seat] = d + } + }) + d, ok := boot[seat] + return d, ok +}