From e866a64be30c8b6725e838c5925961787e3c9bcd Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 00:21:06 +0100 Subject: [PATCH] GT4: the gate watches a source-only registration's branch as any MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The gate reads the registrations page by page from the cursor each page answers, so a source-only registration (no module) past the first page is watched as any branch; its merge's take-in with no movers ends the record nothing to deliver as before. Builds: design 47 H2 §815, §806, §779 --- .../cmd/mesh-delivery-gate/sourcestart.go | 37 +++++++++++++------ .../mesh-delivery-gate/sourcetools_test.go | 26 +++++++++++++ 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/sourcestart.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/sourcestart.go index 1535f950b..ccefaaf20 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/sourcestart.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/sourcestart.go @@ -30,20 +30,33 @@ type Registered interface { // seatCatalog reads the seat mesh-catalog through the tool runner. type seatCatalog struct{ ask asking } +// Registrations reads every registration, a module's and a source-only one alike (design 47 H2 §815), page by page from +// the cursor each page answers (§779, §806), so a registration past the first 768 KB is watched too. func (s seatCatalog) Registrations() (meshcatalog.RegistrationsAnswer, error) { - var a meshcatalog.RegistrationsAnswer - raw, err := s.ask("seat:"+meshcatalog.Seat+"."+meshcatalog.VerbRegistrations, meshcatalog.RegistrationsInput{}) - if err != nil { - return a, err + var all meshcatalog.RegistrationsAnswer + seen := map[string]bool{} + for next := ""; ; { + var a meshcatalog.RegistrationsAnswer + raw, err := s.ask("seat:"+meshcatalog.Seat+"."+meshcatalog.VerbRegistrations, meshcatalog.RegistrationsInput{Next: next}) + if err != nil { + return all, err + } + answer, said, ok := answerOf(raw) + if !ok { + return all, fmt.Errorf("registrations refused: %s", lastLine(said)) + } + if err := json.Unmarshal(answer, &a); err != nil { + return all, fmt.Errorf("the answer of registrations is not readable: %w", err) + } + all.Registrations = append(all.Registrations, a.Registrations...) + if a.Next == "" { + return all, nil + } + if seen[a.Next] { + return all, fmt.Errorf("registrations answered the cursor %q twice: its pages do not end", a.Next) + } + seen[a.Next], next = true, a.Next } - answer, said, ok := answerOf(raw) - if !ok { - return a, fmt.Errorf("registrations refused: %s", lastLine(said)) - } - if err := json.Unmarshal(answer, &a); err != nil { - return a, fmt.Errorf("the answer of registrations is not readable: %w", err) - } - return a, nil } // Branch is the seat git's verb branch: a repository's branch head. diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/sourcetools_test.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/sourcetools_test.go index ddbf95276..5c0ba7fb7 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/sourcetools_test.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/sourcetools_test.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "reflect" + "slices" "strings" "testing" "time" @@ -97,6 +98,31 @@ func (f fakeCatalog) Registrations() (meshcatalog.RegistrationsAnswer, error) { // Design 47 G A-401: a watched branch starts from the forge as a clone does: each registered repository at the branch's head, // the group empty, source-moved said; a repository whose head cannot be read is left out; a key held is never rewritten. func TestAWatchedBranchStartsFromTheForge(t *testing.T) { + // A source-only registration (no module, design 47 H2 §815) is watched as any branch, its registrations read page by + // page from the cursor (§779, §806). + t.Run("a source-only registration past the first page is watched", func(t *testing.T) { + pages := map[string]meshcatalog.RegistrationsAnswer{ + "": {Registrations: []meshcatalog.Registration{{Module: "mesh-a", Origin: "o/mesh", Branches: []string{"main"}}}, Next: "p2", Capped: true}, + "p2": {Registrations: []meshcatalog.Registration{{Origin: "o/hq", Branches: []string{"main"}, Check: &meshcatalog.SourceCheck{Seat: "node-build-go", Step: "unit"}}}}, + } + var asked []string + c := seatCatalog{ask: func(key string, body any) (json.RawMessage, error) { + in := body.(meshcatalog.RegistrationsInput) + asked = append(asked, in.Next) + return json.Marshal(pages[in.Next]) + }} + a, err := c.Registrations() + if err != nil || !slices.Equal(asked, []string{"", "p2"}) { + t.Fatalf("asked %v: %v", asked, err) + } + if w := watchedRepositories(a.Registrations); !slices.Equal(w["main"], []string{"o/hq", "o/mesh"}) { + t.Errorf("main watches %v", w["main"]) + } + pages["p2"] = meshcatalog.RegistrationsAnswer{Next: "p2"} + if _, err := c.Registrations(); err == nil { + t.Error("pages that never end were read on") + } + }) regs := []meshcatalog.Registration{ {Module: "car-hunter", Origin: "o/car-hunter", Branches: []string{"main"}}, {Module: "mesh-a", Origin: "o/mesh", Branches: []string{"main"}},