diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/main.go b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/main.go index 9e75c8b2..201ece77 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/main.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/main.go @@ -20,7 +20,6 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view/viewstate" stdio "git.novox.be/novox/mesh-sdk/go" @@ -486,10 +485,9 @@ func main() { r.BuildLog = stdio.Log(builds.BuildLogRead).Since r.Pending = pendingOf(holderOf(stdio.Ask)) // The build modules are no names (design 47 G A-82): the build seats on the seat list, each held by the module the seat - // list names for it; the seat list and its two tools are wired once by mesh-sdk (§204). - // Its callers name seats, never a module, resolved from the seat-holders view the catalog half's claimant serves (A-295, A-298). - gate := seatlist.NewPart("view", []string{stdio.AnyPerson, stdio.CallerSeatPrefix + "node-tool-runner", stdio.CallerSeatPrefix + "mesh-healers"}) - gate.Holders(branches.SeatHolders(context.Background())) + // list names for it; the seat list and its two tools are wired once by mesh-sdk (§204), open to every caller (design 47 H + // §752, H-A-66). + gate := seatlist.NewPart("view") go func() { <-stdio.Served() gate.Follow(seatlist.StdioBus(), nil, func(f string, a ...any) { fmt.Fprintf(os.Stderr, "[mesh-delivery-view-tools] "+f+"\n", a...) }) @@ -504,7 +502,7 @@ func main() { // view_first_views and view_first_view_again: where the view's process stands with its first views of the indexer's and // the assigner's states (ADR 0615 §6), and a re-read by hand. tools := append(Tools(r, u), gate.Tools()...) - tools = append(tools, AnswersTool(os.Getenv(stdio.ServedAs), views.ParseCallers(os.Getenv(views.CallersEnv(viewstate.ViewAnswersTool))), func(name string) views.Source { return views.KeptSource{State: stdio.State(name)} }, time.Now)) + tools = append(tools, AnswersTool(os.Getenv(stdio.ServedAs), func(name string) views.Source { return views.KeptSource{State: stdio.State(name)} }, time.Now)) tools = append(tools, views.StatusTools(os.Getenv(stdio.ServedAs), "view_first_views", "view_first_view_again", stdio.State(views.StatusState), meshhandactsclient.Recorder{Ask: stdio.Ask}, time.Now)...) if err := stdio.Serve("", tools); err != nil { fmt.Fprintf(os.Stderr, "[mesh-delivery-view-tools] %v\n", err) @@ -513,26 +511,26 @@ func main() { } // AnswersTool is answers, the first-view tool of the seat mesh-delivery-view's state answers (mesh-sdk views.FirstViewTool), -// answered to the callers its list names (the teller): its first view of the answers the view says on views.answers +// answered to every caller (design 47 H §752, H-A-66): its first view of the answers the view says on views.answers // (design 47 G A-175, A-178, §717, A-301). -func AnswersTool(module string, callers stdio.Callers, state func(string) views.Source, now func() time.Time) stdio.Tool { +func AnswersTool(module string, state func(string) views.Source, now func() time.Time) stdio.Tool { return views.FirstViewTool(module, viewstate.ViewAnswersTool, viewstate.ViewAnswersState, "the operator's answers given in the view to the asks of the seat mesh-wants, one key .view each, which the teller fills the ask from.", - callers, state(viewstate.ViewAnswersState), state(views.MarksState), now) + state(viewstate.ViewAnswersState), state(views.MarksState), now) } // pendingOf asks the indexer's tool indexer_pending (declared in invokes) of the module holding the seat mesh-catalog: what it // holds back and why (ADR 0633 §5; design 47 G A-210). -func pendingOf(holder func(seat string) (string, bool)) func() (takein.PendingAnswer, error) { - return func() (takein.PendingAnswer, error) { +func pendingOf(holder func(seat string) (string, bool)) func() (view.HeldTakeIns, error) { + return func() (view.HeldTakeIns, error) { module, ok := holder(view.CatalogSeat) if !ok { - return takein.PendingAnswer{}, fmt.Errorf("the holder of %s is not found", view.CatalogSeat) + return view.HeldTakeIns{}, fmt.Errorf("the holder of %s is not found", view.CatalogSeat) } raw, err := stdio.Ask(module+".indexer_pending", map[string]any{}) if err != nil { - return takein.PendingAnswer{}, err + return view.HeldTakeIns{}, err } - return takein.DecodePendingAnswer(raw) + return view.DecodeHeldTakeIns(raw) } } diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/owners_test.go b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/owners_test.go index 93c1ed2f..e1fc2999 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/owners_test.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/owners_test.go @@ -166,7 +166,7 @@ func ownersAnswerTheToolsAsBefore(t *testing.T) { // the form of the value the tool always answered, the modules without a fingerprint say why, and the module's history // is not a thing the catalog half keeps. a, err := run(t, owned, view.ModuleReadTool, map[string]any{"module": "a"}) - if raw, _ := json.Marshal(a); err != nil || !strings.Contains(string(raw), `"fp2":"`+fp2A+`"`) || !strings.Contains(string(raw), `"commit":"c1"`) || !strings.Contains(string(raw), `"src":7`) || !strings.Contains(string(raw), `"manifest":"`+manifestDigestA+`"`) { + if raw, _ := json.Marshal(a); err != nil || !strings.Contains(string(raw), `"fp2":"`+fp2A+`"`) || !strings.Contains(string(raw), `"commit":"c1"`) || strings.Contains(string(raw), `"src"`) || !strings.Contains(string(raw), `"manifest":"`+manifestDigestA+`"`) { t.Errorf("indexer_module a = %s, %v", raw, err) } if _, err := run(t, owned, view.ModuleReadTool, map[string]any{"module": "gone"}); err == nil { @@ -259,12 +259,12 @@ func startedBranches(t *testing.T, ctx context.Context, ask func(string, any) (j return b } -// catalogAnswer is the seat mesh-catalog's newest trunk revision: a with a fingerprint and the source revision it moved at, -// b with none and the reason. +// catalogAnswer is the seat mesh-catalog's newest trunk revision: a with a fingerprint (no source stamp, design 47 H-A-48), b +// with none and the reason. var catalogAnswer = meshcatalog.RevisionAnswer{ Revision: &meshcatalog.CatalogRevision{Revision: 4, Kind: meshcatalogclient.KindTrunk, Source: 7}, Entries: []meshcatalog.CatalogEntry{ - {Module: "a", Repository: "novox/r", Commit: "c1", Path: ".", Manifest: map[string]any{"module": "a"}, ManifestDigest: "sha256:" + manifestDigestA, Fp: fp2A, Inputs: &meshcatalog.EntryInputs{Src: 7}}, + {Module: "a", Repository: "novox/r", Commit: "c1", Path: ".", Manifest: map[string]any{"module": "a"}, ManifestDigest: "sha256:" + manifestDigestA, Fp: fp2A, Inputs: &meshcatalog.EntryInputs{}}, {Module: "b", Repository: "novox/r", Commit: "c2", Path: "modules/b", Manifest: map[string]any{"module": "b"}, None: "builder's fingerprint not yet known"}, }, } @@ -274,10 +274,10 @@ var catalogAnswer = meshcatalog.RevisionAnswer{ const manifestDigestA = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" // answers is the first-view tool of the seat mesh-delivery-view's state answers (design 47 G A-178, §717, A-301): a page of every -// key, answered to the teller its callers list names and refused to any other caller. +// key, answered to every caller (design 47 H §752, H-A-66). func TestTheViewReadsItsAnswersAsAnOwner(t *testing.T) { answers := source{"hold.plex.ab.view": `{"asking":"a1","option":"release"}`} - tool := AnswersTool("acme-view", views.ParseCallers("mesh-delivery-teller"), func(name string) views.Source { + tool := AnswersTool("acme-view", func(name string) views.Source { if name == viewstate.ViewAnswersState { return answers } @@ -286,11 +286,11 @@ func TestTheViewReadsItsAnswersAsAnOwner(t *testing.T) { if tool.Name != "answers" || !strings.Contains(tool.Description, "acme-view") { t.Fatalf("the tool is %s: %s", tool.Name, tool.Description) } - // Answered only to the callers its list names: the teller, never a call no runtime proved. - if !strings.Contains(tool.Description, "mesh-delivery-teller") { - t.Errorf("the tool's callers are not the teller: %s", tool.Description) + out, err := tool.Run(map[string]any{}) + if err != nil { + t.Fatalf("a caller is refused: %v", err) } - if out, err := tool.Run(map[string]any{}); err == nil { - t.Errorf("an unproven caller is answered: %v", out) + if raw, _ := json.Marshal(out); !strings.Contains(string(raw), "hold.plex.ab.view") { + t.Errorf("the page does not hold the answer: %s", raw) } } diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/tiers_rows_test.go b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/tiers_rows_test.go index 8a497a16..4671f370 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/tiers_rows_test.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-view-tools/tiers_rows_test.go @@ -13,7 +13,6 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view/viewstate" ) @@ -93,33 +92,24 @@ func tiersToolSaysEachModulesWait(t *testing.T) { !reflect.DeepEqual(web.Waits, []view.TierWait{{Owner: "mesh-wants", Step: "delivery", Node: "ace", Bound: "60m", Since: since, Words: "waiting for delivery of db to g14"}}) { t.Errorf("web = %+v, want after db, waiting for the delivery of db in the assigner's words", web) } - // ADR 0633 §5 (1585/T24): a module the indexer holds back, read through indexer_pending, waits on the edge take-in from the - // wait's since; a held module the revision does not move is named in the first tier with that wait alone, a group's wait - // says its group, and a tool that cannot be asked is said and names no module. + // Design 47 H-A-109: a take-in the indexer holds, read through indexer_pending (H-A-102), is said in the tiers' pending words + // with its branch, source, why and since, and names no module; a tool that cannot be asked is said and names no module. heldSince := time.Date(2026, 11, 4, 22, 0, 0, 0, time.UTC) - r.Pending = func() (takein.PendingAnswer, error) { - return takein.PendingAnswer{Waits: []takein.PendingWait{ - {Key: "m.00000000000000000042", What: takein.TakeInRevision, WaitsFor: "src2:abc", Since: heldSince, Holds: []string{"web", "newmod"}}, - {Key: "g.feat", What: takein.TakeInGroup, Group: "feat", Since: heldSince.Add(time.Hour), Holds: []string{"lib"}}}}, nil + r.Pending = func() (view.HeldTakeIns, error) { + return view.DecodeHeldTakeIns([]byte(`{"held":[{"branch":"main","source":3590,"why":"the catalog store is full","since":"2026-11-04T22:00:00Z"}]}`)) } out, err = run(t, r, view.TiersTool, map[string]any{"revision": float64(9)}) held, _ := out.(view.Tiers) - if err != nil || len(held.Tiers) != 2 || held.Pending != "" { - t.Fatalf("view_tiers with waits = %+v, %v", out, err) + if err != nil || len(held.Tiers) != 2 || !reflect.DeepEqual(held.Tiers, got.Tiers) || + held.Pending != "the indexer holds the take-in of source revision 3590 of main since "+heldSince.Format(time.RFC3339)+": the catalog store is full" { + t.Fatalf("view_tiers with a held take-in = %+v, %v; want its tiers unchanged and the take-in said", out, err) } - web = held.Tiers[1][0] - if last := web.Waits[len(web.Waits)-1]; last.Step != view.TakeInStep || !last.Since.Equal(heldSince) || !strings.Contains(last.Words, "unread or lost") { - t.Errorf("web = %+v, want its last wait on the edge take-in since %s", web, heldSince) + if _, err := view.DecodeHeldTakeIns([]byte(`{"held":[{"branch":"main","why":"full"}]}`)); err == nil { + t.Error("a held take-in with no source or since is read") } - if lib := held.Tiers[0][1]; lib.Module != "lib" || lib.Waits[len(lib.Waits)-1].Step != view.TakeInStep || !strings.Contains(lib.Waits[len(lib.Waits)-1].Words, "group feat") { - t.Errorf("lib = %+v, want its last wait the group's", lib) - } - if nm := held.Tiers[0][len(held.Tiers[0])-1]; nm.Module != "newmod" || len(nm.Waits) != 1 || nm.Waits[0].Step != view.TakeInStep { - t.Errorf("the first tier = %+v, want newmod, which the revision does not move, named with its take-in wait alone", held.Tiers[0]) - } - r.Pending = func() (takein.PendingAnswer, error) { return takein.PendingAnswer{}, errors.New("no answer") } + r.Pending = func() (view.HeldTakeIns, error) { return view.HeldTakeIns{}, errors.New("no answer") } if out, err = run(t, r, view.TiersTool, map[string]any{"revision": float64(9)}); err != nil || !strings.Contains(out.(view.Tiers).Pending, "no answer") || - strings.Contains(fmt.Sprint(out.(view.Tiers).Tiers), view.TakeInStep) { + !reflect.DeepEqual(out.(view.Tiers).Tiers, got.Tiers) { t.Errorf("view_tiers with no answer of indexer_pending = %+v, %v", out, err) } r.Pending = nil diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-view/integration_test.go b/modules/mesh-delivery-view/cmd/mesh-delivery-view/integration_test.go index 4ab8a135..90826819 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-view/integration_test.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-view/integration_test.go @@ -11,6 +11,7 @@ import ( "os" "path/filepath" "slices" + "strconv" "strings" "sync" "testing" @@ -127,7 +128,7 @@ func serveCatalog(t testing.TB, ctx context.Context, js jetstream.JetStream, nc var a any = map[string]any{"branches": []string{catalogBranch}} if in.Branch != "" { h.mu.Lock() - a = meshdelivery.SourceAnswer{Branch: in.Branch, Revision: h.src.Revision, Group: h.src.Group, Repositories: h.src.Repositories} + a = meshdelivery.SourceAnswer{Branch: in.Branch, Revision: h.src.Revision, Call: h.src.Call, Repositories: h.src.Repositories} h.mu.Unlock() } raw, _ := json.Marshal(map[string]any{"result": a, "node": "n0"}) @@ -150,16 +151,20 @@ func serveCatalog(t testing.TB, ctx context.Context, js jetstream.JetStream, nc const catalogBranch = "release" // moveSource is the gate's next source revision of catalogBranch, said as source-moved (design 47 G §507, A-173). -func (h *catalogHolder) moveSource(rev int64, group string, heads map[string]string) { +func (h *catalogHolder) moveSource(rev int64, call string, heads map[string]string) { h.t.Helper() h.mu.Lock() - h.src = meshdelivery.SourceAnswer{Revision: rev, Group: group} + h.src = meshdelivery.SourceAnswer{Revision: rev, Call: call} for repository, head := range heads { h.src.Repositories = append(h.src.Repositories, meshdelivery.SourceHead{Repository: repository, Head: head, Trunk: catalogBranch}) } h.mu.Unlock() - body, _ := json.Marshal(meshdelivery.SourceMovedEvent{Branch: catalogBranch, Revision: rev, Group: group}) - if _, err := h.js.Publish(h.ctx, meshdelivery.SubjectSourceMoved(catalogBranch), body); err != nil { + ev := meshdelivery.SourceMovedEvent{V: 1, Branch: catalogBranch, Source: rev, Call: call} + for repository, head := range heads { + ev.Heads = append(ev.Heads, meshdelivery.SourceMovedEventHeadsItem{Repository: repository, Commit: head}) + } + body, _ := json.Marshal(ev) + if _, err := h.js.Publish(h.ctx, meshdelivery.SubjectSourceMoved(catalogBranch, strconv.FormatInt(rev, 10)), body); err != nil { h.t.Fatal(err) } } @@ -515,8 +520,8 @@ func TestProcessWholeListsEveryDifference(t *testing.T) { // 1297/B8 AC const fpOld = "src2:1111111111111111111111111111111111111111111111111111111111111111" const fpNew = "src2:2222222222222222222222222222222222222222222222222222222222222222" for key, d := range map[string]meshwantsclient.Want{ - "want.ace.plex": {Fp: fpNew, Composed: "sha256:" + strings.Repeat("c", 64)}, - "want.g14.plex": {Fp: fpOld, Composed: "sha256:" + strings.Repeat("c", 64), Newest: fpNew, Rule: meshwantsclient.RuleCanary, Words: "the canary ace does not run it healthy yet"}, + "want.ace.plex": {Fp: fpNew}, + "want.g14.plex": {Fp: fpOld, Words: "awaits its hand placement"}, } { v, err := meshwantsclient.EncodeWant(d) if err != nil { @@ -541,7 +546,7 @@ func TestProcessWholeListsEveryDifference(t *testing.T) { // 1297/B8 AC } wait(func(s view.Snapshot) bool { d := s.Wants - return len(d) == 2 && d[0].Node == "ace" && d[0].State == view.WantPending && d[1].Node == "g14" && d[1].State == view.WantHeldBack && d[1].Rule == meshwantsclient.RuleCanary + return len(d) == 2 && d[0].Node == "ace" && d[0].State == view.WantPending && d[1].Node == "g14" && d[1].State == view.WantPending && d[1].Words == "awaits its hand placement" }, "the two wants never showed with where they stand") if err := kv.Delete(ctx, "want.g14.plex"); err != nil { t.Fatal(err) @@ -834,7 +839,7 @@ func TestProcessWholeSaysTheSourceRevisionIsDelivered(t *testing.T) { t.Cleanup(func() { stop(); <-done }) fp := "src2:" + strings.Repeat("2", 64) - want, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fp, Composed: "sha256:" + strings.Repeat("c", 64)}) + want, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fp}) 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}) @@ -846,7 +851,7 @@ func TestProcessWholeSaysTheSourceRevisionIsDelivered(t *testing.T) { } // The gate's source of the watched branch moves: the view asks the verb source for it and reads no gate state (A-173). const rev = 41 - catalog.moveSource(rev, "feat/x", map[string]string{"novox/web": strings.Repeat("1", 40)}) + catalog.moveSource(rev, "c-feat-x", map[string]string{"novox/web": strings.Repeat("1", 40)}) time.Sleep(time.Second) if info, err := events.Info(ctx, jetstream.WithSubjectFilter("mesh.mod.mesh-delivery-view.event."+DeliveredEventType)); err != nil || len(info.State.Subjects) != 0 { t.Fatalf("an event was said before the revision was delivered: %v %+v", err, info.State) @@ -862,8 +867,8 @@ func TestProcessWholeSaysTheSourceRevisionIsDelivered(t *testing.T) { t.Fatal("the delivery of the source revision was never said") } var e view.DeliveredEvent - if err := json.Unmarshal(msg.Data, &e); err != nil || e.Branch != catalogBranch || e.Revision != rev || e.Group != "feat/x" || e.Heads["novox/web"] != strings.Repeat("1", 40) { - t.Errorf("the event = %+v, %v; want the branch %s, revision %d, group feat/x and the heads", e, err, catalogBranch, rev) + if err := json.Unmarshal(msg.Data, &e); err != nil || e.Branch != catalogBranch || e.Revision != rev || e.Heads["novox/web"] != strings.Repeat("1", 40) { + t.Errorf("the event = %+v, %v; want the branch %s, revision %d and the heads", e, err, catalogBranch, rev) } if msg.Header.Get("x-source") != "mesh-delivery-view" || msg.Header.Get("x-event-id") == "" { t.Errorf("the headers = %v", msg.Header) @@ -941,7 +946,6 @@ func TestProcessWholeSaysModulesInMotion(t *testing.T) { time.Sleep(2 * time.Second) // the view has read what stood: nothing fpOld, fpNew := "src2:"+strings.Repeat("1", 64), "src2:"+strings.Repeat("2", 64) - digest := "sha256:" + strings.Repeat("c", 64) put := func(bucket, key string, v []byte, err error) { t.Helper() if err != nil { @@ -952,7 +956,7 @@ func TestProcessWholeSaysModulesInMotion(t *testing.T) { } } want := func(node, module string) { - v, err := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fpNew, Composed: digest}) + v, err := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fpNew}) put(view.WantsBucket, "want."+node+"."+module, v, err) } have := func(node, module, fp string, phase string, health string, detail string) { @@ -990,10 +994,10 @@ func TestProcessWholeSaysModulesInMotion(t *testing.T) { }()) return jetstream.RawStreamMsg{} } - hex := strings.Repeat("c", 64) + hex := fpNew // a motion event is keyed by the fingerprint wanted (design 47 H-A-78) mv := waitFor("moving.ace.web." + hex) var body view.MotionBody - if err := json.Unmarshal(mv.Data, &body); err != nil || body.Node != "ace" || body.Module != "web" || body.FromFP != fpOld || body.ToFP != fpNew || body.Composed != digest || body.BoundSeconds != view.MotionBoundSeconds || body.Since.IsZero() { + if err := json.Unmarshal(mv.Data, &body); err != nil || body.Node != "ace" || body.Module != "web" || body.FromFP != fpOld || body.ToFP != fpNew || body.BoundSeconds != view.MotionBoundSeconds || body.Since.IsZero() { t.Errorf("moving = %+v, %v", body, err) } if mv.Subject != "mesh.mod.mesh-delivery-view.event.moving" { diff --git a/modules/mesh-delivery-view/cmd/mesh-delivery-view/sources.go b/modules/mesh-delivery-view/cmd/mesh-delivery-view/sources.go index 0721deaa..f6472ef8 100644 --- a/modules/mesh-delivery-view/cmd/mesh-delivery-view/sources.go +++ b/modules/mesh-delivery-view/cmd/mesh-delivery-view/sources.go @@ -143,11 +143,11 @@ func (s *branchSources) hear(branch string, f *views.Follower) func(context.Cont if ev.Branch != branch && ev.Branch != esc { return nil } - held := func() bool { return revisionOf(f, esc) >= ev.Revision } + held := func() bool { return revisionOf(f, esc) >= ev.Source } if held() { return nil } - go sourcebranches.CatchUp(s.ctx, f, held, fmt.Sprintf("source of %s moved to %d", branch, ev.Revision)) + go sourcebranches.CatchUp(s.ctx, f, held, fmt.Sprintf("source of %s moved to %d", branch, ev.Source)) return nil } } diff --git a/modules/mesh-delivery-view/internal/view/catalog.go b/modules/mesh-delivery-view/internal/view/catalog.go index 42f5dc4a..a9970023 100644 --- a/modules/mesh-delivery-view/internal/view/catalog.go +++ b/modules/mesh-delivery-view/internal/view/catalog.go @@ -39,7 +39,7 @@ func ModuleValue(entry json.RawMessage) (json.RawMessage, error) { v.Verdict = e.Verdict } if in := e.Inputs; in != nil { - v.Src, v.FpSrc, v.Toolchains, v.Paths, v.Warnings = in.Src, in.FpSrc, in.Toolchains, in.Paths, in.Warnings + v.Toolchains, v.Paths, v.Warnings = in.Toolchains, in.Paths, in.Warnings if f := in.From; f != nil && v.Manifest != "" { v.Inputs2 = &meshcatalog.ModulesByModuleValueInputs2{Bases: f.Bases, Builder: f.Builder, Contexts: f.Contexts, ImportForm: f.ImportForm, Imports: f.Imports, Locks: f.Locks, Packages: f.Packages, Paths: f.Paths, Tree: f.Tree} diff --git a/modules/mesh-delivery-view/internal/view/history.go b/modules/mesh-delivery-view/internal/view/history.go index cdcc5355..e95a341d 100644 --- a/modules/mesh-delivery-view/internal/view/history.go +++ b/modules/mesh-delivery-view/internal/view/history.go @@ -40,7 +40,6 @@ type ModuleRevision struct { Op string `json:"op"` Repository string `json:"repository,omitempty"` Commit string `json:"commit,omitempty"` - Src uint64 `json:"src,omitempty"` FP2 string `json:"fp2,omitempty"` None2 string `json:"none2,omitempty"` Manifest string `json:"manifest,omitempty"` @@ -82,7 +81,7 @@ func (r Reader) ModuleHistory(module string) (ModuleHistory, error) { if err := json.Unmarshal(rev.Value, &m); err != nil { row.Unreadable = err.Error() } else { - row.Repository, row.Commit, row.Src, row.FP2, row.None2, row.Manifest, row.Path = m.Repository, m.Commit, uint64(m.Src), m.Fp2, m.None2, m.Manifest, m.Path + row.Repository, row.Commit, row.FP2, row.None2, row.Manifest, row.Path = m.Repository, m.Commit, m.Fp2, m.None2, m.Manifest, m.Path } } out.Values = append(out.Values, row) diff --git a/modules/mesh-delivery-view/internal/view/motion.go b/modules/mesh-delivery-view/internal/view/motion.go index 4e16e75d..6cc28369 100644 --- a/modules/mesh-delivery-view/internal/view/motion.go +++ b/modules/mesh-delivery-view/internal/view/motion.go @@ -7,8 +7,9 @@ import ( ) // motionOf derives where one module's want stands on one node from the want and the have as their seats carry them, through -// mesh-sdk's seat-neutral derivation (issue 1952 S7), which the condition keeper's hold uses too. +// mesh-sdk's seat-neutral derivation (issue 1952 S7), which the condition keeper's hold uses too. A want counts as applied by +// its fingerprint alone (design 47 H-A-78). func motionOf(w meshwantsclient.Want, wanted bool, h nodeengine.HaveByNodeModuleValue, has bool, words string, stuck bool) motion.Motion { - return motion.MotionOf(motion.Want{FP: w.Fp, Composed: w.Composed, Removed: w.Removed}, wanted, + return motion.MotionOf(motion.Want{FP: w.Fp, Removed: w.Removed}, wanted, motion.Have{FP: h.Fp, Composed: h.Composed, Phase: h.Phase, Health: h.Health, Detail: h.Detail}, has, words, stuck) } diff --git a/modules/mesh-delivery-view/internal/view/reach.go b/modules/mesh-delivery-view/internal/view/reach.go index e2456f9e..5de23073 100644 --- a/modules/mesh-delivery-view/internal/view/reach.go +++ b/modules/mesh-delivery-view/internal/view/reach.go @@ -60,9 +60,6 @@ func (m *Model) applyHistory(e Entry) { } h := m.modHist[e.Key] if n := len(h); n > 0 && h[n-1].Fp2 == mod.Fp2 && h[n-1].Commit == mod.Commit { - if mod.Src != 0 { - h[n-1].Src = mod.Src - } return } h = append(h, mod) @@ -197,10 +194,7 @@ func (m *Model) moduleReach(name string, mod meshcatalog.ModulesByModuleValue, h } var values []meshcatalog.ModulesByModuleValue // the catalogue's value of each change, in step with mr.Changes for i := len(hist) - 1; i >= 0 && len(mr.Changes) < viewstate.MostChanges; i-- { - c := viewstate.Change{Commit: hist[i].Commit, FP: hist[i].Fp2, Src: uint64(hist[i].Src)} - if c.Src == 0 { - c.Src = revOf(heads, c.Commit) - } + c := viewstate.Change{Commit: hist[i].Commit, FP: hist[i].Fp2, Src: revOf(heads, hist[i].Commit)} if n := len(mr.Changes); n > 0 && mr.Changes[n-1].FP == c.FP { mr.Changes[n-1] = c // the same fingerprint again, back to back: its first appearance is the older commit values[n-1] = hist[i] diff --git a/modules/mesh-delivery-view/internal/view/reach_test.go b/modules/mesh-delivery-view/internal/view/reach_test.go index 1616f662..45958694 100644 --- a/modules/mesh-delivery-view/internal/view/reach_test.go +++ b/modules/mesh-delivery-view/internal/view/reach_test.go @@ -26,15 +26,15 @@ func TestTheViewDerivesHowFarEachRepositoryReached(t *testing.T) { commitA, commitB, commitC := strings.Repeat("a", 40), strings.Repeat("b", 40), strings.Repeat("c", 40) commitS, commitX, commitD := strings.Repeat("5", 40), strings.Repeat("e", 40), strings.Repeat("d", 40) const fpMail = "src2:3333333333333333333333333333333333333333333333333333333333333333" - mod := func(module, fp, commit string, src uint64, history bool) Entry { - v, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: strings.Repeat("a", 64), Repository: web, Commit: commit, Src: int64(src), Path: module}) + mod := func(module, fp, commit string, _ uint64, history bool) Entry { // a module carries no source stamp (design 47 H-A-48) + v, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: strings.Repeat("a", 64), Repository: web, Commit: commit, Path: module}) if err != nil { t.Fatal(err) } return Entry{Bucket: ModulesBucket, Key: module, Value: v, At: t0, History: history, Branch: testBranch} } - modIn := func(fp, commit string, src uint64, in *meshcatalog.ModulesByModuleValueInputs2, history bool) Entry { - v, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: strings.Repeat("a", 64), Repository: web, Commit: commit, Src: int64(src), Path: "web", Inputs2: in}) + modIn := func(fp, commit string, _ uint64, in *meshcatalog.ModulesByModuleValueInputs2, history bool) Entry { + v, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: strings.Repeat("a", 64), Repository: web, Commit: commit, Path: "web", Inputs2: in}) if err != nil { t.Fatal(err) } @@ -46,18 +46,22 @@ func TestTheViewDerivesHowFarEachRepositoryReached(t *testing.T) { // A later build of web (fpLater) that g14, running fpNew, lacks; issue 1966: the hold names both builds, what moved when the // commit is the same, and a build that failed as failed. const fpLater = "src2:9999999999999999999999999999999999999999999999999999999999999999" - later := func(commit string, to *meshcatalog.ModulesByModuleValueInputs2, extra ...Entry) []Entry { - return append([]Entry{modIn(fpLater, commit, 12, to, true), modIn(fpLater, commit, 12, to, false)}, extra...) - } // Each watched branch's source as its verb source answers it, one revision heard after another (design 47 G A-173). srcOn := func(branch string, rev uint64, webHead string) Entry { - v, err := meshdeliveryclient.EncodeSource(meshdelivery.SourceByBranchValue{Group: "g", Heads: map[string]string{web: webHead, sdk: commitS}}) + v, err := meshdeliveryclient.EncodeSource(meshdelivery.SourceByBranchValue{Call: "c1", Source: int64(rev), Heads: map[string]string{web: webHead, sdk: commitS}}) if err != nil { t.Fatal(err) } return Entry{Bucket: SourceBucket, Key: keys.EscapeName(branch), Value: v, At: t0, Revision: rev} } src := func(rev uint64, webHead string) Entry { return srcOn(testBranch, rev, webHead) } + later := func(commit string, to *meshcatalog.ModulesByModuleValueInputs2, extra ...Entry) []Entry { + before := []Entry{modIn(fpLater, commit, 12, to, true), modIn(fpLater, commit, 12, to, false)} + if commit != commitC { // another commit is the head of the source revision after C's: no module carries a stamp (H-A-48) + before = append([]Entry{src(13, commit)}, before...) + } + return append(before, extra...) + } // The reach the view's own state held at its start (A-225). kept := func(reached string, rev uint64) Entry { key, _ := trunk.RepositoryKey(web) @@ -121,19 +125,19 @@ func TestTheViewDerivesHowFarEachRepositoryReached(t *testing.T) { then: []Entry{haveFP(t, "g14", "web", fpOld, nodeengineclient.HealthOK), presenceE(t, "g14", false, t0)}}, {name: "a node returned lagging holds the head again", reached: commitB, holds: "web on g14", waiting: "not yet the", then: []Entry{haveFP(t, "g14", "web", fpOld, nodeengineclient.HealthOK), presenceE(t, "g14", false, t0), presenceE(t, "g14", true, t0)}}, - {name: "a want held back at an older build holds the head as a lag does", reached: commitB, holds: "web on g14 runs build", - then: []Entry{wantE(t, "g14", "web", meshwantsclient.Want{Fp: fpOld, Newest: fpNew, Rule: 2}), haveFP(t, "g14", "web", fpOld, nodeengineclient.HealthOK)}}, + {name: "a want at an older build holds the head as a lag does", reached: commitB, holds: "web on g14 runs build", + then: []Entry{wantE(t, "g14", "web", meshwantsclient.Want{Fp: fpOld}), haveFP(t, "g14", "web", fpOld, nodeengineclient.HealthOK)}}, {name: "a later build of the same commit names the mesh package that moved", reached: commitB, holds: "web on ace runs build 22222222 (cccccccc), not yet 99999999 (cccccccc, a mesh package of mesh-sdk/go)", then: later(commitC, in("t1", "mesh-sdk/go"))}, {name: "a later build of the same commit names the tree that moved", reached: commitB, holds: "runs build 22222222 (cccccccc), not yet 99999999 (cccccccc, tree)", then: later(commitC, in("t2", "mesh-sdk/go"))}, - {name: "a later build of another commit names no input", reached: commitB, + {name: "a later build of another commit names no input", reached: commitC, holds: "runs build 22222222 (cccccccc), not yet 99999999 (eeeeeeee)", then: later(commitX, in("t2"))}, - {name: "the newest build, failed, is said failed with its first words", reached: commitB, + {name: "the newest build, failed, is said failed with its first words", reached: commitC, holds: "its newest build 99999999 (eeeeeeee) failed: go build ./...: undefined: Foo", then: later(commitX, in("t2"), builderKey(t, "web", fpLater, builds.BuilderBuild{State: builds.BuildFailed, Error: "go build ./...: undefined: Foo"}))}, - {name: "a failed build that is not the newest is the build the node waits for", reached: commitB, + {name: "a failed build that is not the newest is the build the node waits for", reached: commitC, holds: "the build it waits for 99999999 (eeeeeeee) failed: go build", then: append(later(commitX, in("t2"), builderKey(t, "web", fpLater, builds.BuilderBuild{State: builds.BuildFailed, Error: "go build ./...: undefined: Foo"})), modIn("src2:"+strings.Repeat("8", 64), commitD, 12, in("t3"), true), modIn("src2:"+strings.Repeat("8", 64), commitD, 12, in("t3"), false))}, @@ -246,7 +250,7 @@ func TestTheViewDerivesHowFarEachRepositoryReached(t *testing.T) { t.Errorf("said again: %+v", said[n:]) } for _, e := range said { - if len(e.Heads) != 1 || e.Group != "" || e.Revision == 0 { + if len(e.Heads) != 1 || e.Revision == 0 { t.Errorf("a reached head said as %+v", e) } } diff --git a/modules/mesh-delivery-view/internal/view/read.go b/modules/mesh-delivery-view/internal/view/read.go index 6df09c17..a42a62a5 100644 --- a/modules/mesh-delivery-view/internal/view/read.go +++ b/modules/mesh-delivery-view/internal/view/read.go @@ -21,7 +21,6 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshwantsclient" "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-indexer/takein" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view/viewstate" stdio "git.novox.be/novox/mesh-sdk/go" @@ -79,8 +78,8 @@ type Reader struct { // view_tiers works the tiers of a source revision from (design 47 G §512, A-242). Assignment func(revision int64) (meshwants.AssignmentRevision, error) Difference func(from, to int64) (meshwants.Difference, error) - // Pending reads the indexer's waits through its tool indexer_pending (ADR 0633 §5); unset names no module held back. - Pending func() (takein.PendingAnswer, error) + // Pending reads the take-ins the indexer holds through its tool indexer_pending (design 47 H §744, H-A-102); unset says none. + Pending func() (HeldTakeIns, error) // BuildLog reads the builder's log from a time (stdio.Log(builds.BuildLogRead).Since); unset reads none. BuildLog LogSince } diff --git a/modules/mesh-delivery-view/internal/view/serve.go b/modules/mesh-delivery-view/internal/view/serve.go index c3464576..0114be3f 100644 --- a/modules/mesh-delivery-view/internal/view/serve.go +++ b/modules/mesh-delivery-view/internal/view/serve.go @@ -237,9 +237,6 @@ func wantText(s Snapshot) [][]string { have = "none" } words := w.Words - if w.Rule != 0 { - words = fmt.Sprintf("rule %d: %s", w.Rule, w.Words) - } judged := w.Judgement if judged == "" { judged = "none" diff --git a/modules/mesh-delivery-view/internal/view/source.go b/modules/mesh-delivery-view/internal/view/source.go index d0c05680..6f3487b4 100644 --- a/modules/mesh-delivery-view/internal/view/source.go +++ b/modules/mesh-delivery-view/internal/view/source.go @@ -47,7 +47,7 @@ func SourceEntry(branch string, a meshdelivery.SourceAnswer) (Entry, error) { e.Deleted = true return e, nil } - v, err := meshdeliveryclient.EncodeSource(meshdelivery.SourceByBranchValue{Group: a.Group, Heads: heads}) + v, err := meshdeliveryclient.EncodeSource(meshdelivery.SourceByBranchValue{Source: a.Revision, Call: a.Call, Heads: heads}) if err != nil { return Entry{}, err } diff --git a/modules/mesh-delivery-view/internal/view/tiers.go b/modules/mesh-delivery-view/internal/view/tiers.go index 721b5da9..2dc02305 100644 --- a/modules/mesh-delivery-view/internal/view/tiers.go +++ b/modules/mesh-delivery-view/internal/view/tiers.go @@ -1,6 +1,7 @@ package view import ( + "encoding/json" "fmt" "maps" "slices" @@ -8,8 +9,8 @@ import ( "strings" "time" + "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-indexer/takein" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view/viewstate" ) @@ -41,13 +42,14 @@ type Tiers struct { Tiers [][]TierModule `json:"tiers"` Cut string `json:"cut,omitempty"` Graph string `json:"graph,omitempty"` - // Pending says why the indexer's waits could not be read, so no module is named held by its revision's indexer (ADR 0633 §5). + // Pending says each take-in the indexer holds (its branch, source, why and since; design 47 H-A-109), or why they could not + // be read, and why the parts' waits could not be read. Pending string `json:"pending,omitempty"` } // TierModule is one module of a tier (design 47 G §512): its build (the fingerprint the difference says it is to run), the -// modules it is ordered after with the edge's kind, and each wait of its own now, from the parts' wait-held and the indexer's -// pending revisions (no wait is a module that reached every node present). +// modules it is ordered after with the edge's kind, and each wait of its own now, from the parts' wait-held (no wait is a +// module that reached every node present). type TierModule struct { Module string `json:"module"` // FP is the build. @@ -63,8 +65,7 @@ type TierAfter struct { } // TierWait is one wait of a module, as the part that holds it said it (design 47 G §512, §498): the seat or module that holds it -// (Owner), its step, the node it is on, what it waits on, its bound, since when, and its own words. The pending revision of the -// indexer is Owner mesh-catalog and Step take-in. +// (Owner), its step, the node it is on, what it waits on, its bound, since when, and its own words. type TierWait struct { Owner string `json:"owner"` Step string `json:"step"` @@ -147,12 +148,8 @@ func (r Reader) Tiers(revision uint64) (Tiers, error) { len(names), TiersMost, names[TiersMost], len(names)-TiersMost-1) names = names[:TiersMost] } + r.heldTakeIns(&out) waits := r.waitsHeld(&out) - held, heldAll := r.heldBack(&out) - in := map[string]bool{} - for _, n := range names { - in[n] = true - } for _, n := range names { t := tierOf[n] for len(out.Tiers) <= t { @@ -173,22 +170,8 @@ func (r Reader) Tiers(revision uint64) (Tiers, error) { } slices.SortFunc(tm.After, func(a, b TierAfter) int { return strings.Compare(a.Module+"\x00"+a.Kind, b.Module+"\x00"+b.Kind) }) tm.Waits = waits[n] - if w, ok := held[n]; ok { - tm.Waits = append(tm.Waits, w) - } out.Tiers[t] = append(out.Tiers[t], tm) } - // A module the indexer holds back is not at the revision yet, so no tier of it names it: it is named in the first tier with - // its wait alone (ADR 0633 §5). - for _, n := range heldAll { - if in[n] { - continue - } - if len(out.Tiers) == 0 { - out.Tiers = append(out.Tiers, nil) - } - out.Tiers[0] = append(out.Tiers[0], TierModule{Module: n, Waits: []TierWait{held[n]}}) - } compact := out.Tiers[:0] for _, t := range out.Tiers { if len(t) > 0 { @@ -199,39 +182,49 @@ func (r Reader) Tiers(revision uint64) (Tiers, error) { return out, nil } -// TakeInStep and TakeInOwner are the step and the owner of a wait on the indexer a source revision or a group is held for -// (ADR 0633 §5, design 47 G §512): the pending revision's wait is the seat mesh-catalog's step take-in. -const ( - TakeInStep = "take-in" - TakeInOwner = "mesh-catalog" -) +// HeldTakeIn is one take-in the indexer holds, as its tool indexer_pending answers it (design 47 H §744, H-A-102): the seat +// mesh-catalog's form with since, when it was held. +type HeldTakeIn struct { + meshcatalog.TakeInPending + Since time.Time `json:"since"` +} -// heldBack are the modules the indexer holds back, by module, each with its wait, read through the indexer's tool -// indexer_pending (ADR 0633 §5), and the same modules sorted. A tool that cannot be asked says so in out.Pending. -func (r Reader) heldBack(out *Tiers) (map[string]TierWait, []string) { - held := map[string]TierWait{} +// HeldTakeIns is the answer of indexer_pending (design 47 H-A-102): every branch's held take-in. +type HeldTakeIns struct { + Held []HeldTakeIn `json:"held"` +} + +// DecodeHeldTakeIns reads the answer of indexer_pending, refusing a held take-in with no branch, source or since. +func DecodeHeldTakeIns(raw []byte) (HeldTakeIns, error) { + var a HeldTakeIns + if err := json.Unmarshal(raw, &a); err != nil { + return HeldTakeIns{}, fmt.Errorf("not an answer of indexer_pending: %w", err) + } + for _, h := range a.Held { + if h.Branch == "" || h.Source == 0 || h.Since.IsZero() { + return HeldTakeIns{}, fmt.Errorf("indexer_pending names a held take-in with no branch, source or since: %+v", h) + } + } + return a, nil +} + +// heldTakeIns says each take-in the indexer holds in out.Pending, read through its tool indexer_pending: its branch, source, +// why and since. A held take-in names no module, since its movers are known only once it is taken in (design 47 H-A-109). +func (r Reader) heldTakeIns(out *Tiers) { if r.Pending == nil { - return held, nil + return } a, err := r.Pending() if err != nil { - out.Pending = "the indexer's pending revisions cannot be read, so no module is named waiting for its revision's indexer: " + err.Error() - return held, nil + out.Pending = "the indexer's held take-ins cannot be read: " + err.Error() + return } - for _, w := range a.Waits { - words := "the indexer holds back " + w.Key + " (its message is unread or lost, or it is held for room)" - if w.What == takein.TakeInGroup { - words = "the indexer gathers the group " + w.Group + " and its end has not come" - } else if w.Behind != "" { - words = "the indexer holds back " + w.Key + " behind " + w.Behind - } - for _, module := range w.Holds { - if _, ok := held[module]; !ok { // the oldest wait names it - held[module] = TierWait{Owner: TakeInOwner, Step: TakeInStep, Words: words, Since: w.Since} - } - } + var said []string + for _, h := range a.Held { + said = append(said, fmt.Sprintf("the indexer holds the take-in of source revision %d of %s since %s: %s", + h.Source, h.Branch, h.Since.UTC().Format(time.RFC3339), h.Why)) } - return held, slices.Sorted(maps.Keys(held)) + out.Pending = strings.Join(said, "; ") } // waitsHeld are the waits the parts hold, by module, from the view's own state waits (written from their wait-held and wait-ended, diff --git a/modules/mesh-delivery-view/internal/view/view.go b/modules/mesh-delivery-view/internal/view/view.go index f48b30dd..21a96290 100644 --- a/modules/mesh-delivery-view/internal/view/view.go +++ b/modules/mesh-delivery-view/internal/view/view.go @@ -102,15 +102,14 @@ type Snapshot struct { // The states of a want against the have of its node. const ( - WantApplied = "applied" // the node runs the want's fingerprint, running and healthy - WantPending = "pending" // the node has not yet run the want's fingerprint, or not healthy yet - WantFailed = "failed" // the node runs the want's fingerprint and its health check failed - WantHeldBack = "held back" // the assigner holds the node back from the newest fingerprint (Rule), or set it back - WantRemoved = "removed" // the node's want is removed: the module is no longer assigned to it + WantApplied = "applied" // the node runs the want's fingerprint, running and healthy + WantPending = "pending" // the node has not yet run the want's fingerprint, or not healthy yet + WantFailed = "failed" // the node runs the want's fingerprint and its health check failed + WantRemoved = "removed" // the node's want is removed: the module is no longer assigned to it ) // WantRow is a want of the assigner beside the have of its node: the fingerprint wanted, the one the node runs with its phase and -// health, the state of the two, and for a want held back the newest fingerprint, the rule and the assigner's words. +// health, the state of the two, and the assigner's words. type WantRow struct { Node string `json:"node"` Module string `json:"module"` @@ -119,8 +118,6 @@ type WantRow struct { Phase string `json:"phase,omitempty"` Health string `json:"health,omitempty"` State string `json:"state"` - Newest string `json:"newest,omitempty"` - Rule int `json:"rule,omitempty"` Words string `json:"words,omitempty"` // Judgement is the node agent's judgement of the move that waits for a person's yes (its have in waiting-yes, ADR 0547 // §3), and Judged its words; empty otherwise. The controller's composed copy is no longer read (ADR 0571 §6). @@ -340,7 +337,6 @@ type wantEntry struct { type sourceEntry struct { branch string // the branch's name revision uint64 - group string heads map[string]string err string } @@ -490,17 +486,16 @@ func (m *Model) unsay(ev DeliveredEvent) { } // DeliveredEvent is what the view says when the source revision is delivered (event `delivered` of the view, issue 1906 D9, ADR -// 0539 §17): the revision of the gate's source key, the group that moved it and every repository's merged head at it. A +// 0539 §17): the revision of the gate's source key and every repository's merged head at it. A // consumer takes every earlier revision as covered by it, and takes the same revision twice as once (after a restart of the view). // // The same event says a repository's reached head (ADR 0556 clause 3): Repository names it, Heads holds its head alone, Revision -// is the source revision that named that head and Group is empty; a consumer takes every earlier merge of that repository as on +// is the source revision that named that head; a consumer takes every earlier merge of that repository as on // the machines. type DeliveredEvent struct { // Branch is the watched branch whose source revision it is (design 47 G A-173). Branch string `json:"branch"` Revision uint64 `json:"revision"` - Group string `json:"group"` Heads map[string]string `json:"heads"` Repository string `json:"repository,omitempty"` // NotYet are, in the per-repository form, the merges at or before the reached head that are not yet on the machines: the @@ -532,7 +527,7 @@ func (m *Model) deliveredNow() []DeliveredEvent { continue } m.said[b] = src.revision - out = append(out, DeliveredEvent{Branch: src.branch, Revision: src.revision, Group: src.group, Heads: src.heads}) + out = append(out, DeliveredEvent{Branch: src.branch, Revision: src.revision, Heads: src.heads}) } return out } @@ -659,7 +654,7 @@ func (m *Model) apply(e Entry) { return } src, err := meshdeliveryclient.DecodeSource(e.Value) - m.sources[e.Key] = &sourceEntry{branch: name, revision: e.Revision, group: src.Group, heads: src.Heads, err: errText(err)} + m.sources[e.Key] = &sourceEntry{branch: name, revision: e.Revision, heads: src.Heads, err: errText(err)} if err == nil && e.Revision != 0 { // the history the reach reads: each revision heard since the start (A-225) if m.srcHist[e.Key] == nil { m.srcHist[e.Key] = map[uint64]map[string]string{} @@ -1090,7 +1085,7 @@ func (m *Model) wantRows() []WantRow { } node, module := splitKey(key) v := w.value - row := WantRow{Node: node, Module: module, Want: v.Fp, Newest: v.Newest, Rule: int(v.Rule), Words: v.Words} + row := WantRow{Node: node, Module: module, Want: v.Fp, Words: v.Words} h, has := m.haves[key] if has && h.err == "" { row.Have, row.Phase, row.Health = h.have.Fp, string(h.have.Phase), string(h.have.Health) @@ -1101,8 +1096,6 @@ func (m *Model) wantRows() []WantRow { switch { case v.Removed: row.State = WantRemoved - case v.Rule != 0 || v.Newest != "": - row.State = WantHeldBack case row.Have == v.Fp && h.have.Health == nodeengineclient.HealthFailed: row.State = WantFailed case row.Have == v.Fp && h.have.Phase == nodeengineclient.PhaseRunning && h.have.Health == nodeengineclient.HealthOK: @@ -1237,7 +1230,6 @@ type MotionBody struct { Module string `json:"module"` FromFP string `json:"from_fp"` ToFP string `json:"to_fp"` - Composed string `json:"composed"` Since time.Time `json:"since"` BoundSeconds int `json:"bound_seconds"` // At is when the have or the want last changed, the time the event is about. @@ -1247,7 +1239,7 @@ type MotionBody struct { } // MotionEvent is an event to say: its type (moving, settled or stuck), its id (the bus's dedup id and the event id header, one for -// a type, a node, a module and a composition) and its body. +// a type, a node, a module and the fingerprint wanted, design 47 H-A-78) and its body. type MotionEvent struct { Type string ID string @@ -1342,7 +1334,7 @@ func (m *Model) motionOf(hk string) []MotionEvent { node, module := splitKey(hk) h, has := m.haves[hk] has = has && h.err == "" - body := MotionBody{Node: node, Module: module, ToFP: w.value.Fp, Composed: w.value.Composed, Since: w.at, BoundSeconds: MotionBoundSeconds} + body := MotionBody{Node: node, Module: module, ToFP: w.value.Fp, Since: w.at, BoundSeconds: MotionBoundSeconds} body.At = w.at if has { body.FromFP = h.have.Fp @@ -1351,7 +1343,7 @@ func (m *Model) motionOf(hk string) []MotionEvent { } } id := func(kind string) string { - return kind + "." + node + "." + module + "." + strings.TrimPrefix(w.value.Composed, "sha256:") + return kind + "." + node + "." + module + "." + w.value.Fp } var out []MotionEvent say := func(kind string, b MotionBody) { diff --git a/modules/mesh-delivery-view/internal/view/view_test.go b/modules/mesh-delivery-view/internal/view/view_test.go index ce10ae92..f4e712e0 100644 --- a/modules/mesh-delivery-view/internal/view/view_test.go +++ b/modules/mesh-delivery-view/internal/view/view_test.go @@ -281,7 +281,7 @@ func statusDerivesEachPartFromItsBucket(t *testing.T) { fp1, fp2, fp3 := meshcatalogclient.SourcePrefix2+strings.Repeat("1", 64), meshcatalogclient.SourcePrefix2+strings.Repeat("2", 64), meshcatalogclient.SourcePrefix2+strings.Repeat("3", 64) enc := func(v any) string { b, _ := json.Marshal(v); return string(b) } want := func(fp string) string { - b, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fp, Composed: composedC}) + b, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fp}) return string(b) } have := func(fp string, phase string, health string, detail string) string { diff --git a/modules/mesh-delivery-view/internal/view/wants_test.go b/modules/mesh-delivery-view/internal/view/wants_test.go index f0804d9f..a6e3472c 100644 --- a/modules/mesh-delivery-view/internal/view/wants_test.go +++ b/modules/mesh-delivery-view/internal/view/wants_test.go @@ -28,9 +28,6 @@ func wantE(t *testing.T, node, module string, w meshwantsclient.Want) Entry { if err != nil { t.Fatal(err) } - if !w.Removed { - w.Composed = "sha256:" + strings.Repeat("c", 64) - } v, err := meshwantsclient.EncodeWant(w) if err != nil { t.Fatal(err) @@ -68,7 +65,7 @@ func sourceE(t *testing.T, revision uint64) Entry { return sourceOn(t, testBranc // sourceOn is one watched branch's source as the gate's verb source answers it (A-173). func sourceOn(t *testing.T, branch string, revision uint64) Entry { t.Helper() - v, err := meshdeliveryclient.EncodeSource(meshdelivery.SourceByBranchValue{Group: "g", Heads: map[string]string{"novox/web": strings.Repeat("1", 40)}}) + v, err := meshdeliveryclient.EncodeSource(meshdelivery.SourceByBranchValue{Call: "c1", Source: int64(revision), Heads: map[string]string{"novox/web": strings.Repeat("1", 40)}}) if err != nil { t.Fatal(err) } @@ -92,7 +89,7 @@ func TestEveryWantIsARowAgainstItsHave(t *testing.T) { wantE(t, "ace", "web", meshwantsclient.Want{Fp: fpNew}), haveFP(t, "ace", "web", fpNew, nodeengineclient.HealthOK), wantE(t, "ace", "mail", meshwantsclient.Want{Fp: fpNew}), haveFP(t, "ace", "mail", fpOld, nodeengineclient.HealthOK), wantE(t, "g14", "web", meshwantsclient.Want{Fp: fpNew}), haveFP(t, "g14", "web", fpNew, nodeengineclient.HealthFailed), - wantE(t, "g14", "mail", meshwantsclient.Want{Fp: fpOld, Newest: fpNew, Rule: meshwantsclient.RuleCanary, Words: "the canary ace does not run it healthy yet"}), + wantE(t, "g14", "mail", meshwantsclient.Want{Fp: fpOld, Words: "awaits its hand placement"}), wantE(t, "g14", "old", meshwantsclient.Want{Removed: true}), wantE(t, "novox", "web", meshwantsclient.Want{Fp: fpNew}), ) @@ -101,14 +98,14 @@ func TestEveryWantIsARowAgainstItsHave(t *testing.T) { got[r.Node+"."+r.Module] = r } for key, state := range map[string]string{ - "ace.web": WantApplied, "ace.mail": WantPending, "g14.web": WantFailed, "g14.mail": WantHeldBack, "g14.old": WantRemoved, "novox.web": WantPending, + "ace.web": WantApplied, "ace.mail": WantPending, "g14.web": WantFailed, "g14.mail": WantPending, "g14.old": WantRemoved, "novox.web": WantPending, } { if got[key].State != state { t.Errorf("%s = %+v, want state %s", key, got[key], state) } } - if r := got["g14.mail"]; r.Rule != meshwantsclient.RuleCanary || r.Newest != fpNew || r.Words == "" { - t.Errorf("the held-back row keeps its rule and words: %+v", r) + if r := got["g14.mail"]; r.Words != "awaits its hand placement" { + t.Errorf("a row keeps the want's words: %+v", r) } if r := got["ace.mail"]; r.Want != fpNew || r.Have != fpOld { t.Errorf("a pending row shows both: %+v", r) @@ -246,8 +243,8 @@ func TestTheViewSaysOnceThatASourceRevisionIsDelivered(t *testing.T) { t.Fatalf("said = %+v though the bus refused it", said) } fill(m, wantE(t, "ace", "web", meshwantsclient.Want{Fp: fpNew})) - if len(said) != 1 || said[0].Revision != 14355 || said[0].Group != "g" || said[0].Heads["novox/web"] == "" { - t.Fatalf("said = %+v, want revision 14355 once with its group and heads", said) + if len(said) != 1 || said[0].Revision != 14355 || said[0].Heads["novox/web"] == "" { + t.Fatalf("said = %+v, want revision 14355 once with its heads", said) } fill(m, haveFP(t, "ace", "web", fpNew, nodeengineclient.HealthOK), wantE(t, "ace", "web", meshwantsclient.Want{Fp: fpNew})) if len(said) != 1 { @@ -331,8 +328,8 @@ func TestAModuleInMotionIsSaidMovingThenSettledOnceEach(t *testing.T) { t.Fatalf("said %q, want moving", types(*said)) } mv := (*said)[0] - if mv.Body.Node != "ace" || mv.Body.Module != "web" || mv.Body.FromFP != fpOld || mv.Body.ToFP != fpNew || mv.Body.Composed != "sha256:"+strings.Repeat("c", 64) || - mv.Body.Since.IsZero() || mv.Body.At.IsZero() || mv.Body.BoundSeconds != 1800 || mv.ID != "moving.ace.web."+strings.Repeat("c", 64) { + if mv.Body.Node != "ace" || mv.Body.Module != "web" || mv.Body.FromFP != fpOld || mv.Body.ToFP != fpNew || + mv.Body.Since.IsZero() || mv.Body.At.IsZero() || mv.Body.BoundSeconds != 1800 || mv.ID != "moving.ace.web."+fpNew { // keyed by the fingerprint wanted (design 47 H-A-78) t.Errorf("moving = %+v", mv) } fill(m, haveFP(t, "ace", "web", fpOld, nodeengineclient.HealthOK), wantE(t, "ace", "web", meshwantsclient.Want{Fp: fpNew})) @@ -446,7 +443,7 @@ func TestTheWantsListANodesOwnWant(t *testing.T) { t.Fatal(err) } moduleKey, _ := meshwantsclient.WantKey("ace", "web") - moduleValue, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fpNew, Composed: "sha256:" + strings.Repeat("c", 64)}) + moduleValue, _ := meshwantsclient.EncodeWant(meshwantsclient.Want{Fp: fpNew}) state := map[string][]byte{own: value, moduleKey: moduleValue} r := Reader{WantsState: StateRead{ Keys: func() ([]string, error) { return []string{own, moduleKey}, nil }, diff --git a/modules/mesh-delivery-view/manifest_test.go b/modules/mesh-delivery-view/manifest_test.go index 9f56d84b..ecfbb978 100644 --- a/modules/mesh-delivery-view/manifest_test.go +++ b/modules/mesh-delivery-view/manifest_test.go @@ -18,7 +18,6 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view/viewstate" "git.novox.be/novox/mesh-sdk/go/keys" - "git.novox.be/novox/mesh-sdk/go/views" ) // The controller's manifest reader is mesh-controller internal/catalogue (ParseManifest), an internal package of another @@ -141,9 +140,11 @@ func load(t *testing.T) (manifest, map[string]json.RawMessage) { func TestManifestIsTakenAndReadsOnly(t *testing.T) { // 1134/AC7 m, top := load(t) - for _, a := range m.Build.Artifacts { - if a.Name == "tools" && a.Env[views.CallersEnv("answers")] != "mesh-delivery-teller" { - t.Errorf("the tools' env = %v, want the callers of answers mesh-delivery-teller", a.Env) + for _, a := range m.Build.Artifacts { // every account may call every verb: no tool names its callers (design 47 H §752, H-A-66) + for k := range a.Env { + if strings.Contains(k, "CALLERS") { + t.Errorf("the %s artifact's env names callers: %s", a.Name, k) + } } } // Design 47 G §717: it claims the seat mesh-delivery-view, scope mesh, serving no verb, and its first-view tool answers. @@ -172,16 +173,16 @@ func TestManifestIsTakenAndReadsOnly(t *testing.T) { // 1134/AC7 {Verb: "mesh-delivery-indexer.indexer_read_packages"}, {Verb: "mesh-delivery-indexer.indexer_read_predefined"}, {Verb: "mesh-delivery-indexer.indexer_read_taken"}, {Verb: "mesh-delivery-teller.teller_read_answers"}, // A-175: the teller's answers by their views family {Verb: "seat:mesh-catalog.revision", Fields: []string{"none-yet"}}, - {Verb: "seat:mesh-catalog.registrations"}, // §614: the watched branches of the registrations, then registration-changed - {Verb: "seat:mesh-catalog.entry", Fields: []string{"manifest-digest"}}, // §558: the module's value is the entry's manifest-digest (§506) - {Verb: "seat:mesh-delivery.source", Fields: []string{"branches", "group", "repositories", "revision"}}, // §507, §614, A-173: the branches before the first registrations, and each watched branch's source (§558: fields G adds) // ADR 0663: the modules are the catalog half's, read through the seat's verb revision, never the indexer's - {Verb: "seat:mesh-catalog.seat-definitions"}, // design 47 G A-82, §204: the build seats are read from the seat list - {Verb: "seat:mesh-broker.show"}, // A-274: the binding of its finding-events - {Verb: "seat:mesh-hand-acts.hand-act"}, // the join: its first view asked again by hand is a hand act (views.StatusTools) - {Verb: "seat:mesh-module-assigner.assignments"}, // A-82: the holder of each build seat - {Verb: "seat:mesh-wants.revision"}, // §512, A-242: view_tiers compares kept assignment revisions - {Verb: "seat:mesh-wants.difference"}, // §512, A-242: the tiers and each change's after are the assigner's - {Verb: "seat:node-engine.manifest-reads"}}; !reflect.DeepEqual(m.Invokes, want) { // ADR 0618 §3: node_manifest_reads asks the node-engine seat's verb of every node; 1585/T24: view_tiers asks indexer_pending, a verb edge (ADR 0614 §2) + {Verb: "seat:mesh-catalog.registrations"}, // §614: the watched branches of the registrations, then registration-changed + {Verb: "seat:mesh-catalog.entry", Fields: []string{"manifest-digest"}}, // §558: the module's value is the entry's manifest-digest (§506) + {Verb: "seat:mesh-delivery.source", Fields: []string{"branches", "call", "repositories", "revision"}}, // §507, §614, A-173: the branches before the first registrations, and each watched branch's source with its call, no group (design 47 H §737, §764) // ADR 0663: the modules are the catalog half's, read through the seat's verb revision, never the indexer's + {Verb: "seat:mesh-catalog.seat-definitions"}, // design 47 G A-82, §204: the build seats are read from the seat list + {Verb: "seat:mesh-broker.show"}, // A-274: the binding of its finding-events + {Verb: "seat:mesh-hand-acts.hand-act"}, // the join: its first view asked again by hand is a hand act (views.StatusTools) + {Verb: "seat:mesh-module-assigner.assignments"}, // A-82: the holder of each build seat + {Verb: "seat:mesh-wants.revision"}, // §512, A-242: view_tiers compares kept assignment revisions + {Verb: "seat:mesh-wants.difference"}, // §512, A-242: the tiers and each change's after are the assigner's + {Verb: "seat:node-engine.manifest-reads"}}; !reflect.DeepEqual(m.Invokes, want) { // ADR 0618 §3: node_manifest_reads asks the node-engine seat's verb of every node; 1585/T24: view_tiers asks indexer_pending, a verb edge (ADR 0614 §2) t.Errorf("invokes = %v, want %v", m.Invokes, want) } // design 47 G §387: the keeper's ask for the findings is heard, the finding stream declared (§383), and §368: version is MAJOR.MINOR. diff --git a/modules/mesh-delivery-view/module.json b/modules/mesh-delivery-view/module.json index 5161ae9f..607a9bb1 100644 --- a/modules/mesh-delivery-view/module.json +++ b/modules/mesh-delivery-view/module.json @@ -109,7 +109,7 @@ {"verb": "seat:mesh-catalog.revision", "fields": ["none-yet"]}, "seat:mesh-catalog.registrations", {"verb": "seat:mesh-catalog.entry", "fields": ["manifest-digest"]}, - {"verb": "seat:mesh-delivery.source", "fields": ["branches", "group", "repositories", "revision"]}, + {"verb": "seat:mesh-delivery.source", "fields": ["branches", "call", "repositories", "revision"]}, "seat:mesh-catalog.seat-definitions", "seat:mesh-broker.show", "seat:mesh-hand-acts.hand-act", @@ -229,10 +229,7 @@ "binary": "mesh-delivery-view-tools", "loads": [ "mesh-delivery-view-tools" - ], - "env": { - "MESH_VIEW_CALLERS_ANSWERS": "mesh-delivery-teller" - } + ] }, { "name": "files", diff --git a/modules/mesh-delivery-view/viewstate/reach.go b/modules/mesh-delivery-view/viewstate/reach.go index b2b837ca..229a50b2 100644 --- a/modules/mesh-delivery-view/viewstate/reach.go +++ b/modules/mesh-delivery-view/viewstate/reach.go @@ -67,7 +67,8 @@ type ModuleReach struct { } // Change is one fingerprint of a module, the merge commit it first appeared at (Module.Commit), and the source revision -// that named that commit as the repository's head (Module.Src, or the source's history), 0 when not known. +// that named that commit as the repository's head (the source's history; a module carries no source stamp, design 47 +// H-A-48), 0 when not known. type Change struct { Commit string `json:"commit"` FP string `json:"fp"`