diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/actingwaits.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/actingwaits.go index 2297a750..5ff6f835 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/actingwaits.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/actingwaits.go @@ -31,7 +31,7 @@ func (p *passer) actingOf(module string, released map[string]bool) func(node str } for _, e := range p.entryEdges(node, module) { if acting.Held(e.Step) && !released[acting.Key(node, module, e.Module)+"@"+e.Fp] { - out = append(out, assign.ActingEdge{Node: e.Node, Part: e.Module, Fp: e.Fp, Step: e.Step}) + out = append(out, assign.ActingEdge{Node: e.Node, Part: e.Module, Fp: e.Fp, Step: e.Step, Seat: e.Seat}) } } return out @@ -103,7 +103,10 @@ func (p *passer) actingWaits(ctx context.Context, n assign.Nodes, wanted map[str continue } key := acting.Key(ref.Node, ref.Module, e.Module) - if n.Runs(assign.ActingEdge{Node: e.Node, Part: e.Module, Fp: e.Fp, Step: e.Step}) { + if took, runs := n.ActingRuns(assign.ActingEdge{Node: e.Node, Part: e.Module, Fp: e.Fp, Step: e.Step, Seat: e.Seat}); runs { + if took != e.Fp && kept[key] != nil { + p.logf("the wait of %s on %s for %s ends: %s runs %s, which serves the seat %s, though its newest is %s (design 47 G A-426)", ref.Module, ref.Node, e.Module, e.Node, took, e.Seat, e.Fp) + } continue } standing[key] = true @@ -124,6 +127,7 @@ func (p *passer) actingWaits(ctx context.Context, n assign.Nodes, wanted map[str continue } p.put(ctx, buckets.Waits(), key, func() ([]byte, error) { return acting.Encode(w) }) + p.logf("the want of %s on %s is held: its acting part %s (step %s) does not run the version %s on %s; the wait %s ends when it does, or by assigner_release", ref.Module, ref.Node, e.Module, e.Step, e.Fp, e.Node, key) } } p.actingCycles(g.computed.Entries, engines, held, n) @@ -138,7 +142,9 @@ func (p *passer) actingWaits(ctx context.Context, n assign.Nodes, wanted map[str how := acting.HowRan if w.Released { how = acting.HowReleased - } else if e, ok := p.edgeOf(w); !ok || !n.Runs(e) { + } else if e, ok := p.edgeOf(w); !ok { + how = acting.HowReplaced + } else if _, runs := n.ActingRuns(e); !runs { how = acting.HowReplaced } if !w.EndSaid { @@ -184,7 +190,7 @@ func (p *passer) actingCycles(entries map[string]seat.AssignmentEntry, engines m released := p.actingReleased() cycles := assigngraph.HeldCycles(slices.Collect(maps.Values(entries)), func(e seat.AssignmentEntry, edge seat.Edge) bool { return held[e.Node+"/"+e.Module] && engines[e.Node] != e.Module && edge.Kind == "acting" && acting.Held(edge.Step) && - !released[acting.Key(e.Node, e.Module, edge.Module)+"@"+edge.Fp] && !n.Runs(assign.ActingEdge{Node: edge.Node, Part: edge.Module, Fp: edge.Fp, Step: edge.Step}) + !released[acting.Key(e.Node, e.Module, edge.Module)+"@"+edge.Fp] && !actingRunsOf(n, edge) }) raised := map[string]bool{} for _, at := range slices.Sorted(maps.Keys(cycles)) { @@ -223,3 +229,9 @@ func (p *passer) actingCycles(entries map[string]seat.AssignmentEntry, engines m } } } + +// actingRunsOf says whether an assignment edge's acting part runs a build serving it (A-426). +func actingRunsOf(n assign.Nodes, edge seat.Edge) bool { + _, runs := n.ActingRuns(assign.ActingEdge{Node: edge.Node, Part: edge.Module, Fp: edge.Fp, Step: edge.Step, Seat: edge.Seat}) + return runs +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/actingwaits_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/actingwaits_test.go index 762332aa..8c746b80 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/actingwaits_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/actingwaits_test.go @@ -36,7 +36,9 @@ func TestAnEntryWaitsForItsActingPartAndTheWaitIsKeptSaidAndEnded(t *testing.T) p.graph = &graphKeeper{} p.graph.computed.Revision.Entries = []meshwants.NodeEntryRef{{Node: "ace", Module: "nats", Digest: "d1"}} p.graph.computed.Entries = map[string]meshwants.AssignmentEntry{"d1": entry} - n := assign.Nodes{Online: map[string]bool{"ace": true}, Running: map[string]map[string]nodeengine.Running{"ace": {"mesh-host": {Fingerprint: "src2:old"}}}} + // The old build of mesh-host serves no seat of the edge here, so the entry waits (A-426: one serving it ends the wait). + notServing := func(nodeengine.Running, string) (bool, bool) { return false, true } + n := assign.Nodes{Online: map[string]bool{"ace": true}, Running: map[string]map[string]nodeengine.Running{"ace": {"mesh-host": {Fingerprint: "src2:old"}}}, Serves: notServing} wanted := map[string]map[string]mwc.Want{"nats": {"ace": {Fp: "src2:older"}}} ctx := context.Background() @@ -149,7 +151,7 @@ func TestTheNodeEngineIsWantedFirstAndAWantHeldOnACycleIsAFinding(t *testing.T) } p.graph.computed.Entries = entries n := assign.Nodes{Online: map[string]bool{"ace": true}, Running: map[string]map[string]nodeengine.Running{"ace": { - "mesh-host": {Fingerprint: "src2:old"}, "assigner": {Fingerprint: "src2:old"}}}} + "mesh-host": {Fingerprint: "src2:old"}, "assigner": {Fingerprint: "src2:old"}}}, Serves: func(nodeengine.Running, string) (bool, bool) { return false, true }} wanted := map[string]map[string]mwc.Want{} if got := p.actingOf("mesh-host", nil)("ace"); len(got) != 0 { t.Errorf("the node-engine's want is held by %+v, want by no acting edge", got) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/askfor.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/askfor.go new file mode 100644 index 00000000..bcdb857e --- /dev/null +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/askfor.go @@ -0,0 +1,117 @@ +package main + +import ( + "errors" + "io/fs" + "os" + "slices" + "strings" + + mmac "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient" + mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner" + + "mesh-delivery-assigner/internal/judge" +) + +// Which proposals the assigner asks of the operator is its setting ask-operator-for (design 47 G A-425, A-425a): a list of change +// kinds, set at mesh level with mesh-config's config, its default take-off, remove-node and stops. A proposal none of whose changes +// is listed is applied at once when its verdict passes, said in the log and by assignments-changed; one with a listed kind is +// asked as before. The setting is read from the file the manifest declares with the content ${config:ask-operator-for}, which the +// environment names (A-112), at every pass, and a change of it is said. + +// KindStops is the change kind of a verdict whose answers say a node would stop running a module. +const KindStops = "stops" + +// defaultAskOperatorFor is the setting's default. +var defaultAskOperatorFor = []string{mmac.OpTakeOff, mmac.OpRemoveNode, KindStops} + +// askKinds are the kinds the setting may name. +var askKinds = []string{mmac.OpPlace, mmac.OpTakeOff, mmac.OpPin, mmac.OpUnpin, mmac.OpHold, mmac.OpUnhold, mmac.OpDecide, mmac.OpConfig, + mmac.OpAddNode, mmac.OpRemoveNode, KindStops} + +// parseAskOperatorFor reads the setting's value: kinds separated by commas or spaces; empty is the default. A kind it does not +// know is answered apart and named nowhere in the list. +func parseAskOperatorFor(raw string) (kinds, unknown []string) { + fields := strings.FieldsFunc(raw, func(r rune) bool { return r == ',' || r == ' ' || r == '\n' || r == '\t' }) + if len(fields) == 0 { + return slices.Clone(defaultAskOperatorFor), nil + } + for _, f := range fields { + f = strings.ToLower(strings.TrimSpace(f)) + switch { + case !slices.Contains(askKinds, f): + unknown = append(unknown, f) + case !slices.Contains(kinds, f): + kinds = append(kinds, f) + } + } + slices.Sort(kinds) + return kinds, unknown +} + +// readAskOperatorFor reads the setting's file: the default for no path or no file. +func readAskOperatorFor(path string) (kinds, unknown []string, err error) { + if path == "" { + k, u := parseAskOperatorFor("") + return k, u, nil + } + raw, err := os.ReadFile(path) + if errors.Is(err, fs.ErrNotExist) { + k, u := parseAskOperatorFor("") + return k, u, nil + } + if err != nil { + return nil, nil, err + } + k, u := parseAskOperatorFor(string(raw)) + return k, u, nil +} + +// askOperatorFor is the setting as this pass read it: the file read again each pass, a change said once, a file that cannot be +// read keeping what was read last (the default before any). +func (p *passer) askOperatorFor() []string { + kinds, unknown, err := readAskOperatorFor(p.askForFile) + if err != nil { + if p.askFor == nil { + p.askFor = slices.Clone(defaultAskOperatorFor) + } + p.logf("the setting ask-operator-for cannot be read from %s, so %s stands: %v", p.askForFile, strings.Join(p.askFor, ", "), err) + return p.askFor + } + if !slices.Equal(kinds, p.askFor) { + words := "the setting ask-operator-for is " + strings.Join(kinds, ", ") + ": a proposal with a change of another kind only is applied with no ask" + if len(unknown) > 0 { + words += "; kinds it names that are none are left out: " + strings.Join(unknown, ", ") + } + p.logf("%s", words) + p.askFor = kinds + } + return p.askFor +} + +// asksFor says whether a proposal of these change kinds is asked of the operator. +func (p *passer) asksFor(kinds []string) bool { + set := p.askOperatorFor() + for _, k := range kinds { + if slices.Contains(set, k) { + return true + } + } + return false +} + +// proposalKinds are the change kinds of a proposal whose verdict is v: each change's op, and stops when an answer says a node +// would stop running a module. +func proposalKinds(prop mma.Proposal, v mma.Verdict) []string { + var out []string + for _, c := range prop.Changes { + if c.Op != "" && !slices.Contains(out, c.Op) { + out = append(out, c.Op) + } + } + if len(judge.Stops(v)) > 0 { + out = append(out, KindStops) + } + slices.Sort(out) + return out +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/buildended.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/buildended.go index 5c09da9d..43d2af42 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/buildended.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/buildended.go @@ -4,6 +4,9 @@ import ( "context" "encoding/json" "fmt" + "maps" + "strconv" + "strings" "sync" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" @@ -97,7 +100,7 @@ func (r *releasedVersions) put(data []byte) error { } parts := map[string]string{} for _, a := range e.Artifacts { - parts[e.Module+":"+a.Artifact] = a.Digest + parts[partRef(e.Module, a.Artifact)] = a.Digest } r.mu.Lock() defer r.mu.Unlock() @@ -116,6 +119,41 @@ func (r *releasedVersions) put(data []byte) error { return nil } +// withParts is the version of module whose release named exactly parts (`:` -> digest), the newest such when +// more than one did; false when none did or parts is empty (design 47 G A-421). +func (r *releasedVersions) withParts(module string, parts map[string]string) (assign.KeptBuild, bool) { + if len(parts) == 0 { + return assign.KeptBuild{}, false + } + r.mu.Lock() + defer r.mu.Unlock() + var out assign.KeptBuild + found := false + for key, k := range r.seen { + if m, _, ok := strings.Cut(key, "@"); !ok || m != module || !maps.Equal(k.Parts, parts) { + continue + } + if !found || compareVersion(k.Version, out.Version) > 0 { + out, found = k, true + } + } + return out, found +} + +// madeOf is what module's done build at fp made, by `:`, as its build.ended names it; none for a build not heard +// or not done (design 47 G A-421). +func (b *builtEnds) madeOf(module, fp string) map[string]string { + e, ok := b.endOf(module, fp) + if !ok || e.Outcome != builds.BuildDone { + return nil + } + parts := map[string]string{} + for name, digest := range e.Made { + parts[module+":"+name] = digest + } + return parts +} + // of is the version of module released from the source revision, with its parts' digests; false before it is heard. func (r *releasedVersions) of(module string, source int64) (assign.KeptBuild, bool) { r.mu.Lock() @@ -143,7 +181,7 @@ func hearBuilds(ctx context.Context, js jetstream.JetStream, ends *builtEnds, wa logf("acknowledging %s: %v", m.Subject(), err) } wake() - }, logf) + }, logf, process.FromFirst()) // read whole from its first message whether the bus keeps it last per subject or by age (A-181, A-233) if err != nil { nh.NotHeard(buildsStreamName, "what the builder built is not heard until the assigner starts again, so no want names a build's parts or its keeping node and no put goes on", err) return @@ -168,3 +206,30 @@ func hearTaken(hub *process.EventHub, taken *takenSources, wake func(), logf fun wake() }) } + +// compareVersion orders two MAJOR.MINOR.PATCH versions by their numbers; a part that is no number counts as 0. +func compareVersion(a, b string) int { + pa, pb := strings.Split(a, "."), strings.Split(b, ".") + for i := 0; i < 3; i++ { + var x, y int + if i < len(pa) { + x, _ = strconv.Atoi(pa[i]) + } + if i < len(pb) { + y, _ = strconv.Atoi(pb[i]) + } + if x != y { + return x - y + } + } + return 0 +} + +// partRef is a release's artifact as a part's key, `:`: the contract's VersionArtifact names the artifact +// reference whole (an ArtifactRef), as the catalog's version-released says it; a bare name is taken as the module's (A-96). +func partRef(module, artifact string) string { + if strings.Contains(artifact, ":") { + return artifact + } + return module + ":" + artifact +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/buildended_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/buildended_test.go index 7a86f9b3..7dfc7904 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/buildended_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/buildended_test.go @@ -2,7 +2,9 @@ package main import ( "encoding/json" + "fmt" "reflect" + "strings" "testing" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" @@ -54,11 +56,12 @@ func TestAVersionReleasedHeardNamesItsVersionAndPartsBySource(t *testing.T) { } } -// Design 47 G §379, A-96: the trunk's entry takes its version and parts from the version-released of the kept assignment graph -// revision's source; a kept build from its end; no revision kept, or another fingerprint, names none. -func TestATrunkEntryTakesItsVersionFromTheReleaseOfTheKeptRevisionsSource(t *testing.T) { +// Design 47 G §379, A-96, A-419: the trunk's entry takes its version and parts from the version-released of the source its +// fingerprint was built at (its fp-src), whatever source the kept assignment graph revision is at; a kept build from its end; no +// revision kept, another fingerprint, an fp-src with no release or none names none, and an unheard release is said once. +func TestATrunkEntryTakesItsVersionFromTheReleaseOfItsFingerprintsSource(t *testing.T) { w := newWorld() - raw, _ := json.Marshal(meshcatalog.VersionReleasedEvent{Module: "mail", Source: 7, Version: "1.2.3", Artifacts: []meshcatalog.VersionArtifact{{Artifact: "image", Digest: "sha256:9"}}}) + raw, _ := json.Marshal(meshcatalog.VersionReleasedEvent{Module: "mail", Source: 7, Version: "1.2.3", Artifacts: []meshcatalog.VersionArtifact{{Artifact: "mail:image", Digest: "sha256:9"}}}) if err := w.released.put(raw); err != nil { t.Fatal(err) } @@ -66,8 +69,9 @@ func TestATrunkEntryTakesItsVersionFromTheReleaseOfTheKeptRevisionsSource(t *tes if err := w.ends.put(endRaw); err != nil { t.Fatal(err) } - p := &passer{w: w, graph: &graphKeeper{ok: true, source: 7}} - named := p.namedBuild("mail", "t") + var logs []string + p := &passer{w: w, graph: &graphKeeper{ok: true, source: 7}, logf: func(f string, a ...any) { logs = append(logs, fmt.Sprintf(f, a...)) }} + named := p.namedBuild("mail", "t", 7) if k, ok := named("t"); !ok || k.Version != "1.2.3" || k.Parts["mail:image"] != "sha256:9" || k.KeptOn != "" { t.Errorf("trunk entry = %+v, %v", k, ok) } @@ -77,12 +81,39 @@ func TestATrunkEntryTakesItsVersionFromTheReleaseOfTheKeptRevisionsSource(t *tes if _, ok := named("other"); ok { t.Error("another fingerprint names a release") } - p.graph.source = 8 - if _, ok := named("t"); ok { - t.Error("a source with no release names a version") + p.graph.source = 8 // a later merge that did not rebuild mail + if k, ok := named("t"); !ok || k.Version != "1.2.3" { + t.Errorf("after a later merge the trunk entry = %+v, %v; want the release of its fingerprint's source", k, ok) + } + if _, ok := p.namedBuild("mail", "t", 8)("t"); ok { + t.Error("an fp-src with no release names a version") + } + _, _ = p.namedBuild("mail", "t", 8)("t") + if _, ok := p.namedBuild("mail", "t", 0)("t"); ok { + t.Error("an entry naming no fp-src, whose build.ended is not heard, names a version") + } + // The release names each artifact by its whole reference, as the catalog says it, and the parts are keyed so (A-96); the + // assigner reads the entry's fp-src from its inputs (A-419). + // A-429: a released version's build counts as done for rule 1; a kept build (no version) and an unknown one do not. + if !releasedBuild(p.namedBuild("mail", "t", 7), "t") || releasedBuild(p.namedBuild("mail", "t", 7), "k") || releasedBuild(p.namedBuild("mail", "t", 8), "t") || releasedBuild(nil, "t") { + t.Error("rule 1's released build: the release of the entry's fingerprint counts, a kept build, another source or none does not") + } + if v, _, _ := fromEntry(meshcatalog.CatalogEntry{Module: "mail", Fp: "t", Inputs: &meshcatalog.EntryInputs{Src: 9, FpSrc: 7}}); v.FpSrc != 7 || v.Src != 9 { + t.Errorf("the entry's module value carries fp-src %d and src %d, want 7 and 9", v.FpSrc, v.Src) + } + // A-421: an entry naming no fp-src takes the release whose parts are what its build.ended made. + made, _ := json.Marshal(builds.BuildEnded{Module: "mail", Fingerprint: "t", Made: map[string]string{"image": "sha256:9"}}) + if err := w.ends.put(made); err != nil { + t.Fatal(err) + } + if k, ok := p.namedBuild("mail", "t", 0)("t"); !ok || k.Version != "1.2.3" { + t.Errorf("an entry naming no fp-src, its build made the released digests: %+v, %v", k, ok) + } + if len(logs) != 2 || !strings.Contains(logs[0], "the release of mail at fingerprint t is not heard: no version-released of it from source 8") || !strings.Contains(logs[1], "names no fp-src, and no version-released of it names the parts its build.ended made") { + t.Errorf("logs = %q, want each unheard release said once, naming the module, the fingerprint and the source", logs) } p.graph.ok = false - if _, ok := p.namedBuild("mail", "t")("t"); ok { + if _, ok := p.namedBuild("mail", "t", 7)("t"); ok { t.Error("no revision kept names a release") } } diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded.go index 1bbfa391..61748b49 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded.go @@ -28,18 +28,25 @@ func (p *passer) addedOf(node string, laid *mma.Assignments, current map[string] if p.ends.following() { branch = p.ends.branchOf(module, placed[module]) } - fp := p.w.trunkOf(branch)[module].Fp2 + entry := p.w.trunkOf(branch)[module] + fp := entry.Fp2 if fp == "" { + p.skippedAdd(node, module, "", "the branch "+branch+" names no fingerprint of it") continue } - k, ok := p.namedBuild(module, fp)(fp) + k, ok := p.namedBuild(module, fp, entry.FpSrc)(fp) if !ok { + p.skippedAdd(node, module, fp, "no version-released of it is heard for that fingerprint, so the candidate carries no version and no parts") continue } if out == nil { out = map[string]mma.AddedModule{} } - out[module] = mma.AddedModule{Version: k.Version, Parts: k.Parts} + added := mma.AddedModule{Version: k.Version, Parts: k.Parts} + if k.Version != "" { + added.Parts = nil // a released build is named by its version alone (design 47 G A-430, A-430a) + } + out[module] = added } return out } @@ -48,3 +55,18 @@ func (p *passer) addedOf(node string, laid *mma.Assignments, current map[string] func (p *passer) candidateOf(id, node string, laid *mma.Assignments, current map[string]mma.Assignments) mma.CandidatesByProposalNodeValue { return mma.CandidatesByProposalNodeValue{Proposal: id, Assignments: laid, Added: p.addedOf(node, laid, current)} } + +// skippedAdd says once per node, module and fingerprint why a module the candidate adds is not listed in `added`. +func (p *passer) skippedAdd(node, module, fp, why string) { + key := node + "/" + module + "@" + fp + ": " + why + if p.skipped[key] { + return + } + if p.skipped == nil { + p.skipped = map[string]bool{} + } + p.skipped[key] = true + if p.logf != nil { + p.logf("the candidate adds %s to %s with no parts: %s (fingerprint %q)", module, node, why, fp) + } +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded_test.go index b6a9505f..e2f49be4 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/candidateadded_test.go @@ -17,10 +17,10 @@ import ( func TestACandidateThatAddsAModuleCarriesItsParts(t *testing.T) { w := newWorld() for _, m := range []string{"mail", "web", "db"} { - w.putModule("main", m, meshcatalog.ModulesByModuleValue{Fp2: "fp-" + m}, graph.Node{}, nil) + w.putModule("main", m, meshcatalog.ModulesByModuleValue{Fp2: "fp-" + m, FpSrc: 7}, graph.Node{}, nil) } w.first = "main" - rel, _ := json.Marshal(meshcatalog.VersionReleasedEvent{Module: "mail", Source: 7, Version: "1.2.3", Artifacts: []meshcatalog.VersionArtifact{{Artifact: "image", Digest: "sha256:9"}}}) + rel, _ := json.Marshal(meshcatalog.VersionReleasedEvent{Module: "mail", Source: 7, Version: "1.2.3", Artifacts: []meshcatalog.VersionArtifact{{Artifact: "mail:image", Digest: "sha256:9"}}}) if err := w.released.put(rel); err != nil { t.Fatal(err) } @@ -29,12 +29,12 @@ func TestACandidateThatAddsAModuleCarriesItsParts(t *testing.T) { t.Fatal(err) } w.put(buckets.Wants(), "want.ace.web", []byte(`{}`)) - p := &passer{w: w, graph: &graphKeeper{ok: true, source: 7}} + p := &passer{w: w, graph: &graphKeeper{ok: true, source: 9}} // a later merge: the release is matched by fp-src (A-419) laid := &mma.Assignments{Node: "ace", Modules: []mma.PlacedModule{{Module: "mail"}, {Module: "web"}, {Module: "db"}, {Module: "old"}}} current := map[string]mma.Assignments{"ace": {Node: "ace", Modules: []mma.PlacedModule{{Module: "old"}}}} c := p.candidateOf("p1", "ace", laid, current) want := map[string]mma.AddedModule{ - "mail": {Version: "1.2.3", Parts: map[string]string{"mail:image": "sha256:9"}}, + "mail": {Version: "1.2.3"}, // a released build is named by its version alone (A-430a) "db": {Parts: map[string]string{"db:program": "sha256:3"}}, } if c.Proposal != "p1" || c.Assignments != laid || !reflect.DeepEqual(c.Added, want) { diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs.go index fa91aadb..2e763747 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs.go @@ -3,18 +3,19 @@ package main import ( "bytes" "context" + "crypto/rand" + "encoding/base64" + "encoding/hex" "encoding/json" "errors" "fmt" "slices" - "strconv" "sync" "time" nec "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" meshwants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" - "git.novox.be/novox/mesh-sdk/go/keys" ) // The inputs of a composition step (design 47 G §354, A-243, A-252): one request per machine, each carrying that machine's input, @@ -28,11 +29,11 @@ const composeCandidateKey = "seat:" + ne.Seat + "." + ne.VerbComposeCandidate func candidateKeyOf(run meshwants.StepRun) (string, error) { switch { case run.Run != "": - return "run-" + run.Run, nil + return nec.RunKey(run.Run) case run.Branch == "" || run.Revision <= 0: return "", errors.New("the step names neither a run on request nor a branch's revision, so no candidate is named") } - return keys.EscapeName(run.Branch) + "." + strconv.FormatInt(run.Revision, 10), nil + return nec.RevisionKey(run.Branch, run.Revision) // built by the seat's client, never by hand (A-226b) } // machinesFor are the machines of a step (A-252): the nodes whose placement of the module names the step's branch (a placement @@ -72,9 +73,11 @@ type nodeInput struct { // compositionInputs asks the machines of a step for their inputs. type compositionInputs struct { machines func(module, branch string) []string - // call asks one node's seat verb (process.Conn.CallKeptOn). - call func(node, key string, body any) (json.RawMessage, error) - bound time.Duration + // callFile asks a seat verb marked chunks, addressed to one node as `seat:.@`, and answers the verb's answer with + // the whole file received added as its member `file`, base64 (process.Conn.CallFile; design 47 G A-237b, A-237c, A-249). The call + // token is the body's `call`. + callFile func(key string, body any) (json.RawMessage, error) + bound time.Duration } // gather asks each machine of the step's module and branch for its input with the step's candidate key, and answers every machine in @@ -121,7 +124,13 @@ func (c *compositionInputs) one(ctx context.Context, bound time.Duration, node, } got := make(chan reply, 1) go func() { - raw, err := c.call(node, composeCandidateKey, ne.ComposeCandidateInput{Candidate: key, Input: true}) + // The input is any size, so the verb sends it in chunks on the call token chosen here, and the file is the input (A-237b, A-237c). + var bits [16]byte + if _, err := rand.Read(bits[:]); err != nil { + got <- reply{nil, err} + return + } + raw, err := c.callFile(composeCandidateKey+"@"+node, ne.ComposeCandidateInput{Candidate: key, Input: true, Call: hex.EncodeToString(bits[:])}) got <- reply{raw, err} }() var raw json.RawMessage @@ -148,17 +157,36 @@ func (c *compositionInputs) one(ctx context.Context, bound time.Duration, node, case a.Verdict == nec.Unready: in.Why = "unready: " + a.Refused return in - case len(a.Input) == 0: + case a.Chunks == 0 && len(a.Input) == 0: in.Why = "the engine answered no composition input" if a.Refused != "" { in.Why += ": " + a.Refused } return in } - body, err := json.Marshal(a.Input) - if err != nil { - in.Why = "its composition input cannot be encoded again: " + err.Error() - return in + var body []byte + if a.Chunks > 0 { + // The composition input is the file the chunks carried, the engine's own bytes (numbers as written). + var whole struct { + File string `json:"file"` + } + if err := json.Unmarshal(raw, &whole); err != nil { + in.Why = "its answer is not a compose-candidate answer: " + err.Error() + return in + } + file, err := base64.StdEncoding.DecodeString(whole.File) + if err != nil || len(file) == 0 { + in.Why = fmt.Sprintf("the engine named %d chunks of composition input and the file received is empty or not base64: %v", a.Chunks, err) + return in + } + body = file + } else { + // An answer with the input inline (an engine before A-237b, read until the checker is removed, A-237c, G-6 §321): the object, as it was. + var err error + if body, err = json.Marshal(a.Input); err != nil { + in.Why = "its composition input cannot be encoded again: " + err.Error() + return in + } } in.Body = body return in diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs_test.go index fee01d44..78fe48e1 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs_test.go @@ -2,13 +2,16 @@ package main import ( "context" + "encoding/base64" "encoding/json" "errors" + "regexp" "strings" "sync" "testing" "time" + nec "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" meshwants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" ) @@ -21,12 +24,21 @@ func TestTheCandidateKeyOfAStep(t *testing.T) { }{ {run: meshwants.StepRun{Run: "r1", Branch: "main"}, want: "run-r1"}, {run: meshwants.StepRun{Branch: "feat/x", Revision: 42}, want: "feat/x.42"}, + {run: meshwants.StepRun{Branch: "main", Revision: 362}, want: "main.362"}, {run: meshwants.StepRun{Branch: "main"}, fail: true}, + {run: meshwants.StepRun{Branch: "main", Revision: 100000000000}, fail: true}, // a number the client's key would read as a heads hash + {run: meshwants.StepRun{Run: "a.b"}, fail: true}, // a run id the client refuses } { got, err := candidateKeyOf(c.run) if (err != nil) != c.fail || got != c.want { t.Errorf("%+v: %q, %v; want %q", c.run, got, err, c.want) } + // A-226b: the node-engine reads every key the step names with the client's one parser. + if !c.fail { + if _, err := nec.ParseCandidateKey(got); err != nil { + t.Errorf("%+v: the key %q is refused by the seat's parser: %v", c.run, got, err) + } + } } } @@ -59,8 +71,9 @@ func TestAStepsInputsAreAskedOfEachMachine(t *testing.T) { // gather asks the machines side by side, so the record of what each was asked is guarded. var mu sync.Mutex asked := map[string]string{} - call := func(node, key string, body any) (json.RawMessage, error) { + call := func(key string, body any) (json.RawMessage, error) { raw, _ := json.Marshal(body) + key, node, _ := strings.Cut(key, "@") // addressed to one node (A-237b) mu.Lock() asked[node] = key + " " + string(raw) mu.Unlock() @@ -72,13 +85,15 @@ func TestAStepsInputsAreAskedOfEachMachine(t *testing.T) { } return json.RawMessage(`{"candidate":"run-r1","node":"` + node + `","verdict":"composed","input":{"n":12345678901234567890,"node":"` + node + `"},"modules":[],"own":{},"took":1,"v":1}`), nil } - c := &compositionInputs{machines: func(module, branch string) []string { return []string{"ace", "g14", "novox", "shanks"} }, call: call, bound: time.Second} + c := &compositionInputs{machines: func(module, branch string) []string { return []string{"ace", "g14", "novox", "shanks"} }, callFile: call, bound: time.Second} got, err := c.gather(context.Background(), meshwants.StepRun{Module: "m", Branch: "main", Run: "r1"}, func(node string) bool { return node == "shanks" }) if err != nil || len(got) != 4 { t.Fatalf("%+v %v", got, err) } - if want := `seat:node-engine.compose-candidate {"candidate":"run-r1","input":true}`; asked["ace"] != want { - t.Errorf("asked %q, want %q", asked["ace"], want) + // With a call token of 128 random bits (32 hex digits), the verb being marked chunks. + if k, body, _ := strings.Cut(asked["ace"], " "); k != "seat:node-engine.compose-candidate" || + !regexp.MustCompile(`^\{"call":"[0-9a-f]{32}","candidate":"run-r1","input":true\}$`).MatchString(body) { + t.Errorf("asked %q", asked["ace"]) } if got[0].Node != "ace" || got[0].Why != "" || !strings.Contains(string(got[0].Body), "12345678901234567890") { t.Errorf("ace: %+v", got[0]) @@ -89,8 +104,34 @@ func TestAStepsInputsAreAskedOfEachMachine(t *testing.T) { if _, was := asked["shanks"]; was || !got[3].Away { t.Errorf("the machine away is asked or not said away: %+v", got[3]) } - none := &compositionInputs{machines: func(string, string) []string { return nil }, call: call} + none := &compositionInputs{machines: func(string, string) []string { return nil }, callFile: call} if _, err := none.gather(context.Background(), meshwants.StepRun{Module: "m", Run: "r1"}, nil); err == nil { t.Error("a step with no machine is gathered") } } + +// A-237b: the composition input is any size, so a node names the chunks it sent and the assigner reads the file the chunked call +// received as the input, its numbers as written; a node that names chunks and sends no file is said so. +func TestAStepsInputIsTheFileOfTheNodesChunks(t *testing.T) { + input := `{"n":12345678901234567890,"big":"` + strings.Repeat("x", 1<<20) + `"}` + file := base64.StdEncoding.EncodeToString([]byte(input)) + call := func(key string, body any) (json.RawMessage, error) { + _, node, _ := strings.Cut(key, "@") + answer := `{"candidate":"run-r1","node":"` + node + `","verdict":"composed","modules":[],"own":{},"took":1,"v":1,"chunks":3` + if node == "g14" { + return json.RawMessage(answer + `}`), nil // names chunks, none received + } + return json.RawMessage(answer + `,"file":"` + file + `"}`), nil + } + c := &compositionInputs{machines: func(module, branch string) []string { return []string{"ace", "g14"} }, callFile: call, bound: time.Second} + got, err := c.gather(context.Background(), meshwants.StepRun{Module: "m", Branch: "main", Run: "r1"}, func(string) bool { return false }) + if err != nil || len(got) != 2 { + t.Fatalf("%+v %v", got, err) + } + if got[0].Why != "" || string(got[0].Body) != input { + t.Errorf("ace: why %q, %d bytes, want the file received (%d bytes) as the input", got[0].Why, len(got[0].Body), len(input)) + } + if !strings.Contains(got[1].Why, "chunks") || got[1].Body != nil { + t.Errorf("g14: %+v", got[1]) + } +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go index c4b576f4..3abf6f12 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go @@ -378,7 +378,8 @@ func caseOf(half mcc.Half) (map[string]composer.Manifest, map[string]json.RawMes func nodeEngineEntry(entries map[string]meshcatalog.CatalogEntry) (meshcatalog.CatalogEntry, bool) { for _, name := range slices.Sorted(mapsKeys(entries)) { for _, s := range entries[name].Serves { - if strings.HasPrefix(s, ne.Seat+".") { + // The catalog writes a served seat verb as `seat:.` (as the compose words above are made). + if strings.HasPrefix(strings.TrimPrefix(s, "seat:"), ne.Seat+".") { return entries[name], true } } @@ -410,7 +411,7 @@ func programOfEntry(e meshcatalog.CatalogEntry) (buildstep.RunProgram, error) { // programs answers, per machine, the composer its run builds (A-226, A-243, A-252): where the revision's node-engine entry differs // from the trunk's, that build for every machine; else the build the machine's node-engine runs, as its `running` says, its entry -// read through mesh-catalog's `entry`. +// read through mesh-catalog's `entry`; a machine whose node-engine's `running` is not heard gets the revision's entry, said (A-451). func (r *compositionRun) programs(half mcc.Half) (func(node string) (buildstep.RunProgram, error), error) { engine, ok := nodeEngineEntry(half.Entries) if !ok { @@ -425,7 +426,9 @@ func (r *compositionRun) programs(half mcc.Half) (func(node string) (buildstep.R return func(node string) (buildstep.RunProgram, error) { running, ok := r.running(node, engine.Module) if !ok || running.Fingerprint == "" { - return buildstep.RunProgram{}, fmt.Errorf("no build of %s is heard running there", engine.Module) + r.logf("%s: no build of %s is heard running there, so its composer is the catalog revision's entry %s (A-451)", node, + engine.Module, engine.Fp) + return programOfEntry(engine) } mu.Lock() p, ok := byFp[running.Fingerprint] diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go index fa0ca057..fe99d51d 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go @@ -71,7 +71,8 @@ func newRunStand(t *testing.T, revisionEngine, trunkEngine, seatDigest string) * } return nil, errors.New("no such verb " + key) } - engines := func(node, _ string, _ any) (json.RawMessage, error) { + engines := func(key string, _ any) (json.RawMessage, error) { + _, node, _ := strings.Cut(key, "@") // addressed to one node (A-237b) return json.RawMessage(`{"candidate":"main.7","node":"` + node + `","verdict":"composed","input":{"node":"` + node + `"},"modules":[],"own":{},"took":1,"v":1}`), nil } running := map[string]string{"ace": "src2:e1", "g14": "src2:e2"} @@ -80,7 +81,7 @@ func newRunStand(t *testing.T, revisionEngine, trunkEngine, seatDigest string) * keeper := testKeeper(&objectsMem{objs: map[string][]byte{}}, time.Now) ends := &runEnds{} s.r = &compositionRun{ - inputs: &compositionInputs{machines: func(string, string) []string { return []string{"ace", "g14", "shanks"} }, call: engines, bound: time.Second}, + inputs: &compositionInputs{machines: func(string, string) []string { return []string{"ace", "g14", "shanks"} }, callFile: engines, bound: time.Second}, keeper: keeper, call: call, ends: ends, away: away, now: time.Now, logf: t.Logf, trunk: func() (mcc.Half, bool) { return mcc.Half{Entries: map[string]meshcatalog.CatalogEntry{"engine": engine(trunkEngine, commitE1)}}, true @@ -117,7 +118,7 @@ func newRunStand(t *testing.T, revisionEngine, trunkEngine, seatDigest string) * // Design 47 G §354, §63, §64, A-226, A-238, A-240, A-243, A-252, A-254, A-261: one request and one run ask per machine, the request // depth compose with the one machine and one case `change`, its manifests, verdicts and seats from the step's revision; the // composer is the node-engine build each machine runs, its entry read through `entry`, or the revision's where it differs from the -// trunk's; the run's verdict is read from its step-ended; a machine away passes with a warning, one not composing fails the step. +// trunk's, or the revision's for a machine whose node-engine is not heard running (A-451); the run's verdict is read from its step-ended; a machine away passes with a warning, one not composing fails the step. func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) { step := meshwants.StepRun{Module: "m", Branch: "main", Revision: 7, Step: meshwants.StepRunStepComposition} s := newRunStand(t, "src2:e1", "src2:e1", "d1") @@ -159,6 +160,18 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) { t.Errorf("the change's node-engine does not compose every machine: %+v %+v %v", changed.asks["ace"].Run.Program, changed.asks["g14"].Run.Program, changed.entries) } + // No running of the node-engine is heard on g14: its composer is the revision's entry, and no entry is asked for it (A-451). + unheard := newRunStand(t, "src2:e1", "src2:e1", "d1") + unheard.r.running = func(node, module string) (ne.Running, bool) { + return ne.Running{Node: node, Module: module, Fingerprint: "src2:e1"}, node == "ace" && module == "engine" + } + if out := unheard.r.run(context.Background(), "ask-step", step); out.Outcome != meshwants.StepEndedOutcomeFailed || !strings.Contains(out.Said, "g14 does not compose") { + t.Fatalf("the step with g14's node-engine not heard came to %+v", out) + } + if unheard.asks["g14"].Run == nil || unheard.asks["g14"].Run.Program.Commit != commitE1 { + t.Errorf("g14's composer with no running heard is %+v, want the revision's entry", unheard.asks["g14"].Run) + } + // A seat digest neither the revision nor the trunk holds: could not run, naming the seat and the digest (A-261). other := newRunStand(t, "src2:e1", "src2:e1", "d2") if out := other.r.run(context.Background(), "ask-step", step); out.Outcome != meshwants.StepEndedOutcomeCouldNotRun || diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/delivered.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/delivered.go index c49f7e43..ced1cd13 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/delivered.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/delivered.go @@ -365,6 +365,7 @@ func (p *passer) holdForDelivery(ctx context.Context, module, fp, branch string, } kept := deliveryWaiting{Wait: body} p.put(ctx, buckets.DeliveryWaits(), key, func() ([]byte, error) { return json.Marshal(kept) }) + p.logf("%s at %s on %s waits for the delivery of its dependency %s on %s: the rules write no want of it until then (design 47 G §376)", module, shortHex(fp), branch, body.On, strings.Join(body.Machines, ", ")) return true } diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/graphkept.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/graphkept.go index d8a20de6..6e6c14d5 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/graphkept.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/graphkept.go @@ -178,15 +178,59 @@ func (p *passer) sayWanted(node, module, fp string, removed bool) { // namedBuild answers what a want of module at fp names of its build (design 47 G §379, §526, A-96): a kept build's or another watched // branch's parts and keeping node from the builder's `build.ended`; for the trunk's entry (fp is the module's, trunkFP), the released -// version and the parts of the `version-released` whose source is the one the kept assignment graph revision was computed from (A-67). -func (p *passer) namedBuild(module, trunkFP string) func(fp string) (assign.KeptBuild, bool) { +// version and the parts of the `version-released` of the module whose source is the one its fingerprint was built at, the entry's +// `fp-src` (A-419: a merge that does not rebuild the module leaves it so), or for an entry naming none the one whose parts are the +// digests its build.ended made (A-421). A trunk entry whose release is not heard is said, once, naming which was tried. +func (p *passer) namedBuild(module, trunkFP string, fpSrc int64, unreleased ...bool) func(fp string) (assign.KeptBuild, bool) { return func(fp string) (assign.KeptBuild, bool) { if k, ok := p.w.ends.partsOf(module, fp); ok { return k, true } - if fp != trunkFP || p.graph == nil || !p.graph.ok { + if len(unreleased) > 0 && unreleased[0] && fp == trunkFP { + // Wanted with no passed pipeline (the holder of mesh-catalog, the runner's first start): no pipeline released it, + // so its want names the parts its build.ended made, until a release of it is heard (design 47 G §16, A-428). + if k, ok := p.w.released.withParts(module, p.w.ends.madeOf(module, fp)); ok { + return k, true + } + if made := p.w.ends.madeOf(module, fp); len(made) > 0 { + return assign.KeptBuild{Parts: made}, true + } + } + if fp != trunkFP { return assign.KeptBuild{}, false } - return p.w.released.of(module, p.graph.source) + if p.graph == nil || !p.graph.ok { + p.unheardRelease(module, fp, "no assignment graph revision is kept yet, so no release is looked up") + return assign.KeptBuild{}, false + } + if fpSrc == 0 { + // No fp-src (its fingerprint moved with no merge): the release whose parts are what its build made (A-421). + if k, ok := p.w.released.withParts(module, p.w.ends.madeOf(module, fp)); ok { + return k, true + } + p.unheardRelease(module, fp, "its catalog entry names no fp-src, and no version-released of it names the parts its build.ended made") + return assign.KeptBuild{}, false + } + k, ok := p.w.released.of(module, fpSrc) + if !ok { + p.unheardRelease(module, fp, fmt.Sprintf("no version-released of it from source %d, the one its fingerprint was built at, is heard", fpSrc)) + } + return k, ok + } +} + +// unheardRelease says once per module, fingerprint and why that a trunk entry's release is not heard, so its wants and candidates +// carry no version and no parts (design 47 G A-419). +func (p *passer) unheardRelease(module, fp, why string) { + key := "release " + module + "@" + fp + ": " + why + if p.skipped[key] { + return + } + if p.skipped == nil { + p.skipped = map[string]bool{} + } + p.skipped[key] = true + if p.logf != nil { + p.logf("the release of %s at fingerprint %s is not heard: %s; its wants and candidates carry no version and no parts", module, fp, why) } } diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halves.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halves.go index 558657ac..49dad157 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halves.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halves.go @@ -51,9 +51,39 @@ func (h *halves) follow() error { h.mu.Lock() h.branches = b h.mu.Unlock() + h.settleWhenNoBranch() return nil } +// settleWhenNoBranch tells the first pass once, when the registrations and the gate's source are answered and name no branch: the +// trunk is none-yet and the world is empty, as the catalog client's Ready says it (design 47 G, A-372). A mesh that names a branch is +// told by adopted, when that branch's first view is answered. +func (h *halves) settleWhenNoBranch() { + if h.settled == nil { + return + } + h.mu.Lock() + b := h.branches + h.mu.Unlock() + go func() { + select { + case <-b.FirstViews(h.ctx): + case <-h.ctx.Done(): + return + } + if len(b.Followed()) > 0 || b.Ready() != nil { + return + } + h.mu.Lock() + told := h.told + h.told = true + h.mu.Unlock() + if !told { + h.settled <- struct{}{} + } + }() +} + // first is the first watched branch followed, the trunk's: "" while none is. func (h *halves) first() string { h.mu.Lock() @@ -118,6 +148,11 @@ func (h *halves) changed(branch, module string, raw json.RawMessage, deleted boo func fromEntry(e meshcatalog.CatalogEntry) (meshcatalog.ModulesByModuleValue, graph.Node, *parsed) { v := meshcatalog.ModulesByModuleValue{Commit: e.Commit, Fp2: e.Fp, Needs: e.Needs, None2: e.None, Packages: e.Packages, Path: e.Path, Repository: e.Repository, Verdict: e.Verdict} + // The source revisions it was taken in at and its fingerprint was built at: the release of a trunk build is matched by the + // latter (design 47 G A-419). + if e.Inputs != nil { + v.Src, v.FpSrc = e.Inputs.Src, e.Inputs.FpSrc + } n := graph.Node{FP: e.Fp, None: e.None, Repository: e.Repository, Path: e.Path, Bases: e.Bases, Provides: e.Provides, Requires: e.Requires, Awaits: e.Awaits, Invokes: e.Invokes, Serves: e.Serves, LeftOut: e.LeftOut} for p := range e.Packages { diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halvesnone_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halvesnone_test.go new file mode 100644 index 00000000..18c4c33c --- /dev/null +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halvesnone_test.go @@ -0,0 +1,50 @@ +package main + +import ( + "context" + "encoding/json" + "testing" + "time" + + mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" + seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + "git.novox.be/novox/mesh-sdk/go/views" +) + +// Design 47 G A-372: the assigner's wait for its catalog half asks the catalog client's Ready as well: a mesh whose registrations and +// gate's source are answered and name no branch is none-yet, and the first pass is told so once; before they answer it is not told. +func TestAMeshThatNamesNoBranchSettlesTheAssignersFirstPass(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + defer cancel() + call := func(key string, _ any) (json.RawMessage, error) { + if key == mcc.RegistrationsVerb { + return json.Marshal(seat.RegistrationsAnswer{Registrations: []seat.Registration{}}) + } + return json.Marshal(map[string][]string{"branches": {}}) + } + for _, answered := range []bool{false, true} { + settled := make(chan struct{}, 2) + reader := &views.ProcessReader{Module: "mesh-delivery-assigner", Call: call, Logf: t.Logf} + h := &halves{w: newWorld(), call: call, reader: reader, wake: func() {}, logf: t.Logf, ctx: ctx, settled: settled} + if err := h.follow(); err != nil { + t.Fatal(err) + } + if answered { + for _, f := range reader.Followers() { + if err := f.Start(ctx); err != nil { + t.Fatal(err) + } + } + select { + case <-settled: + case <-ctx.Done(): + t.Fatal("a mesh that names no branch never settled the first pass") + } + } + select { + case <-settled: + t.Errorf("answered %v: the first pass was told twice or before the first views", answered) + default: + } + } +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go index 899fe7a1..1c6e113b 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go @@ -208,7 +208,7 @@ func startBed(t *testing.T, leaveOut string) *bed { } // The builder's stream of build ends, kept last per subject (its manifest's `last-per-subject`, design 47 G A-181), which the assigner // reads whole at its start and follows through its durable, as the grants part makes it (from the last of each subject). - if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: buildsStreamName, Subjects: []string{process.ModuleStreamSubject(builds.BuilderModule, builds.BuildEndedEvent+".>")}, MaxMsgsPerSubject: 1}); err != nil { + if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: buildsStreamName, Subjects: []string{process.ModuleStreamSubject(builds.BuilderModule, builds.BuildEndedEvent+".>")}, MaxAge: 168 * time.Hour}); err != nil { // kept by age, as the bus keeps it live (2026-11-15): read whole from its first message all the same (A-233) t.Fatal(err) } if _, err := js.CreateOrUpdateConsumer(ctx, buildsStreamName, jetstream.ConsumerConfig{Durable: "n1_mesh-delivery-assigner", AckPolicy: jetstream.AckExplicitPolicy, diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go index ef9a14aa..4d3da00a 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go @@ -587,7 +587,8 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber, } } p := &passer{kvs: kvs, w: w, logf: logger.Printf, say: say, findings: findings, said: map[string]bool{}, answeredAt: map[string]uint64{}, - reads: reads, seats: gate} + reads: reads, seats: gate, askForFile: getenv("MESH_ASSIGNER_ASK_OPERATOR_FOR_FILE")} + p.askOperatorFor() // the setting ask-operator-for said once at the start (design 47 G A-425a) // The wait on an outside cause (outside.go, design 47 G §706): the keeper's three events say when to judge again, and the // seat mesh-wants' wait-held and wait-ended are said; registered before the hub starts. if bus != nil && kvs[buckets.Waits()] != nil { @@ -674,7 +675,7 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber, } // The composition step (design 47 G §22, §354): the seat mesh-wants' accepted kind step, run by one run ask per machine. if bus != nil && js != nil && inputs != nil && p.publishWants != nil { - run := &compositionRun{inputs: &compositionInputs{machines: w.machinesOf, call: bus.CallKeptOn}, keeper: inputs, call: bus.CallKept, + run := &compositionRun{inputs: &compositionInputs{machines: w.machinesOf, callFile: bus.CallFile}, keeper: inputs, call: bus.CallKept, trunk: trunkOf(iv, w.trunkName), running: w.runningOf, away: away, put: runAskPublisher(js), ends: ends, ask: bus.CallFile, now: time.Now, logf: logger.Printf} steps := &compositionSteps{node: thisNode, say: p.publishWants, run: run.run, now: time.Now, logf: logger.Printf, asker: stepAskerOf(seatlist.Definition(gate.Reader, meshwants.Seat))} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/nodeengineentry_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/nodeengineentry_test.go new file mode 100644 index 00000000..135d72c7 --- /dev/null +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/nodeengineentry_test.go @@ -0,0 +1,26 @@ +package main + +import ( + "testing" + + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" +) + +// The module claiming the seat node-engine is found by its served verbs, in the catalog's form `seat:.` +// and in the bare form (live, 2026-11-16: every composition step said "holds no module claiming the seat node-engine"). +func TestTheNodeEngineEntryIsFoundByItsServedVerbs(t *testing.T) { + for _, c := range []struct { + name string + serves []string + found bool + }{ + {"the catalog's seat form", []string{"seat:node-engine.compose", "seat:node-engine.acts"}, true}, + {"the bare form", []string{"node-engine.compose"}, true}, + {"another seat", []string{"seat:node-engine-x.compose", "seat:mesh-wants.ask"}, false}, + } { + e, ok := nodeEngineEntry(map[string]meshcatalog.CatalogEntry{"other": {Serves: []string{"seat:mesh-builds.ask"}}, "engine": {Serves: c.serves}}) + if ok != c.found || (ok && e.Serves[0] != c.serves[0]) { + t.Errorf("%s: found %v (%v), want %v", c.name, ok, e.Serves, c.found) + } + } +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go index b9a59b6e..511d18a8 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" "errors" + "fmt" "maps" "mesh-delivery-assigner/internal/buckets" "slices" @@ -23,8 +24,10 @@ import ( "git.novox.be/novox/mesh-sdk/go/seatlist" "sync" + "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel" "git.novox.be/novox/mesh-contracts/provisioning/go/clients/meshprovisionerclient" + mpr "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph" "git.novox.be/novox/mesh-sdk/go/catalogue" @@ -47,6 +50,14 @@ type passer struct { // pass says a condition once and a restart says it again (the router keeps one per key). say func(oc.Condition) error said map[string]bool + // askForFile is the file of the setting ask-operator-for, askFor the kinds read last (design 47 G A-425a). + askForFile string + askFor []string + // skipped are the added modules whose absence from a candidate's added was said (skippedAdd), and the trunk entries whose + // release is not heard (unheardRelease), once each. + skipped map[string]bool + // whys is, by key, the why of a want this process last wrote, the time aside (why.go). + whys map[string]string // findings is the assigner's findings bucket (its said conditions, ADR 0564 §2). findings assign.Findings // calls is the wait of the kept manifest-reads calls (enginereads.ReadsCalls, ADR 0668 §3), made at the first pass. @@ -87,6 +98,7 @@ type passer struct { // laid again is not ended on a seat it does not name (ADR 0636 §1). Nil reads nothing. seats *seatlist.Part seatWaitSaid sync.Once + derivedSaid map[string]bool // each seat-holders key last written as derived from a claim (A-400), so each is said once publish publisher saidProposed map[string]bool // copied says the retired state was copied into `assignments` by this process, or found empty (copyRetired). @@ -220,6 +232,9 @@ func (p *passer) pass(ctx context.Context) { p.deliveredAgain(ctx) if p.graph == nil || !p.graph.full { // a full assignment graph store keeps the last revision and writes no new want (design 47 G §181) p.wants(ctx) + p.sayPass(ctx, "judged") + } else { + p.sayPass(ctx, "the assignment graph store is full: no want is written (design 47 G §181)") } p.puts(ctx) p.nodeWants(ctx) @@ -276,7 +291,7 @@ func (p *passer) wants(ctx context.Context) { missing := map[string]bool{} defer func() { p.provisionsMissing(ctx, missing) }() defer p.unplacedFindings() - defer p.seatHolders(ctx) + defer func() { p.seatHolders(ctx, viewOf(p.w.trunkName()).manifests) }() p.clearStaleCalls() placed := p.w.placedNodes() puts := p.putsByModule() @@ -320,10 +335,31 @@ func (p *passer) wants(ctx context.Context) { branches = []string{g.branch} } if fp != "" && !p.ends.mayWant(name, fp, branches, wantedOf[name]) { - return + if !runnerFirstStart(name, manifests, p.w.runningNow()) && !manifests[name].ClaimsSeat(meshcatalog.Seat) { + none := assign.Outcome{Rules: noPipelineRules(g.nodes, name, fp, branches)} + p.sayNoWant(name, g.nodes, wantedOf[name], none) + p.sayWhy(ctx, name, g.nodes, wantWhy{Branch: g.branch, Fp: fp, Step: whyNoPipeline}, wantedOf[name], &none, nil) + return + } + // The first start of the pipeline runner (design 47 G A-428): no runner runs to pass its pipeline, so its want is + // written from the trunk's entry by the other rules, and said once. So is the holder of mesh-catalog's: every + // pipeline runs on a revision it took in, and a revision naming a newer one is taken in only by that one (§16, + // G-5's whole test of indexer and assigner: the new indexer is wanted and granted, starts, and takes it in). + if key := "no-pipeline-start " + name + "@" + fp; !p.skipped[key] { + if p.skipped == nil { + p.skipped = map[string]bool{} + } + p.skipped[key] = true + if manifests[name].ClaimsSeat(meshcatalog.Seat) { + p.logf("%s at %s is wanted with no passed pipeline: it claims the seat %s, every pipeline runs on a revision it took in, and a revision naming it is taken in only by it (design 47 G §16)", name, shortHex(fp), meshcatalog.Seat) + } else { + p.logf("%s at %s is wanted with no passed pipeline: it claims the seat %s and no module holding that seat runs on any node, so none can pass one (design 47 G A-428)", name, shortHex(fp), mpr.Seat) + } + } } // A dependent's new version waits for its dependency's newest released version to be delivered (§376, A-189). if p.holdForDelivery(ctx, name, fp, g.branch, g.nodes) { + p.sayWhy(ctx, name, g.nodes, wantWhy{Branch: g.branch, Fp: fp, Step: whyDelivery, Words: p.saidDeliveryWaits()[name].Wait.On}, wantedOf[name], nil, nil) return } m := assign.Module{Name: name, FP: fp, Manifest: manifests[name], Needs: trunk[name].Needs, Chosen: chosenOf(chosen, name), Provisions: provisionsOf(name), Answering: answering(manifests, nodes), Offered: offered(manifests), Nodes: nodesOf[name], Now: time.Now(), Puts: puts[name], FormNeeds: p.w.buildNeeds(name, fp), @@ -347,11 +383,17 @@ func (p *passer) wants(ctx context.Context) { held, _ := mwc.HeldKey(name, fp) grant, _ := grantsstate.PartGrantKey(name, fp) hold, _ := asks.HoldAskKey(name, fp) - m.KeptBuilds = p.namedBuild(name, m.FP) + noPipeline := runnerFirstStart(name, manifests, p.w.runningNow()) || manifests[name].ClaimsSeat(meshcatalog.Seat) + m.KeptBuilds = p.namedBuild(name, m.FP, trunk[name].FpSrc, noPipeline) m.Released = p.answeredWith(hold, "release") m.Kept = p.answeredWith(hold, "keep") m.Built, m.Held, m.Granted = p.w.built(name, fp), p.w.has(buckets.Wants(), held) && !m.Released, p.w.has(grants, grant) m.BuildFailed, m.BuildError = p.w.buildStanding(name, fp) + // A build whose version is released counts as done for rule 1; its build.ended counts only for a build not + // released (design 47 G A-429), so a restart that lost the end loses nothing of a released build. + if releasedBuild(m.KeptBuilds, fp) { + m.Built, m.BuildFailed, m.BuildError = true, false, "" + } if raw := p.w.value(grants, grant); raw != nil { if g, err := grantsstate.DecodeGrant(raw); err == nil { m.GrantedOn = func(node string) bool { return assign.GrantNamesNode(g, node, name) } @@ -377,6 +419,8 @@ func (p *passer) wants(ctx context.Context) { actingOf, orderOf := p.actingOf(name, released), p.orderActing(name, released, unread, func() assign.Nodes { return nodes }) m.Acting = func(node string) []assign.ActingEdge { return append(actingOf(node), orderOf(node)...) } out := assign.Wants(m, nodes, wantedOf[name], last) + p.sayWhy(ctx, name, m.Nodes, wantWhy{Branch: g.branch, Fp: fp, Step: whyRules}, wantedOf[name], &out, &m) + p.sayParts(name, m, nodes, out, wantedOf[name]) for _, node := range m.Nodes { for _, prov := range m.MissingProvisions(node) { missing[node+"."+name+"."+prov] = true @@ -1041,7 +1085,7 @@ func (p *passer) backups(ctx context.Context, reverting map[string]bool) { continue } current, currentAsk, there := assign.DecodeAsk(akey, p.w.read(buckets.Asks())[akey]) - if there != nil || assign.BackupAskDigest(current) != want.Composed { + if there != nil || assign.BackupAskDigest(current) != assign.ShortDigest(want.Composed) { after := -1 if there == nil { after = current.Asking @@ -1319,7 +1363,10 @@ func (p *passer) unplacedFindings() { // seat held once, ``, and one per node of a node seat, `.`, written only where it differs, and a key no // assignments holds any more deleted. A pass follows each assignments change and each manifest the indexer takes in, so no // timer writes it. -func (p *passer) seatHolders(ctx context.Context) { +// +// A seat no assignments holds is held by the first assigned module whose manifest of the trunk claims it (lead answer A-400): +// manifests is the trunk's, by module. Each holder so derived is said once while it stays derived. +func (p *passer) seatHolders(ctx context.Context, manifests map[string]catalogue.Manifest) { kv := p.kvs[plc.SeatHoldersBucket()] if kv == nil { return @@ -1336,7 +1383,20 @@ func (p *passer) seatHolders(ctx context.Context) { } return } - want := plc.SeatHoldersOf(assignments) + want, derived := plc.SeatHoldersWithClaimants(assignments, manifests) + now := map[string]bool{} + for _, d := range derived { + now[d] = true + if !p.derivedSaid[d] { + p.logf("seat-holders: the seat %s: no holding on record, written as held by the assigned module whose manifest claims it (A-400)", d) + } + } + for d := range p.derivedSaid { + if !now[d] { + p.logf("seat-holders: the seat %s is no longer derived (a holding is on record, or nobody assigned claims it)", d) + } + } + p.derivedSaid = now have := p.w.read(plc.SeatHoldersBucket()) for key, sh := range want { value, err := json.Marshal(sh) @@ -1469,3 +1529,75 @@ func wantedHere(wanted map[string]mwc.Want, own []string, groups []group, first } return out } + +// noPipelineRules is why each node of module gets no want while no pipeline passed at fp on its branches (design 47 G §29): said as +// any rule's reason (sayNoWant), once. +func noPipelineRules(nodes []string, module, fp string, branches []string) map[string]assign.Holding { + out := map[string]assign.Holding{} + for _, node := range nodes { + out[node] = assign.Holding{Rule: mwc.RuleNotHeld, Words: fmt.Sprintf("no pipeline of %s passed at %s on %s, and a want follows a passed pipeline (design 47 G §29)", + module, shortHex(fp), strings.Join(branches, ", "))} + } + return out +} + +// runnerFirstStart says whether module claims the seat mesh-pipeline-runner while no module claiming it runs on any node (design 47 +// G A-428): read from the node-engine seat's running statements the assigner hears, each module's claims from its manifest. With +// no running heard yet it says false: the gate stands until the assigner knows. +func runnerFirstStart(module string, manifests map[string]catalogue.Manifest, running map[string]map[string]nodeengine.Running) bool { + if !manifests[module].ClaimsSeat(mpr.Seat) || running == nil { + return false + } + for _, mods := range running { + for m, r := range mods { + if !r.Stopped && r.Fingerprint != "" && manifests[m].ClaimsSeat(mpr.Seat) { + return false + } + } + } + return true +} + +// releasedBuild says whether the build at fp is a released version's, as a want of it names it (namedBuild): such a build counts as +// done for rule 1 whatever the builder's build.ended said or the assigner kept of it (design 47 G A-429). +func releasedBuild(named func(fp string) (assign.KeptBuild, bool), fp string) bool { + if named == nil { + return false + } + k, ok := named(fp) + return ok && k.Version != "" +} + +// sayParts says once per node, module and reason why a want the pass writes or keeps at the module's fingerprint names no parts +// (design 47 G §379, §525, §526): whether the node's engine reads a want's parts (its record's capabilities, its manifest reads) +// and whether the build has a release or a kept build the want could name. +func (p *passer) sayParts(name string, m assign.Module, n assign.Nodes, out assign.Outcome, before map[string]mwc.Want) { + for _, node := range m.Nodes { + w, ok := out.Wants[node] + if !ok { + w, ok = before[node] // kept as it stands this pass + } + if !ok || w.Removed || w.Fp == "" || len(w.Parts) > 0 || w.Version != "" { + continue + } + reads := n.ReadsParts(node) + var k assign.KeptBuild + found := false + if m.KeptBuilds != nil { + k, found = m.KeptBuilds(w.Fp) + } + why := fmt.Sprintf("its engine reads parts: %v (capabilities %v); a release or kept build of %s found: %v", reads, n.Capable[node], shortHex(w.Fp), found) + if found && len(k.Parts) == 0 { + why += ", naming no parts" + } + key := "parts " + node + "." + name + "@" + w.Fp + ": " + why + if p.skipped[key] { + continue + } + if p.skipped == nil { + p.skipped = map[string]bool{} + } + p.skipped[key] = true + p.logf("the want of %s on %s names no version and no parts: %s", name, node, why) + } +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go index 97d0d04c..86dfc7f4 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go @@ -10,6 +10,8 @@ import ( "maps" "mesh-delivery-assigner/internal/buckets" "mesh-delivery-assigner/internal/puts" + "os" + "path/filepath" "slices" "strings" "testing" @@ -1327,6 +1329,31 @@ func TestAnApprovedAssignmentsCallsNoControllerVerb(t *testing.T) { if len(bus.calls) != 0 || !slices.Equal(said, []string{mma.EventAssignmentsChanged}) { t.Fatalf("calls = %d, said = %v", len(bus.calls), said) } + // Design 47 G A-425a: the setting ask-operator-for says which change kinds are asked; its default is take-off, remove-node and + // stops; a kind it does not know is left out; it is read from its file at each pass and a change of it is said. + if k, u := parseAskOperatorFor(""); !slices.Equal(k, []string{"take-off", "remove-node", "stops"}) || u != nil { + t.Errorf("the default = %v %v", k, u) + } + if k, u := parseAskOperatorFor("place, Stops,typo"); !slices.Equal(k, []string{"place", "stops"}) || !slices.Equal(u, []string{"typo"}) { + t.Errorf("parsed %v, unknown %v", k, u) + } + file := filepath.Join(t.TempDir(), "ask-operator-for") + var logs []string + p.logf = func(f string, a ...any) { logs = append(logs, fmt.Sprintf(f, a...)) } + p.askForFile = file + if p.asksFor([]string{"place"}) || !p.asksFor([]string{"place", "take-off"}) { + t.Error("with no file, a place alone is asked or a take-off is not") + } + if err := os.WriteFile(file, []byte("place"), 0o600); err != nil { + t.Fatal(err) + } + if !p.asksFor([]string{"place"}) || p.asksFor([]string{"take-off"}) || len(logs) != 2 || !strings.Contains(logs[1], "the setting ask-operator-for is place") { + t.Errorf("after the setting changed to place: logs %q", logs) + } + stopping := mma.Verdict{Answers: map[string]map[string]any{"anchor": {"removed": []any{"db"}}}} + if got := proposalKinds(mma.Proposal{Changes: []mma.ProposalChange{{Op: "place"}, {Op: "pin"}, {Op: "place"}}}, stopping); !slices.Equal(got, []string{"pin", "place", "stops"}) { + t.Errorf("proposal kinds = %v, want pin, place and stops", got) + } var conds []oc.Condition p.say = func(c oc.Condition) error { conds = append(conds, c); return nil } @@ -1390,6 +1417,21 @@ func aWantWaitsOnTheVerbEdgesTheGraphKeeps(t *testing.T) { t.Errorf("served(%s) = %v, want %v: the running server's manifest serves w alone, late's is not read", v, served(v), want) } } + // A-426a: a healthy build held (no catalog entry of it) or waiting for a yes serves what it serves, said once; one held unhealthy, + // or whose running statement says it stopped, does not. + held := at(fp("2")) + held.Phase = nodeengineclient.PhaseHeld + served = p.served(g, assign.Nodes{Haves: map[string]map[string]nodeengine.HaveByNodeModuleValue{"novox": {"late": held}}}) + if !served("late.t") { + t.Error("a healthy held build of late does not serve late.t") + } + stopped := assign.Nodes{Haves: map[string]map[string]nodeengine.HaveByNodeModuleValue{"novox": {"late": held}}, + Running: map[string]map[string]nodeengine.Running{"novox": {"late": {Stopped: true}}}} + sick := held + sick.Health = "failed" + if p.served(g, stopped)("late.t") || p.served(g, assign.Nodes{Haves: map[string]map[string]nodeengine.HaveByNodeModuleValue{"novox": {"late": sick}}})("late.t") { + t.Error("a held build stopped, or not healthy, serves late.t") + } // ADR 0614 §5: bus-state counts as offered only from a healthy build on a node present; the bus module's build on an // offline node offers nothing, and one whose manifest is not read counts its trunk manifest's offer. A-352: a have waiting // for a person's yes on a newer build names the build that still runs, healthy, and it offers bus-state too. diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines.go index 8c1eef61..03c481d2 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines.go @@ -344,8 +344,12 @@ func hearEnds(hub *process.EventHub, e *pipelineEnds) error { // writtenTools is the tool assigner_written: every key of the state written, with its end. func writtenTools(st store) []stdio.Tool { - return []stdio.Tool{{Name: writtenTool, Description: "the pipeline ends the assigner's wants follow: per module and watched branch, the source revision and end count of the newest end heard, whether it passed and whether the wants were written from it.", - Run: func(map[string]any) (any, error) { + return []stdio.Tool{{Name: writtenTool, Description: "the pipeline ends the assigner's wants follow: per module and watched branch, the source revision and end count of the newest end heard, whether it passed and whether the wants were written from it; with why, why each want is what it is (as assigner_why).", + Input: schema(map[string]string{"why": "true: why each want is what it is", "module": "with why: a module's name", "node": "with why: a node's name"}, nil, "why"), + Run: func(args map[string]any) (any, error) { + if args["why"] == true || args["why"] == "true" { + return whyTools(st)[0].Run(args) // a want's why (why.go), until the manifest naming assigner_why is taken in + } ks, err := st.keys(writtenState) if err != nil { return nil, err @@ -353,6 +357,9 @@ func writtenTools(st store) []stdio.Tool { sort.Strings(ks) out := map[string]End{} for _, k := range ks { + if strings.HasPrefix(k, whyPrefix) { + continue // a want's why (why.go), read by assigner_why + } raw, _, ok, err := st.get(writtenState, k) if err != nil || !ok { continue diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines_test.go index 535fa85c..b29ba21d 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines_test.go @@ -196,6 +196,17 @@ func TestAWantFollowsAPassedPipeline(t *testing.T) { t.Error("the runner's member that failed is wanted") } } + // Design 47 G A-428: the runner's first start skips the gate while no module claiming the seat runs; another module never + // does, and a runner running anywhere (stopped ones aside) closes it; with no running heard the gate stands. + manifests := map[string]catalogue.Manifest{"runner": {Claims: []catalogue.Claim{{Name: mpr.Seat}}}, "web": {}} + none := map[string]map[string]nodeengine.Running{"ace": {"web": {Fingerprint: fp1}}} + if !runnerFirstStart("runner", manifests, none) || runnerFirstStart("web", manifests, none) || runnerFirstStart("runner", manifests, nil) { + t.Error("the runner's first start: the runner skips the gate, another module or an unknown world does not") + } + if runnerFirstStart("runner", manifests, map[string]map[string]nodeengine.Running{"novox": {"runner": {Fingerprint: "fp-runner"}}}) || + !runnerFirstStart("runner", manifests, map[string]map[string]nodeengine.Running{"novox": {"runner": {Stopped: true}}}) { + t.Error("a runner running closes the gate's opening; one stopped does not") + } // A want that names the fingerprint already is not held by a later failure (a node placed afterwards gets it). e := newPipelineEnds(newMemEnds(), func() {}, t.Logf) e.on.Store(true) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat.go index 958ef63d..d406ece6 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat.go @@ -266,6 +266,7 @@ func (p *passer) ask(ctx context.Context, prop mma.Proposal, akey, brief string) p.pulse(ctx, pk, assign.ExpiresAt(placed).Sub(p.clock())) } prop.State, prop.Ask = mmac.ProposalAsked, placed.ID + p.logf("the proposal %s is asked of the operator: its ask %s is written under %s, which the teller raises on the operator channel", prop.ID, placed.ID, akey) return prop, true } @@ -346,6 +347,14 @@ func (p *passer) stepProposal(ctx context.Context, prop mma.Proposal, rev uint64 prop.State, prop.Ask = mmac.ProposalAnswering, "" case mdcc.VerdictPass: if prop.State != mmac.ProposalAsked || again { + // A proposal none of whose changes the setting ask-operator-for names is applied at once, with no ask (A-425a). + if kinds := proposalKinds(prop, v); !p.asksFor(kinds) { + words := fmt.Sprintf("applied with no ask: its changes (%s) are none of the kinds the setting ask-operator-for names (%s); proposed by %s: %s", + strings.Join(kinds, ", "), strings.Join(p.askOperatorFor(), ", "), prop.By, prop.Why) + p.logf("the proposal %s is %s", prop.ID, words) + p.apply(ctx, prop, rev, mdc.Answer{Words: words}, current, revs) + return + } var ok bool if prop, ok = p.ask(ctx, prop, akey, judge.Brief(prop, v)); !ok { return @@ -499,6 +508,12 @@ func (p *passer) warranted(ctx context.Context, prop mma.Proposal, rev uint64, a return } answer, _ := p.w.answer(akey) + p.apply(ctx, prop, rev, answer, current, revs) +} + +// apply writes a proposal's laid candidates, its answer carried by assignments-changed: the operator's warranted answer, or the +// words of a proposal applied with no ask (design 47 G A-425a). +func (p *passer) apply(ctx context.Context, prop mma.Proposal, rev uint64, answer mdc.Answer, current map[string]mma.Assignments, revs map[string]uint64) { if moved(prop, revs) { p.layAgain(ctx, prop, rev, current, revs, "a key moved since it was approved, so its warrant is spent") return diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools.go index 0673524f..6be29e84 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools.go @@ -7,6 +7,7 @@ import ( "fmt" "maps" "mesh-delivery-assigner/internal/buckets" + "os" "slices" "sort" "strings" @@ -67,13 +68,17 @@ func indexerView(ask func(string, any) (json.RawMessage, error), state string) ( } page := views.AskVia(ask, tool) out := map[string]json.RawMessage{} + started, pages := time.Now(), 0 for after := ""; ; { a, err := page(context.Background(), after) if err != nil { + fmt.Fprintf(os.Stderr, "mesh-delivery-assigner: %s does not answer page %d after %s: %v\n", tool, pages+1, time.Since(started).Round(time.Millisecond), err) return nil, fmt.Errorf("%s does not answer: %w", tool, err) } + pages++ maps.Copy(out, a.Values) if a.Next == "" || a.Next == after { + fmt.Fprintf(os.Stderr, "mesh-delivery-assigner: %s read, %d values in %d pages, %s\n", tool, len(out), pages, time.Since(started).Round(time.Millisecond)) return out, nil } after = a.Next @@ -103,25 +108,18 @@ type keyed struct { // assignments reads every node's assignments and the revision of its node key (its legacy key's before it is converted), // assembled from its keys in either form (mmac.Keys; research 072 row 37). func (s *seatTools) assignments() (map[string]mma.Assignments, map[string]uint64, error) { - keys, err := s.st.keys(mma.StateAssignments) + all, err := readAll(s.st, mma.StateAssignments) if err != nil { - return nil, nil, fmt.Errorf("assignments cannot be listed: %w", err) + return nil, nil, fmt.Errorf("assignments cannot be read: %w", err) } - sort.Strings(keys) + keys := slices.Sorted(maps.Keys(all)) held := mmac.NewKeys() var bad []string for _, key := range keys { if _, _, _, err := mmac.ParseKey(key); err != nil { continue } - raw, rev, found, err := s.st.get(mma.StateAssignments, key) - if err != nil { - return nil, nil, fmt.Errorf("assignments key %s cannot be read: %w", key, err) - } - if !found { - continue - } - if _, err := held.Put(key, raw, rev, false); err != nil { + if _, err := held.Put(key, all[key].raw, all[key].rev, false); err != nil { bad = append(bad, err.Error()) } } @@ -145,20 +143,18 @@ func (s *seatTools) lays() (func(string) bool, func(string) bool, error) { held[name] = true } } - haves, err := s.st.keys(haveState) + haves, err := readAll(s.st, haveState) if err != nil { - return nil, nil, fmt.Errorf("the nodes' records cannot be listed: %w", err) + return nil, nil, fmt.Errorf("the nodes' records cannot be read: %w", err) } recorded := map[string]bool{} - for _, k := range haves { + for k, v := range haves { node, _, isNode, err := nodeengineclient.ParseHaveKey(k) if err != nil || !isNode { continue } - if raw, _, found, err := s.st.get(haveState, k); err == nil && found { - if h, err := nodeengineclient.DecodeHaveNode(raw); err == nil && h.Record != nil { - recorded[node] = true - } + if h, err := nodeengineclient.DecodeHaveNode(v.raw); err == nil && h.Record != nil { + recorded[node] = true } } return func(m string) bool { return held[m] }, func(n string) bool { return recorded[n] }, nil @@ -239,11 +235,21 @@ func (s *seatTools) doPropose(args map[string]any, by string) (any, error) { return nil, errors.New("the seed is gone with adopt: propose takes place, take-off, pin, unpin, hold, unhold, decide and config") } } + started := time.Now() + step := func(what string, err error) { + if err != nil { + fmt.Fprintf(os.Stderr, "mesh-delivery-assigner: propose by %s: %s failed after %s: %v\n", by, what, time.Since(started).Round(time.Millisecond), err) + return + } + fmt.Fprintf(os.Stderr, "mesh-delivery-assigner: propose by %s: %s at %s\n", by, what, time.Since(started).Round(time.Millisecond)) + } current, revs, err := s.assignments() + step("assignments read", err) if err != nil { return nil, err } held, recorded, err := s.lays() + step("the indexer's modules and the nodes' records read", err) if err != nil { return nil, err } @@ -259,11 +265,15 @@ func (s *seatTools) doPropose(args map[string]any, by string) (any, error) { findings = append(findings, refusal) } if len(findings) > 0 { + step(fmt.Sprintf("refused (%d findings)", len(findings)), nil) return nil, fmt.Errorf("the proposal is refused: %s", strings.Join(findings, "; ")) } + step("judged", nil) if err := s.write(p); err != nil { + step("the proposal "+p.ID+" written", err) return nil, err } + step("the proposal "+p.ID+" written", nil) return proposed{Proposal: p, Follow: followProposal(p.ID)}, nil } @@ -477,21 +487,17 @@ func (s *seatTools) doProposals(args map[string]any) (any, error) { if err != nil { return nil, fmt.Errorf("the candidates cannot be listed: %w", err) } - haves, err := s.st.keys(haveState) + haves, err := readAll(s.st, haveState) if err != nil { - return nil, fmt.Errorf("the nodes' haves cannot be listed: %w", err) + return nil, fmt.Errorf("the nodes' haves cannot be read: %w", err) } answers := map[string]map[string]nodeengine.CandidateAnswer{} // by proposal, then node - for _, k := range haves { + for k, v := range haves { node, _, isNode, err := nodeengineclient.ParseHaveKey(k) if err != nil || !isNode { continue } - raw, _, found, err := s.st.get(haveState, k) - if err != nil || !found { - continue - } - h, err := nodeengineclient.DecodeHaveNode(raw) + h, err := nodeengineclient.DecodeHaveNode(v.raw) if err != nil { continue } diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools_test.go index f1a25eaf..1916b044 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools_test.go @@ -325,11 +325,11 @@ func TestTheSeatsVerbs(t *testing.T) { place("ace", mma.Holding{Claim: "mesh-broker", Scope: "mesh", Module: "nats"}, mma.Holding{Claim: "node-shell", Scope: "node", Module: "web"}) place("g14", mma.Holding{Claim: "node-shell", Scope: "node", Module: "web"}) ctx := context.Background() - if p.seatHolders(ctx); writes != 0 { + if p.seatHolders(ctx, nil); writes != 0 { t.Fatalf("seat-holders was written from an unread seat list: %v", kv.values) } p.seats = gateOver(t, false) - p.seatHolders(ctx) + p.seatHolders(ctx, nil) var broker mma.SeatHolders if err := json.Unmarshal(kv.values["mesh-broker"], &broker); err != nil || broker.Outside { t.Errorf("mesh-broker's holders %+v, %v: a seat the list names is no seat outside it", broker, err) @@ -337,12 +337,12 @@ func TestTheSeatsVerbs(t *testing.T) { if writes != 3 || kv.values["mesh-broker"] == nil || kv.values["node-shell.ace"] == nil || kv.values["node-shell.g14"] == nil { t.Fatalf("%d writes: %v", writes, kv.values) } - p.seatHolders(ctx) + p.seatHolders(ctx, nil) if writes != 3 { t.Errorf("an unchanged assignments wrote %d keys", writes-3) } place("g14") // g14 holds nothing now - p.seatHolders(ctx) + p.seatHolders(ctx, nil) if writes != 3 || kv.values["node-shell.g14"] != nil || kv.values["node-shell.ace"] == nil { t.Errorf("after g14's change: %d writes, %v", writes, kv.values) } @@ -531,6 +531,14 @@ func TestTheSeatsVerbs(t *testing.T) { t.Errorf("keyed again: findings %v", findings) } }) + // A whole state is read in pages where the store has them, never a key at a time (27 s for the assignments live, + // 2026-11-14): the paged read answers what the key-by-key read answers, and asks no key alone. + direct, err := readAll(st, haveState) + paged := &pagedStore{memStore: st} + viaPages, perr := readAll(paged, haveState) + if err != nil || perr != nil || len(viaPages) != len(direct) || paged.pages == 0 || paged.gets != 0 { + t.Errorf("readAll in pages = %d keys in %d pages with %d gets (%v, %v), want the %d keys of the direct read, no get", len(viaPages), paged.pages, paged.gets, err, perr, len(direct)) + } } // wantsVerbs (novox/hq ADR 0565 §7, §8, §9): upgrade answers each module's policy and its source; a person's choice is @@ -943,3 +951,35 @@ func (f *fakeIndexer) answer(key string, body any) (json.RawMessage, bool, error raw, err := json.Marshal(a) return raw, true, err } + +// pagedStore is a memStore whose states are read in pages of one key, counting pages and single gets. +type pagedStore struct { + memStore + pages, gets int +} + +func (p *pagedStore) get(state, key string) ([]byte, uint64, bool, error) { + p.gets++ + return p.memStore.get(state, key) +} + +func (p *pagedStore) page(state, after string) (stdio.StatePage, error) { + p.pages++ + keys, err := p.memStore.keys(state) + if err != nil { + return stdio.StatePage{}, err + } + slices.Sort(keys) + for i, k := range keys { + if k <= after { + continue + } + raw, rev, _, _ := p.memStore.get(state, k) + pg := stdio.StatePage{Entries: []stdio.StateEntry{{Key: k, Value: raw, Revision: rev}}} + if i < len(keys)-1 { + pg.Next = k + } + return pg, nil + } + return stdio.StatePage{}, nil +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/skippedadd_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/skippedadd_test.go new file mode 100644 index 00000000..78893e2c --- /dev/null +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/skippedadd_test.go @@ -0,0 +1,18 @@ +package main + +import ( + "strings" + "testing" +) + +// A module a candidate adds with no release heard is said once, not each pass. +func TestASkippedAddIsSaidOncePerModuleAndFingerprint(t *testing.T) { + var logs []string + p := &passer{logf: func(f string, a ...any) { logs = append(logs, strings.TrimSpace(f)) }} + p.skippedAdd("n", "m", "fp", "why") + p.skippedAdd("n", "m", "fp", "why") + p.skippedAdd("n", "m", "fp2", "why") + if len(logs) != 2 { + t.Fatalf("said %d times, want 2: %v", len(logs), logs) + } +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/store_pages.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/store_pages.go new file mode 100644 index 00000000..4e823727 --- /dev/null +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/store_pages.go @@ -0,0 +1,69 @@ +package main + +import ( + "errors" + "fmt" + "time" + + stdio "git.novox.be/novox/mesh-sdk/go" +) + +// kept is one key's value and revision, as a whole state read gives it. +type kept struct { + raw []byte + rev uint64 +} + +// pager is a store that reads a state's values many to a request (stdio.KeptState.Page): the runtime's store. +type pager interface { + page(state, after string) (stdio.StatePage, error) +} + +// pageBytes and pageBudget bound one page of a whole state read, so its answer fits one bus message and its time. +const ( + pageBytes = 768 * 1024 + pageBudget = 10 * time.Second +) + +func (runtimeStore) page(state, after string) (stdio.StatePage, error) { + return stdio.State(state).Page(after, pageBytes, pageBudget) +} + +// readAll is every key of a state with its value and revision: in pages when the store has them, else key by key. Key by +// key cost one bus request each, so the assignments (about 330 keys) took 27 s to read and a proposal outlasted its +// caller's 30 s (2026-11-14), as the indexer's view of the trunk had the hour before. +func readAll(st store, state string) (map[string]kept, error) { + out := map[string]kept{} + if p, ok := st.(pager); ok { + for after := ""; ; { + pg, err := p.page(state, after) + if errors.Is(err, errors.ErrUnsupported) { + break + } + if err != nil { + return nil, fmt.Errorf("%s cannot be read: %w", state, err) + } + for _, e := range pg.Entries { + out[e.Key] = kept{raw: e.Value, rev: e.Revision} + } + if pg.Next == "" || pg.Next == after { + return out, nil + } + after = pg.Next + } + } + keys, err := st.keys(state) + if err != nil { + return nil, fmt.Errorf("%s cannot be listed: %w", state, err) + } + for _, k := range keys { + raw, rev, found, err := st.get(state, k) + if err != nil { + return nil, fmt.Errorf("%s %s cannot be read: %w", state, k, err) + } + if found { + out[k] = kept{raw: raw, rev: rev} + } + } + return out, nil +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tools.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tools.go index 51803186..f2989df9 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tools.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tools.go @@ -426,6 +426,7 @@ func serveTools() error { // What each node's engine reads, as the assigner uses it (ADR 0618 §3): its own state engine-reads, asked again through it. tools = append(tools, enginereads.Tool(engineReadsTool, "the assigner", enginereads.KeptState(stdio.State(engineReadsState)), false, time.Now)) tools = append(tools, writtenTools(runtimeStore{})...) + tools = append(tools, whyTools(runtimeStore{})...) tools = append(tools, pinsTools(runtimeStore{}, stdio.Ask)...) tools = append(tools, askAgainTools(runtimeStore{}, stdio.Ask, time.Now)...) return stdio.Serve("", tools) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/verbs.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/verbs.go index 369b2c81..ac6766de 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/verbs.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/verbs.go @@ -4,6 +4,7 @@ import ( "slices" "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" + "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-sdk/go/catalogue" @@ -50,7 +51,7 @@ func (p *passer) served(g graph.Graph, n assign.Nodes) func(string) bool { if len(g) == 0 { return nil } - served, unread := graph.Served(n.Haves, func(module, fp string) ([]string, bool) { return p.servesOf(module, fp) }, + served, unread := graph.Served(servingHaves(n, p.countedServing), func(module, fp string) ([]string, bool) { return p.servesOf(module, fp) }, func(module string) []string { return g[module].Serves }) if len(unread) > 0 { p.logf("the manifest of the running build of %v cannot be read, so what the module graph says they serve is counted as served", unread) @@ -108,3 +109,40 @@ func (p *passer) manifestOf(module, fp string) (catalogue.Manifest, bool) { } return got.manifest, true } + +// servingHaves are the haves rule 8 counts (design 47 G A-426, A-426a): a node that runs a healthy build of a part serves what that +// build serves, whatever its version and whether or not the catalog lists it, so a have held (its build has no catalog entry, a +// put holds it) or waiting for a person's yes, whose build runs healthy, counts as running; a running statement that names a build +// stopped, or not healthy, does not. counted is told each build so counted that its phase alone would have left out. +func servingHaves(n assign.Nodes, counted func(node, module string, h nodeengine.HaveByNodeModuleValue)) map[string]map[string]nodeengine.HaveByNodeModuleValue { + out := map[string]map[string]nodeengine.HaveByNodeModuleValue{} + for node, haves := range n.Haves { + out[node] = map[string]nodeengine.HaveByNodeModuleValue{} + for module, h := range haves { + if (h.Phase == nodeengineclient.PhaseHeld || h.Phase == nodeengineclient.PhaseWaitingYes) && h.Health == nodeengineclient.HealthOK { + if r, ok := n.Running[node][module]; !ok || (!r.Stopped && (r.Healthy == nil || *r.Healthy)) { + if counted != nil { + counted(node, module, h) + } + h.Phase = nodeengineclient.PhaseRunning + } + } + out[node][module] = h + } + } + return out +} + +// countedServing says once per node, module and build that rule 8 counted a build whose have is not in phase running as serving +// its verbs (A-426a): the rule says which build it counted. +func (p *passer) countedServing(node, module string, h nodeengine.HaveByNodeModuleValue) { + key := "serving " + node + "." + module + "@" + h.Fp + "." + h.Phase + if p.skipped[key] { + return + } + if p.skipped == nil { + p.skipped = map[string]bool{} + } + p.skipped[key] = true + p.logf("%s on %s runs %s healthy in phase %s: counted as serving what that build serves, whatever its version (design 47 G A-426a)", module, node, shortHex(h.Fp), h.Phase) +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/wants_tools.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/wants_tools.go index 8608def4..2cf52c0e 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/wants_tools.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/wants_tools.go @@ -71,21 +71,15 @@ func (s *wantsTools) values(state string) (map[string][]byte, error) { return s.direct(state) } -// direct reads a state key by key, for a small state of the seat's own. +// direct reads a state whole, in pages where the runtime has them (readAll). func (s *wantsTools) direct(state string) (map[string][]byte, error) { - keys, err := s.st.keys(state) + all, err := readAll(s.st, state) if err != nil { - return nil, fmt.Errorf("%s cannot be listed: %w", state, err) + return nil, err } - out := map[string][]byte{} - for _, k := range keys { - raw, _, found, err := s.st.get(state, k) - if err != nil { - return nil, fmt.Errorf("%s %s cannot be read: %w", state, k, err) - } - if found { - out[k] = raw - } + out := make(map[string][]byte, len(all)) + for k, v := range all { + out[k] = v.raw } return out, nil } diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/why.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/why.go new file mode 100644 index 00000000..54b585f7 --- /dev/null +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/why.go @@ -0,0 +1,155 @@ +package main + +import ( + "context" + "encoding/json" + "sort" + "strings" + "time" + + mwc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshwantsclient" + stdio "git.novox.be/novox/mesh-sdk/go" + + "mesh-delivery-assigner/internal/assign" +) + +// Why a want is what it is (lead-47 2026-11-15, the tools rule: novox's want of the indexer stood unwritten for a day and nothing +// said why). Each pass writes, in the state written beside the pipeline ends, one key `why..`: the step of the pass +// that decided the want and what it read there. A key whose time stands still says the pass no longer judges that module. +// assigner_why reads them. + +// whyPrefix starts every key of a want's why in the state written; a pipeline end's key starts with a module's name. +const whyPrefix = "why." + +// whyTool is the tool that reads them. +const whyTool = "assigner_why" + +// The steps of the pass that decide a want. +const ( + whyNoPipeline = "no-passed-pipeline" // the trunk's fingerprint passed no pipeline on the branch, and no want names it + whyDelivery = "waits-for-delivery" // a dependency's newest released version is not delivered yet + whyRules = "rules" // the six rules judged it +) + +// wantWhy is one key's value. +type wantWhy struct { + At time.Time `json:"at"` + Branch string `json:"branch,omitempty"` + // Fp is the fingerprint the trunk's entry names, the one the pass judged. + Fp string `json:"fp,omitempty"` + Step string `json:"step"` + // Before is the want that stood before the pass, After the one the pass wrote (none: it kept Before). + Before *mwc.Want `json:"before,omitempty"` + After *mwc.Want `json:"after,omitempty"` + // Rule is the rule holding the node back from Fp, with its words. + Rule string `json:"rule,omitempty"` + // What the rules read of the module. + Built, BuildFailed, Held, Granted, Released, Kept bool `json:",omitempty"` + BuildError string `json:"build-error,omitempty"` + Acting []string `json:"acting,omitempty"` + Words string `json:"words,omitempty"` +} + +func whyKey(node, module string) string { return whyPrefix + node + "." + module } + +// sayWhy writes the why of module on each of nodes, once per change (the time aside): every put is a change its watchers hear. +func (p *passer) sayWhy(ctx context.Context, module string, nodes []string, w wantWhy, before map[string]mwc.Want, out *assign.Outcome, m *assign.Module) { + kv := p.kvs[writtenBucket()] + if kv == nil { + return + } + if p.whys == nil { + p.whys = map[string]string{} + } + for _, node := range nodes { + one := w + one.At = time.Now().UTC() + if b, ok := before[node]; ok { + one.Before = &b + } + if out != nil { + if a, ok := out.Wants[node]; ok { + one.After = &a + } + if h, ok := out.Rules[node]; ok { + one.Rule = h.Reason() + } + } + if m != nil { + one.Built, one.BuildFailed, one.BuildError, one.Held, one.Granted, one.Released, one.Kept = m.Built, m.BuildFailed, m.BuildError, m.Held, m.Granted, m.Released, m.Kept + if m.Acting != nil { + for _, e := range m.Acting(node) { + one.Acting = append(one.Acting, e.Step+" "+e.Node+"/"+e.Part+"@"+shortHex(e.Fp)+" (seat "+e.Seat+")") + } + } + } + same := one + same.At = time.Time{} + cmp, _ := json.Marshal(same) + key := whyKey(node, module) + if p.whys[key] == string(cmp) { + continue + } + raw, err := json.Marshal(one) + if err != nil { + continue + } + if _, err := kv.Put(ctx, key, raw); err != nil { + p.logf("the why of %s on %s is not written: %v", module, node, err) + continue + } + p.whys[key] = string(cmp) + } +} + +// whyTools is the tool assigner_why: every want's why, or those of one module or one node. +func whyTools(st store) []stdio.Tool { + return []stdio.Tool{{Name: whyTool, Description: "why a want is what it is: per node and module, the step of the assigner's last pass that decided the want (no passed pipeline, waits for a dependency's delivery, or the six rules with the rule holding it back), the fingerprint the trunk names, the want before and the one written, and what the rules read (built, held, granted, acting waits). A time that stands still says the pass no longer judges that module. Arguments: module and node narrow it.", + Input: schema(map[string]string{"module": "a module's name", "node": "a node's name"}, nil), + Run: func(args map[string]any) (any, error) { + ks, err := st.keys(writtenState) + if err != nil { + return nil, err + } + module, node := arg(args, "module"), arg(args, "node") + sort.Strings(ks) + out := map[string]wantWhy{} + for _, k := range ks { + rest, ok := strings.CutPrefix(k, whyPrefix) + if !ok { + continue + } + n, mod, _ := strings.Cut(rest, ".") + if (module != "" && mod != module) || (node != "" && n != node) { + continue + } + raw, _, ok, err := st.get(writtenState, k) + if err != nil || !ok { + continue + } + var w wantWhy + if json.Unmarshal(raw, &w) == nil { + out[rest] = w + } + } + return out, nil + }}} +} + +// sayPass writes, under `why.pass`, whether the last pass judged the wants at all, once per change of its words. +func (p *passer) sayPass(ctx context.Context, words string) { + kv := p.kvs[writtenBucket()] + if kv == nil { + return + } + if p.whys == nil { + p.whys = map[string]string{} + } + if p.whys[whyPrefix+"pass"] == words { + return + } + raw, _ := json.Marshal(wantWhy{At: time.Now().UTC(), Step: words}) + if _, err := kv.Put(ctx, whyPrefix+"pass", raw); err == nil { + p.whys[whyPrefix+"pass"] = words + } +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/world.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/world.go index c9927d9c..ff932523 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/world.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/world.go @@ -407,8 +407,19 @@ func (w *world) wantsOf() map[string]map[string]mwc.Want { // nodes is what the six rules read of the nodes: presence, haves, and every provision's providers with their nodes. func (w *world) nodes(manifests map[string]catalogue.Manifest, assigned map[string][]string) assign.Nodes { n := assign.Nodes{Online: map[string]bool{}, Running: w.runningNow(), Haves: map[string]map[string]nodeengine.HaveByNodeModuleValue{}, Providers: map[string]map[string][]string{}, - Reads: map[string][]string{}} + Reads: map[string][]string{}, Capable: map[string][]string{}} n.Online = w.online() + // The build a running statement names serves an acting edge's seat when its manifest claims it (design 47 G A-426). + n.Serves = func(r nodeengine.Running, seat string) (bool, bool) { + if r.Manifest == "" { + return false, false + } + got := w.manifest(r.Manifest) + if got.err != "" { + return false, false + } + return got.manifest.ClaimsSeat(seat), true + } for key, value := range w.read(buckets.Have) { node, module, isNode, err := nodeengineclient.ParseHaveKey(key) if err != nil { @@ -418,6 +429,7 @@ func (w *world) nodes(manifests map[string]catalogue.Manifest, assigned map[stri // What the node's engine reads (ADR 0614 §4); a record that states none is read as the baseline. if h, err := nodeengineclient.DecodeHaveNode(value); err == nil && h.Record != nil { n.Reads[node] = h.Record.ManifestReads + n.Capable[node] = h.Record.Capabilities // where a node-engine of G states want-parts (§525) } continue } diff --git a/modules/mesh-delivery-assigner/internal/assign/askjson.go b/modules/mesh-delivery-assigner/internal/assign/askjson.go index c7d9f48f..880b09fb 100644 --- a/modules/mesh-delivery-assigner/internal/assign/askjson.go +++ b/modules/mesh-delivery-assigner/internal/assign/askjson.go @@ -5,6 +5,7 @@ import ( "fmt" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-assigner/asks" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" + "regexp" "time" occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient" @@ -13,6 +14,10 @@ import ( // assignerAsk is the asking-th ask a, as the asks state holds it: the router's ask as JSON (asks.Ask.Ask). func assignerAsk(asking int, a oc.Ask) asks.Ask { + a.Headline, a.Explanation, a.Details, a.OnExpiry = said(a.Headline), said(a.Explanation), said(a.Details), said(a.OnExpiry) + for i := range a.Options { + a.Options[i].Label, a.Options[i].Does = said(a.Options[i].Label), said(a.Options[i].Does) + } raw, err := json.Marshal(a) if err != nil { // an oc.Ask holds only strings, bools and a slice of them: it cannot fail panic(fmt.Sprintf("assign: the ask %q does not marshal: %v", a.ID, err)) @@ -20,6 +25,17 @@ func assignerAsk(asking int, a oc.Ask) asks.Ask { return asks.Ask{Asking: asking, Ask: raw} } +// longHex is a digest or fingerprint whole: 64 hexadecimal digits. +var longHex = regexp.MustCompile(`[0-9a-f]{64}`) + +// said is words as an ask carries them out of the mesh: each digest or fingerprint cut to its first 12 digits, which the +// router lets pass, where it refuses a long hexadecimal string as a secret's shape (mesh-sdk outward; novox 2026-11-16 01:24: +// every backup ask was refused for its "(composition sha256:…)" and the fingerprints in the node's words, and the operator +// was never asked). +func said(words string) string { + return longHex.ReplaceAllStringFunc(words, func(h string) string { return h[:12] }) +} + // AskOf is the router's ask an asks-state value carries. func AskOf(a asks.Ask) (oc.Ask, error) { var ask oc.Ask diff --git a/modules/mesh-delivery-assigner/internal/assign/asks.go b/modules/mesh-delivery-assigner/internal/assign/asks.go index f5359702..f88290fe 100644 --- a/modules/mesh-delivery-assigner/internal/assign/asks.go +++ b/modules/mesh-delivery-assigner/internal/assign/asks.go @@ -288,9 +288,10 @@ func NextBackupAsking(after int) int { return max(after+1, 2) } -var backupDigest = regexp.MustCompile(`\(composition (sha256:[0-9a-f]{64})\)`) +var backupDigest = regexp.MustCompile(`\(composition (sha256:[0-9a-f]{12})\)`) -// BackupAskDigest is the digest of the composition a backup ask was made about, from its explanation; empty for an ask that names +// BackupAskDigest is the digest of the composition a backup ask was made about, from its explanation, cut to its first 12 digits as +// the ask says it (ShortDigest); empty for an ask that names // none. An answer is taken for the composition of the ask it answers, and a new revision at the same fingerprint is asked again // under a new number (ADR 0539 §16). func BackupAskDigest(a asks.Ask) string { @@ -304,6 +305,10 @@ func BackupAskDigest(a asks.Ask) string { return "" } +// ShortDigest is a composition's digest as a backup ask names it, its first 12 digits (said): the ask stays bound to its +// composition, and a new composition is asked again. +func ShortDigest(digest string) string { return said(digest) } + // BackupAnswerWords are the words of a want carrying the answer to the asking-th ask: each asking's answer is another want // value, so a backup that fails again after "back up again" and is answered "again" again changes the key and the node retries. func BackupAnswerWords(option string, asking int) string { diff --git a/modules/mesh-delivery-assigner/internal/assign/asks_test.go b/modules/mesh-delivery-assigner/internal/assign/asks_test.go index 29772b9b..d6ff0f23 100644 --- a/modules/mesh-delivery-assigner/internal/assign/asks_test.go +++ b/modules/mesh-delivery-assigner/internal/assign/asks_test.go @@ -5,6 +5,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-teller/tellerevents" "mesh-delivery-assigner/internal/assignment" "mesh-delivery-assigner/internal/puts" + "regexp" "slices" "strings" "testing" @@ -366,8 +367,13 @@ func TestTheRecordAndBackupAsksAreValid(t *testing.T) { if NextBackupAsking(-1) != 0 || NextBackupAsking(0) != 2 || NextBackupAsking(2) != 3 { t.Errorf("the numbers of the askings: %d %d %d", NextBackupAsking(-1), NextBackupAsking(0), NextBackupAsking(2)) } - if BackupAskDigest(b) != dgst { - t.Errorf("the ask names composition %q, want %q", BackupAskDigest(b), dgst) + if BackupAskDigest(b) != ShortDigest(dgst) || ShortDigest(dgst) == dgst { + t.Errorf("the ask names composition %q, want %q", BackupAskDigest(b), ShortDigest(dgst)) + } + // novox 2026-11-16: the router refuses a long hexadecimal string, so no word of an ask carries a digest or fingerprint whole. + held := BackupAsk(bkey, "novox", "mail", fNew, dgst, "the kept data between "+fNew+" and "+fNew+" is not known", 0, now) + if a := mustAsk(t, held); regexp.MustCompile(`[0-9a-f]{20,}`).MatchString(a.Headline + a.Explanation + a.Details) { + t.Errorf("the ask carries a long hexadecimal string: %q", a.Explanation) } if BackupAnswerWords("again", 0) == BackupAnswerWords("again", 1) { t.Errorf("two answers of the same option are one want value") diff --git a/modules/mesh-delivery-assigner/internal/assign/put.go b/modules/mesh-delivery-assigner/internal/assign/put.go index bec0609e..da2515f2 100644 --- a/modules/mesh-delivery-assigner/internal/assign/put.go +++ b/modules/mesh-delivery-assigner/internal/assign/put.go @@ -79,6 +79,23 @@ func StepPut(w PutWorld) PutNext { if !w.Assigned { return say(puts.Refused, "%s is not assigned to %s: a put moves a module where it stands assigned (propose its assignments first)", w.Module, w.Node) } + if p.Step != puts.Wanted && p.Step != puts.Holding && w.Build == "" { + // Only where the builder's store holds no build of it: one it built goes the put's whole way (composition, the yes). + if r := w.Running; r != nil && !r.Stopped && r.Fingerprint != "" && r.Fingerprint == p.FP { + // The build the node runs now (design 47 G A-427): read from the node's running statement, held there with the + // composition its have names, and the builder's store is not asked for it (a part started by hand has none there). + if h := w.Have; h == nil || h.Fp != p.FP || h.Composed == "" { + return say(puts.Refused, "%s runs %s at %s, and its have names no composition at that fingerprint, so the want cannot name what runs", w.Node, w.Module, fp) + } + p.Composed = w.Have.Composed + words := fmt.Sprintf("the want of %s on %s names %s, the build it runs now (composition %s), from its running statement; the builder's store is not asked", + w.Module, w.Node, fp, short(p.Composed)) + if p.Hold { + words += ", held until released" + } + return PutNext{Put: applied(w, p.Said(w.Now, puts.Wanted, words))} + } + } switch w.Build { case builds.BuildDone: case builds.BuildFailed: @@ -86,8 +103,13 @@ func StepPut(w PutWorld) PutNext { case "": if p.FP != w.Newest { // The builder builds the trunk's newest fingerprint and the candidates', and takes no ask for another yet (ADR 0546 - // clause 3): an older fingerprint it never built, or whose key it removed, cannot be put. - return say(puts.Refused, "the builder holds no build of %s at %s, and builds by itself only the trunk's newest (%s): put that, or a version it built", w.Module, fp, short(w.Newest)) + // clause 3): an older fingerprint it never built, or whose key it removed, cannot be put; the build the node runs now + // can (A-427), and the refusal names it. + runs := "states no running build of it" + if r := w.Running; r != nil && !r.Stopped && r.Fingerprint != "" { + runs = "runs " + short(r.Fingerprint) + } + return say(puts.Refused, "the builder holds no build of %s at %s, and builds by itself only the trunk's newest (%s), and %s %s by its running statement: put that, or a version the builder built", w.Module, fp, short(w.Newest), w.Node, runs) } return say(puts.Build, "waits for the builder's build of %s at %s, the trunk's newest, which it builds by itself", w.Module, fp) default: diff --git a/modules/mesh-delivery-assigner/internal/assign/wants.go b/modules/mesh-delivery-assigner/internal/assign/wants.go index 9434cc0b..ebefa460 100644 --- a/modules/mesh-delivery-assigner/internal/assign/wants.go +++ b/modules/mesh-delivery-assigner/internal/assign/wants.go @@ -108,7 +108,7 @@ type Module struct { } // ActingEdge is one acting edge: Part's version Fp acts in Step on Node, before the entry moves. -type ActingEdge struct{ Node, Part, Fp, Step string } +type ActingEdge struct{ Node, Part, Fp, Step, Seat string } // Runs says the part's version of the edge runs on its node, as the node-engine seat's `running` says it. func (n Nodes) Runs(e ActingEdge) bool { @@ -126,13 +126,19 @@ func (m Module) actingWaiting(node string, n Nodes) (string, bool) { return "", false } for _, e := range m.Acting(node) { - if !n.Runs(e) { + if _, runs := n.ActingRuns(e); !runs { return fmt.Sprintf("%s on %s waits in %s for %s at %s to run on %s", m.Name, node, e.Step, e.Part, short(e.Fp), e.Node), true } } return "", false } +// ReadsParts says whether node's node-engine reads a want's version, parts and kept-on: it states WantParts among its record's +// capabilities, where a node-engine of G states it (design 47 G §525), or, as read before, among its manifest reads. +func (n Nodes) ReadsParts(node string) bool { + return slices.Contains(n.Capable[node], WantParts) || slices.Contains(n.Reads[node], WantParts) +} + // WantParts is the capability a node-engine of G states (ADR 0614 §4, design 47 G §525): it reads a want's `parts` and `kept-on`. const WantParts = "want-parts" @@ -153,10 +159,29 @@ func (n Nodes) withKept(m Module, node string, w mwc.Want) mwc.Want { return w } k, ok := m.KeptBuilds(w.Fp) - if !ok || !slices.Contains(n.Reads[node], WantParts) { + if !ok { return w } - w.Parts, w.KeptOn, w.Version = k.Parts, k.KeptOn, k.Version + if k.Version != "" { + // A want names the module and its version, never its artifacts' digests (design 47 G A-430, A-430a): the node-engine + // resolves each artifact at that version through its kind's registry seat. + w.Version, w.Parts = k.Version, nil + if k.KeptOn != "" { + w.KeptOn = k.KeptOn + } + // Bootstrap, until G is delivered (lead-47, 2026-11-15): a node whose node-engine reads parts gets them beside the + // version, so it composes without asking a registry seat its grant does not yet admit (the grant follows the + // node-engine build wanted there, which needs a pipeline, which needs the pipeline runner this composes). + if n.ReadsParts(node) { + w.Parts = k.Parts + } + return w + } + // A build with no version known to the assigner (another watched branch's, a kept one: build.ended names none) is named by its + // parts and keeping node as before, for a node that reads them, until the builder says the version it numbered it under. + if n.ReadsParts(node) { + w.Parts, w.KeptOn = k.Parts, k.KeptOn + } return w } @@ -182,6 +207,49 @@ type Nodes struct { // Reads is, by node, the reader capabilities its node-engine states in its node record (nodeengine.NodeRecord.ManifestReads, // ADR 0614 §4). A node with none, or none read, is read as stating the baseline (catalogue.StatedManifestReads). Reads map[string][]string + // Capable is, by node, the capabilities its node-engine states in its node record (nodeengine.NodeRecord.Capabilities): a + // node-engine of G states WantParts there (design 47 G §525). + Capable map[string][]string + // Serves says whether the build of a running statement serves an acting edge's seat, from that build's manifest: known false + // when its manifest cannot be read (design 47 G A-426). Nil: none is read. + Serves func(r nodeengine.Running, seat string) (serves, known bool) +} + +// ActingRuns says whether an acting edge's part runs a build serving the edge's seat on its node, and which build (design 47 G +// A-426): any running build of the part that serves the seat ends the wait, whatever version its newest is, so a wait on a version +// not yet built is never held for that alone. A build whose manifest cannot be read counts as serving it when it is the part's +// (the part holds the seat by its claim). Without the running statements the have is read as before: the edge's version only. +func (n Nodes) ActingRuns(e ActingEdge) (string, bool) { + if n.Running == nil { + return e.Fp, n.Runs(e) + } + r, ok := n.Running[e.Node][e.Part] + if !ok { + // No running statement names the part on its node: its node-engine states running only of what it applied itself (a + // part placed before, the node-engine itself, or an engine from before G states none), so the part is read from its + // have: a build running there, its health check not failed (such an engine may write no health), ends the wait, + // whatever its version, as a statement would (A-426). Read by the edge's version only, a part placed there waited for + // ever (lead-47 2026-11-16: the indexer on novox for the assigner on ace and novox's own node-engine). + if h, ok := n.Haves[e.Node][e.Part]; ok && h.Fp != "" && h.Phase == nodeengineclient.PhaseRunning && !failed(h) { + return h.Fp, true + } + // The node's own node-engine writes that node's haves and keeps it heard: a node online runs its node-engine, whatever + // phase or health its have of itself says (novox's said held, health unknown, while it composed every other module). + if h, ok := n.Haves[e.Node][e.Part]; ok && e.Seat == nodeengine.Seat && n.Online[e.Node] { + return h.Fp, true + } + return e.Fp, n.Runs(e) + } + if r.Stopped || r.Fingerprint == "" { + return "", false + } + if r.Fingerprint == e.Fp || e.Seat == "" || n.Serves == nil { + return r.Fingerprint, true + } + if serves, known := n.Serves(r, e.Seat); known && !serves { + return "", false + } + return r.Fingerprint, true } // healthy says whether a have runs fp healthy. @@ -670,6 +738,11 @@ func Wants(m Module, n Nodes, wants map[string]mwc.Want, lastHealthy map[string] if !write { continue } + // Every want that names a build names its version (A-430a), whichever rule made or kept it: a want held at its fingerprint + // by the rules, a node's own (self) want too. + if !next.Removed && next.Fp != "" && next.Version == "" { + next = n.withKept(m, node, next) + } if !had || !mwc.SameWant(normal(before), normal(next)) { out.Wants[node] = next } diff --git a/modules/mesh-delivery-assigner/internal/assign/wants_test.go b/modules/mesh-delivery-assigner/internal/assign/wants_test.go index b2f428ae..92b98146 100644 --- a/modules/mesh-delivery-assigner/internal/assign/wants_test.go +++ b/modules/mesh-delivery-assigner/internal/assign/wants_test.go @@ -424,6 +424,17 @@ func TestEachRuleHoldsTheWantBack(t *testing.T) { return composedEverywhere(node, fp) } }, want: mwc.Want{Fp: fNew, Self: true}}, + // A-430a: a placed node's want held at F by the rules names F's release, as a moved want does (novox's want of + // mesh-delivery-pipeline stood as {fp, self}, the hold having rebuilt it without its version). + {name: "placed, held at F, names its release", before: fNew, set: func(m *Module, n *Nodes) { + atF(m, n) + m.Held = true + m.Self = func(node string) bool { return node == "g14" } + m.KeptBuilds = func(fp string) (KeptBuild, bool) { + return KeptBuild{Parts: map[string]string{"mail:image": "sha256:1"}, KeptOn: "g14", Version: "1.2.3"}, fp == fNew + } + }, rule: mwc.RuleNotHeld, want: mwc.Want{Fp: fNew, Self: true, Version: "1.2.3", KeptOn: "g14", Yes: dig(fNew), + Words: "mail is held at " + short(fNew) + " and g14 ran no other fingerprint healthy to set it back to"}}, } { m, n := ready() c.set(&m, &n) @@ -882,6 +893,21 @@ func stepsOfAPut(t *testing.T) { {"not assigned", func() PutWorld { w := bus(); w.Assigned = false; return w }, puts.Refused, "not assigned", false, false, false}, {"no build yet of the newest", func() PutWorld { w := bus(); w.Build = ""; return w }, puts.Build, "builds by itself", false, false, false}, {"no build of an older one", func() PutWorld { w := bus(); w.Build, w.Newest = "", fpOf('c'); return w }, puts.Refused, "holds no build", false, false, false}, + // A-427: the build the node runs now is put from its running statement, held with the have's composition, the + // builder's store not asked (a part started by hand has no build there); a have naming no composition refuses it. + {"the build the node runs now, not in the builder's store: held there", func() PutWorld { + w := bus() + w.Build, w.Newest = "", fpOf('c') + w.Running = &nodeengine.Running{Node: "novox", Module: "nats", Fingerprint: fNew} + w.Have = &nodeengine.HaveByNodeModuleValue{Fp: fNew, Composed: dig(fNew), Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK} + return w + }, puts.Holding, "held there until released", false, false, false}, + {"the build the node runs now, its have naming no composition: refused", func() PutWorld { + w := bus() + w.Build, w.Newest = "", fpOf('c') + w.Running = &nodeengine.Running{Node: "novox", Module: "nats", Fingerprint: fNew} + return w + }, puts.Refused, "names no composition", false, false, false}, {"a failed build", func() PutWorld { w := bus(); w.Build, w.BuildWords = builds.BuildFailed, "go vet"; return w }, puts.Refused, "go vet", false, false, false}, {"no composition yet: waits", func() PutWorld { w := bus(); w.Composed = nil; return w }, puts.Compose, "no composition of nats for novox", false, false, false}, {"composed, grant not naming the node", func() PutWorld { w := bus(); w.Granted = false; return w }, puts.Compose, "does not name novox", false, false, false}, @@ -1584,26 +1610,32 @@ func TestAProviderRunsHealthyByItsRunning(t *testing.T) { } } -// Design 47 G §525, §526: a want at a kept build names its parts and the node that keeps it, only for a node whose engine states -// the capability want-parts. +// Design 47 G A-430, A-430a (over §525, §526): a want names the module's version, never its artifacts' digests, whichever node it +// is for; a build the assigner knows no version of (another branch's, a kept one) is named by its parts and keeping node, as +// before, for a node whose engine reads them (its record's capabilities or its manifest reads). func TestAWantNamesAKeptBuildsPartsAndNodeForANodeThatReadsThem(t *testing.T) { - kept := KeptBuild{Parts: map[string]string{"mail:image": "sha256:1"}, KeptOn: "g14", Version: "1.2.3"} + released := KeptBuild{Parts: map[string]string{"mail:image": "sha256:1"}, KeptOn: "g14", Version: "1.2.3"} + unversioned := KeptBuild{Parts: map[string]string{"mail:image": "sha256:1"}, KeptOn: "g14"} for name, row := range map[string]struct { - reads []string - kept func(string) (KeptBuild, bool) - wanted bool + reads, capable []string + kept func(string) (KeptBuild, bool) + version string + parts bool }{ - "states it": {[]string{WantParts}, func(fp string) (KeptBuild, bool) { return kept, fp == fNew }, true}, - "does not state": {[]string{"form:oci"}, func(fp string) (KeptBuild, bool) { return kept, fp == fNew }, false}, - "build not kept": {[]string{WantParts}, func(string) (KeptBuild, bool) { return KeptBuild{}, false }, false}, - "no kept builds": {[]string{WantParts}, nil, false}, - "another fingerp": {[]string{WantParts}, func(fp string) (KeptBuild, bool) { return kept, fp == fOld }, false}, + "released, reads parts": {[]string{WantParts}, nil, func(fp string) (KeptBuild, bool) { return released, fp == fNew }, "1.2.3", true}, + "released, reads none": {[]string{"form:oci"}, nil, func(fp string) (KeptBuild, bool) { return released, fp == fNew }, "1.2.3", false}, + "unversioned, capability": {[]string{"form:oci"}, []string{WantParts}, func(fp string) (KeptBuild, bool) { return unversioned, fp == fNew }, "", true}, + "unversioned, reads none": {[]string{"form:oci"}, nil, func(fp string) (KeptBuild, bool) { return unversioned, fp == fNew }, "", false}, + "build not kept": {[]string{WantParts}, nil, func(string) (KeptBuild, bool) { return KeptBuild{}, false }, "", false}, + "no kept builds": {[]string{WantParts}, nil, nil, "", false}, + "another fingerprint's release": {[]string{WantParts}, nil, func(fp string) (KeptBuild, bool) { return released, fp == fOld }, "", false}, } { m, n := ready() n.Reads = map[string][]string{"ace": row.reads, "g14": row.reads} + n.Capable = map[string][]string{"ace": row.capable} m.KeptBuilds = row.kept w := Wants(m, heardOfHaves(n), wantedOld(), nil).Wants["ace"] - if w.Fp != fNew || (w.KeptOn == "g14") != row.wanted || (w.Version == "1.2.3") != row.wanted || (len(w.Parts) == 1) != row.wanted { + if w.Fp != fNew || w.Version != row.version || (len(w.Parts) == 1) != row.parts { t.Errorf("%s: ace's want = %+v", name, w) } } @@ -1679,27 +1711,38 @@ func TestRuleOneSaysHowTheBuildStands(t *testing.T) { } } -// Design 47 G §266, §268 (AS9): an entry whose acting edge names a step the assigner holds waits, its want held, until the acting part's -// version runs on the edge's node, as the node-engine seat's `running` says it; then the want moves. +// Design 47 G §266, §268 (AS9), A-426: an entry whose acting edge names a step the assigner holds waits, its want held, only while +// the acting part runs nothing that serves the edge's seat on the edge's node: any build of it serving the seat (an older one, a +// hand start) ends the wait at once, a build not serving it or a stopped part holds it, and a released wait is no edge. func TestAWantWaitsForItsActingPartsNewVersion(t *testing.T) { - edge := ActingEdge{Node: "g14", Part: "mesh-host", Fp: fNew, Step: "compose"} - run := func(fp string, stopped bool) Nodes { + edge := ActingEdge{Node: "g14", Part: "mesh-host", Fp: fNew, Step: "compose", Seat: "node-engine"} + run := func(fp string, stopped bool, serves bool) Nodes { _, n := ready() - n.Running = map[string]map[string]nodeengine.Running{"g14": {"mesh-host": {Fingerprint: fp, Stopped: stopped}}} + n.Running = map[string]map[string]nodeengine.Running{"g14": {"mesh-host": {Fingerprint: fp, Stopped: stopped, Manifest: "m"}}} + n.Serves = func(nodeengine.Running, string) (bool, bool) { return serves, true } return n } m, _ := ready() m.Acting = func(string) []ActingEdge { return []ActingEdge{edge} } m.Nodes = []string{"g14"} - out := Wants(m, run(fOld, false), wantedOld(), nil) + out := Wants(m, run("", true, true), wantedOld(), nil) if out.Wants["g14"].Fp == fNew || out.Rules["g14"].Rule != mwc.RuleComposed || !strings.Contains(out.Rules["g14"].Words, "waits in compose for mesh-host") { - t.Fatalf("the old version runs: want %+v rule %+v", out.Wants["g14"], out.Rules["g14"]) + t.Fatalf("the part stopped: want %+v rule %+v", out.Wants["g14"], out.Rules["g14"]) } - if out := Wants(m, run(fNew, false), wantedOld(), nil); out.Wants["g14"].Fp != fNew { + if out := Wants(m, run(fOld, false, false), wantedOld(), nil); out.Wants["g14"].Fp == fNew { + t.Errorf("an old build not serving the seat runs: want %+v", out.Wants["g14"]) + } + if out := Wants(m, run(fOld, false, true), wantedOld(), nil); out.Wants["g14"].Fp != fNew { + t.Errorf("an old build serving the seat runs: want %+v, want the new version moved", out.Wants["g14"]) + } + if took, runs := run(fOld, false, true).ActingRuns(edge); !runs || took != fOld { + t.Errorf("ActingRuns took %q, %v: want the old build it runs", took, runs) + } + if out := Wants(m, run(fNew, false, true), wantedOld(), nil); out.Wants["g14"].Fp != fNew { t.Errorf("the new version runs: want %+v", out.Wants["g14"]) } m.Acting = func(string) []ActingEdge { return nil } // a released wait is no edge - if out := Wants(m, run(fOld, false), wantedOld(), nil); out.Wants["g14"].Fp != fNew { + if out := Wants(m, run("", true, true), wantedOld(), nil); out.Wants["g14"].Fp != fNew { t.Errorf("released: want %+v", out.Wants["g14"]) } } diff --git a/modules/mesh-delivery-assigner/internal/assignment/assignments_test.go b/modules/mesh-delivery-assigner/internal/assignment/assignments_test.go index 33a30427..c6e336ba 100644 --- a/modules/mesh-delivery-assigner/internal/assignment/assignments_test.go +++ b/modules/mesh-delivery-assigner/internal/assignment/assignments_test.go @@ -11,6 +11,7 @@ import ( client "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient" seat "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner" + "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/keys" ) @@ -356,5 +357,30 @@ func TestAssignments(t *testing.T) { if h, _ := client.HoldersOf(keyed, "node-files", "novox"); h != nil { t.Errorf("a node seat nobody holds there is held by %v", h) } + + // A-400: a seat no holding names is held by the first assigned module whose manifest claims it; a holding on record wins. + assigned := map[string]seat.Assignments{ + "ace": {Node: "ace", Modules: []seat.PlacedModule{{Module: "mesh-delivery-assigner"}, {Module: "mesh-files"}}}, + "novox": {Node: "novox", Modules: []seat.PlacedModule{{Module: "nats"}, {Module: "mesh-files"}}, Holds: []seat.Holding{{Claim: "mesh-broker", Scope: "mesh", Module: "nats"}}}, + } + manifests := map[string]catalogue.Manifest{ + "mesh-delivery-assigner": {Claims: []catalogue.Claim{{Name: "mesh-module-assigner", Scope: "mesh"}}}, + "nats": {Claims: []catalogue.Claim{{Name: "mesh-broker", Scope: "mesh"}}}, + "mesh-files": {Claims: []catalogue.Claim{{Name: "node-files"}}}, + } + with, derived := SeatHoldersWithClaimants(assigned, manifests) + keyed = map[string][]byte{} + for k, v := range with { + keyed[k], _ = json.Marshal(v) + } + if h, err := client.HoldersOf(keyed, "mesh-module-assigner", ""); err != nil || len(h) != 1 || h[0].Module != "mesh-delivery-assigner" || h[0].Node != "ace" { + t.Errorf("an unheld seat's claimant is %v, %v", h, err) + } + if h, _ := client.HoldersOf(keyed, "node-files", "novox"); len(h) != 1 || h[0].Module != "mesh-files" { + t.Errorf("a node seat's claimant on novox is %v", h) + } + if h, _ := client.HoldersOf(keyed, "mesh-broker", ""); len(h) != 1 || h[0].Node != "novox" || len(derived) != 3 { + t.Errorf("a held seat is %v; derived %v", h, derived) + } }) } diff --git a/modules/mesh-delivery-assigner/internal/assignment/check.go b/modules/mesh-delivery-assigner/internal/assignment/check.go index 3e6a6a3a..a4f5d82a 100644 --- a/modules/mesh-delivery-assigner/internal/assignment/check.go +++ b/modules/mesh-delivery-assigner/internal/assignment/check.go @@ -252,3 +252,54 @@ func sortedKeys[V any](m map[string]V) []string { sort.Strings(out) return out } + +// SeatHoldersWithClaimants is SeatHoldersOf over the assignments with, for each seat no holding names (a seat held once: +// on no node; a seat of every node: on that node), the first module assigned to a node (nodes and modules in order) whose +// manifest claims it, as its holder (lead answer A-400, the same rule as grants' A-398; the operator, 2026-11-14: who holds +// a seat follows from the module graph and the assignments). derived lists each key so held, for its writer to say. Pure. +func SeatHoldersWithClaimants(assignments map[string]seat.Assignments, manifests map[string]catalogue.Manifest) (out map[string]seat.SeatHolders, derived []string) { + held := map[string]bool{} // "" for a seat held once, "." for a seat of every node + keyOf := func(claim, scope, node string) string { + name := claim + if s, ok := catalogue.SeatNamed(claim); ok { + name = s.Name + } + if scope == catalogue.ScopeNode { + return name + "." + node + } + return name + } + for _, n := range sortedKeys(assignments) { + for _, h := range assignments[n].Holds { + held[keyOf(h.Claim, h.Scope, n)] = true + } + } + with := map[string]seat.Assignments{} + var added []string + for _, n := range sortedKeys(assignments) { + a := assignments[n] + a.Holds = append([]seat.Holding(nil), a.Holds...) + modules := make([]string, 0, len(a.Modules)) + for _, m := range a.Modules { + modules = append(modules, m.Module) + } + sort.Strings(modules) + for _, module := range modules { + m, ok := manifests[module] + if !ok { + continue + } + for _, c := range m.Claims { + k := keyOf(c.Name, c.At(), n) + if held[k] { + continue + } + held[k] = true + a.Holds = append(a.Holds, seat.Holding{Claim: c.Name, Module: module, Scope: c.At()}) + added = append(added, k+" by "+module+" on "+n) + } + } + with[n] = a + } + return SeatHoldersOf(with), added +} diff --git a/modules/mesh-delivery-assigner/internal/judge/judge.go b/modules/mesh-delivery-assigner/internal/judge/judge.go index 44b83b75..13510df0 100644 --- a/modules/mesh-delivery-assigner/internal/judge/judge.go +++ b/modules/mesh-delivery-assigner/internal/judge/judge.go @@ -11,6 +11,7 @@ import ( "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" mdcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient" "reflect" + "slices" "sort" "strconv" "strings" @@ -351,3 +352,16 @@ func answerOf(body map[string]any) nodeengine.CandidateAnswer { _ = json.Unmarshal(raw, &out) return out } + +// Stops are the modules a node's answer to the verdict says it would stop running, as `: ` (design 47 G A-425a: the +// change kind `stops`). +func Stops(v mma.Verdict) []string { + var out []string + for node, body := range v.Answers { + for _, m := range answerOf(body).Removed { + out = append(out, node+": "+m) + } + } + slices.Sort(out) + return out +} diff --git a/modules/mesh-delivery-assigner/manifest_test.go b/modules/mesh-delivery-assigner/manifest_test.go index 01bec1c4..8de78a40 100644 --- a/modules/mesh-delivery-assigner/manifest_test.go +++ b/modules/mesh-delivery-assigner/manifest_test.go @@ -105,8 +105,8 @@ func TestManifest(t *testing.T) { // which lists and asks again what each node's engine reads. if !slices.Equal(m.Tools, []string{"assigner_put", "assigner_release", "assigner_puts", "assigner_waits", "assigner_inputs", "assignments", "seat-holders", "wants", "asks", "assigner_read_assignments", "assigner_read_seat_holders", "assigner_read_wants", "assigner_read_findings", "assigner_read_differences", "assigner_read_copies", - "assigner_first_views", "assigner_first_view_again", "assigner_engine_reads", "assigner_seat_list", "assigner_seat_list_again", "assigner_ask_again", "assigner_written", "assigner_pins", "assigner_unpin", "assigner_delivered_again"}) { - t.Errorf("the assigner serves tools %v, want its three put tools, three first views, six read tools, assigner_engine_reads, the seat list's two (ADR 0636 §7) and assigner_ask_again (ADR 0668 §5)", m.Tools) + "assigner_first_views", "assigner_first_view_again", "assigner_engine_reads", "assigner_seat_list", "assigner_seat_list_again", "assigner_ask_again", "assigner_written", "assigner_why", "assigner_pins", "assigner_unpin", "assigner_delivered_again"}) { + t.Errorf("the assigner serves tools %v, want its three put tools, three first views, six read tools, assigner_engine_reads, the seat list's two (ADR 0636 §7) assigner_ask_again (ADR 0668 §5) and assigner_why (design 47 G A-439)", m.Tools) } if m.RunsAs != m.Module || m.SecretsOwner != m.RunsAs { t.Errorf("runs-as = %q: the bundle runs on the assigner's own account (ADR 0621 §1)", m.RunsAs) @@ -166,12 +166,14 @@ func TestManifest(t *testing.T) { } `json:"config"` } file, _ := os.ReadFile("module.json") - if err := json.Unmarshal(file, &raw); err != nil || raw.Config["outside-wait-minutes"].Default != float64(30) || raw.Config["outside-settle-seconds"].Default != float64(90) || len(raw.Config) != 2 { - t.Errorf("config = %+v (%v), want outside-wait-minutes of 30 and outside-settle-seconds of 90", raw.Config, err) + if err := json.Unmarshal(file, &raw); err != nil || raw.Config["outside-wait-minutes"].Default != float64(30) || raw.Config["outside-settle-seconds"].Default != float64(90) || + raw.Config["ask-operator-for"].Default != "take-off,remove-node,stops" || len(raw.Config) != 3 { + t.Errorf("config = %+v (%v), want outside-wait-minutes of 30, outside-settle-seconds of 90 and ask-operator-for of take-off,remove-node,stops (A-425a)", raw.Config, err) } for _, f := range []struct{ env, path, key string }{ {"MESH_ASSIGNER_OUTSIDE_WAIT_FILE", "${dir:state}/outside-wait-minutes", "outside-wait-minutes"}, {"MESH_ASSIGNER_OUTSIDE_SETTLE_FILE", "${dir:state}/outside-settle-seconds", "outside-settle-seconds"}, + {"MESH_ASSIGNER_ASK_OPERATOR_FOR_FILE", "${dir:state}/ask-operator-for", "ask-operator-for"}, } { if !strings.Contains(string(file), `"`+f.env+`": "`+f.path+`"`) || !strings.Contains(string(file), `"path": "`+f.path+`"`) || !strings.Contains(string(file), `"content": "${config:`+f.key+`}"`) { diff --git a/modules/mesh-delivery-assigner/module.json b/modules/mesh-delivery-assigner/module.json index 99c7955c..b239baa2 100644 --- a/modules/mesh-delivery-assigner/module.json +++ b/modules/mesh-delivery-assigner/module.json @@ -129,6 +129,7 @@ "assigner_seat_list_again", "assigner_ask_again", "assigner_written", + "assigner_why", "assigner_pins", "assigner_unpin", "assigner_delivered_again" @@ -174,6 +175,12 @@ "maximum": 3600, "trusted": false, "default": 90 + }, + "ask-operator-for": { + "type": "string", + "description": "the change kinds of a proposal the assigner asks the operator before it writes it, separated by commas: place, take-off, pin, unpin, hold, unhold, decide, config, add-node, remove-node, and stops for a verdict whose answers say a node would stop running a module (design 47 G A-425, A-425a). A proposal none of whose changes is of a kind named is applied at once when its verdict passes, said in the log and by assignments-changed. The default is take-off,remove-node,stops; empty asks for nothing.", + "trusted": false, + "default": "take-off,remove-node,stops" } }, "objects": [ @@ -215,6 +222,14 @@ "mode": "0600", "content": "${config:outside-settle-seconds}" }, + { + "id": "ask-operator-for", + "type": "file", + "path": "${dir:state}/ask-operator-for", + "owner": "mesh-delivery-assigner", + "mode": "0600", + "content": "${config:ask-operator-for}" + }, { "id": "assigner", "type": "process", @@ -226,7 +241,8 @@ "env": { "MESH_BROKER_FILE": "${dir:state}/broker", "MESH_ASSIGNER_OUTSIDE_WAIT_FILE": "${dir:state}/outside-wait-minutes", - "MESH_ASSIGNER_OUTSIDE_SETTLE_FILE": "${dir:state}/outside-settle-seconds" + "MESH_ASSIGNER_OUTSIDE_SETTLE_FILE": "${dir:state}/outside-settle-seconds", + "MESH_ASSIGNER_ASK_OPERATOR_FOR_FILE": "${dir:state}/ask-operator-for" }, "user": "mesh-delivery-assigner", "health": { diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go index e6f4d2db..8aaec502 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog.go @@ -45,7 +45,7 @@ func (m *entryManifests) keep(e meshcatalog.CatalogEntry) error { if m.byFp == nil { m.byFp = map[string]catalogue.Manifest{} } - m.byFp[e.ManifestDigest] = mf + m.byFp[meshcatalog.BareManifestDigest(e.ManifestDigest)] = mf return nil } diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog_test.go index 40ec236c..8d9c45b1 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/catalog_test.go @@ -15,10 +15,10 @@ func TestTheManifestOfAnEntryIsReadByItsDigest(t *testing.T) { if err := m.keep(e); err != nil { t.Fatal(err) } - if mf, err := m.Manifest(context.Background(), "sha256:aa"); err != nil || mf.Module != "netcheck" { - t.Errorf("Manifest(sha256:aa) = %+v, %v", mf, err) + if mf, err := m.Manifest(context.Background(), "aa"); err != nil || mf.Module != "netcheck" { + t.Errorf("Manifest(aa) = %+v, %v", mf, err) } - if _, err := m.Manifest(context.Background(), "sha256:bb"); err == nil { + if _, err := m.Manifest(context.Background(), "bb"); err == nil { t.Error("Manifest of a digest no entry holds: want an error") } if err := m.keep(meshcatalog.CatalogEntry{Module: "bare"}); err != nil || len(m.byFp) != 1 { diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/filledread.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/filledread.go new file mode 100644 index 00000000..1b6934a2 --- /dev/null +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/filledread.go @@ -0,0 +1,87 @@ +package main + +import ( + "context" + "errors" + "sync/atomic" + "time" + + "github.com/nats-io/nats.go/jetstream" + + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + "git.novox.be/novox/mesh-sdk/go/process" +) + +// lastKept reads whether the stream keeps a message on a subject: found false when the stream or the message is not there. +type lastKept func(ctx context.Context, subject string) (found bool, err error) + +// lastKeptOf reads the seat event's own kept stream (the contract's StreamVersionsFilled, kept by age) the way any kept event +// is heard (design 47 G A-411, A-233): the SDK's hearing of it from its first message, whose start read hands every message +// kept to the handler; the reading is stopped once the read ended, the hub's own hearing following the durable. Nothing of +// EVENTS is read. +func lastKeptOf(js jetstream.JetStream, acct process.Account, logf func(string, ...any)) lastKept { + return func(ctx context.Context, subject string) (bool, error) { + var found atomic.Bool + cc, err := acct.HearSeatEvents(ctx, js, meshcatalog.StreamVersionsFilled, func(m jetstream.Msg) { + if m.Subject() == subject { + found.Store(true) + } + _ = m.Ack() // a message of the durable is taken as the hub takes it; an ordered read's has nothing to acknowledge + }, logf, process.FromFirst()) + if err != nil { + if errors.Is(err, jetstream.ErrStreamNotFound) { + return false, nil + } + return false, err + } + cc.Stop() + return found.Load(), nil + } +} + +// readFilled reads at the builder's start the last versions-filled the stream keeps (design 47 G §369, §372, A-411) and takes it as heard; the event heard later sets it as before. Nothing found leaves it unset, said; a +// read that failed is said and tried again in the background with backoff, never holding the start. +func (rv *reservations) readFilled(ctx context.Context, read lastKept, wait func(context.Context, time.Duration) bool) { + const first, most = time.Second, time.Minute + try := func() (done bool, err error) { + found, err := read(ctx, meshcatalog.SubjectVersionsFilled) + if err != nil { + return false, err + } + if !found { + rv.logf("the stream keeps no versions-filled yet (read at start): versions are reserved once the catalog says it") + return true, nil + } + rv.filled.Store(true) + rv.logf("the catalog said versions-filled (read at start): versions are reserved from now on") + if rv.wake != nil { + rv.wake(ctx) + } + return true, nil + } + if done, err := try(); done { + return + } else { + rv.logf("the last versions-filled is not read at start: %v; read again in the background", err) + } + go func() { + for d := first; ; d = min(d*2, most) { + if !wait(ctx, d) { + return + } + done, err := try() + if done { + return + } + rv.logf("the last versions-filled is not read: %v; read again in %s", err, min(d*2, most)) + } + }() +} + +// sleeps waits d, as a context's bound (ADR 0437 §8: the builder holds no timer); false when ctx ended first. +func sleeps(ctx context.Context, d time.Duration) bool { + bound, cancel := context.WithTimeout(ctx, d) + defer cancel() + <-bound.Done() + return ctx.Err() == nil +} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/filledread_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/filledread_test.go new file mode 100644 index 00000000..fef97a57 --- /dev/null +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/filledread_test.go @@ -0,0 +1,64 @@ +package main + +import ( + "context" + "errors" + "reflect" + "sync" + "testing" + "time" +) + +func TestTheLastVersionsFilledIsReadAtStart(t *testing.T) { + boom := errors.New("bus down") + for _, tc := range []struct { + name string + results []error // per read: nil found, boom fails + notFound bool + wantFilled bool + wantReads int + waits []time.Duration + }{ + {"kept", []error{nil}, false, true, 1, nil}, + {"none kept", []error{nil}, true, false, 1, nil}, + {"read fails then kept", []error{boom, boom, nil}, false, true, 3, []time.Duration{time.Second, 2 * time.Second}}, + } { + t.Run(tc.name, func(t *testing.T) { + rv := newReservations(nil, nil, nil, nil, nil, t.Logf) + var mu sync.Mutex + woke := make(chan struct{}, 1) + rv.wake = func(context.Context) { woke <- struct{}{} } + reads := 0 + read := func(_ context.Context, subject string) (bool, error) { + mu.Lock() + defer mu.Unlock() + err := tc.results[reads] + reads++ + return !tc.notFound, err + } + var waits []time.Duration + wait := func(_ context.Context, d time.Duration) bool { + mu.Lock() + defer mu.Unlock() + waits = append(waits, d) + return true + } + rv.readFilled(context.Background(), read, wait) + if tc.wantFilled { + select { + case <-woke: + case <-time.After(5 * time.Second): + t.Fatal("the read did not take the fill") + } + } + mu.Lock() + defer mu.Unlock() + if rv.Filled() != tc.wantFilled || reads != tc.wantReads { + t.Fatalf("filled %v reads %d", rv.Filled(), reads) + } + if !reflect.DeepEqual(waits, tc.waits) { + t.Fatalf("backoff %v, want %v", waits, tc.waits) + } + }) + } +} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/gone_integration_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/gone_integration_test.go index a76aaf99..9f5bcb00 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/gone_integration_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/gone_integration_test.go @@ -14,6 +14,8 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" sweep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshartifactsweep" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + "git.novox.be/novox/mesh-sdk/go/process" ) // A done key whose blob the artifact store no longer holds is built again, by the builder whole against the bus @@ -185,3 +187,31 @@ func TestArtifactsGoneLeadsTheBuilderToBuildTheKeyAgain(t *testing.T) { b.fake.count("mesh-build-go.build_go_build")) } } + +// The last versions-filled is read at the start from the seat event's own kept stream, kept by age, through the SDK's hearing +// from the first message (design 47 G A-411), never from EVENTS: a message the stream keeps is found, an empty one is none. +func TestTheLastVersionsFilledIsReadFromItsKeptStream(t *testing.T) { + b := startBed(t) + acct := process.Account{Node: "n1", Module: "mesh-delivery-builder"} + if err := b.js.DeleteStream(b.ctx, eventsStream); err != nil { // the bus keeps a kept event off EVENTS: its subject is nowhere else + t.Fatal(err) + } + if _, err := b.js.CreateOrUpdateStream(b.ctx, jetstream.StreamConfig{Name: meshcatalog.StreamVersionsFilled, + Subjects: []string{meshcatalog.SubjectVersionsFilled}, MaxAge: 24 * time.Hour}); err != nil { + t.Fatal(err) + } + if _, err := b.js.CreateOrUpdateConsumer(b.ctx, meshcatalog.StreamVersionsFilled, jetstream.ConsumerConfig{ + Durable: acct.EventConsumerName(), AckPolicy: jetstream.AckExplicitPolicy, FilterSubject: meshcatalog.SubjectVersionsFilled}); err != nil { + t.Fatal(err) + } + read := lastKeptOf(b.js, acct, t.Logf) + if found, err := read(b.ctx, meshcatalog.SubjectVersionsFilled); err != nil || found { + t.Fatalf("empty stream: found %v, %v", found, err) + } + if _, err := b.js.Publish(b.ctx, meshcatalog.SubjectVersionsFilled, []byte(`{"v":1}`)); err != nil { + t.Fatal(err) + } + if found, err := read(b.ctx, meshcatalog.SubjectVersionsFilled); err != nil || !found { + t.Fatalf("kept message: found %v, %v", found, err) + } +} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index 7e5219cf..8a3c040c 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -226,6 +226,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro return emitSeatEvent(context.WithoutCancel(ctx), js, cred, meshbuilds.SubjectPackagePublished, "package-published-"+p.Module+"-"+p.Version+"-"+p.Artifact, p) } b.Reserved = reserved + // The last versions-filled the stream keeps is read at the start (design 47 G §369, §372): a restart does not lose it. + reserved.readFilled(ctx, lastKeptOf(js, cred, logger.Printf), sleeps) // A state bound later numbers the builds looked at without it. versionsKV.Ready(func(jetstream.KeyValue) { b.Reconsider(ctx) }) // The versions' hand acts (builder_publish_again, builder_floor_again) come through reasks, as builder_build_again. @@ -240,7 +242,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro actedKV := process.AwaitBucket(ctx, js, conn, own.acted, "no version is published again on an event or by builder_publish_again", logger.Printf) republish := &versions.Republisher{Reserved: reserved.r, Queue: awaitedQueue{awaitedReserved{awaitedVersions{b: queueKV, bucket: own.queue}}}, Acted: awaitedReserved{awaitedVersions{b: actedKV, bucket: own.acted}}, Entry: entryVia(calls.Call), Send: sendVia(calls.Call), - Unreleased: reserved.unreleasedWords, Max: republishMax, Logf: logger.Printf} + Unreleased: reserved.unreleasedWords, Max: republishMax, Logf: logger.Printf, + Holders: holders} // a registry seat's holder from the seat-holders view, from the start (design 47 G A-416, A-416a) acts.Republish = republish.Republish again := &republishing{rp: republish} // The operator is asked once a key's event builds are spent (design 47 G §568): the builder's asker on the seat operator-channel. @@ -408,7 +411,10 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro // The seat mesh-builds' verb reserved, answered here (A-115, A-127): the reservations, the catalog half's carriers and the seat // mesh-catalog's versions. stopReserved, err := calls.AnswerSeat(meshbuilds.Seat, seatlist.Definition(seatGate.Reader, meshbuilds.Seat), map[string]process.SeatHandler{ - meshbuilds.VerbReserved: reservedVerb(ctx, reservedReader(ctx, reserved.r.Store), versions.CarriersFrom(versions.EntriesOf(branches)), catalogReleased(calls.Call))}) + meshbuilds.VerbReserved: reservedVerb(ctx, reservedReader(ctx, reserved.r.Store), versions.CarriersFrom(versions.EntriesOf(branches)), catalogReleased(calls.Call), + func(name string) { + logger.Printf("reserved: no entry carries the name %s; the entries looked at: %s", name, versions.LookedAt(versions.EntriesOf(branches))) + })}) if err != nil { return fmt.Errorf("answering the verb reserved: %w", err) } @@ -443,7 +449,13 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro // Every part has registered: the hub pulls the module's durable. Where the consumer is not there yet the builder says so // and binds it at a later change (heard.Writer; ADR 0615 §5). _ = notHeard.Bind(eventsStream, sweep.EventArtifactsGone+", what wakes a floor, the registry seats' words, the views and manifest-reads-changed are not heard until the builder starts again", func() error { - return hub.Start(ctx, js, cred) + if err := hub.Start(ctx, js, cred); err != nil { + return err + } + // And the kept seat events it handles (the build seats' toolchain-reported, the seat mesh-catalog's versions-filled + // and version-released), each on its own stream: the tool runner reads its own twin there (lead answer A-397). + hub.StartKept(ctx, js, cred) + return nil }) go func() { <-ctx.Done(); hub.Stop() }() // A person asks a key's build again with builder_ask_again, which writes the reasks state (issue 1945): watched, as diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go index 42a8cafe..04fc96f9 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go @@ -31,6 +31,8 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds/forms" sweep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshartifactsweep" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "mesh-delivery-builder/internal/build" "mesh-delivery-builder/internal/versions" @@ -226,6 +228,8 @@ type wakeMsg struct { acked bool naked bool delayed time.Duration + // delivered is the delivery count Metadata says; 0 says no metadata. + delivered uint64 } func (m *wakeMsg) Subject() string { return m.subject } @@ -237,6 +241,9 @@ func (m *wakeMsg) NakWithDelay(d time.Duration) error { return nil } func (m *wakeMsg) Metadata() (*jetstream.MsgMetadata, error) { + if m.delivered > 0 { + return &jetstream.MsgMetadata{NumDelivered: m.delivered}, nil + } return nil, errors.New("no metadata") } func (m *wakeMsg) Headers() nats.Header { @@ -271,13 +278,39 @@ func aFloorsWakeIsHeard(t *testing.T) { if !h.heard(context.Background(), byDigest) || !byDigest.acked || !strings.Contains(logs.String(), "the floor of m/pkg is asked again: go-package-registry said published") { t.Fatalf("published: acked %v, log %q", byDigest.acked, logs.String()) } - refused := &wakeMsg{subject: "mesh.seat.oci-artifact-registry.event.refused", data: []byte(`{"name":"m/program","version":"0.1.3","digest":"sha256:bb","reason":"bytes differ"}`)} - if !h.heard(context.Background(), refused) || refused.acked || !refused.naked { - t.Fatalf("a refusal the state cannot take: acked %v, naked %v, log %q", refused.acked, refused.naked, logs.String()) + // Design 47 G §369, A-415: a published of a version the reservation numbered, which the state versions does not hold, is + // taken: its artifact is marked and package-published said, never left for the bus to give again. + var saidPub []meshbuilds.PackagePublished + rv := newReservations(&memReserve{vals: map[string][]byte{}, revs: map[string]uint64{}}, func(string, any) (json.RawMessage, error) { + return json.Marshal(meshcatalog.VersionsAnswer{Module: "m"}) + }, func() jetstream.KeyValue { return &boundsKV{keys: map[string]bool{}} }, + &findings{module: builds.BuilderModule, w: &memFindings{vals: map[string][]byte{}}, logf: t.Logf, now: time.Now}, nil, t.Logf) + rv.say = func(_ context.Context, p meshbuilds.PackagePublished) error { saidPub = append(saidPub, p); return nil } + rv.filled.Store(true) + res, err := rv.Reserve(context.Background(), "m", "0.1", []string{"m:program"}, versions.Source{}) + if err != nil { + t.Fatal(err) + } + if err := rv.Built(context.Background(), "m", res.Version, map[string]string{"m:program": "sha256:bb"}, nil); err != nil { + t.Fatal(err) + } + h.res = rv + published := &wakeMsg{subject: "mesh.seat.oci-artifact-registry.event.published", data: []byte(`{"name":"m/program","version":"` + res.Version + `","digest":"sha256:bb","kind":"bundle"}`)} + if !h.heard(context.Background(), published) || !published.acked || published.naked || len(saidPub) != 1 || saidPub[0].Artifact != "m:program" { + t.Fatalf("a published of a reserved version: acked %v, naked %v, said %+v, log %q", published.acked, published.naked, saidPub, logs.String()) } if h.heard(context.Background(), &wakeMsg{subject: manifestAcceptedSubject}) { t.Fatal("manifest-accepted was taken as a seat's outcome") } + // Design 47 G A-420: a message left for the bus is said given up on the last delivery its consumer allows, never before. + for _, n := range []uint64{4, EventDeliveries} { + logs.Reset() + givenUp(&wakeMsg{subject: "mesh.seat.oci-artifact-registry.event.published", delivered: n}, "oci-artifact-registry's published of m/program@0.1.6", errors.New("down"), log.New(&logs, "", 0).Printf) + said := strings.Contains(logs.String(), "gives up mesh.seat.oci-artifact-registry.event.published: oci-artifact-registry's published of m/program@0.1.6, delivered 5 times, the most its consumer allows; the last refusal: down") + if said != (n == EventDeliveries) { + t.Errorf("delivery %d: log %q", n, logs.String()) + } + } } // noVersions is a state versions that holds nothing. diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/republish.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/republish.go index 2e0e8fa8..83ed02ae 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/republish.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/republish.go @@ -140,6 +140,7 @@ func (g *republishing) heard(ctx context.Context, m jetstream.Msg, logf func(str if nakErr := m.Nak(); nakErr != nil { logf("leaving %s for the bus to give again: %v", m.Subject(), nakErr) } + givenUp(m, "its event", err, logf) return true } return false diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go index 6fd3ced9..8a805fde 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go @@ -96,6 +96,17 @@ func (rv *reservations) Built(ctx context.Context, module, version string, diges return err } rv.arm(ctx, cur) + // A published heard before the digests were recorded marks its artifact now, said as one heard after (design 47 G A-415). + marked, unmatched, err := rv.r.Kept(ctx, module, version) + if err != nil { + rv.logf("the published kept on %s %s are not taken in: %v", module, version, err) + } + for _, h := range unmatched { + rv.logf("a published of %s@%s kept on %s %s marks no artifact: its digest %s is none of the built digests %v", h.Name, h.Version, module, version, h.Digest, cur.Artifacts) + } + for _, m := range marked { + rv.sayPublished(ctx, m, m.Reserved.Artifacts[m.Artifact]) + } return nil } @@ -181,6 +192,7 @@ func (rv *reservations) heard(ctx context.Context, m jetstream.Msg) bool { if nakErr := m.Nak(); nakErr != nil { rv.logf("leaving %s for the bus to give again: %v", m.Subject(), nakErr) } + givenUp(m, "the version-released of "+ev.Module+" "+ev.Version, err, rv.logf) return true } gone, err := rv.r.Released(ctx, ev.Module, ev.Version) @@ -189,6 +201,7 @@ func (rv *reservations) heard(ctx context.Context, m jetstream.Msg) bool { if nakErr := m.Nak(); nakErr != nil { rv.logf("leaving %s for the bus to give again: %v", m.Subject(), nakErr) } + givenUp(m, "the version-released of "+ev.Module+" "+ev.Version, err, rv.logf) return true } for _, k := range gone { @@ -206,18 +219,31 @@ func (rv *reservations) heard(ctx context.Context, m jetstream.Msg) bool { // published marks the artifacts of the reservation a registry seat's published names (its version and digest). func (rv *reservations) published(ctx context.Context, o versions.Outcome) { - marked, err := rv.r.Published(ctx, o.Version, o.Digest) + marked, kept, err := rv.r.Published(ctx, o.Name, o.Version, o.Digest) if err != nil { rv.logf("a published of %s@%s is not recorded in the reservations: %v", o.Name, o.Version, err) } + if len(kept) > 0 { + rv.logf("the published of %s@%s (digest %s, holder %s) is kept on %s until the build records its digests", o.Name, o.Version, o.Digest, o.Holder, strings.Join(kept, ", ")) + } else if len(marked) == 0 { + rv.logf("package-published not said: the published of %s@%s (digest %s, holder %s) marks no artifact of a reservation: %s", o.Name, o.Version, o.Digest, o.Holder, rv.noMark(ctx, o)) + } // Each artifact the holder's published newly marked is said as the seat mesh-builds' package-published (design 47 G §52, §334). for _, m := range marked { - if rv.say == nil { - continue - } - if err := rv.say(ctx, m.PackagePublished(o.Digest, time.Now())); err != nil { - rv.logf("the package-published of %s at %s is not said: %v", m.Artifact, m.Reserved.Version, err) - } + rv.sayPublished(ctx, m, o.Digest) + } +} + +// sayPublished says the seat mesh-builds' package-published of an artifact a published marked. +func (rv *reservations) sayPublished(ctx context.Context, m versions.Marked, digest string) { + if rv.say == nil { + rv.logf("package-published of %s at %s not said: no seat to say it on", m.Artifact, m.Reserved.Version) + return + } + if err := rv.say(ctx, m.PackagePublished(digest, time.Now())); err != nil { + rv.logf("the package-published of %s at %s is not said: %v", m.Artifact, m.Reserved.Version, err) + } else { + rv.logf("package-published said: %s at %s, digest %s", m.Artifact, m.Reserved.Version, digest) } } @@ -261,3 +287,26 @@ func (rv *reservations) tagged(ctx context.Context, ev meshcatalog.VersionReleas rv.logf("%s is tagged %s at %s", ev.Module, res.Tag, res.Commit) return nil } + +// noMark says why a published marked nothing: which reservation holds that version, and what it holds of digests. +func (rv *reservations) noMark(ctx context.Context, o versions.Outcome) string { + version := strings.TrimPrefix(o.Version, "v") + if version == "" || o.Digest == "" { + return "it names no version or no digest (a by-digest publish)" + } + all, err := rv.r.All(ctx) + if err != nil { + return "the reservations cannot be read: " + err.Error() + } + var out []string + for _, v := range all { + if v.Version != version { + continue + } + out = append(out, fmt.Sprintf("%s holds %d built digests %v, published %v (a published heard before the build recorded its digests is kept until it does)", v.Module, len(v.Artifacts), v.Artifacts, v.Published)) + } + if len(out) == 0 { + return "no reservation holds version " + version + } + return strings.Join(out, "; ") +} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go index 274b5c45..bc4c71b4 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go @@ -3,6 +3,7 @@ package main import ( "context" "encoding/json" + "fmt" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "strings" "testing" @@ -201,3 +202,43 @@ func TestAReleasedVersionIsTaggedAtTheCommitItWasBuiltFrom(t *testing.T) { t.Fatalf("the newer build's version: tags %+v; want go/v0.1.1 at b0b", tags) } } + +// Design 47 G A-415: a published heard before the build recorded its digests is kept on its reservation, and when the build +// records them it marks its artifact and package-published is said then; a kept one whose digest is none of the built digests +// is said in the log. +func TestAPublishedHeardBeforeTheDigestsIsSaidWhenTheBuildRecordsThem(t *testing.T) { + ctx := context.Background() + var logs []string + logf := func(f string, a ...any) { logs = append(logs, fmt.Sprintf(f, a...)) } + none := func(string, any) (json.RawMessage, error) { + return json.Marshal(meshcatalog.VersionsAnswer{Module: "m"}) + } + rv := newReservations(&memReserve{vals: map[string][]byte{}, revs: map[string]uint64{}}, none, func() jetstream.KeyValue { return &boundsKV{keys: map[string]bool{}} }, + &findings{module: builds.BuilderModule, w: &memFindings{vals: map[string][]byte{}}, logf: t.Logf, now: time.Now}, nil, logf) + var said []meshbuilds.PackagePublished + rv.say = func(_ context.Context, p meshbuilds.PackagePublished) error { said = append(said, p); return nil } + rv.filled.Store(true) + res, err := rv.Reserve(ctx, "m", "1.4", []string{"m:a", "m:b"}, versions.Source{Branch: "main", Revision: 41}) + if err != nil { + t.Fatal(err) + } + rv.published(ctx, versions.Outcome{Name: "m-a", Version: res.Version, Digest: "sha256:a"}) + rv.published(ctx, versions.Outcome{Name: "m-x", Version: res.Version, Digest: "sha256:x"}) + if len(said) != 0 { + t.Fatalf("package-published said before the digests are recorded: %+v", said) + } + if err := rv.Built(ctx, "m", res.Version, map[string]string{"m:a": "sha256:a", "m:b": "sha256:b"}, nil); err != nil { + t.Fatal(err) + } + if len(said) != 1 || said[0].Artifact != "m:a" || said[0].Version != res.Version || said[0].Digest != "sha256:a" || said[0].Branch != "main" || said[0].Source != 41 { + t.Fatalf("package-published said %+v, want one of m:a at %s for main at source 41", said, res.Version) + } + if log := strings.Join(logs, "\n"); !strings.Contains(log, "is kept on") || !strings.Contains(log, "m-x@"+res.Version+" kept on m "+res.Version+" marks no artifact") { + t.Fatalf("log = %q, want the published kept and the one never matching said", logs) + } + // Taken in once: a published of m:a heard again says nothing more. + rv.published(ctx, versions.Outcome{Name: "m-a", Version: res.Version, Digest: "sha256:a"}) + if len(said) != 1 { + t.Fatalf("package-published said again: %+v", said) + } +} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reservedverb.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reservedverb.go index 5eedc4a0..b45a2905 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reservedverb.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reservedverb.go @@ -28,8 +28,9 @@ func reservedReader(ctx context.Context, store versions.Store) versions.Reader { }} } -// reservedVerb is the handler of the verb reserved. -func reservedVerb(ctx context.Context, rr versions.Reader, carriers func(context.Context, string) ([]versions.Built, error), released versions.CatalogVersions) process.SeatHandler { +// reservedVerb is the handler of the verb reserved; missed is told each name no entry carries, for the builder's log (design 47 G +// A-418). +func reservedVerb(ctx context.Context, rr versions.Reader, carriers func(context.Context, string) ([]versions.Built, error), released versions.CatalogVersions, missed func(name string)) process.SeatHandler { return func(_ string, body json.RawMessage) (any, error) { var in meshbuilds.ReservedInput if len(body) > 0 { @@ -38,7 +39,11 @@ func reservedVerb(ctx context.Context, rr versions.Reader, carriers func(context } } if name := strings.TrimSpace(in.Name); name != "" { - return versions.AnswerReservedByName(ctx, rr, carriers, released, name, in.Version) + a, err := versions.AnswerReservedByName(ctx, rr, carriers, released, name, in.Version) + if err == nil && missed != nil && strings.HasPrefix(a.Error, versions.NoEntryCarries) { + missed(name) + } + return a, err } return versions.AnswerReservedVerb(rr, in.Module, in.Version) } diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reservedverb_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reservedverb_test.go index 12da9d44..e7f1040c 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reservedverb_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reservedverb_test.go @@ -27,7 +27,8 @@ func TestTheProcessAnswersReserved(t *testing.T) { return json.Marshal(meshcatalog.VersionsAnswer{Versions: []meshcatalog.VersionEntry{{Module: "mesh-sdk", Version: "0.1.2", Artifacts: []meshcatalog.VersionArtifact{{Artifact: "mesh-sdk:ts", Digest: "sha256:dd"}}}}}) }) - handle := reservedVerb(context.Background(), none, carriers, released) + var missed []string + handle := reservedVerb(context.Background(), none, carriers, released, func(name string) { missed = append(missed, name) }) got, err := handle("", json.RawMessage(`{"name":"@novox/mesh-sdk","version":"0.1.2"}`)) a, ok := got.(meshbuilds.ReservedAnswer) if err != nil || !ok || !a.Released || a.Module != "mesh-sdk" || len(a.Artifacts) != 1 || a.Artifacts[0].Digest != "sha256:dd" { @@ -36,6 +37,10 @@ func TestTheProcessAnswersReserved(t *testing.T) { if len(asked) != 1 || asked[0] != "seat:mesh-catalog.versions" { t.Errorf("the released versions were asked of %v, want the seat mesh-catalog's versions", asked) } + // Design 47 G A-418: a name no entry carries is answered error and told for the builder's log. + if got, err := handle("", json.RawMessage(`{"name":"nobody/program","version":"0.1.6"}`)); err != nil || got.(meshbuilds.ReservedAnswer).Error == "" || len(missed) != 1 || missed[0] != "nobody/program" { + t.Errorf("a name no entry carries: %+v (%v), told %v", got, err, missed) + } if _, err := handle("", json.RawMessage(`{"module":"mesh-sdk"}`)); err == nil { t.Error("a module with no reservation was answered") } diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/retake.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/retake.go index 5c9cae8a..5163558e 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/retake.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/retake.go @@ -27,6 +27,7 @@ func (g *retaking) heard(ctx context.Context, m jetstream.Msg, logf func(string, if nakErr := m.Nak(); nakErr != nil { logf("leaving %s for the bus to give again: %v", m.Subject(), nakErr) } + givenUp(m, "its event", err, logf) return true } return false @@ -67,6 +68,7 @@ func (d *decisions) hear(logf func(string, ...any)) func(pattern string, handle if nakErr := m.Nak(); nakErr != nil { logf("leaving %s for the bus to give again: %v", m.Subject(), nakErr) } + givenUp(m, "the operator's warrant", err, logf) return } if err := m.Ack(); err != nil { diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seats.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seats.go index 75e75287..51283e17 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seats.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/seats.go @@ -4,6 +4,8 @@ import ( "context" "encoding/json" "errors" + "fmt" + "strconv" "strings" "github.com/nats-io/nats.go/jetstream" @@ -82,11 +84,19 @@ func (h *seatHearer) heard(ctx context.Context, m jetstream.Msg) bool { id = m.Headers().Get("x-event-id") } wake, err := h.n.Heard(ctx, se.seat, se.event, id, o) + if errors.Is(err, versions.ErrNotNumbered) { + // The version is no entry of the state versions, design 51's numbering by name, which G keeps only until it is removed + // (§372); the reservation numbers a version (§369, §52) and takes the outcome in (A-415). Heard again it would stay + // unnumbered there, so it is taken, not left for the bus. + h.logf("%v in the state versions; the reservations take it (design 47 G §369, A-415)", err) + err = nil + } if err != nil { - h.logf("%v; heard again", err) + h.logf("%v; heard again (delivery %s)", err, deliveryOf(m)) if nakErr := m.Nak(); nakErr != nil { h.logf("leaving %s for the bus to give again: %v", m.Subject(), nakErr) } + givenUp(m, fmt.Sprintf("%s's %s of %s@%s", se.seat, se.event, o.Name, o.Version), err, h.logf) return true } if h.pub != nil { @@ -103,6 +113,28 @@ func (h *seatHearer) heard(ctx context.Context, m jetstream.Msg) bool { return true } +// deliveryOf is the message's delivery count as the bus says it, so a message the bus stops giving after its consumer's +// bound is readable in the log; "unknown" when it says none. +func deliveryOf(m jetstream.Msg) string { + md, err := m.Metadata() + if err != nil || md == nil { + return "unknown" + } + return strconv.FormatUint(md.NumDelivered, 10) +} + +// EventDeliveries is how many times the bus gives a message of the builder's events consumer: the MaxDeliver the grants part +// composes a module's durable with (mesh-grants buscompose). +const EventDeliveries = 5 + +// givenUp says, on the last delivery the events consumer allows, that the builder gives the message up, naming its subject, what +// it carries and the last refusal (design 47 G A-420): past it the bus drops the message without a word. +func givenUp(m jetstream.Msg, what string, err error, logf func(string, ...any)) { + if md, merr := m.Metadata(); merr == nil && md != nil && md.NumDelivered >= EventDeliveries { + logf("gives up %s: %s, delivered %d times, the most its consumer allows; the last refusal: %v", m.Subject(), what, md.NumDelivered, err) + } +} + func (h *seatHearer) ack(m jetstream.Msg) { if err := m.Ack(); err != nil { h.logf("acknowledging %s: %v", m.Subject(), err) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/toolchains.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/toolchains.go index 2581cd56..42bc9ccf 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/toolchains.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/toolchains.go @@ -157,7 +157,9 @@ func (h *toolchainsHeard) Reported(ctx context.Context, m jetstream.Msg) bool { h.logf("%s is no toolchain, and is dropped: %v", subject, err) return true } - if h.set.Set(e.Node, tc) { + changed := h.set.Set(e.Node, tc) + h.logf("toolchain heard on %s: %s %s of %s (changed: %v)", subject, e.Language, e.Version, e.Node, changed) + if changed { h.keep(e.Node, tc) h.agree(ctx) h.changed(ctx) diff --git a/modules/mesh-delivery-builder/internal/build/buildagain.go b/modules/mesh-delivery-builder/internal/build/buildagain.go index 2c135769..e72384b9 100644 --- a/modules/mesh-delivery-builder/internal/build/buildagain.go +++ b/modules/mesh-delivery-builder/internal/build/buildagain.go @@ -42,6 +42,8 @@ type handWatch struct { shut bool // ended is set when the look ended before the asks were all put. ended bool + // why is what the look that wrote nothing said in the builder's log. + why string } // settle closes done once the claim is written and every lane has put its ask. Call with b.mu held. @@ -73,8 +75,9 @@ func (b *Builder) handAsk(key, language, id string) { } // handEnded ends the watch of a request whose look ended: it wrote no claim, or the build ended. -func (b *Builder) handEnded(key string) { +func (b *Builder) handEnded(key, why string) { b.hand(key, func(w *handWatch) { + w.why = why if !w.shut { w.shut, w.ended = true, true close(w.done) @@ -158,11 +161,14 @@ func (b *Builder) BuildAgain(ctx context.Context, module, fp, why, by string, bo } b.mu.Lock() res := BuildAgainResult{Revision: w.rev, Asks: maps.Clone(w.asks)} - ended, shut, lanes := w.ended, w.shut, w.lanes + ended, shut, lanes, said := w.ended, w.shut, w.lanes, w.why b.mu.Unlock() switch { case res.Revision == 0 && shut: res.Refused = fmt.Sprintf("the builder looked at %s and wrote nothing (a toolchain moved, the claim was lost or could not be written): its log says why", key) + if said != "" { + res.Refused = fmt.Sprintf("the builder looked at %s and wrote nothing: %s", key, said) + } case res.Revision == 0: res.Pending = fmt.Sprintf("the builder has not claimed %s within %s: it waits behind other builds; builder_stuck shows where it stands", key, bound) case ended && len(res.Asks) < max(lanes, 0)+boolInt(lanes < 0): diff --git a/modules/mesh-delivery-builder/internal/build/entry_test.go b/modules/mesh-delivery-builder/internal/build/entry_test.go index eba6952f..dbf0432e 100644 --- a/modules/mesh-delivery-builder/internal/build/entry_test.go +++ b/modules/mesh-delivery-builder/internal/build/entry_test.go @@ -16,7 +16,7 @@ func TestAnEntryOfTheCatalogHalfIsTheFormTheBuilderBuildsBy(t *testing.T) { Inputs: &meshcatalog.EntryInputs{Src: 7, Toolchains: map[string]meshcatalog.ToolchainUsed{"go": {Version: "go1", Recipe: "1"}}, Paths: map[string][]string{"lib": {"a/b", "c"}}}} got := ModuleOf(e) - if got.Fp2 != "src2:f" || got.Manifest != "sha256:m" || got.Path != "modules/netcheck" || got.Commit != "abc" || got.Src != 7 || + if got.Fp2 != "src2:f" || got.Manifest != "m" || got.Path != "modules/netcheck" || got.Commit != "abc" || got.Src != 7 || got.Toolchains["go"].Version != "go1" || got.Packages["p"] != "1" || !reflect.DeepEqual(got.Needs, []string{"n"}) || got.Inputs2 == nil || !reflect.DeepEqual(got.Inputs2.Bases, []string{"base"}) || !reflect.DeepEqual(got.Inputs2.Paths, map[string]string{"a/b": "lib", "c": "lib"}) { diff --git a/modules/mesh-delivery-builder/internal/build/r4e_test.go b/modules/mesh-delivery-builder/internal/build/r4e_test.go index a79c0ed0..f48baf7b 100644 --- a/modules/mesh-delivery-builder/internal/build/r4e_test.go +++ b/modules/mesh-delivery-builder/internal/build/r4e_test.go @@ -253,8 +253,8 @@ func TestTheFetchOfAModuleNamingItsPathsCarriesItsDirectoryAndThosePaths(t *test } r2 := newRig(t, goBundle) r2.consider(t, "modules/m") - if a := r2.bm.callsOf("build_go_fetch")[0].body.(map[string]any); a["dir"] != nil || a["paths"] != nil { - t.Errorf("fetch args = %+v, want no dir or paths for a module naming none", a) + if a := r2.bm.callsOf("build_go_fetch")[0].body.(map[string]any); a["dir"] != "modules/m" || a["paths"] != nil { + t.Errorf("fetch args = %+v, want the module's directory and no paths for a module naming none (A-447)", a) } } diff --git a/modules/mesh-delivery-builder/internal/build/run.go b/modules/mesh-delivery-builder/internal/build/run.go index 5e0b5bea..9212971b 100644 --- a/modules/mesh-delivery-builder/internal/build/run.go +++ b/modules/mesh-delivery-builder/internal/build/run.go @@ -270,7 +270,7 @@ func (b *Builder) take(ctx context.Context, o Origin, key string, m meshcatalog. // built against, its packages and needs, and the named paths of its artifacts. func ModuleOf(e meshcatalog.CatalogEntry) meshcatalog.ModulesByModuleValue { m := meshcatalog.ModulesByModuleValue{Repository: e.Repository, Path: e.Path, Commit: e.Commit, Fp2: e.Fp, None2: e.None, - Manifest: e.ManifestDigest, Packages: e.Packages, Needs: e.Needs} + Manifest: meshcatalog.BareManifestDigest(e.ManifestDigest), Packages: e.Packages, Needs: e.Needs} if len(e.Bases) > 0 { m.Inputs2 = &meshcatalog.ModulesByModuleValueInputs2{Bases: e.Bases} } @@ -562,14 +562,20 @@ func (b *Builder) startOnce(ctx context.Context, key, module string, m meshcatal // building by this builder: it takes it again when it starts (ADR 0478 clause 5). func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesByModuleValue) { key, _ := builds.BuilderBuildKey(module, m.Fp2) - defer b.handEnded(key) + whyEnded := "" + defer func() { b.handEnded(key, whyEnded) }() defer b.unrelease(key) + // end logs why a look wrote nothing and keeps it for the answer to a build asked again (design 47 G A-412). + end := func(format string, args ...any) { + whyEnded = fmt.Sprintf(format, args...) + b.logf("%s at %s: %s", module, m.Fp2, whyEnded) + } plan, planErr, read := b.planOf(ctx, m.Manifest) var noModule *NoBuildModule if errors.As(planErr, &noModule) { // The seat list or the catalog half does not name the build module yet: nothing is claimed, and the look is made again // when they do (Reconsider, at each change of either; design 47 G A-82). - b.logf("%s at %s is not built yet: %v", module, m.Fp2, planErr) + end("is not built yet: %v", planErr) return } nothing := read && planErr == nil && len(plan.Tasks) == 0 @@ -580,7 +586,7 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB } // The fingerprint names a toolchain the build nodes no longer agree on: a new fingerprint is coming, and a build // now would be of this source with another toolchain (ADR 0584 clause 1, which changes ADR 0477 clause 2). Nothing is written. - b.logf("%s at %s is not built: %s", module, m.Fp2, why) + end("is not built: %s", why) return } if b.Waits != nil { @@ -599,12 +605,14 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB if trunk && planErr == nil && !nothing { var goOn bool if numbering, goOn = b.number(ctx, module, m, plan); !goOn { + end("is not built yet: it waits for its package's floor, nothing is claimed") return } } // Only a build of the registration's first watched branch reserves and releases a version (design 47 G §371). reserving := trunk && b.originOf(key).First && planErr == nil && !nothing && b.reserves(ctx, module, m, plan) if reserving && b.waitFill(module, m) { + end("is not built yet: wait-held, the catalog has not said versions-filled") return } // A key built again by hand is taken over as it stands too: one left building by a look that ended without its write @@ -612,10 +620,11 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB cl, err := b.Claimer.Claim(ctx, module, m.Fp2, m.Manifest, ClaimOptions{TakeOver: first || byHand, ByHand: byHand, ByEvent: byEvent, ImageBuilder: imageSeat, Seats: b.Seats, Trunk: trunk, Published: b.isPublished, Stored: b.storedOnce(key)}) if err != nil { - b.logf("%s: %v", module, err) + end("the claim was refused: %v", err) return } if cl == nil { + end("nothing was claimed: the key is held by a build or a look already, is done or failed for a reason not retried on this fingerprint, waits for a package, or was made by another builder first") return } b.handClaimed(key, cl.Rev) @@ -1038,11 +1047,12 @@ func (n *askNotes) note(ctx context.Context, language, id, step string) error { // is copied by its pinned reference with no fetch (ADR 0498 clause 4); a lane of copies alone fetches nothing. A lane of a // key taken over at start waits for the ask the key names and puts none. func (b *Builder) runLane(ctx context.Context, l *lane, repository string, m meshcatalog.ModulesByModuleValue, module string, asked *askNotes) { - req := sdkstep.Fetch{Repository: repository, Commit: m.Commit} + // The module's directory goes with every fetch, so a Go build downloads and judges that module and what its go.mod + // replaces alone, never another Go module of the tree (design 47 G, A-447). + req := sdkstep.Fetch{Repository: repository, Commit: m.Commit, Dir: m.Path} if m.Inputs2 != nil && len(m.Inputs2.Paths) > 0 { // A module whose every artifact names its paths is built from those alone (ADR 0499 clause 4): the paths come from // the indexer's kept inputs, never from a manifest (the lead's decision L8 of R4e). - req.Dir = m.Path for p := range m.Inputs2.Paths { req.Paths = append(req.Paths, p) } diff --git a/modules/mesh-delivery-builder/internal/build/run_test.go b/modules/mesh-delivery-builder/internal/build/run_test.go index 1d0d2bef..b30aeab5 100644 --- a/modules/mesh-delivery-builder/internal/build/run_test.go +++ b/modules/mesh-delivery-builder/internal/build/run_test.go @@ -902,7 +902,7 @@ func TestABuildAskWaitingInItsStreamIsNotBounded(t *testing.T) { key: &builds.BuilderBuild{State: builds.BuildFailed, Error: "ace: no tun"}}, {name: "build again: a module with no manifest is refused", again: true, refuse: "names no manifest", edit: func(m *meshcatalog.ModulesByModuleValue) { m.Manifest = "" }, key: &builds.BuilderBuild{State: builds.BuildFailed, Error: "ace: no tun"}}, - {name: "build again: a toolchain that moved writes nothing and is said at once", again: true, refuse: "wrote nothing", + {name: "build again: a toolchain that moved writes nothing and says why at once", again: true, refuse: "wrote nothing: is not built:", edit: func(m *meshcatalog.ModulesByModuleValue) { m.Toolchains = CatalogToolchains(map[string]builds.ToolchainUsed{"go": {Version: "go1.0", Recipe: "1"}}) }, diff --git a/modules/mesh-delivery-builder/internal/build/step.go b/modules/mesh-delivery-builder/internal/build/step.go index f92fa35d..df195edb 100644 --- a/modules/mesh-delivery-builder/internal/build/step.go +++ b/modules/mesh-delivery-builder/internal/build/step.go @@ -71,8 +71,8 @@ func (b *Builder) buildEntry(ctx context.Context, e meshbuilds.BuildEntry) (outc } return meshbuilds.StepEndedOutcomeFailed, failedWords } - m := meshcatalog.ModulesByModuleValue{Repository: entry.Repository, Commit: entry.Commit, Fp2: entry.Fp, Manifest: entry.ManifestDigest, Path: entry.Path, - Toolchains: CatalogToolchains(b.agreedFor(ctx, entry.ManifestDigest)), Packages: entry.Packages} + m := meshcatalog.ModulesByModuleValue{Repository: entry.Repository, Commit: entry.Commit, Fp2: entry.Fp, Manifest: meshcatalog.BareManifestDigest(entry.ManifestDigest), Path: entry.Path, + Toolchains: CatalogToolchains(b.agreedFor(ctx, meshcatalog.BareManifestDigest(entry.ManifestDigest))), Packages: entry.Packages} b.consider(ctx, entry.Module, m) select { case log := <-ended: diff --git a/modules/mesh-delivery-builder/internal/versions/entrynames.go b/modules/mesh-delivery-builder/internal/versions/entrynames.go index d3761808..e317b4a5 100644 --- a/modules/mesh-delivery-builder/internal/versions/entrynames.go +++ b/modules/mesh-delivery-builder/internal/versions/entrynames.go @@ -2,6 +2,7 @@ package versions import ( "context" + "fmt" "sort" "strings" @@ -38,7 +39,9 @@ func NamesFrom(all Entries) PackageNames { } // CarriersFrom are the module artifacts a package's name in its ecosystem is the name of, as the entries hold them (design 47 G -// §572, §478), each distinct module and artifact once, sorted; a name no entry carries answers none. +// §572, §478), each distinct module and artifact once, sorted; a name no entry carries answers none. A bundle's or an archive's +// name is `/` (NameOf), read from its artifact reference `:`: the entry gives it no +// `package` (design 47 G A-418). func CarriersFrom(all Entries) func(ctx context.Context, name string) ([]Built, error) { return func(_ context.Context, name string) ([]Built, error) { seen := map[Built]bool{} @@ -46,7 +49,7 @@ func CarriersFrom(all Entries) func(ctx context.Context, name string) ([]Built, for _, e := range all() { for _, a := range e.Artifacts { artifact, ok := artifactOf(e.Module, a.Ref) - if !ok || a.Package == nil || a.Package.Name != name || seen[Built{e.Module, artifact}] { + if !ok || !carries(e.Module, artifact, a, name) || seen[Built{e.Module, artifact}] { continue } seen[Built{e.Module, artifact}] = true @@ -58,6 +61,39 @@ func CarriersFrom(all Entries) func(ctx context.Context, name string) ([]Built, } } +// carries says whether artifact a of module is named name: its package's name, or a bundle's or an archive's NameOf (A-418). +func carries(module, artifact string, a meshcatalog.Artifact, name string) bool { + if a.Package != nil { + return a.Package.Name == name + } + return (a.Kind == KindBundle || a.Kind == KindArchive) && NameOf(module, artifact) == name +} + +// LookedAt says the entries a name was looked for in, for the log of a name no entry carries (design 47 G A-418): how many, +// and each module's artifacts with the name each is carried as. +func LookedAt(all Entries) string { + entries := all() + var out []string + for _, e := range entries { + for _, a := range e.Artifacts { + artifact, ok := artifactOf(e.Module, a.Ref) + if !ok { + continue + } + switch { + case a.Package != nil: + out = append(out, a.Ref+" as "+a.Package.Name) + case a.Kind == KindBundle || a.Kind == KindArchive: + out = append(out, a.Ref+" as "+NameOf(e.Module, artifact)) + default: + out = append(out, a.Ref+" ("+a.Kind+", named nothing)") + } + } + } + sort.Strings(out) + return fmt.Sprintf("%d entries: %s", len(entries), strings.Join(out, ", ")) +} + // ModuleFrom is the module and artifact a package's name is built from, from the entries (CarriersFrom); more than one entry // carrying it is an error naming them. func ModuleFrom(all Entries) func(ctx context.Context, name string) (module, artifact string, found bool, err error) { diff --git a/modules/mesh-delivery-builder/internal/versions/entrynames_test.go b/modules/mesh-delivery-builder/internal/versions/entrynames_test.go index 32644613..7cb1276b 100644 --- a/modules/mesh-delivery-builder/internal/versions/entrynames_test.go +++ b/modules/mesh-delivery-builder/internal/versions/entrynames_test.go @@ -3,6 +3,7 @@ package versions import ( "context" "reflect" + "strings" "testing" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" @@ -19,7 +20,8 @@ func named(module, artifact, name string) meshcatalog.CatalogEntry { func TestPackageNamesAreReadFromTheCatalogHalfsEntries(t *testing.T) { entries := func() []meshcatalog.CatalogEntry { return []meshcatalog.CatalogEntry{named("mesh-sdk", "go", "git.novox.be/novox/mesh-sdk/go"), named("netcheck", "lib", "netcheck"), - named("twin-a", "lib", "twin"), named("twin-b", "lib", "twin"), {Module: "bare"}} + named("twin-a", "lib", "twin"), named("twin-b", "lib", "twin"), {Module: "bare"}, + {Module: "pipe", Artifacts: []meshcatalog.Artifact{{Ref: "pipe:program", Kind: KindBundle}, {Ref: "pipe:img", Kind: KindImage}}}} } ctx := context.Background() for _, c := range []struct { @@ -48,6 +50,17 @@ func TestPackageNamesAreReadFromTheCatalogHalfsEntries(t *testing.T) { if _, _, _, err := ModuleFrom(entries)(ctx, "twin"); err == nil { t.Error("ModuleFrom(twin): two entries carry it, want an error") } + // Design 47 G A-418: a bundle is carried as /, from its reference, with no package in its entry; a kind + // that is neither a bundle nor an archive is not named so. + if got, _ := CarriersFrom(entries)(ctx, "pipe/program"); !reflect.DeepEqual(got, []Built{{"pipe", "program"}}) { + t.Errorf("CarriersFrom(pipe/program) = %v, want the bundle pipe:program", got) + } + if got, _ := CarriersFrom(entries)(ctx, "pipe/img"); len(got) != 0 { + t.Errorf("CarriersFrom(pipe/img) = %v, want none: an image with no package is named nothing", got) + } + if looked := LookedAt(entries); !strings.Contains(looked, "6 entries") || !strings.Contains(looked, "pipe:program as pipe/program") { + t.Errorf("LookedAt = %q, want the six entries and the bundle's name", looked) + } got, _ := CarriersFrom(entries)(ctx, "twin") if want := []Built{{"twin-a", "lib"}, {"twin-b", "lib"}}; !reflect.DeepEqual(got, want) { t.Errorf("CarriersFrom(twin) = %v, want %v", got, want) diff --git a/modules/mesh-delivery-builder/internal/versions/republish.go b/modules/mesh-delivery-builder/internal/versions/republish.go index 1939a23c..cefb74af 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish.go +++ b/modules/mesh-delivery-builder/internal/versions/republish.go @@ -17,8 +17,8 @@ import ( // **A reserved version left unpublished is published again by the builder, on an event or by a person's tool** (design 47 // G §588, ADR 0674): on the node-engine seat's `running` of a module whose catalog graph entry claims the registry seat -// of the missing artifacts' kind, and on its `manifest-reads-changed` with `why` `returned` of the node such a holder -// runs on. Each message is acted on once, by its stream sequence (state `acted`); each holder has one queue of versions, +// of the missing artifacts' kind, and on its `manifest-reads-changed` with `why` `returned`, at each registry seat's holder +// the seat-holders view names (A-416, A-416a: known from the start, not from the running heard). Each message is acted on once, by its stream sequence (state `acted`); each holder has one queue of versions, // kept in the state `publish-queue`, sent one at a time. A send is the registry seat's `publish` with the digest and no // parts (A-73): the holder takes the bytes from the artifact store by digest, and refuses what no store holds. @@ -41,6 +41,13 @@ const ( VerbPublish = "publish" ) +// RepublishTransfer is a publish again's transfer name, the builder's own (the registry part's publish: the caller names its +// transfer): safe as a transfer id, which holds none of "/", ".", " ", "*" or ">" (mesh-sdk's parts receiver refuses them), so a +// version's dots are dashes (design 47 G §588). +func RepublishTransfer(module, version, artifact string) string { + return strings.NewReplacer("/", "-", ".", "-", " ", "-", "*", "-", ">", "-", "@", "-").Replace("republish-" + module + "-" + version + "-" + artifact) +} + // RegistrySeats are the four registry seats a version is published to. var RegistrySeats = []string{SeatImages, SeatArtifacts, SeatGoPackages, SeatNPM} @@ -112,9 +119,11 @@ type Republisher struct { Logf func(string, ...any) // Go starts the sending of a holder's queue; nil starts a goroutine. Go func(func()) + // Holders answers a registry seat's holders: the catalog's SeatHolders, the part's one holder function that its FollowSeat + // of the assignments takes too, read from the builder's start (design 47 G A-416, A-416a); nil answers none. + Holders func(seat string) []string mu sync.Mutex - runs map[string]map[string][]string // node -> holder module -> the registry seats it claims busy map[string]bool // lastQueued is the newest time a version was queued at: a clock that has not moved between two versions (a coarse clock, // or a fixed one) must not make the queue's order the order of its keys, so each is queued after the last. @@ -205,8 +214,8 @@ func (r *Republisher) registrySeatsOf(ctx context.Context, fingerprint string) ( return out, nil } -// running takes a running in: a module stopped is forgotten; one running whose entry claims a registry seat is a holder on -// its node, and its versions are queued. +// running takes a running in: one of a module whose entry claims a registry seat queues the versions waiting on it (§588). It +// is not how a holder is known: Holders answers that (design 47 G A-416). func (r *Republisher) running(ctx context.Context, data []byte) error { var ev nodeengine.Running if err := json.Unmarshal(data, &ev); err != nil || ev.Module == "" || ev.Node == "" { @@ -214,28 +223,12 @@ func (r *Republisher) running(ctx context.Context, data []byte) error { return nil } if ev.Stopped || ev.Fingerprint == "" { - r.mu.Lock() - delete(r.runs[ev.Node], ev.Module) - r.mu.Unlock() return nil } seats, err := r.registrySeatsOf(ctx, ev.Fingerprint) if err != nil { return fmt.Errorf("the catalog entry %s of %s cannot be read: %w", ev.Fingerprint, ev.Module, err) } - r.mu.Lock() - if r.runs == nil { - r.runs = map[string]map[string][]string{} - } - if r.runs[ev.Node] == nil { - r.runs[ev.Node] = map[string][]string{} - } - if len(seats) == 0 { - delete(r.runs[ev.Node], ev.Module) - } else { - r.runs[ev.Node][ev.Module] = seats - } - r.mu.Unlock() if len(seats) == 0 { return nil } @@ -243,7 +236,30 @@ func (r *Republisher) running(ctx context.Context, data []byte) error { return err } -// returned takes a manifest-reads-changed in: only one with why returned acts, for every holder known to run on its node. +// heldSeats are the registry seats' holders as Holders answers them: holder module -> the registry seats it holds. +func (r *Republisher) heldSeats() map[string][]string { + held := map[string][]string{} + if r.Holders == nil { + return held + } + for _, seat := range RegistrySeats { + for _, h := range r.Holders(seat) { + held[h] = append(held[h], seat) + } + } + return held +} + +// holdersFn answers a seat's holders from Holders. +func (r *Republisher) holdersFn(seat string) []string { + if r.Holders == nil { + return nil + } + return r.Holders(seat) +} + +// returned takes a manifest-reads-changed in: only one with why returned acts, for every registry seat's holder Holders +// answers (design 47 G A-416a); a version queued at a holder already is not queued again. func (r *Republisher) returned(ctx context.Context, data []byte) error { var ev nodeengine.ManifestReadsChanged if err := json.Unmarshal(data, &ev); err != nil || ev.Node == "" { @@ -253,12 +269,7 @@ func (r *Republisher) returned(ctx context.Context, data []byte) error { if ev.Why != nodeengine.ManifestReadsChangedWhyReturned { return nil } - r.mu.Lock() - holders := map[string][]string{} - for m, seats := range r.runs[ev.Node] { - holders[m] = seats - } - r.mu.Unlock() + holders := r.heldSeats() if len(holders) == 0 { return nil } @@ -311,6 +322,7 @@ func (r *Republisher) queue(ctx context.Context, vs []ReservedVersion, holdersOf break } if v.Fingerprint == "" || v.BuiltAt.IsZero() { + r.logf("publish again: %s %s is not queued: it holds no fingerprint or its build has not ended with every digest", v.Module, v.Version) continue } e, err := r.Entry(ctx, v.Fingerprint) @@ -320,20 +332,28 @@ func (r *Republisher) queue(ctx context.Context, vs []ReservedVersion, holdersOf byHolder := map[string]map[string]string{} for _, ref := range v.Missing() { if _, no := v.Unstored[ref]; no { + r.logf("publish again: %s %s: %s is not queued: a holder refused it as not stored", v.Module, v.Version, ref) continue } + found := false for _, a := range e.Artifacts { seat, ok := SeatOfArtifact(a) if a.Ref != ref || !ok { continue } + found = true if hs := holdersOf(seat); len(hs) > 0 { if byHolder[hs[0]] == nil { byHolder[hs[0]] = map[string]string{} } byHolder[hs[0]][ref] = v.Artifacts[ref] + } else { + r.logf("publish again: %s %s: %s is not queued: the registry seat %s has no holder in the seat-holders view", v.Module, v.Version, ref, seat) } } + if !found { + r.logf("publish again: %s %s: %s is not queued: the catalog entry %s names no registry seat for it", v.Module, v.Version, ref, v.Fingerprint) + } } did := false for holder, arts := range byHolder { @@ -361,6 +381,7 @@ func (r *Republisher) enqueue(ctx context.Context, v ReservedVersion, holder str if _, _, found, err := r.Queue.Get(ctx, key); err != nil { return false, err } else if found { + r.logf("publish again: %s %s is queued at %s already", v.Module, v.Version, holder) return false, nil } raw, _ := json.Marshal(QueuedPublish{V: 1, Holder: holder, Module: v.Module, Version: v.Version, Artifacts: arts, Queued: r.queuedAt()}) @@ -380,13 +401,14 @@ func (r *Republisher) enqueue(ctx context.Context, v ReservedVersion, holder str } return false, fmt.Errorf("%s cannot be queued: %w", key, err) } + r.logf("publish again: %s %s is queued to publish at %s: %d artifacts", v.Module, v.Version, holder, len(arts)) return true, nil } // Republish is builder_publish_again: with module and version, that reserved version's missing artifacts; with module // alone, each reserved version of it whose artifacts are not all published; with neither, every version the finding -// version-unreleased names. It queues as the events do (no limit but the cap), for the holders known to run, and answers -// the versions it queued. +// version-unreleased names. It queues as the events do (no limit but the cap), at the holders Holders answers (design 47 G +// A-416), and answers the versions it queued. func (r *Republisher) Republish(ctx context.Context, module, version string) ([]string, error) { var vs []ReservedVersion if module == "" { @@ -413,15 +435,7 @@ func (r *Republisher) Republish(ctx context.Context, module, version string) ([] return nil, fmt.Errorf("%s holds no reserved version%s with an artifact unpublished", module, map[bool]string{true: " " + version, false: ""}[version != ""]) } } - r.mu.Lock() - known := map[string][]string{} - for _, mods := range r.runs { - for m, seats := range mods { - known[m] = seats - } - } - r.mu.Unlock() - return r.queue(ctx, vs, func(seat string) []string { return holdersOf(known, seat) }, 0) + return r.queue(ctx, vs, r.holdersFn, 0) } // Queued are the queued versions, per holder in the order they are sent, and the acted keys with their sequences: @@ -605,9 +619,13 @@ func (r *Republisher) send(ctx context.Context, q QueuedPublish) { kind := art.Kind bound, cancel := context.WithTimeout(ctx, UnreleasedBound) // a context's bound, no timer (ADR 0437 §8) err := r.Send(bound, Publish{Seat: seat, Kind: kind, Name: name, Version: v.Version, Digest: q.Artifacts[ref], Fingerprint: v.Fingerprint, - Commit: v.Commit, Transfer: "republish-" + q.Module + "-" + v.Version + "-" + strings.TrimPrefix(ref, q.Module+":")}) + Commit: v.Commit, Transfer: RepublishTransfer(q.Module, v.Version, strings.TrimPrefix(ref, q.Module+":"))}) cancel() + if err == nil { + r.logf("publish again: %s %s: %s sent to %s as %s %s, digest %s; the package-published is said when the seat says published", q.Module, q.Version, ref, seat, name, v.Version, q.Artifacts[ref]) + } if err != nil { + r.logf("publish again: %s %s: %s refused by %s: %v", q.Module, q.Version, ref, seat, err) words := err.Error() if strings.Contains(words, strings.TrimSuffix(NotStoredWords, ": ")) { if ok, merr := r.Reserved.MarkUnstored(ctx, q.Module, q.Version, ref, words); merr != nil { diff --git a/modules/mesh-delivery-builder/internal/versions/republish_test.go b/modules/mesh-delivery-builder/internal/versions/republish_test.go index 1fbe7274..62433295 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish_test.go +++ b/modules/mesh-delivery-builder/internal/versions/republish_test.go @@ -31,6 +31,8 @@ type republishBed struct { sent []Publish said []string refuse string // the words Send fails with, empty for none + // holders are the registry seats' holders the seat-holders view names (design 47 G A-416). + holders map[string][]string } func newRepublishBed(t *testing.T, max int) *republishBed { @@ -58,6 +60,7 @@ func newRepublishBed(t *testing.T, max int) *republishBed { b.said = append(b.said, v.Module+" "+v.Version+": "+why) }, Logf: t.Logf} + b.Holders = func(seat string) []string { return b.holders[seat] } return b } @@ -102,7 +105,8 @@ func TestRepublish(t *testing.T) { } } p := b.sent[0] - if p.Seat != SeatArtifacts || p.Name != "m/prog" || p.Kind != "bundle" || p.Version != v.Version || p.Digest != "sha256:aa" || p.Fingerprint != "src2:m" { + if p.Seat != SeatArtifacts || p.Name != "m/prog" || p.Kind != "bundle" || p.Version != v.Version || p.Digest != "sha256:aa" || p.Fingerprint != "src2:m" || + p.Transfer != "republish-m-"+strings.ReplaceAll(v.Version, ".", "-")+"-prog" || strings.ContainsAny(p.Transfer, "/. *>") { t.Errorf("sent %+v, want the bundle by digest to the oci seat, the Go package left to its own seat's holder", p) } if _, err := b.Heard(ctx, subject, data, 5); err != nil || len(b.sent) != 1 { @@ -115,14 +119,10 @@ func TestRepublish(t *testing.T) { t.Errorf("a key stays in the queue after its outcome: %v", keys) } }) - t.Run("returned acts, started does not", func(t *testing.T) { + t.Run("returned acts at the seat's holder, started does not", func(t *testing.T) { b := newRepublishBed(t, 50) b.reserve(t, "m") - subject, data := running("n1", "oci", "src2:holder", true) // stopped: not a holder yet - _, _ = b.Heard(ctx, subject, data, 1) - subject, data = running("n1", "oci", "src2:holder", false) - _, _ = b.Heard(ctx, subject, data, 2) - b.sent = nil + b.holders = map[string][]string{SeatArtifacts: {"oci"}} for i, why := range []string{nodeengine.ManifestReadsChangedWhyStarted, "", nodeengine.ManifestReadsChangedWhyReturned} { ev, _ := json.Marshal(nodeengine.ManifestReadsChanged{Node: "n1", Why: why}) handled, err := b.Heard(ctx, nodeengine.SubjectManifestReadsChanged("n1"), ev, uint64(10+i)) @@ -194,23 +194,25 @@ func TestRepublish(t *testing.T) { t.Errorf("resume sent %d (%v), want the begun version sent anew", len(b.sent), err) } }) - t.Run("the tool queues for a holder known to run", func(t *testing.T) { + t.Run("after a fresh start the tool queues at the seat's holder, no running heard", func(t *testing.T) { + // Design 47 G A-416, A-416a: the holder is the one the seat-holders view names from the start, not one learnt from a + // running heard since; a seat with no holder queues nothing. b := newRepublishBed(t, 1) b.reserve(t, "m1") b.reserve(t, "m2") if q, err := b.Republish(ctx, "", ""); err != nil || len(q) != 0 { - t.Errorf("no holder known: queued %v (%v), want none", q, err) + t.Errorf("no holder named: queued %v (%v), want none", q, err) } - subject, data := running("n1", "oci", "src2:holder", false) - _, _ = b.Heard(ctx, subject, data, 1) // Max 1: only m2 sent - b.sent = nil + b.holders = map[string][]string{SeatArtifacts: {"oci"}} q, err := b.Republish(ctx, "", "") - if err != nil || fmt.Sprint(q) != "[m2 0.1.0 m1 0.1.0]" || len(b.sent) != 2 { - t.Errorf("the tool with neither queued %v (%v), sent %d: want both versions, with no limit", q, err, len(b.sent)) + if err != nil || fmt.Sprint(q) != "[m2 0.1.0 m1 0.1.0]" || len(b.sent) != 2 || b.sent[0].Seat != SeatArtifacts { + t.Errorf("the tool with neither queued %v (%v), sent %+v: want both versions at oci, with no limit", q, err, b.sent) } if _, err := b.Republish(ctx, "m1", "0.1.9"); err == nil { t.Error("a version no reservation holds is not refused") } + subject, data := running("n1", "oci", "src2:holder", false) + _, _ = b.Heard(ctx, subject, data, 1) answer, err := AnswerQueue(Reader{Keys: func() ([]string, error) { return nil, nil }}, Reader{Keys: func() ([]string, error) { return b.acted.KeysOf(ctx, AllFilter) }, Get: func(k string) (json.RawMessage, bool, error) { v, _, ok, err := b.acted.Get(ctx, k); return v, ok, err }}) if err != nil || answer.Acted[ActedKey(subject)] != 1 { diff --git a/modules/mesh-delivery-builder/internal/versions/reserve.go b/modules/mesh-delivery-builder/internal/versions/reserve.go index eef5f337..c6216f79 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve.go @@ -66,6 +66,16 @@ type ReservedVersion struct { // Dependencies are, by artifact reference, what the step's result says each artifact resolved (kind 1) and was built with // (kind 3), kept for `package-published` (design 47 G §466, §673, A-57). Dependencies map[string][]meshbuilds.Dependency `json:"dependencies,omitempty"` + // Kept are the registry seats' published heard while the build had not yet recorded every digest and whose digest marked + // no artifact then: kept as heard, they mark their artifact when the build records its digests (design 47 G A-415). + Kept []KeptPublished `json:"kept-published,omitempty"` +} + +// KeptPublished is a registry seat's published kept on a reservation, as heard (design 47 G A-415). +type KeptPublished struct { + Name string `json:"name"` + Version string `json:"version"` + Digest string `json:"digest"` } // Source is what a build reserving a version is made from (design 47 G §370): the repository and commit the git tag is @@ -345,30 +355,38 @@ func (m Marked) PackagePublished(digest string, at time.Time) meshbuilds.Package // Published takes a registry seat's published in: the artifacts of a reservation at version (a leading v is the Go form) // whose built digest it names are marked published. It answers each artifact it newly marked, with the reservation as marked. -func (r *Reserver) Published(ctx context.Context, version, digest string) ([]Marked, error) { +// A published that marks no artifact of a reservation at version whose build has not recorded every digest is kept on that +// reservation as heard (name, version, digest), and the keys it is kept on are answered too (design 47 G A-415): Kept marks +// it when the build records its digests. +func (r *Reserver) Published(ctx context.Context, name, version, digest string) ([]Marked, []string, error) { version = strings.TrimPrefix(version, "v") if version == "" || digest == "" { - return nil, nil + return nil, nil, nil } keys, err := r.Store.KeysOf(ctx, AllFilter) if err != nil { - return nil, fmt.Errorf("the reservations cannot be listed: %w", err) + return nil, nil, fmt.Errorf("the reservations cannot be listed: %w", err) } sort.Strings(keys) var marked []Marked + var kept []string for _, k := range keys { again: cur, rev, found, err := r.get(ctx, k) if err != nil { - return marked, err + return marked, kept, err } if !found || cur.Version != version { continue } - changed := false + changed, matched, keep := false, false, false var arts []string for a, d := range cur.Artifacts { - if d == digest && !cur.Published[a] { + if d != digest { + continue + } + matched = true + if !cur.Published[a] { if cur.Published == nil { cur.Published = map[string]bool{} } @@ -377,6 +395,10 @@ func (r *Reserver) Published(ctx context.Context, version, digest string) ([]Mar } } sort.Strings(arts) + if !matched && cur.BuiltAt.IsZero() && !cur.keeps(name, digest) { + cur.Kept = append(cur.Kept, KeptPublished{Name: name, Version: version, Digest: digest}) + changed, keep = true, true + } if !changed { continue } @@ -384,13 +406,76 @@ func (r *Reserver) Published(ctx context.Context, version, digest string) ([]Mar if _, err := r.Store.Update(ctx, k, raw, rev); errors.Is(err, ErrConflict) { goto again } else if err != nil { - return marked, fmt.Errorf("%s cannot be written: %w", k, err) + return marked, kept, fmt.Errorf("%s cannot be written: %w", k, err) } for _, a := range arts { marked = append(marked, Marked{Reserved: cur, Artifact: a}) } + if keep { + kept = append(kept, k) + } + } + return marked, kept, nil +} + +func (v ReservedVersion) keeps(name, digest string) bool { + for _, h := range v.Kept { + if h.Name == name && h.Digest == digest { + return true + } + } + return false +} + +// Kept takes the published kept on module's reservation of version in once its build recorded every digest (design 47 G +// A-415): each kept published whose digest is an artifact's marks that artifact, as one heard after would, and every kept one +// leaves the reservation. It answers the artifacts newly marked and the kept published whose digest matched no artifact. +func (r *Reserver) Kept(ctx context.Context, module, version string) ([]Marked, []KeptPublished, error) { + series, _, err := SplitVersion(version) + if err != nil { + return nil, nil, err + } + key := ReservedKey(module, series) + for { + cur, rev, found, err := r.get(ctx, key) + if err != nil || !found || cur.Version != version || cur.BuiltAt.IsZero() || len(cur.Kept) == 0 { + return nil, nil, err + } + var arts []string + var unmatched []KeptPublished + for _, h := range cur.Kept { + matched := false + for a, d := range cur.Artifacts { + if d != h.Digest { + continue + } + matched = true + if !cur.Published[a] { + if cur.Published == nil { + cur.Published = map[string]bool{} + } + cur.Published[a] = true + arts = append(arts, a) + } + } + if !matched { + unmatched = append(unmatched, h) + } + } + cur.Kept = nil + sort.Strings(arts) + raw, _ := json.Marshal(cur) + if _, err := r.Store.Update(ctx, key, raw, rev); errors.Is(err, ErrConflict) { + continue + } else if err != nil { + return nil, nil, fmt.Errorf("%s cannot be written: %w", key, err) + } + var marked []Marked + for _, a := range arts { + marked = append(marked, Marked{Reserved: cur, Artifact: a}) + } + return marked, unmatched, nil } - return marked, nil } // Of is module's reservation of series, and whether there is one; with an empty series the module's highest. @@ -496,7 +581,7 @@ func AnswerReservedByName(ctx context.Context, r Reader, carriers func(context.C } switch { case len(got) == 0: - return meshbuilds.ReservedAnswer{Error: "no entry carries the name " + name}, nil + return meshbuilds.ReservedAnswer{Error: NoEntryCarries + name}, nil case len(got) > 1: return meshbuilds.ReservedAnswer{Error: MoreThanOne(name, got)}, nil } @@ -527,6 +612,9 @@ func AnswerReservedByName(ctx context.Context, r Reader, carriers func(context.C return meshbuilds.ReservedAnswer{Error: fmt.Sprintf("%s (%s) has no reserved version", name, module)}, nil } +// NoEntryCarries opens the answer of reserved given a name no entry carries. +const NoEntryCarries = "no entry carries the name " + // The descriptions of the reservation's tools. const ( ReservedDescription = "The versions the builder reserved (its state reserved, design 47 G section 369): one per module and MAJOR.MINOR, " + diff --git a/modules/mesh-delivery-builder/internal/versions/reserve_test.go b/modules/mesh-delivery-builder/internal/versions/reserve_test.go index 4fd7936f..2ba984d3 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve_test.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve_test.go @@ -143,7 +143,7 @@ func TestReservationIsReadAndMarkedPublished(t *testing.T) { if got, err := AnswerReserved(rd, "other"); err != nil || len(got["reserved"].([]ReservedVersion)) != 0 { t.Errorf("builder_reserved of another module = %v (%v), want none", got, err) } - marked, err := r.Published(ctx, "v1.4.3", "sha256:aa") + marked, _, err := r.Published(ctx, "m-a", "v1.4.3", "sha256:aa") if err != nil || len(marked) != 1 { t.Fatalf("a published of 1.4.3 with a built digest marked %v (%v)", marked, err) } @@ -155,7 +155,7 @@ func TestReservationIsReadAndMarkedPublished(t *testing.T) { if wantSaid := (meshbuilds.PackagePublished{V: 1, Artifact: "m:a", At: &atUTC, Branch: "main", Source: 41, Module: "m", Version: "1.4.3", Digest: "sha256:aa", Dependencies: deps}); !reflect.DeepEqual(said, wantSaid) { t.Errorf("package-published = %+v, want %+v", said, wantSaid) } - if marked, _ := r.Published(ctx, "1.4.3", "sha256:other"); len(marked) != 0 { + if marked, _, _ := r.Published(ctx, "m-a", "1.4.3", "sha256:other"); len(marked) != 0 { t.Errorf("a published with another digest marked %v", marked) } cur, _, _ := r.At(ctx, ReservedKey("m", "1.4")) diff --git a/modules/mesh-delivery-builder/internal/versions/store.go b/modules/mesh-delivery-builder/internal/versions/store.go index efe216af..66fb89fe 100644 --- a/modules/mesh-delivery-builder/internal/versions/store.go +++ b/modules/mesh-delivery-builder/internal/versions/store.go @@ -104,6 +104,10 @@ func (v Versions) Number(ctx context.Context, c Claim) (Decision, Entry, error) return Decision{}, Entry{}, fmt.Errorf("%s: the versions kept changing under 16 claims", c.Name) } +// ErrNotNumbered is a version the state versions does not hold (design 51's numbering by name): a version the reservation +// numbered (§369) is never held there. +var ErrNotNumbered = errors.New("not numbered by the builder") + // Mark moves one version to a new state by compare-and-set, as the holders' events say (published, refused, removed): // change edits the entry read; a version the state does not hold is an error naming it. func (v Versions) Mark(ctx context.Context, name, version string, change func(*Entry)) (Entry, error) { @@ -114,7 +118,7 @@ func (v Versions) Mark(ctx context.Context, name, version string, change func(*E return Entry{}, fmt.Errorf("%s: %w", key, err) } if !found { - return Entry{}, fmt.Errorf("%s@%s is not numbered by the builder", name, version) + return Entry{}, fmt.Errorf("%s@%s is %w", name, version, ErrNotNumbered) } e, err := Decode(raw) if err != nil { diff --git a/modules/mesh-delivery-checker/internal/check/engines.go b/modules/mesh-delivery-checker/internal/check/engines.go index 02110b28..bf2fc352 100644 --- a/modules/mesh-delivery-checker/internal/check/engines.go +++ b/modules/mesh-delivery-checker/internal/check/engines.go @@ -227,7 +227,7 @@ func (e EngineCompositions) inSandbox(ctx context.Context, c *Case, head, node s return a, err } } - job := buildstep.ComposeJob{Fetch: buildstep.Fetch{Repository: nodeEngineRepo, Commit: head, Packages: packagesFor(e.Published, c, nodeEngineRepo)}, Dir: meshcatalogclient.RootPath, + job := buildstep.ComposeJob{Fetch: buildstep.Fetch{Repository: nodeEngineRepo, Commit: head, Dir: meshcatalogclient.RootPath, Packages: packagesFor(e.Published, c, nodeEngineRepo)}, Dir: meshcatalogclient.RootPath, Package: composer.Package, Request: raw, Reader: "the node-engine head of " + c.Group} // The ask travels on the bus, whose message limit a whole request passes (1.2 MB for a large node): it goes packed. if err := job.PackRequest(raw); err != nil { diff --git a/modules/mesh-delivery-checker/internal/check/engines_test.go b/modules/mesh-delivery-checker/internal/check/engines_test.go index 499d3ce5..66483abb 100644 --- a/modules/mesh-delivery-checker/internal/check/engines_test.go +++ b/modules/mesh-delivery-checker/internal/check/engines_test.go @@ -219,6 +219,9 @@ func TestTheCompositionIsMadeFromTheEnginesAnswers(t *testing.T) { t.Fatalf("asked %+v, jobs %+v: want the input asked and one job", e.asked, sb.jobs) } job := sb.jobs[0] + if job.Fetch.Dir == "" || job.Fetch.Dir != job.Dir { // a build is for one module: its fetch names the directory (A-447b) + t.Errorf("the compose job's fetch names the directory %q, want its module's %q", job.Fetch.Dir, job.Dir) + } var req composer.Request if len(job.Request) == 0 || job.Request[0] != '"' { t.Errorf("the request went whole, not packed (issue 1966): %.60s", job.Request) diff --git a/modules/mesh-delivery-checker/internal/check/manifests_judge.go b/modules/mesh-delivery-checker/internal/check/manifests_judge.go index e137cfbc..f665de95 100644 --- a/modules/mesh-delivery-checker/internal/check/manifests_judge.go +++ b/modules/mesh-delivery-checker/internal/check/manifests_judge.go @@ -160,7 +160,7 @@ func (st *state) runJudge(ctx context.Context, req composer.Request, touched []s st.fail(st.goModule(), err.Error()) return change, trunk, false } - job := buildstep.ComposeJob{Fetch: buildstep.Fetch{Repository: DeliveryRepository, Commit: commit, Packages: versions}, Dir: JudgeDir, + job := buildstep.ComposeJob{Fetch: buildstep.Fetch{Repository: DeliveryRepository, Commit: commit, Dir: JudgeDir, Packages: versions}, Dir: JudgeDir, Package: JudgePackage, Request: raw, Reader: "the indexer's judge at " + at} a := buildstep.StepAsk{ID: buildstep.NewID(), Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: st.j.Module, At: st.j.now().UTC(), Compose: &job} diff --git a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/entry.go b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/entry.go index 19e6ff16..362b9448 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/entry.go +++ b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/entry.go @@ -12,10 +12,16 @@ import ( ) // Ready is nil once every watched branch has its first view (`none-yet` counting as one), else says what it waits for -// (design 47 G §614, A-103): a part acts on nothing until then. +// (design 47 G §614, A-103): a part acts on nothing until then. On a fresh mesh, where the registrations and the gate's source are both +// answered and name no branch, it is nil too: the trunk is `none-yet` (A-368). func (b *Branches) Ready() error { followed := b.Followed() if len(followed) == 0 { + // A fresh mesh: the registrations and the gate's source are both answered and name no branch, so the trunk is `none-yet` + // and the view is empty (design 47 G, A-368). + if b.namesNoBranch() { + return nil + } return fmt.Errorf("the catalog half names no watched branch yet (the registrations of the seat %s are asked until they answer)", seat.Seat) } var waiting []string @@ -34,6 +40,59 @@ func (b *Branches) Ready() error { return nil } +// namesNoBranch says the first view of the registrations is in and, while the gate's source is followed, so is its, and +// neither names a branch (none is followed). +func (b *Branches) namesNoBranch() bool { + select { + case <-b.Registrations.Ready(): + default: + return false + } + // A first view closes before the follower's change is taken into the branches followed, so what the views hold is read too. + for _, reg := range b.Registrations.All() { + if len(reg.Branches) > 0 { + return false + } + } + b.mu.Lock() + s := b.source + b.mu.Unlock() + if s == nil { + return true + } + select { + case <-s.Follower.Ready(): + default: + return false + } + return len(s.Branches()) == 0 +} + +// FirstViews is closed once the first views of the registrations and, while it is followed, of the gate's source are in: a part +// that waits for the catalog half to settle looks at Followed and Ready once it is closed (design 47 G, A-372). +func (b *Branches) FirstViews(ctx context.Context) <-chan struct{} { + done := make(chan struct{}) + go func() { + select { + case <-b.Registrations.Ready(): + case <-ctx.Done(): + return + } + b.mu.Lock() + s := b.source + b.mu.Unlock() + if s != nil { + select { + case <-s.Follower.Ready(): + case <-ctx.Done(): + return + } + } + close(done) + }() + return done +} + // Entry is a module's entry at the trunk: the module's own registration decides, so the branch followed first, which lists // the module, is the one read (design 47 G A-103). An error says a watched branch has no first view yet, never "no module". func (b *Branches) Entry(module string) (seat.CatalogEntry, bool, error) { diff --git a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/entry_test.go b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/entry_test.go index 3a92d0a5..92c45723 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/entry_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/entry_test.go @@ -94,3 +94,81 @@ func TestTheBranchFollowerGivesEveryPartItsEntryHelpers(t *testing.T) { t.Error("a released entry kept its finding") } } + +// A-368 (design 47 G, C6): on a fresh mesh, where neither the registrations nor the gate's source name a branch, the catalog half +// counts the trunk as `none-yet`: Ready is nil once both are answered, and the view is empty (Entry finds no module); until +// both answer, no part is ready. +func TestAMeshThatNamesNoBranchIsReadyWithAnEmptyView(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + for _, c := range []struct { + name string + start []string // the followers started, by the name they are adopted under + ready bool + }{ + {"nothing answered", nil, false}, + {"only the registrations answered", []string{"mesh-catalog.registrations"}, false}, + {"only the gate's source answered", []string{"mesh-delivery.source"}, false}, + {"both answered", []string{"mesh-catalog.registrations", "mesh-delivery.source"}, true}, + } { + t.Run(c.name, func(t *testing.T) { + seats := &fakeSeats{regs: map[string][]string{}} + w := &fakeWiring{adopted: map[string]*views.Follower{}, hears: map[string]func(context.Context, []byte) error{}} + b, err := NewBranches(w, seats.call) + if err != nil { + t.Fatal(err) + } + for _, name := range c.start { + f, _ := w.get(name) + if err := f.Start(ctx); err != nil { + t.Fatal(err) + } + } + if err := b.Ready(); (err == nil) != c.ready { + t.Fatalf("Ready = %v, want ready %v", err, c.ready) + } + if c.ready { + if e, found, err := b.Entry("m"); err != nil || found { + t.Errorf("Entry = %v, %v, %v: want an empty view, no error", e, found, err) + } + } + }) + } +} + +// A-368: a first view closes before the follower's change reaches the branches followed, so a registration or a gate's source that +// names a branch is no mesh that names none, though Followed holds nothing yet. +func TestAFirstViewThatNamesABranchIsNotReadyBeforeItIsFollowed(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + for _, c := range []struct { + name string + source []string + regs map[string][]string + }{ + {"a registration names main", nil, map[string][]string{"nats": {"main"}}}, + {"the gate's source names main", []string{"main"}, map[string][]string{}}, + } { + t.Run(c.name, func(t *testing.T) { + seats := &fakeSeats{source: c.source, regs: c.regs, version: 1} + w := &fakeWiring{adopted: map[string]*views.Follower{}, hears: map[string]func(context.Context, []byte) error{}} + b, err := NewBranches(w, seats.call) + if err != nil { + t.Fatal(err) + } + for _, name := range []string{"mesh-catalog.registrations", "mesh-delivery.source"} { + f, _ := w.get(name) + f.Changed = nil // the change is not yet taken into the branches followed + if err := f.Start(ctx); err != nil { + t.Fatal(err) + } + } + if len(b.Followed()) != 0 { + t.Fatalf("followed %v: the test means no branch is followed yet", b.Followed()) + } + if err := b.Ready(); err == nil { + t.Error("Ready said ready with a branch named and not yet followed") + } + }) + } +} diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go index 61f1966b..59ca3d53 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go @@ -1154,6 +1154,8 @@ type TakeInTaken struct { OwnBuildUnknown string `json:"own-build-unknown,omitempty"` // why the manifest of the indexer the revision names was refused Refused string `json:"refused,omitempty"` + // the catalog graph revision of the branch the take-in made, which the pipelines of its entries start at (design 47 G section 476, A-448) + Revision int64 `json:"revision,omitempty"` // when the wait began Since time.Time `json:"since"` // the source revision taken in (design 47 G section 476) diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/manifestdigest.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/manifestdigest.go new file mode 100644 index 00000000..b48e93ff --- /dev/null +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/manifestdigest.go @@ -0,0 +1,21 @@ +package meshcatalog + +import "strings" + +// manifestDigestPrefix is how a catalog entry's field manifest-digest begins, as every digest a record names (design 47 G §578). +const manifestDigestPrefix = "sha256:" + +// EntryManifestDigest is the entry's field manifest-digest for the module's digest bare, the 64 hex digits the module's +// value and the key of `manifests` hold: `sha256:` and the digits (design 47 G §578). A digest already prefixed stays, and +// none stays none. +func EntryManifestDigest(bare string) string { + if bare == "" || strings.HasPrefix(bare, manifestDigestPrefix) { + return bare + } + return manifestDigestPrefix + bare +} + +// BareManifestDigest is the 64 hex digits of an entry's manifest-digest: the module's value and the key of `manifests` +// (design 47 G §578). An entry taken in before G carries the digits alone, which is what its module value held (§609), and +// stays as it is. +func BareManifestDigest(field string) string { return strings.TrimPrefix(field, manifestDigestPrefix) } diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index f9bdeca2..f1cbb799 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go @@ -27,7 +27,6 @@ const ( VerbAccept = "accept" VerbCancel = "cancel" VerbAskAgain = "ask-again" - VerbRelease = "release" ) const ( @@ -46,7 +45,7 @@ const ( // Verbs is every verb the seat serves, in its definition's order: a new copy each call. func Verbs() []string { - return []string{VerbRun, VerbStart, VerbShow, VerbList, VerbStands, VerbWhyCarried, VerbKept, VerbReview, VerbRerun, VerbAccept, VerbCancel, VerbAskAgain, VerbRelease} + return []string{VerbRun, VerbStart, VerbShow, VerbList, VerbStands, VerbWhyCarried, VerbKept, VerbReview, VerbRerun, VerbAccept, VerbCancel, VerbAskAgain} } // Events is every event published on the seat's subject: a new copy each call. @@ -360,14 +359,6 @@ const ( GroupEndedOutcomeCancelled = "cancelled" ) -// Held is a pipeline held for the new version of the runner: its steps are placed and asked when the node-engine seat says that fingerprint runs healthy (design 47 G 65, 266, 534, A-195). -type Held struct { - // the fingerprint of the runner's own module the pipeline awaits running healthy (design 47 G 266, 276, A-195) - Fingerprint string `json:"fingerprint"` - // since when the pipeline is held, RFC 3339 - Since time.Time `json:"since"` -} - // KeptResult is a package's passing result the runner keeps, by the digest of what its tests read (ADR 0666 section 8). type KeptResult struct { // sha256: of what the package's tests read @@ -452,7 +443,6 @@ type Pipeline struct { Fingerprint string `json:"fingerprint,omitempty"` // the gathered group, when the pipeline is its Group string `json:"group,omitempty"` - Held *Held `json:"held,omitempty"` Module string `json:"module"` Outcome string `json:"outcome"` // yes when the module is over its test budget (design 47 G section 419) @@ -720,18 +710,16 @@ type Wait struct { Artifact string `json:"artifact,omitempty"` // the watched branch, or the branch of a run on request Branch string `json:"branch"` - // the time the bound counts from (design 47 G section 266, section 269, section 498) - ClockFrom *time.Time `json:"clock-from,omitempty"` // the commit the module's entry was last changed at Commit string `json:"commit,omitempty"` // the module's build-input fingerprint at the commit Fingerprint string `json:"fingerprint,omitempty"` // the gathered group, when the pipeline is its Group string `json:"group,omitempty"` - // for its end, how it ended: answered, ran, released, superseded + // for its end, how it ended: answered, ran, superseded How string `json:"how,omitempty"` Module string `json:"module"` - // what the step waits on (design 47 *Health and going back*); the runner version is what a pipeline held for the runner's new version waits on (design 47 G 534, A-206) + // what the step waits on (design 47 *Health and going back*) On string `json:"on"` // the pipeline's key, .., a branch escaped as a key's name is Pipeline string `json:"pipeline"` @@ -742,7 +730,7 @@ type Wait struct { Since time.Time `json:"since"` // the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) Source int64 `json:"source,omitempty"` - // a pipeline step a wait inside a pipeline is in; pipeline is the acting step of design 47 G 203, for a wait of the entries the runner holds for its new version (design 47 G 534) + // a pipeline step a wait inside a pipeline is in Step string `json:"step"` V int64 `json:"v"` // for a wait on a person, who: the operator, a reviewer @@ -751,10 +739,9 @@ type Wait struct { // The values of Wait's on. const ( - WaitOnPerson = "person" - WaitOnBuildNode = "build node" - WaitOnRevisionView = "revision view" - WaitOnRunnerVersion = "runner version" + WaitOnPerson = "person" + WaitOnBuildNode = "build node" + WaitOnRevisionView = "revision view" ) // The values of Wait's step. @@ -766,7 +753,6 @@ const ( WaitStepComposition = "composition" WaitStepReview = "review" WaitStepApproval = "approval" - WaitStepPipeline = "pipeline" ) // Widening is a part serving a step the change alters, or an acting rule, a grant or a credential it widens, computed by the running runner (ADR 0666 section 23). @@ -991,18 +977,6 @@ type AskAgainAnswer struct { Result StepResult `json:"result"` } -// ReleaseInput is what release takes. -type ReleaseInput struct { - // why, written with the caller the runtime proves in the hand-act log - Why string `json:"why"` -} - -// ReleaseAnswer is what release answers. -type ReleaseAnswer struct { - // how many held pipelines were started - Released int64 `json:"released"` -} - // PipelineStartedEvent is the body of the event pipeline-started. type PipelineStartedEvent = PipelineStarted diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json index cd1d0387..118c8e13 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json @@ -66,7 +66,8 @@ "required": [ "modules" ] - } + }, + "class": "read" }, { "name": "module", @@ -127,7 +128,8 @@ "required": [ "module" ] - } + }, + "class": "read" }, { "name": "provides", @@ -147,7 +149,8 @@ "answer": { "type": "object", "description": "what provides answers, as its description says" - } + }, + "class": "read" }, { "name": "dependents", @@ -167,7 +170,8 @@ "answer": { "type": "object", "description": "what dependents answers, as its description says" - } + }, + "class": "read" }, { "name": "seat-definitions", @@ -246,7 +250,8 @@ ] } } - } + }, + "class": "read" }, { "name": "revision", @@ -2954,6 +2959,10 @@ }, "description": "the merges it holds, oldest first" }, + "revision": { + "type": "integer", + "description": "the catalog graph revision of the branch the take-in made, which the pipelines of its entries start at (design 47 G section 476, A-448)" + }, "group": { "type": "string", "description": "the delivery group, for a group being gathered" diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json index 60c9f06c..41b0d914 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -6,12 +6,6 @@ "domain": "Delivery", "decision": "novox/hq ADR 0666", "description": "The pipeline runner: it runs each module's pipeline on each of its watched branches, asking each step of the seat that serves it and hearing its end, and says each pipeline's and each step's start and end (design 47 *Pipelines per module*). Held once for the mesh; a foundation part.", - "acts": [ - { - "step": "pipeline", - "bound": "30m" - } - ], "verbs": [ { "name": "run", @@ -501,35 +495,6 @@ ] }, "class": "act" - }, - { - "name": "release", - "description": "The pipelines the runner holds for its new version started by hand with the running runner, whatever the new version's state; written in the hand-act log (design 47 G 276, A-206).", - "input": { - "type": "object", - "properties": { - "why": { - "type": "string", - "description": "why, written with the caller the runtime proves in the hand-act log" - } - }, - "required": [ - "why" - ] - }, - "answer": { - "type": "object", - "properties": { - "released": { - "type": "integer", - "description": "how many held pipelines were started" - } - }, - "required": [ - "released" - ] - }, - "class": "act" } ], "events": [ @@ -719,25 +684,6 @@ }, "description": "how many tests a step ran and carried, per level (ADR 0666 section 8)" }, - "Held": { - "type": "object", - "properties": { - "since": { - "type": "string", - "format": "date-time", - "description": "since when the pipeline is held, RFC 3339" - }, - "fingerprint": { - "type": "string", - "description": "the fingerprint of the runner's own module the pipeline awaits running healthy (design 47 G 266, 276, A-195)" - } - }, - "required": [ - "since", - "fingerprint" - ], - "description": "a pipeline held for the new version of the runner: its steps are placed and asked when the node-engine seat says that fingerprint runs healthy (design 47 G 65, 266, 534, A-195)" - }, "ToolchainUsed": { "type": "object", "properties": { @@ -1074,9 +1020,6 @@ "type": "boolean", "description": "yes when the module is over its test budget (design 47 G section 419)" }, - "held": { - "$ref": "#/defs/Held" - }, "widens": { "type": "array", "items": { @@ -1524,10 +1467,9 @@ "integration", "composition", "review", - "approval", - "pipeline" + "approval" ], - "description": "a pipeline step a wait inside a pipeline is in; pipeline is the acting step of design 47 G 203, for a wait of the entries the runner holds for its new version (design 47 G 534)" + "description": "a pipeline step a wait inside a pipeline is in" }, "artifact": { "type": "string" @@ -1537,10 +1479,9 @@ "enum": [ "person", "build node", - "revision view", - "runner version" + "revision view" ], - "description": "what the step waits on (design 47 *Health and going back*); the runner version is what a pipeline held for the runner's new version waits on (design 47 G 534, A-206)" + "description": "what the step waits on (design 47 *Health and going back*)" }, "who": { "type": "string", @@ -1552,12 +1493,7 @@ }, "how": { "type": "string", - "description": "for its end, how it ended: answered, ran, released, superseded" - }, - "clock-from": { - "type": "string", - "format": "date-time", - "description": "the time the bound counts from (design 47 G section 266, section 269, section 498)" + "description": "for its end, how it ended: answered, ran, superseded" } }, "description": "a step's wait, held and ended; a wait on a person is said as waiting on that person, never a stall (ADR 0283)", diff --git a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts index d26823b6..6f31c3a3 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts @@ -608,6 +608,8 @@ export interface TakeInTaken { "own-build-unknown"?: string; /** why the manifest of the indexer the revision names was refused */ "refused"?: string; + /** the catalog graph revision of the branch the take-in made, which the pipelines of its entries start at (design 47 G section 476, A-448) */ + "revision"?: number; /** when the wait began */ "since": string; /** the source revision taken in (design 47 G section 476) */ diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts index b878f1ab..5f8b49b3 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -17,7 +17,6 @@ export declare const verbs: { readonly accept: "accept"; readonly cancel: "cancel"; readonly askAgain: "ask-again"; - readonly release: "release"; }; export declare const events: { @@ -154,14 +153,6 @@ export interface GroupEnded { "why"?: string; } -/** a pipeline held for the new version of the runner: its steps are placed and asked when the node-engine seat says that fingerprint runs healthy (design 47 G 65, 266, 534, A-195) */ -export interface Held { - /** the fingerprint of the runner's own module the pipeline awaits running healthy (design 47 G 266, 276, A-195) */ - "fingerprint": string; - /** since when the pipeline is held, RFC 3339 */ - "since": string; -} - /** a package's passing result the runner keeps, by the digest of what its tests read (ADR 0666 section 8) */ export interface KeptResult { /** sha256: of what the package's tests read */ @@ -211,7 +202,6 @@ export interface Pipeline { "fingerprint"?: string; /** the gathered group, when the pipeline is its */ "group"?: string; - "held"?: Held; "module": string; "outcome": "running" | "passed" | "failed" | "refused" | "superseded" | "cancelled"; /** yes when the module is over its test budget (design 47 G section 419) */ @@ -403,19 +393,17 @@ export interface Wait { "artifact"?: string; /** the watched branch, or the branch of a run on request */ "branch": string; - /** the time the bound counts from (design 47 G section 266, section 269, section 498) */ - "clock-from"?: string; /** the commit the module's entry was last changed at */ "commit"?: string; /** the module's build-input fingerprint at the commit */ "fingerprint"?: string; /** the gathered group, when the pipeline is its */ "group"?: string; - /** for its end, how it ended: answered, ran, released, superseded */ + /** for its end, how it ended: answered, ran, superseded */ "how"?: string; "module": string; - /** what the step waits on (design 47 *Health and going back*); the runner version is what a pipeline held for the runner's new version waits on (design 47 G 534, A-206) */ - "on": "person" | "build node" | "revision view" | "runner version"; + /** what the step waits on (design 47 *Health and going back*) */ + "on": "person" | "build node" | "revision view"; /** the pipeline's key, .., a branch escaped as a key's name is */ "pipeline": string; /** the catalog graph revision of the branch the pipeline runs for */ @@ -425,8 +413,8 @@ export interface Wait { "since": string; /** the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) */ "source"?: number; - /** a pipeline step a wait inside a pipeline is in; pipeline is the acting step of design 47 G 203, for a wait of the entries the runner holds for its new version (design 47 G 534) */ - "step": "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval" | "pipeline"; + /** a pipeline step a wait inside a pipeline is in */ + "step": "build" | "lint" | "unit" | "integration" | "composition" | "review" | "approval"; "v": number; /** for a wait on a person, who: the operator, a reviewer */ "who"?: string; @@ -606,18 +594,6 @@ export interface AskAgainAnswer { "result": StepResult; } -/** is what release takes. */ -export interface ReleaseInput { - /** why, written with the caller the runtime proves in the hand-act log */ - "why": string; -} - -/** is what release answers. */ -export interface ReleaseAnswer { - /** how many held pipelines were started */ - "released": number; -} - /** is the body of the event pipeline-started. */ export type PipelineStartedEvent = PipelineStarted; diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js index 64a18312..e797aedb 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js @@ -17,7 +17,6 @@ export const verbs = { accept: "accept", cancel: "cancel", askAgain: "ask-again", - release: "release", }; export const events = { diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main.go index 5e666620..1add275e 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main.go @@ -123,7 +123,7 @@ func Tools(ask asker, now func() time.Time, groupsRead func() ([]groups.Row, []s // number, branch and head through the seat git's verb pull (by number when given, else by the merge commit; a merge made // on the forge is read the same way), the rest from the forge through trees and files (bridge.MergedMessage), and, for a // member of a delivery group the seat mesh-delivery names (of), the group and its members as the process sets them. -func MergedOf(of []seat.Group, repository, merge string, number int, trees bridge.Trees, files bridge.Files, forge bridge.Caller) (json.RawMessage, error) { +func MergedOf(groupOf func(id string) ([]seat.Group, error), repository, merge string, number int, trees bridge.Trees, files bridge.Files, forge bridge.Caller) (json.RawMessage, error) { owner, repo, ok := strings.Cut(repository, "/") if !ok || owner == "" || repo == "" { return nil, fmt.Errorf("%q is not owner/name", repository) @@ -140,6 +140,10 @@ func MergedOf(of []seat.Group, repository, merge string, number int, trees bridg if err != nil { return nil, err } + of, err := groupOf(f.Branch) // the one group the pull request's branch names, never the whole list + if err != nil { + return nil, err + } if g, ok := groups.Named(of, f.Branch, f.Repository, f.Number); ok { f.Group, f.Members = g.ID, groups.MembersOf(g) } @@ -251,7 +255,7 @@ func main() { performed, asks := stdio.State(groups.PerformedState), stdio.State(groups.EndAsksState) tools := Tools(askEnd(asks, served, 25*time.Second), time.Now, func() ([]groups.Row, []string, error) { - of, err := groups.Read(context.Background(), askCaller) + of, err := groups.ReadAll(context.Background(), askCaller) if err != nil { return nil, nil, err } @@ -259,11 +263,7 @@ func main() { }, func(repository, merge string, number int) (json.RawMessage, error) { ctx := context.Background() - of, err := groups.Read(ctx, askCaller) - if err != nil { - return nil, err - } - return MergedOf(of, repository, merge, number, bridge.TreesVia(ctx, askCaller), bridge.FilesVia(ctx, askCaller), askCaller) + return MergedOf(func(id string) ([]seat.Group, error) { return groups.ReadGroup(ctx, askCaller, id) }, repository, merge, number, bridge.TreesVia(ctx, askCaller), bridge.FilesVia(ctx, askCaller), askCaller) }, askCaller) owedAsks := stdio.State(groups.OwedAsksState) recorder := meshhandactsclient.Recorder{Ask: stdio.Ask} diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main_test.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main_test.go index c88ff795..7d0523ee 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main_test.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge-tools/main_test.go @@ -199,7 +199,7 @@ func TestTheBridgeToolsReadTheGroupsAndAskTheEndAgain(t *testing.T) { }, fail: "the forge is down"}, } { t.Run(c.name, func(t *testing.T) { - raw, err := MergedOf(c.of, c.repository, c.merge, c.number, trees, files, c.api) + raw, err := MergedOf(func(string) ([]seat.Group, error) { return c.of, nil }, c.repository, c.merge, c.number, trees, files, c.api) if c.fail != "" { if err == nil || !strings.Contains(err.Error(), c.fail) { t.Fatalf("err %v, want %q", err, c.fail) @@ -212,7 +212,7 @@ func TestTheBridgeToolsReadTheGroupsAndAskTheEndAgain(t *testing.T) { } }) } - if _, err := MergedOf(nil, "novox/a", c2, 9, func(string, string, string) (string, map[string]string, error) { + if _, err := MergedOf(func(string) ([]seat.Group, error) { return nil, nil }, "novox/a", c2, 9, func(string, string, string) (string, map[string]string, error) { return "", nil, errors.New("the forge does not answer") }, files, forgeAnswers(t, 9, "", "merged", "fix/x", h2, c2, "main")); err == nil || !strings.Contains(err.Error(), "does not answer") { t.Errorf("a forge that does not answer: %v", err) diff --git a/modules/mesh-delivery-forge-bridge/internal/groups/groups.go b/modules/mesh-delivery-forge-bridge/internal/groups/groups.go index 3257299d..f3f76197 100644 --- a/modules/mesh-delivery-forge-bridge/internal/groups/groups.go +++ b/modules/mesh-delivery-forge-bridge/internal/groups/groups.go @@ -230,11 +230,21 @@ func Rows(of []seat.Group, published, ended map[string]string, asks map[string][ func sortRows(rows []Row) { sort.Slice(rows, func(i, j int) bool { return rows[i].Key < rows[j].Key }) } -// MembersOf are a group's members with their heads, in the group's order. +// MembersOf are a group's members with their heads, in the group's order, each pull request once: a group the seat +// answers with a member twice (feat/47-G-join11 named novox/mesh-sdk#189 twice, 2026-11-14) keeps the later head at the +// first place, since a merged message naming a member twice is refused whole and no merge of that branch is taken in. func MembersOf(g seat.Group) []meshdeliveryclient.Head { out := make([]meshdeliveryclient.Head, 0, len(g.Members)) + at := map[string]int{} for _, m := range g.Members { - out = append(out, meshdeliveryclient.Head{Repository: m.Repository, Number: int(m.Number), Head: m.Head}) + h := meshdeliveryclient.Head{Repository: m.Repository, Number: int(m.Number), Head: m.Head} + k := fmt.Sprintf("%s#%d", m.Repository, m.Number) + if i, twice := at[k]; twice { + out[i] = h + continue + } + at[k] = len(out) + out = append(out, h) } return out } @@ -255,12 +265,28 @@ func Named(of []seat.Group, id, repository string, number int) (seat.Group, bool return seat.Group{}, false } -// Read is every delivery group the seat mesh-delivery's verb groups answers, the ended ones too (all), called through call -// by the verb's manifest key: the bridge reads a group from the seat, never from the gate's state (design 47 *A group's -// merges are taken in together*). An answer saying an error, or one the contract cannot type, is an error: a failed read -// is never read as no group. +// Read is the open delivery groups the seat mesh-delivery's verb groups answers by default, called through call by the +// verb's manifest key: the bridge reads a group from the seat, never from the gate's state (design 47 *A group's merges are +// taken in together*). The ended ones are never asked whole: their list outgrows one bus message (lead: principle 7, live +// 02:06); one is read by its id with ReadGroup. An answer saying an error, or one the contract cannot type, is an error: a +// failed read is never read as no group. func Read(ctx context.Context, call func(ctx context.Context, key string, body any) (json.RawMessage, error)) ([]seat.Group, error) { - raw, err := call(ctx, "seat:"+seat.Seat+"."+seat.VerbGroups, seat.GroupsInput{All: seat.GroupsInputAllTrue}) + return ask(ctx, call, seat.GroupsInput{}) +} + +// ReadAll is every delivery group, the ended ones too (all). Its answer grows with every group that ended, so only a +// tool a person asks reads it, never the take-in or the catch-up. +func ReadAll(ctx context.Context, call func(ctx context.Context, key string, body any) (json.RawMessage, error)) ([]seat.Group, error) { + return ask(ctx, call, seat.GroupsInput{All: seat.GroupsInputAllTrue}) +} + +// ReadGroup is the one group id names, ended or not, as the verb answers with its group: none for a group it does not know. +func ReadGroup(ctx context.Context, call func(ctx context.Context, key string, body any) (json.RawMessage, error), id string) ([]seat.Group, error) { + return ask(ctx, call, seat.GroupsInput{Group: id}) +} + +func ask(ctx context.Context, call func(ctx context.Context, key string, body any) (json.RawMessage, error), in seat.GroupsInput) ([]seat.Group, error) { + raw, err := call(ctx, "seat:"+seat.Seat+"."+seat.VerbGroups, in) if err != nil { return nil, fmt.Errorf("the seat %s did not answer %s: %w", seat.Seat, seat.VerbGroups, err) } diff --git a/modules/mesh-delivery-forge-bridge/internal/groups/read_test.go b/modules/mesh-delivery-forge-bridge/internal/groups/read_test.go new file mode 100644 index 00000000..672f4aee --- /dev/null +++ b/modules/mesh-delivery-forge-bridge/internal/groups/read_test.go @@ -0,0 +1,49 @@ +package groups + +import ( + "context" + "encoding/json" + "errors" + "strings" + "testing" + + seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" +) + +// The seat answers the whole list of groups with more than one bus message carries once many have ended (live 02:06); +// a read of the open ones, or of one by its id, is answered; Read never asks for all (lead: principle 7). +func TestReadsNeverAskTheEndedGroupsWhole(t *testing.T) { + const bus = 1 << 20 + seatOf := func(_ context.Context, _ string, body any) (json.RawMessage, error) { + in := body.(seat.GroupsInput) + groups := []seat.Group{{ID: "feat/open", State: "gathering"}} + switch { + case in.Group != "": + groups = []seat.Group{{ID: in.Group}} + case in.All == seat.GroupsInputAllTrue: + for i := 0; i < 3000; i++ { + groups = append(groups, seat.Group{ID: "ended", Why: strings.Repeat("x", 500)}) + } + } + raw, _ := json.Marshal(seat.GroupsAnswer{Groups: groups}) + if len(raw) > bus { + return nil, errors.New("the answer is more than the bus carries in one message") + } + return raw, nil + } + if got, err := Read(context.Background(), seatOf); err != nil || len(got) != 1 || got[0].ID != "feat/open" { + t.Errorf("Read: %v %v; want the open group alone", got, err) + } + if got, err := ReadGroup(context.Background(), seatOf, "feat/ended"); err != nil || len(got) != 1 || got[0].ID != "feat/ended" { + t.Errorf("ReadGroup: %v %v; want the group by its id", got, err) + } + if _, err := ReadAll(context.Background(), seatOf); err == nil { + t.Errorf("ReadAll: want the seat's refusal to be an error, never read as no group") + } + // A member the seat names twice is said once, at its later head (2026-11-14: the take-in of every repository with a + // branch of that group was refused whole). + twice := seat.Group{ID: "feat/twice", Members: []seat.Member{{Repository: "o/a", Number: 1, Head: "old"}, {Repository: "o/b", Number: 2, Head: "b"}, {Repository: "o/a", Number: 1, Head: "new"}}} + if got := MembersOf(twice); len(got) != 2 || got[0].Repository != "o/a" || got[0].Head != "new" || got[1].Repository != "o/b" { + t.Errorf("MembersOf a group naming o/a#1 twice = %+v, want o/a#1 at new, then o/b#2", got) + } +} diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go index b695e570..664447b7 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go @@ -286,7 +286,9 @@ func main() { tools := Tools(asks, time.Now, stdio.State(index.VerdictsState), heldCounts(stdio.State(index.OldSectionsState)), acts) // The modules and the module graph are the newest catalog graph revision's (milestone 47/G): revision.go. revisions := bundleObjects{busstate.ObjectsOf(index.CatalogRevisionsObjects)} - trunk := index.TrunkStates{Objects: revisions, Under: keptSource} + trunk := index.TrunkStates{Objects: revisions, Under: keptSource, Kept: &index.KeptTrunk{Say: func(format string, a ...any) { + fmt.Fprintf(os.Stderr, "[mesh-delivery-indexer-tools] "+format+"\n", a...) + }}} tools = append(tools, catalogTools(trunk.State)...) // The seat mesh-catalog's verb revision, a first view of the catalog half answered in this runtime of its own to exactly // the parts whose entry declares it (novox/hq ADR 0663). @@ -310,7 +312,7 @@ func main() { return err })...) tools = append(tools, index.ConsumerTools(keptRead{stdio.State(process.ConsumersState)})...) - tools = append(tools, index.RegistrationTools(keptRead{stdio.State(index.ProposalsState)}, asks, time.Now, func(cause, verb, what, why string) error { + tools = append(tools, index.RegistrationTools(keptRead{stdio.State(index.RegistrationsState)}, keptRead{stdio.State(index.ProposalsState)}, asks, time.Now, func(cause, verb, what, why string) error { _, err := acts.Record(meshhandactsclient.Request{What: what, Why: why, Cause: cause, Verb: verb}) return err })...) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/catalogrevision_subject_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/catalogrevision_subject_test.go new file mode 100644 index 00000000..848b230f --- /dev/null +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/catalogrevision_subject_test.go @@ -0,0 +1,68 @@ +package main + +import ( + "context" + "errors" + "strings" + + "git.novox.be/novox/mesh-sdk/go/process" + "github.com/nats-io/nats.go" + "testing" + + meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" +) + +func TestACatalogRevisionIsSaidOnTheSeatsSubjectWithItsBranch(t *testing.T) { + for _, c := range []struct { + name string + e meshcatalog.CatalogRevisionEvent + want string + refused bool + }{ + {"trunk", meshcatalog.CatalogRevisionEvent{Kind: "trunk", Branch: "main", Revision: 3}, "mesh.seat.mesh-catalog.event.catalog-revision.main", false}, + {"candidate", meshcatalog.CatalogRevisionEvent{Kind: "candidate", Branch: "fix/x=2ey", Revision: 1}, "mesh.seat.mesh-catalog.event.catalog-revision.fix/x=2ey", false}, + {"no branch", meshcatalog.CatalogRevisionEvent{Kind: "trunk", Revision: 3}, "", true}, + } { + got, err := catalogRevisionSubject(c.e) + if (err != nil) != c.refused || got != c.want { + t.Errorf("%s: subject %q (%v), want %q refused=%v", c.name, got, err, c.want, c.refused) + } + } +} + +// The duplicate id names the branch, and the publish goes through the acknowledging publisher, its error returned. +func TestACatalogRevisionIsPublishedAcknowledgedUnderAnIdNamingItsBranch(t *testing.T) { + cred := process.Account{Module: "mesh-delivery-indexer", Node: "n1"} + ev := func(branch string) meshcatalog.CatalogRevisionEvent { + return meshcatalog.CatalogRevisionEvent{Kind: "candidate", Branch: branch, Revision: 7} + } + var ids []string + var subjects []string + publish := func(_ context.Context, m *nats.Msg, id string) error { + ids = append(ids, id) + subjects = append(subjects, m.Subject) + if m.Header.Get(nats.MsgIdHdr) != id { + t.Errorf("header id %q, passed id %q", m.Header.Get(nats.MsgIdHdr), id) + } + return nil + } + say := sayCatalogRevision(cred, publish) + for _, b := range []string{"main", "fix/x"} { + if err := say(context.Background(), ev(b)); err != nil { + t.Fatal(err) + } + } + if len(ids) != 2 || ids[0] == ids[1] || !strings.Contains(ids[0], "main") || !strings.Contains(ids[1], "fix/x") { + t.Errorf("ids %v: the same number on two branches must be two ids naming each branch", ids) + } + if subjects[0] != "mesh.seat.mesh-catalog.event.catalog-revision.main" { + t.Errorf("subject %q", subjects[0]) + } + boom := errors.New("stream refused") + if err := sayCatalogRevision(cred, func(context.Context, *nats.Msg, string) error { return boom })(context.Background(), ev("main")); !errors.Is(err, boom) { + t.Errorf("a publish the bus refused returned %v", err) + } + if err := say(context.Background(), meshcatalog.CatalogRevisionEvent{Kind: "trunk", Revision: 1}); err == nil { + t.Error("an event with no branch was published") + } +} diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/integration_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/integration_test.go index a3b2c506..29e8e44a 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/integration_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/integration_test.go @@ -1064,7 +1064,7 @@ func TestIndexerWritesModulesAtAMerge(t *testing.T) { // 1239/AC9; I1, I3: the m if err != nil { t.Fatal(err) } - if msg, err := events.GetLastMsgForSubject(ctx, "mesh.seat.mesh-catalog.event."+meshcatalog.EventCatalogRevision); err != nil || + if msg, err := events.GetLastMsgForSubject(ctx, meshcatalog.SubjectCatalogRevisionAll); err != nil || !strings.Contains(string(msg.Data), fmt.Sprintf(`"revision":%d`, newest)) { t.Errorf("catalog-revision said: %v (%v): want revision %d", msg, err, newest) } diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go index f1aa923e..b99d4b94 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -460,14 +460,14 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro ix := &index.Indexer{Module: cred.Module, NamedSets: named, Findings: writer, OldSections: awaitedStore{b: oldSections}, Unjudged: awaitedStore{b: unjudged}, Requirements: awaitedStore{b: requirements}, Store: kvStore{candidates}, Modules: modules, Manifests: kvStore{manifests}, Taken: awaitedStore{b: taken}, Builds: known, Verdicts: awaitedStore{b: verdicts}, SayRefused: sayRefused(conn, cred, logger.Printf), SayAccepted: sayAccepted(conn, cred), Predefined: awaitedStore{b: predefined}, ConfigCandidates: awaitedStore{b: configCandidates}, Logf: logger.Printf, - Named: namedVia(calls.Call), Trunk: trunkVia(calls.Call), Contains: containsVia(calls.Call), Read: readVia(calls.Call), + Named: namedVia(calls.Call), Trunk: trunkVia(calls.Call), BranchHead: branchHeadVia(calls.Call), Contains: containsVia(calls.Call), Read: readVia(calls.Call), ReadOpen: openVia(calls.Call), Packages: awaitedStore{b: packages, js: js, name: index.Bucket(cred.Module, index.PackagesState)}, Files: filesVia(calls.Call), GoSum: goSumVia(calls.Call), GoMod: goModVia(calls.Call), OwnBuild: ownBuildVia(calls.Call, cred.Module, cred.Node), OwnBuildState: awaitedStore{b: ownBuildState}, Heard: heardStore, Placement: placementVia(calls.CallKept), RunningWhole: runningWholeVia(js), Runs: awaitedStore{b: runs}, Graph: graph, SeatDefinitions: awaitedStore{b: seatDefs}, ReadFile: readFileVia(calls.Call), SaySeatDefinition: saySeats, Revisions: revisions, EntryIndex: awaitedStore{b: process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.EntryIndexState), "no entry is found by its fingerprint", logger.Printf)}, // Message a kept call: a read, called again through a transport fault (ADR 0668 §1) // Each catalog revision may bring another holder of a build seat: the build modules are found again (buildmodules.go). // A new trunk revision that changes the modules is said on the views family of modules too (design 47 G A-360). - SayCatalogRevision: afterRevision(refreshingBuildModules(sayingModulesView(sayCatalogRevision(conn, cred), cred, views.JetStreamPublish(js)), &buildFollow), &fillFollow), + SayCatalogRevision: afterRevision(refreshingBuildModules(sayingModulesView(sayCatalogRevision(cred, views.JetStreamPublish(js)), cred, views.JetStreamPublish(js)), &buildFollow), &fillFollow), SayFill: sayFill(conn, cred), // The catalog's released versions (design 47 G §349): the state versions, bound when it appears, and the event version-released. Versions: awaitedStore{b: process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.VersionsState), "no released version is kept, so no package-published makes a version", logger.Printf)}, @@ -509,6 +509,14 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro // node-engine names the successor while it replaces this process, and an old process that learnt it later would take // revisions in with its old judge. ix.FixOwnBuild(ctx) + // Each step of the start says when it begins and how long it took, so a start that does not end is read in the journal + // and not guessed (lead-47 2026-11-16: two starts on novox ran 25 minutes at one CPU with no line). + step := func(name string) func() { + began := time.Now() + logger.Printf("start: %s", name) + return func() { logger.Printf("start: %s done in %s", name, time.Since(began).Round(time.Millisecond)) } + } + done := step("reading the build log") // The log's entries at the start are read before any fingerprint is computed or registered module indexed (below); each // new one indexes the module it names when that module is registered and the bucket holds none (registered.go). var started atomic.Bool @@ -537,6 +545,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro "indexed from it, until the indexer starts again", builds.BuildLogRead, err) } started.Store(true) + done() + logger.Printf("start: the build log held %d entries at the start", len(startEnds)) // The source revision of a watched branch (design 47 G §15, §115, §362): asked of the seat mesh-delivery's verb source as a // kept call, once at the start, before the handler of its event source-moved reads anything; a source-moved heard // meanwhile is read after. @@ -553,6 +563,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro } return nil }} + done = step("the build modules and the seat holders") buildModules.refresh() // The assignments is the seat mesh-module-assigner's: read through its holder's first view and views family, never its bucket (DLV-F1r). assignmentsErrs := make(chan error) @@ -566,11 +577,15 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro seatHolders := &seatHoldersFollow{ctx: ctx, ix: ix, reader: reader, logf: logger.Printf} seatHolders.refresh() buildModules.seatHolders.Store(seatHolders) + done() + done = step("following the assignments") followAssignments(ctx, reader, seatHolders.holders(), process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, views.StatusState), "indexer_first_views reads nothing and indexer_first_view_again is not heard", logger.Printf), cred, js, gate, func(ctx context.Context) { if err := ix.Recompute(ctx); err != nil { logger.Printf("writing the modules again after the assignments of a build module changed: %v", err) } }, logger.Printf) + done() + done = step("the toolchain watch and the previews") tools := newToolchainWatch(ctx, js, toolchainSink{ put: gate.Toolchain, apply: func(ctx context.Context, module, key string, value []byte, deleted bool) error { @@ -597,26 +612,42 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro // having no toolchain reported, and back). // The packages the held modules reach and the state does not hold yet are published at their trunk's taken merge, and // the imports the log's done builds reported are then kept, before the fingerprints are computed (ADR 0593 §2, §4). + done() packages.Ready(func(jetstream.KeyValue) { + done := step("publishing the packages at start") if err := ix.FillPackages(ctx); err != nil { logger.Printf("publishing the packages at start: %v", err) } + done() }) - for _, le := range startEnds { + done = step(fmt.Sprintf("the out-of-step findings of %d build ends", len(startEnds))) + values := make([][]byte, len(startEnds)) + for i, le := range startEnds { ix.ApplyOutOfStepBuild(ctx, le.Value) - if err := ix.ApplyBuildEnd(ctx, le.Value); err != nil { - logger.Printf("%s entry %d: its imports are not kept: %v", builds.BuildLogRead, le.Sequence, err) + values[i] = le.Value + if (i+1)%50000 == 0 { + logger.Printf("start: out-of-step findings: %d of %d entries", i+1, len(startEnds)) } } + done() + if err := ix.ApplyBuildEndsAtStart(ctx, values, func(i int, err error) { + logger.Printf("%s entry %d: its imports are not kept: %v", builds.BuildLogRead, startEnds[i].Sequence, err) + }); err != nil { + logger.Printf("keeping the view after the build ends at start: %v", err) + } startEnds = nil + done = step("computing the fingerprints") if err := ix.RecomputeAtStart(ctx); err != nil { logger.Printf("computing the new-form fingerprints at start: %v", err) } + done() + done = step("indexing the registered modules") // A module registered in the catalogue from its own repository gets its manifest indexed when the builder's log names // it and the bucket holds none (registered.go); the entries that follow are heard above. if err := ix.IndexRegisteredAll(ctx); err != nil { logger.Printf("indexing the registered modules at start: %v", err) } + done() // A person takes a registered module in now with indexer_take_in, which writes the takeins state (issue 1945): watched, // as every other input. A module the forge could not read is also read again by itself on the next source revision and // merged message (index.RetryUnread). @@ -751,7 +782,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro logger.Printf("the open changes of the registrations are not all read again at the start: %v", err) } _ = notHeard.Bind(process.EventsStream, "no package's series moves, no warrant for a change of a registration is heard, no node's manifest-reads-changed and no assignments view is heard until the indexer starts again", func() error { - if err := hub.Start(ctx, js, cred); err != nil { + if err := startHearing(ctx, hub, js, cred); err != nil { stopped = cmp.Or(stopped, err) return err } diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main_test.go index e23be889..8477025c 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main_test.go @@ -180,6 +180,41 @@ func TestAMessageIsIndexedAndAcked(t *testing.T) { // 1238/AC2 (unit part) } } }) + // Design 47 G A-397: the program hears its kept seat events (package-published among them) on their own streams once its + // durable on EVENTS is bound, never when that fails. + for _, startErr := range []error{nil, errors.New("not composed yet")} { + h := &startedHub{startErr: startErr} + if err := startHearing(context.Background(), h, nil, process.Account{}); !errors.Is(err, startErr) || h.kept != (startErr == nil) { + t.Errorf("start error %v: answered %v, kept streams bound %v", startErr, err, h.kept) + } + } + // Design 47 G A-420: a package-published that cannot be kept is left for the bus, and on its last delivery said given up, + // naming its subject, the artifact and version and the last refusal; before it, nothing more is said. + for _, n := range []uint64{4, EventDeliveries} { + var said []string + m := &deliveredMsg{subject: "mesh.seat.mesh-builds.event.package-published", data: []byte(`{"artifact":"m:program","version":"0.1.6"}`), n: n} + heardPackagePublished(context.Background(), &index.Indexer{}, m, func(f string, a ...any) { said = append(said, fmt.Sprintf(f, a...)) }) + givenUp := strings.Contains(strings.Join(said, "\n"), "gives up mesh.seat.mesh-builds.event.package-published: the package-published of m:program 0.1.6, delivered 5 times") + if !m.naked || givenUp != (n == EventDeliveries) || (givenUp && !strings.Contains(strings.Join(said, "\n"), "the last refusal: the state versions is not kept here")) { + t.Errorf("delivery %d: naked %v, said %q", n, m.naked, said) + } + } +} + +// deliveredMsg is a message delivered n times, which records a Nak. +type deliveredMsg struct { + jetstream.Msg + subject string + data []byte + n uint64 + naked bool +} + +func (d *deliveredMsg) Subject() string { return d.subject } +func (d *deliveredMsg) Data() []byte { return d.data } +func (d *deliveredMsg) Nak() error { d.naked = true; return nil } +func (d *deliveredMsg) Metadata() (*jetstream.MsgMetadata, error) { + return &jetstream.MsgMetadata{NumDelivered: d.n}, nil } // opener is a bus that answers every bucket with err. @@ -270,3 +305,17 @@ func TestTheIndexerTakesAPushedMessage(t *testing.T) { } } } + +// startedHub records which of an event hub's starts were asked. +type startedHub struct { + startErr error + kept bool +} + +func (h *startedHub) Start(context.Context, jetstream.JetStream, process.Account) error { + return h.startErr +} +func (h *startedHub) StartKept(context.Context, jetstream.JetStream, process.Account) int { + h.kept = true + return 1 +} diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/named.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/named.go index 41d4a90f..46f39a95 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/named.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/named.go @@ -260,3 +260,14 @@ func openVia(call toolCaller) func(ctx context.Context) ([]forgemsg.OpenPull, er return out, nil } } + +// branchHeadVia is the head of a repository's branch through the seat git's verb branch. +func branchHeadVia(call toolCaller) func(ctx context.Context, repository, branch string) (string, error) { + return func(_ context.Context, repository, branch string) (string, error) { + var a git.BranchAnswer + if err := askGit(call, git.VerbBranch, git.BranchInput{Repository: repository, Branch: branch}, &a); err != nil { + return "", err + } + return a.Head, nil + } +} diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/named_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/named_test.go index e0ca9587..c628ec4a 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/named_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/named_test.go @@ -7,6 +7,7 @@ import ( "fmt" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" + "git.novox.be/novox/mesh-sdk/go/process" "mesh-delivery-indexer/internal/index" "slices" "strings" @@ -125,6 +126,28 @@ func TestTheTrunkIsTheDirectoriesTheForgeListsTrees(t *testing.T) { // 1900/AC3 t.Errorf("%s: own build = %q %v, want %q", row.name, fp, err, row.want) } } + // Design 47 G A-366: a process started with a fingerprint takes it and asks no engine; one started without asks the engine. + for _, row := range []struct { + name string + started process.Build + want string + wantAsked bool + }{ + {"started with a fingerprint", process.Build{Fingerprint: "src2:env"}, "src2:env", false}, + {"started without one", process.Build{Unknown: process.OwnBuildUnknown}, "src2:abc", true}, + } { + started := startedBuild + startedBuild = func() process.Build { return row.started } + defer func() { startedBuild = started }() + called := false + ask := func(string, any) (json.RawMessage, error) { + called = true + return json.RawMessage(`{"runs":{"fp":"src2:abc"}}`), nil + } + if fp, err := ownBuildVia(ask, "acme-indexer", "n1")(context.Background()); err != nil || fp != row.want || called != row.wantAsked { + t.Errorf("%s: own build = %q %v, engine asked %v, want %q asked %v", row.name, fp, err, called, row.want, row.wantAsked) + } + } none := func(string, any) (json.RawMessage, error) { return json.RawMessage(`{}`), nil } if _, err := ownBuildVia(none, "acme-indexer", "n1")(context.Background()); err == nil { t.Error("an engine that says nothing runs gave a build") diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/objects.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/objects.go index 459c2584..6cc94729 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/objects.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/objects.go @@ -125,24 +125,49 @@ func (b *busObjects) Fill(ctx context.Context) (int64, int64, error) { return int64(st.Size()), info.CachedInfo().Config.MaxBytes, nil } -// sayCatalogRevision publishes the seat mesh-catalog's event catalog-revision under the duplicate id of its kind and -// number, so a revision said twice is heard once (design 47, Two graphs). -func sayCatalogRevision(conn *nats.Conn, cred process.Account) func(context.Context, meshcatalog.CatalogRevisionEvent) error { - return func(_ context.Context, e meshcatalog.CatalogRevisionEvent) error { - data, err := json.Marshal(e) +// catalogRevisionSubject is where an event says: the seat's catalog-revision. (the seat definition's subject), the +// branch the event's own field names. An event with no branch is refused: the indexer names the branch of every revision it +// keeps, and a bare subject is one the bus refuses. +func catalogRevisionSubject(e meshcatalog.CatalogRevisionEvent) (string, error) { + if e.Branch == "" { + return "", fmt.Errorf("the catalog-revision of %s revision %d names no branch, so it has no subject", e.Kind, e.Revision) + } + return meshcatalog.SubjectCatalogRevision(e.Branch), nil +} + +// catalogRevisionMessage is the seat mesh-catalog's event catalog-revision as it is published, with its duplicate id: the +// event's name, its branch, its kind and its number, so a revision said twice is heard once and the same number on two +// branches (a candidate's and the trunk's) is two events (design 47 G A-409). +func catalogRevisionMessage(cred process.Account, e meshcatalog.CatalogRevisionEvent) (*nats.Msg, string, error) { + data, err := json.Marshal(e) + if err != nil { + return nil, "", err + } + subject, err := catalogRevisionSubject(e) + if err != nil { + return nil, "", err + } + msg := nats.NewMsg(subject) + id := fmt.Sprintf("%s-%s-%s-%d%s", meshcatalog.EventCatalogRevision, e.Branch, e.Kind, e.Revision, e.Heads) + msg.Header.Set("x-event-id", id) + msg.Header.Set("x-source", cred.Module) + msg.Header.Set("x-node", cred.Node) + msg.Header.Set("x-time", time.Now().UTC().Format(time.RFC3339Nano)) + msg.Header.Set("content-type", "application/json") + msg.Header.Set(nats.MsgIdHdr, id) + msg.Data = data + return msg, id, nil +} + +// sayCatalogRevision publishes the event through the bus's acknowledgement (views.JetStreamPublish), an error returned when +// the bus did not keep it: a core publish says nothing of a stream that refused it (design 47 G A-409). +func sayCatalogRevision(cred process.Account, publish func(context.Context, *nats.Msg, string) error) func(context.Context, meshcatalog.CatalogRevisionEvent) error { + return func(ctx context.Context, e meshcatalog.CatalogRevisionEvent) error { + msg, id, err := catalogRevisionMessage(cred, e) if err != nil { return err } - msg := nats.NewMsg(seatEventSubject(meshcatalog.EventCatalogRevision)) - id := fmt.Sprintf("%s-%s-%d%s", meshcatalog.EventCatalogRevision, e.Kind, e.Revision, e.Heads) - msg.Header.Set("x-event-id", id) - msg.Header.Set("x-source", cred.Module) - msg.Header.Set("x-node", cred.Node) - msg.Header.Set("x-time", time.Now().UTC().Format(time.RFC3339Nano)) - msg.Header.Set("content-type", "application/json") - msg.Header.Set(nats.MsgIdHdr, id) - msg.Data = data - return conn.PublishMsg(msg) + return publish(ctx, msg, id) } } diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/ownbuild.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/ownbuild.go index 6d74a199..dd7ce7cf 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/ownbuild.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/ownbuild.go @@ -5,6 +5,8 @@ import ( "encoding/json" "errors" "fmt" + + "git.novox.be/novox/mesh-sdk/go/process" ) // compositionVerb is the node-engine seat's read verb that says what runs of a module on a machine (its Runs.FP), asked of @@ -12,9 +14,17 @@ import ( // from the trunk's value of itself or the haves bucket. const compositionVerb = "seat:node-engine.composition" -// ownBuildVia asks the engine of node which fingerprint of the indexer runs there. +// startedBuild is the build the process was started with (mesh-sdk process.OwnBuild: MESH_FINGERPRINT, set by the node-engine and +// by a unit started by hand); a variable so a test starts the process with another. +var startedBuild = process.OwnBuild + +// ownBuildVia is the build of the indexer: the one it was started with, else what the engine of node says which fingerprint of the indexer runs there. func ownBuildVia(call toolCaller, module, node string) func(ctx context.Context) (string, error) { return func(context.Context) (string, error) { + // The build the process was started with is the build; the engine is asked only when there is none (design 47 G A-366). + if fp := startedBuild().Fingerprint; fp != "" { + return fp, nil + } raw, err := call(compositionVerb+"@"+node, map[string]any{"module": module}) if err != nil { return "", fmt.Errorf("%s: %w", compositionVerb, err) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/registry.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/registry.go index f38d322d..4ab8eb42 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/registry.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/registry.go @@ -59,12 +59,19 @@ func newRegistry(js jetstream.JetStream, conn *nats.Conn, cred process.Account, } _, err = js.Publish(ctx, historySubject(cred.Module, r.Module), data, jetstream.WithMsgID(fmt.Sprintf("%s.%d", r.Module, r.Version))) if err == nil { - // Past 80 % full the stream's fill is a finding (design 47 G §704). - if st, serr := js.Stream(ctx, catalogue.StreamBusName(index.RegistrationHistoryStream)); serr == nil { - if info, ierr := st.Info(ctx); ierr == nil { + // Past 80 % full the stream's fill is a finding (design 47 G §704); read within a second, and said when it cannot be. + fctx, cancel := context.WithTimeout(ctx, time.Second) + st, serr := js.Stream(fctx, catalogue.StreamBusName(index.RegistrationHistoryStream)) + if serr == nil { + var info *jetstream.StreamInfo + if info, serr = st.Info(fctx); serr == nil { ix.HistoryFill(ctx, int64(info.State.Bytes), info.Config.MaxBytes) } } + cancel() + if serr != nil { + logf("the fill of %s is not read, so its finding is not judged: %v", index.RegistrationHistoryStream, serr) + } } return err }, diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein.go index dde180b0..c2b5210b 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein.go @@ -48,6 +48,11 @@ func takenIn(ctx context.Context, ix takerIn, kv jetstream.KeyValue, e jetstream return } asked, r := "take-in", index.TakenIn{} + logf("%s.%s: asked by %s (%s): started", index.TakeInsState, e.Key(), a.By, a.Why) + started := time.Now() + defer func() { + logf("%s.%s: ended after %s", index.TakeInsState, e.Key(), time.Since(started).Round(time.Millisecond)) + }() if a.Registry != nil { asked, r = "registrations' act "+a.Registry.Verb, ix.RegistryAct(ctx, a) } else if a.Recompute { diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/versions.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/versions.go index 1c473918..e50e8423 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/versions.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/versions.go @@ -48,6 +48,38 @@ func sayVersionReleased(conn *nats.Conn, cred process.Account) func(context.Cont } } +// hubStarter is the event hub as startHearing starts it. +type hubStarter interface { + Start(ctx context.Context, js jetstream.JetStream, cred process.Account) error + StartKept(ctx context.Context, js jetstream.JetStream, cred process.Account) int +} + +// startHearing binds the indexer's durable on the shared events stream and then, beside it, its durable on each kept seat +// event's own stream (SEAT__) whose event it handles: package-published, toolchain-agreed and the build seats' +// step-ended are never on EVENTS, and its tool runner reads only its own twin there, so the program hears them only so +// (design 47 G A-397; mesh-sdk process.EventHub.StartKept). +func startHearing(ctx context.Context, hub hubStarter, js jetstream.JetStream, cred process.Account) error { + if err := hub.Start(ctx, js, cred); err != nil { + return err + } + hub.StartKept(ctx, js, cred) + return nil +} + +// EventDeliveries is how many times the bus gives a message of the indexer's events consumer: the MaxDeliver the grants part +// composes a module's durable with (mesh-grants buscompose). +const EventDeliveries = 5 + +// leftForBus leaves a message the indexer could not take for the bus to give again, and on the last delivery its consumer allows +// says that it gives the message up, naming its subject, what it carries and the last refusal (design 47 G A-420): past it the bus +// drops the message without a word. +func leftForBus(m jetstream.Msg, what string, err error, logf func(string, ...any)) { + _ = m.Nak() + if md, merr := m.Metadata(); merr == nil && md != nil && md.NumDelivered >= EventDeliveries { + logf("gives up %s: %s, delivered %d times, the most its consumer allows; the last refusal: %v", m.Subject(), what, md.NumDelivered, err) + } +} + // heardPackagePublished takes one package-published of the seat mesh-builds into the catalog's versions (design 47 G §349): // one that does not decode is said and acknowledged; one that cannot be kept is left, so the bus gives it again. func heardPackagePublished(ctx context.Context, ix *index.Indexer, m jetstream.Msg, logf func(string, ...any)) { @@ -59,7 +91,7 @@ func heardPackagePublished(ctx context.Context, ix *index.Indexer, m jetstream.M } if err := ix.HearPackagePublished(ctx, p); err != nil { logf("versions: the package-published of %s %s could not be kept, so the bus gives it again: %v", p.Artifact, p.Version, err) - _ = m.Nak() + leftForBus(m, fmt.Sprintf("the package-published of %s %s", p.Artifact, p.Version), err, logf) return } _ = m.Ack() @@ -76,7 +108,7 @@ func heardToolchainAgreed(ctx context.Context, ix *index.Indexer, m jetstream.Ms } if err := ix.HearToolchainAgreed(ctx, t); err != nil { logf("versions: the toolchain-agreed of %s could not be kept, so the bus gives it again: %v", t.Language, err) - _ = m.Nak() + leftForBus(m, "the toolchain-agreed of "+t.Language, err, logf) return } _ = m.Ack() @@ -93,7 +125,7 @@ func heardVersionDelivered(ctx context.Context, ix *index.Indexer, m jetstream.M } if err := ix.HearVersionDelivered(ctx, d); err != nil { logf("versions: the version-delivered of %s %s could not be kept, so the bus gives it again: %v", d.Module, d.Version, err) - _ = m.Nak() + leftForBus(m, fmt.Sprintf("the version-delivered of %s %s", d.Module, d.Version), err, logf) return } _ = m.Ack() @@ -109,7 +141,7 @@ func heardWaitEnded(ctx context.Context, ix *index.Indexer, m jetstream.Msg, log } if err := ix.HearWaitEnded(ctx, w); err != nil { logf("versions: the wait-ended of %s for %s could not be kept, so the bus gives it again: %v", w.Part, w.Module, err) - _ = m.Nak() + leftForBus(m, fmt.Sprintf("the wait-ended of %s for %s", w.Part, w.Module), err, logf) return } _ = m.Ack() @@ -128,13 +160,13 @@ func heardStepEnded(ctx context.Context, ix *index.Indexer, m jetstream.Msg, log if err := json.Unmarshal(m.Data(), &end); err == nil { if err := ix.HearValidationEnded(ctx, end); err != nil { logf("take-in: the end of the validation ask %s is not taken in, so the bus gives it again: %v", end.Ask, err) - _ = m.Nak() + leftForBus(m, "the end of the validation ask "+end.Ask, err, logf) return } } if err := ix.HearInputEnded(ctx, e); err != nil { logf("inputs: the input of the ask %s could not be deleted, so the bus gives it again: %v", e.Ask, err) - _ = m.Nak() + leftForBus(m, "the step-ended of the ask "+e.Ask, err, logf) return } _ = m.Ack() diff --git a/modules/mesh-delivery-indexer/internal/index/branch_take_in_test.go b/modules/mesh-delivery-indexer/internal/index/branch_take_in_test.go index 64786d5b..38170e4a 100644 --- a/modules/mesh-delivery-indexer/internal/index/branch_take_in_test.go +++ b/modules/mesh-delivery-indexer/internal/index/branch_take_in_test.go @@ -11,6 +11,7 @@ import ( "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/meshdelivery" + "git.novox.be/novox/mesh-sdk/go/catalogue" ) // Design 47 G §13, §14, §291, A-93: a watched branch other than the first is taken in as a pure computation from the merged @@ -111,3 +112,117 @@ func TestABranchTakeInKeepsNoRevisionWithARefusedCycle(t *testing.T) { t.Errorf("the journal %q does not say the cycle %s", logs.String(), want) } } + +// Design 47 G A-401, A-93: a head the source names that has no merged message (a branch newly watched) is read whole at that +// commit through the seat git and taken in as a merge of every file of its tree, so the branch keeps its first revision; +// a head with a merged message is taken in as before and the seat git is not asked. +func TestAHeadWithNoMergedMessageIsReadWholeAtItsCommit(t *testing.T) { + for _, row := range []struct { + name string + hasMessage bool + readFails bool + wantRevision bool + wantRead bool + }{ + {name: "no merged message: read whole", wantRevision: true, wantRead: true}, + {name: "a merged message: taken in as before", hasMessage: true, wantRevision: true}, + {name: "no merged message and the seat git cannot read it: no revision", readFails: true, wantRead: true}, + } { + t.Run(row.name, func(t *testing.T) { + ctx := context.Background() + ix, _, merged := newFormIndexerUnmerged(t, builderModules(t)...) + ix.Revisions = newMemObjects(0) + ix.Graph = newMem() + var logs strings.Builder + ix.Logf = func(format string, args ...any) { fmt.Fprintf(&logs, format+"\n", args...) } + ix.Message = func(context.Context, string, string, int) ([]byte, error) { + if !row.hasMessage { + return nil, fmt.Errorf("the forge gives no merged pull request") + } + return json.Marshal(merged) + } + reads := 0 + ix.ReadFile = func(context.Context, string, string, string) ([]byte, error) { return nil, nil } // no predefined list + ix.Read = func(_ context.Context, _, sha, dir string) (RepoRead, error) { + reads++ + if row.readFails || sha != merged.Merge { + return RepoRead{}, fmt.Errorf("the seat git does not answer") + } + r := RepoRead{Root: merged.Root, Trees: merged.Trees, Manifests: map[string]string{}, Locks: map[string]map[string]string{}, Packages: map[string][]string{}} + if _, ok := merged.Trees[dir]; ok { + r.Manifests[dir], r.Locks[dir], r.Packages[dir] = merged.Manifests[dir], merged.Locks[dir], merged.Packages[dir] + } + return r, nil + } + answer := meshdelivery.SourceAnswer{Branch: "beta", Revision: 9, Repositories: []meshdelivery.SourceHead{{Repository: catalogueRepo, Head: merged.Merge, Trunk: "beta"}}} + if err := ix.ApplyBranchSource(ctx, "beta", answer); err != nil { + t.Fatal(err) + } + if (reads > 0) != row.wantRead { + t.Errorf("the seat git was asked %d times, want asked: %v", reads, row.wantRead) + } + rev, entries, err := ReadRevision(ctx, ix.Revisions, BranchObject("beta", 1)) + if (err == nil) != row.wantRevision { + t.Fatalf("branch.beta.1 read: %v, want a revision: %v", err, row.wantRevision) + } + if row.wantRevision && (rev.Branch != "beta" || len(entries) != len(builderModules(t))) { + t.Errorf("branch.beta.1 = %+v with %d entries, want every module", rev, len(entries)) + } + if said := strings.Contains(logs.String(), "has no merged message"); said != row.wantRead { + t.Errorf("the journal %q says the whole read: %v, want %v", logs.String(), said, row.wantRead) + } + }) + } +} + +// Design 47 G A-401, A-402: the message a head read whole gives equals the forge bridge's: a templated module's needs +// include its template's text (ADR 0632 §2), and the catalogue's predefined list is carried, or said absent. +func TestAHeadReadWholeCarriesTheTemplateNeedsAndThePredefinedList(t *testing.T) { + templated := strings.Replace(catalogueManifest(t, "avahi"), `"resources": [`, `"resources": [ + {"id": "conf", "type": "file", "path": "/etc/avahi-x.conf", "template": "files/x.conf"},`, 1) + for _, row := range []struct { + name string + template []byte // nil: the forge has no such file + predefined []byte + wantNeeds bool + wantList string + wantNotFound bool + }{ + {name: "template and predefined list", template: []byte("host=${seat:node-service-manager:reach}"), predefined: []byte(`{"a":1}`), wantNeeds: true, wantList: `{"a":1}`}, + {name: "no template file and no list", wantNotFound: true}, + } { + t.Run(row.name, func(t *testing.T) { + ix, _, merged := newFormIndexerUnmerged(t, mod{name: "avahi", manifest: templated}) + ix.ReadFile = func(_ context.Context, repository, sha, p string) ([]byte, error) { + if repository != catalogueRepo || sha != merged.Merge { + return nil, fmt.Errorf("unexpected read of %s at %s", repository, sha) + } + switch p { + case "modules/avahi/files/x.conf": + return row.template, nil + case "predefined.json": + return row.predefined, nil + } + return nil, fmt.Errorf("unexpected file %s", p) + } + ix.Read = func(_ context.Context, _, _, dir string) (RepoRead, error) { + return RepoRead{Root: merged.Root, Trees: merged.Trees, Manifests: map[string]string{dir: merged.Manifests[dir]}, Locks: map[string]map[string]string{dir: merged.Locks[dir]}}, nil + } + f, err := ix.wholeAt(context.Background(), catalogueRepo, merged.Merge) + if err != nil { + t.Fatal(err) + } + text := map[string]string{} + if row.template != nil { + text["files/x.conf"] = string(row.template) + } + want, _ := catalogue.ModuleNeeds([]byte(templated), text) + if got := f.Needs["modules/avahi"]; !slices.Equal(got, want) || (row.wantNeeds && !slices.Contains(got, catalogue.ReadForm+catalogue.ReferenceFormSeatReach)) { + t.Errorf("needs %v, want %v", got, want) + } + if string(f.Predefined) != row.wantList || f.PredefinedRead != row.wantNotFound { + t.Errorf("predefined %q (read-absent %v), want %q (%v)", f.Predefined, f.PredefinedRead, row.wantList, row.wantNotFound) + } + }) + } +} diff --git a/modules/mesh-delivery-indexer/internal/index/candidates.go b/modules/mesh-delivery-indexer/internal/index/candidates.go index a600e0f4..8a6a521f 100644 --- a/modules/mesh-delivery-indexer/internal/index/candidates.go +++ b/modules/mesh-delivery-indexer/internal/index/candidates.go @@ -55,6 +55,11 @@ const writeTries = 8 // Indexer writes candidates. from the forge bridge's messages. type Indexer struct { + // BranchHead is the head of a repository's branch, asked of the seat git's verb branch: TakeIn reads a module a + // registration names at its first watched branch's head (design 47 G A-85: the trunk is the first watched branch's). + BranchHead func(ctx context.Context, repository, branch string) (string, error) + // keptView replaces KeepView for a test that counts the writes of the view; nil in the program. + keptView func(context.Context) error // Module is the indexer's own module, the credential's: the observer of its findings and the key of its own entry (design 47 G A-296). Module string Store Store // candidates diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_branches_test.go b/modules/mesh-delivery-indexer/internal/index/catalog_branches_test.go index d6d653a7..e5f21613 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_branches_test.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_branches_test.go @@ -96,3 +96,37 @@ func TestACatalogRevisionIsKeptPerWatchedBranch(t *testing.T) { t.Error("a candidate never kept was answered") } } + +// A-450: a node-engine's call is proved as node.; it is answered as the module whose entry serves the seat node-engine +// (a part of the revision, so on the list as its own call would be), and refused when the revision holds no such module or the +// account is no node's. +func TestTheNodeEngineReadsTheRevisionAsTheModuleHoldingItsSeat(t *testing.T) { + ctx := context.Background() + for _, c := range []struct { + name string + invokes []string + caller string + want bool + }{ + {"the engine's module declares the verb", []string{RevisionInvoke}, "node.novox", true}, + {"no module of the revision serves the seat node-engine", nil, "node.novox", false}, + {"a caller with a dot after the machine is no engine's account", []string{RevisionInvoke}, "node.novox.extra", false}, + {"a module that serves no engine seat is no engine", []string{RevisionInvoke}, "node.", false}, + } { + t.Run(c.name, func(t *testing.T) { + ix := &Indexer{Module: testSelf, Revisions: newMemObjects(1 << 20)} + engine := meshcatalog.CatalogEntry{Module: "mesh-host", Repository: "novox/h", Commit: "c1", Manifest: map[string]any{}, + Serves: []string{"seat:node-engine.compose", "seat:node-engine.compose-candidate"}, Invokes: c.invokes} + if c.name == "no module of the revision serves the seat node-engine" { + engine.Serves = nil + } + if err := ix.KeepBranchEntries(ctx, "main", 5, map[string]meshcatalog.CatalogEntry{"mesh-host": engine}); err != nil { + t.Fatal(err) + } + _, err := Revision(ctx, ix.Revisions, "indexer", c.caller, meshcatalog.RevisionInput{Branch: "main"}) + if (err == nil) != c.want { + t.Errorf("caller %q: err %v, want answered %v", c.caller, err, c.want) + } + }) + } +} diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_graph.go b/modules/mesh-delivery-indexer/internal/index/catalog_graph.go index 24c653b1..93d43574 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_graph.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_graph.go @@ -8,7 +8,6 @@ import ( "maps" "reflect" "slices" - "strings" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph" @@ -24,24 +23,6 @@ import ( // CatalogEntryLayout is the layout version an entry and a revision are written in. const CatalogEntryLayout = 1 -// manifestDigestPrefix is how an entry's field manifest-digest begins, as every digest a record names (design 47 G §578). -const manifestDigestPrefix = "sha256:" - -// EntryManifestDigest is the entry's field manifest-digest for the module's digest bare, the 64 hex digits the module's -// value and the key of `manifests` hold: `sha256:` and the digits (design 47 G §578). A digest already prefixed stays, and -// none stays none. -func EntryManifestDigest(bare string) string { - if bare == "" || strings.HasPrefix(bare, manifestDigestPrefix) { - return bare - } - return manifestDigestPrefix + bare -} - -// BareManifestDigest is the 64 hex digits of an entry's manifest-digest: the module's value and the key of `manifests` -// (design 47 G §578). An entry taken in before G carries the digits alone, which is what its module value held (§609), and -// stays as it is. -func BareManifestDigest(field string) string { return strings.TrimPrefix(field, manifestDigestPrefix) } - // CatalogEntryOf is the catalog graph entry of one module: the module graph's node of it as a recompute computed it // (its build, provision and verb edges, the verb edges left out on a cycle, ADR 0614), with where the trunk holds it, // its manifest's digest and verdict, the main package its process runs (MainOf), the package versions it builds against @@ -49,7 +30,7 @@ func BareManifestDigest(field string) string { return strings.TrimPrefix(field, // ModuleValueOf gives the module's value back from the entry alone. The acting rules are the revision's to add. func CatalogEntryOf(module string, cur meshcatalog.ModulesByModuleValue, m catalogue.Manifest, raw string, n graph.Node) meshcatalog.CatalogEntry { e := meshcatalog.CatalogEntry{V: CatalogEntryLayout, Module: module, Repository: cur.Repository, Path: cur.Path, - Commit: cur.Commit, Manifest: manifestWhole(raw), ManifestDigest: EntryManifestDigest(cur.Manifest), Verdict: cur.Verdict, Fp: n.FP, None: n.None, Bases: n.Bases, + Commit: cur.Commit, Manifest: manifestWhole(raw), ManifestDigest: meshcatalog.EntryManifestDigest(cur.Manifest), Verdict: cur.Verdict, Fp: n.FP, None: n.None, Bases: n.Bases, Packages: maps.Clone(cur.Packages), Provides: n.Provides, Requires: n.Requires, Awaits: n.Awaits, Invokes: n.Invokes, Serves: n.Serves, LeftOut: n.LeftOut, Main: MainOf(m), Contributes: contributesOf(m)} // requires names every requirement as catalogue.Manifest.Wants lists them, optional ones and those only contributes names @@ -86,7 +67,7 @@ func CatalogEntryOf(module string, cur meshcatalog.ModulesByModuleValue, m catal // ruling on milestone 47/G finding 1; ADR 0656 §6: one form of the fact). The old line's fields (the old-form // fingerprint, the reader needs) are not kept. func ModuleValueOf(e meshcatalog.CatalogEntry) meshcatalog.ModulesByModuleValue { - v := meshcatalog.ModulesByModuleValue{V: keys.Version, Repository: e.Repository, Path: e.Path, Commit: e.Commit, Manifest: BareManifestDigest(e.ManifestDigest), + v := meshcatalog.ModulesByModuleValue{V: keys.Version, Repository: e.Repository, Path: e.Path, Commit: e.Commit, Manifest: meshcatalog.BareManifestDigest(e.ManifestDigest), Verdict: e.Verdict, Fp2: e.Fp, None2: e.None, Packages: maps.Clone(e.Packages)} if in := e.Inputs; in != nil { v.Toolchains, v.Paths, v.Problems, v.Warnings, v.Unknown = maps.Clone(in.Toolchains), maps.Clone(in.Paths), in.Problems, in.Warnings, in.Unknown diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go b/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go index c65774f4..ca51d308 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go @@ -8,6 +8,7 @@ import ( "slices" "strconv" "strings" + "sync" "time" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" @@ -489,11 +490,25 @@ var ErrNoRevision = errors.New("view-waits: the indexer keeps no catalog graph r type TrunkStates struct { Objects Objects Under func(string) views.Source + // Kept, when set, holds the view of the newest revision read, so a read asks only which revision is newest and reads + // the view again only when a newer one is kept: without it every key read the whole revision again, one object per + // module, and a first view of the modules took about 11 s a page. Nil reads the view at every read. + Kept *KeptTrunk +} + +// KeptTrunk is the view of the trunk as last read, at its revision, shared by every read of a TrunkStates; Say, when set, +// says each read of a revision and how long it took. +type KeptTrunk struct { + Say func(format string, a ...any) + mu sync.Mutex + at int64 + mods Store + held Store } // read is the view's modules and nodes, and the revision they were read at; none kept yet is ErrNoRevision. func (t TrunkStates) read(nodes bool) (Store, int64, error) { - mods, held, at, err := TrunkView(context.Background(), t.Objects) + mods, held, at, err := t.view() if err == nil && at == 0 { err = ErrNoRevision } @@ -503,6 +518,38 @@ func (t TrunkStates) read(nodes bool) (Store, int64, error) { return mods, at, err } +// view is the view of the newest trunk revision: the one kept when it is still the newest, else read whole and kept. +func (t TrunkStates) view() (modules, nodes Store, at int64, err error) { + ctx := context.Background() + if t.Kept == nil { + return TrunkView(ctx, t.Objects) + } + k := t.Kept + newest, any, err := newestOf(ctx, t.Objects, TrunkBranch) + if err != nil || !any { + return newOverlay(nil), newOverlay(nil), 0, err + } + k.mu.Lock() + defer k.mu.Unlock() + if k.mods != nil && k.at == newest.Revision { + return k.mods, k.held, k.at, nil + } + started := time.Now() + mods, held, at, err := TrunkView(ctx, t.Objects) + if err != nil { + if k.Say != nil { + k.Say("the view of the trunk: revision %d cannot be read after %s: %v", newest.Revision, time.Since(started).Round(time.Millisecond), err) + } + return nil, nil, 0, err + } + if k.Say != nil { + n, _ := mods.Keys(ctx) + k.Say("the view of the trunk: read revision %d (was %d), %d modules, in %s", at, k.at, len(n), time.Since(started).Round(time.Millisecond)) + } + k.mods, k.held, k.at = mods, held, at + return mods, held, at, nil +} + // state is the source of a state by its name: modules and graph from the revision, their marks at its number, every // other the indexer's own state. func (t TrunkStates) State(name string) views.Source { @@ -541,6 +588,40 @@ func (r revisionSource) Get(key string) (*views.Entry, bool, error) { return &views.Entry{Value: value, Revision: uint64(at)}, true, nil } +// Page is the values in key order after a key from one read of the revision, as many as fit maxBytes and at least one +// (views.Pager): a first view's page reads the revision once, never once per key. +func (r revisionSource) Page(after string, maxBytes int, _ time.Duration) ([]views.KeyedEntry, string, error) { + s, at, err := r.t.read(r.nodes) + if err != nil { + return nil, "", err + } + ctx := context.Background() + keys, err := s.Keys(ctx) + if err != nil { + return nil, "", err + } + slices.Sort(keys) + out, size := []views.KeyedEntry{}, 0 + for _, k := range keys { + if after != "" && k <= after { + continue + } + value, _, found, err := s.Get(ctx, k) + if err != nil { + return nil, "", err + } + if !found { + continue + } + if len(out) > 0 && size+len(k)+len(value) > maxBytes { + return out, out[len(out)-1].Key, nil + } + out = append(out, views.KeyedEntry{Key: k, Entry: views.Entry{Value: value, Revision: uint64(at)}}) + size += len(k) + len(value) + } + return out, "", nil +} + // markSource answers the mark of modules and graph as the newest trunk revision's number, which catalog-revision says // the changes after; every other mark is the views family's. type markSource struct { @@ -576,3 +657,16 @@ func (ix *Indexer) manifestBytes(ctx context.Context, digest string) string { } return raw } + +// NewestRevision is the number of the newest catalog graph revision kept for the watched branch, 0 when none is kept: the +// revision a take-in has just made, said with its take-in.taken (design 47 G §476, A-448). +func (ix *Indexer) NewestRevision(ctx context.Context, branch string) int64 { + if ix.Revisions == nil { + return 0 + } + newest, any, err := newestOf(ctx, ix.Revisions, branch) + if err != nil || !any { + return 0 + } + return newest.Revision +} diff --git a/modules/mesh-delivery-indexer/internal/index/form.go b/modules/mesh-delivery-indexer/internal/index/form.go index 2546ccdc..96636838 100644 --- a/modules/mesh-delivery-indexer/internal/index/form.go +++ b/modules/mesh-delivery-indexer/internal/index/form.go @@ -7,6 +7,7 @@ import ( "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/meshcatalog" sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" "mesh-delivery-indexer/internal/fingerprint" ) @@ -32,12 +33,14 @@ type form struct { // another repository its go.sum names, read as the indexer always read it (fingerprint.HeldVersionsOf), and the // content of each mesh Go module of its own repository its go.mod replaces by a directory (fingerprint.VersionLine), // so a change of that directory alone moves it (review finding 2). Its versions are the other repositories' alone. +// A package of another repository none of them publishes takes the commit the gate's source names for its repository +// (heads, design 47 G A-365). // - **An accepted series** (DLV-I6): published and pins come from acceptedSeries, so a mesh Go module of another // repository whose series the module accepts enters, in either form, by its series' newest published version and the // digests of that version's commit. // // It sets kept.ImportForm when it writes the import form. -func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, toolchains map[string]meshcatalogclient.Toolchain2, prev meshcatalog.ModulesByModuleValue, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, logf func(string, ...any)) form { +func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, toolchains map[string]meshcatalogclient.Toolchain2, prev meshcatalog.ModulesByModuleValue, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string, logf func(string, ...any)) form { in := inputsFrom(module, *kept, toolchains) if len(kept.Imports) > 0 { r := fingerprint.Resolve(repository, kept.Imports, published) @@ -71,6 +74,19 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp unpublished = slices.DeleteFunc(unpublished, func(u string) bool { return u == p }) } } + // A mesh Go package no module the indexer holds publishes is built at the commit the gate's source names for its + // repository, as an import of the same repository is; once a version is published, the version applies (design 47 G A-365). + for _, p := range slices.Clone(unpublished) { + if repo, _, ok := trunk.PackageRepository(p); ok { + if head := heads[repo]; len(head) == 40 { + if versions == nil { + versions = sdkstep.PackageVersions{} + } + versions[p] = head + unpublished = slices.DeleteFunc(unpublished, func(u string) bool { return u == p }) + } + } + } if len(unpublished) > 0 && logf != nil { logf("%s: no module the indexer holds publishes %s, so its fingerprint takes no version of it", module, strings.Join(unpublished, ", ")) } diff --git a/modules/mesh-delivery-indexer/internal/index/imports.go b/modules/mesh-delivery-indexer/internal/index/imports.go index f59e9324..d691af6b 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports.go +++ b/modules/mesh-delivery-indexer/internal/index/imports.go @@ -6,6 +6,7 @@ import ( "maps" "slices" "strings" + "time" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" @@ -27,50 +28,96 @@ import ( // Imports that cannot be resolved (a package the forge cannot list) are kept with no ImportForm: the next recompute that // resolves them writes the import form, one rebuild too many, never a stale module. func (ix *Indexer) ApplyBuildEnd(ctx context.Context, value []byte) error { - if err := ix.applyBuildEnd(ctx, value); err != nil { - return err + wrote, err := ix.applyBuildEnd(ctx, value) + if err != nil || !wrote { + return err // an entry that wrote nothing leaves the view as it is } - return ix.KeepView(ctx) // the imports kept with the view (KeepView), so a restart reads them back + return ix.keepView(ctx) // the imports kept with the view (KeepView), so a restart reads them back } -func (ix *Indexer) applyBuildEnd(ctx context.Context, value []byte) error { +// ApplyBuildEndsAtStart applies every entry of the build log read at start as ApplyBuildEnd does, and keeps the view +// once, after them, when any entry wrote a module: KeepView writes the whole catalog view, so once per entry is a start +// that never ends (measured: 50 min CPU per start). An entry that fails is passed to failed with its position. +func (ix *Indexer) ApplyBuildEndsAtStart(ctx context.Context, values [][]byte, failed func(i int, err error)) error { + began := time.Now() + ix.logf("replaying %d build ends of the build log at start", len(values)) + wrote := 0 + slow := 0 // entries that took over a second + for i, v := range values { + if (i+1)%50000 == 0 { + ix.logf("replaying the build ends at start: %d of %d, %d wrote a module, %d took over a second, %s so far", i+1, len(values), wrote, slow, time.Since(began).Round(time.Millisecond)) + } + t := time.Now() + w, err := ix.applyBuildEnd(ctx, v) + if d := time.Since(t); d > time.Second { + slow++ + ix.logf("replaying the build ends at start: entry %d took %s", i+1, d.Round(time.Millisecond)) + } + if err != nil { + if failed != nil { + failed(i, err) + } + continue + } + if w { + wrote++ + } + } + var err error + if wrote > 0 { + err = ix.keepView(ctx) + } + ix.logf("replayed %d build ends at start: %d wrote a module, in %s", len(values), wrote, time.Since(began).Round(time.Millisecond)) + return err +} + +// keepView is KeepView; a test replaces it to count the writes of the view. +func (ix *Indexer) keepView(ctx context.Context) error { + if ix.keptView != nil { + return ix.keptView(ctx) + } + return ix.KeepView(ctx) +} + +// applyBuildEnd reports whether it wrote the module (its final write changed the held value). +func (ix *Indexer) applyBuildEnd(ctx context.Context, value []byte) (bool, error) { if !builds.IsBuildEntry(value) { - return nil + return false, nil } e, err := builds.DecodeBuildLogEntry(value) if err != nil { - return err + return false, err } if e.Event != builds.BuildEndedEvent || e.Outcome != builds.BuildDone || len(e.Imports) == 0 || ix.Modules == nil || e.FP == "" { - return nil + return false, nil } key, err := meshcatalogclient.ModulesKey(e.Module) if err != nil { - return nil + return false, nil } ix.recompute.Lock() defer ix.recompute.Unlock() raw, _, found, err := ix.Modules.Get(ctx, key) if err != nil || !found { - return err + return false, err } cur, err := meshcatalogclient.DecodeModule(raw) if err != nil || cur.Fp2 != e.FP || cur.Inputs2 == nil || cur.Manifest == "" { - return nil // a build of a fingerprint the module no longer holds says nothing of its inputs now + return false, nil // a build of a fingerprint the module no longer holds says nothing of its inputs now } if slices.Equal(cur.Inputs2.Imports, e.Imports) && cur.Inputs2.ImportForm != "" { - return nil + return false, nil } _, m, err := ix.manifestRaw(ctx, cur.Manifest) if err != nil { - return fmt.Errorf("modules.%s: its manifest: %w", key, err) + return false, fmt.Errorf("modules.%s: its manifest: %w", key, err) } toolchains := map[string]meshcatalogclient.Toolchain2{} for artifact, language := range languagesOf(m) { used, ok := cur.Toolchains[language] if !ok { ix.logf("%s: its fingerprint names no %s toolchain, so the imports of its build are not kept", e.Module, language) - return nil + return false, nil } toolchains[artifact] = meshcatalogclient.Toolchain2{Language: language, Version: used.Version, Recipe: used.Recipe} } @@ -87,7 +134,9 @@ func (ix *Indexer) applyBuildEnd(ctx context.Context, value []byte) error { kept.ImportForm = fp } } - return write(ctx, ix.Modules, key, func(value []byte, found bool) ([]byte, bool, error) { + wrote := false + err = write(ctx, ix.Modules, key, func(value []byte, found bool) ([]byte, bool, error) { + wrote = false // a conflict computes again if !found { return nil, false, nil } @@ -99,8 +148,10 @@ func (ix *Indexer) applyBuildEnd(ctx context.Context, value []byte) error { in.Imports, in.ImportForm = kept.Imports, kept.ImportForm now.Inputs2 = &in data, err := meshcatalogclient.EncodeModule(now) + wrote = err == nil && !unchanged(data, false, value, found) return data, false, err }) + return wrote && err == nil, err } // publishedAsBuilt are the published Go modules holding the imports of build e of module cur, each as the build took diff --git a/modules/mesh-delivery-indexer/internal/index/imports_test.go b/modules/mesh-delivery-indexer/internal/index/imports_test.go index 118986d8..3f0c3c82 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports_test.go +++ b/modules/mesh-delivery-indexer/internal/index/imports_test.go @@ -372,16 +372,78 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t * t.Fatalf("fingerprints again of a module not held answered stored: %+v", r) } }) + t.Run("formOf builds a package no module publishes at the source's commit of its repository", func(t *testing.T) { // design 47 G A-365 + head := strings.Repeat("c", 40) + contracts := "git.novox.be/novox/mesh-contracts/go/seats/findings" + held := map[string]meshcatalog.ModulesByModuleValue{"other": {Repository: "novox/mesh-sdk", Commit: strings.Repeat("d", 40), Path: "go"}} + for _, c := range []struct { + name string + heads map[string]string + held map[string]meshcatalog.ModulesByModuleValue + want string + }{ + {"the source names its repository", map[string]string{"novox/mesh-contracts": head}, held, head}, + {"the source names another repository only", map[string]string{"novox/mesh-sdk": head}, held, ""}, + {"a module the indexer holds publishes it", map[string]string{"novox/mesh-contracts": head}, + map[string]meshcatalog.ModulesByModuleValue{"c": {Repository: "novox/mesh-contracts", Commit: strings.Repeat("e", 40), Path: "go/seats/findings"}}, strings.Repeat("e", 40)}, + } { + kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t", Packages: []string{contracts}} + f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, c.held, nil, nil, c.heads, nil) + if got := f.versions[contracts]; got != c.want { + t.Errorf("%s: version of %s = %q, want %q", c.name, contracts, got, c.want) + } + } + }) t.Run("formOf clears the import form when it writes the version line", func(t *testing.T) { for _, c := range []struct { name string imports []string }{{"an import no package holds", []string{meshSDK + "/announce"}}, {"no import reported", nil}} { kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t", Imports: c.imports, ImportForm: "src2:" + strings.Repeat("a", 64)} - f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil) + f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil, nil) if kept.ImportForm != "" { t.Errorf("%s: kept import form %q after the version line %q", c.name, kept.ImportForm, f.fp) } } }) } + +// A start replays every build end of the build log: an entry that writes no module keeps no view, and the entries that +// write keep it once, after all of them (measured: the view kept per entry cost 50 min CPU per start). +func TestBuildEndsKeepTheViewOnlyWhenTheyWrite(t *testing.T) { + ctx := context.Background() + ix, _ := newFormIndexer(t, mod{"avahi", catalogueManifest(t, "avahi")}) + reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + raw, _, _, _ := ix.Modules.Get(ctx, "avahi") + cur, err := meshcatalogclient.DecodeModule(raw) + if err != nil || cur.Fp2 == "" { + t.Fatalf("no fingerprint to start from: %v %q", err, cur.None2) + } + older := buildEnd(t, "avahi", "src2:"+strings.Repeat("e", 64), meshSDK) + writes := buildEnd(t, "avahi", cur.Fp2, meshSDK) + kept := 0 + ix.keptView = func(context.Context) error { kept++; return nil } + for _, c := range []struct { + name string + entries [][]byte + want int + }{ + {"no entry", nil, 0}, + {"entries that write nothing", [][]byte{older, []byte("not a build entry"), older}, 0}, + {"a write among entries that write nothing", [][]byte{older, writes, older}, 1}, + {"the same write again keeps nothing", [][]byte{writes, older}, 0}, + } { + kept = 0 + if err := ix.ApplyBuildEndsAtStart(ctx, c.entries, nil); err != nil || kept != c.want { + t.Errorf("%s: the view was kept %d times (%v), want %d", c.name, kept, err, c.want) + } + } + // The live path, one entry: the view is kept when it wrote. + kept = 0 + if err := ix.ApplyBuildEnd(ctx, older); err != nil || kept != 0 { + t.Errorf("a live entry that writes nothing kept the view %d times (%v)", kept, err) + } +} diff --git a/modules/mesh-delivery-indexer/internal/index/packages.go b/modules/mesh-delivery-indexer/internal/index/packages.go index ed8fbbb2..74e1302c 100644 --- a/modules/mesh-delivery-indexer/internal/index/packages.go +++ b/modules/mesh-delivery-indexer/internal/index/packages.go @@ -10,6 +10,7 @@ import ( "reflect" "slices" "strings" + "time" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein" @@ -347,9 +348,11 @@ func (ix *Indexer) FillPackages(ctx context.Context) error { if err != nil { continue } + began := time.Now() if err := ix.publish(ctx, repo, t.Merge, held, true); err != nil { ix.logf("%s: its packages are not published at %s: %v", repo, t.Merge, err) } + ix.logf("publishing the packages at start: %s at %.12s took %s", repo, t.Merge, time.Since(began).Round(time.Millisecond)) } return nil } diff --git a/modules/mesh-delivery-indexer/internal/index/pending.go b/modules/mesh-delivery-indexer/internal/index/pending.go index f3de90d9..6a373b1f 100644 --- a/modules/mesh-delivery-indexer/internal/index/pending.go +++ b/modules/mesh-delivery-indexer/internal/index/pending.go @@ -949,7 +949,7 @@ func (ix *Indexer) dry() *dryRun { } d := &dryRun{} x := &Indexer{Module: ix.Module, Manifests: ix.Manifests, Packages: ix.Packages, JudgeID: ix.JudgeID, Files: ix.Files, GoSum: ix.GoSum, - GoMod: ix.GoMod, Now: ix.Now, Builds: ix.Builds, Named: ix.Named, Trunk: ix.Trunk, Read: ix.Read, Contains: ix.Contains, + GoMod: ix.GoMod, Now: ix.Now, Builds: ix.Builds, Named: ix.Named, Trunk: ix.Trunk, BranchHead: ix.BranchHead, Read: ix.Read, Contains: ix.Contains, ReadOpen: nil, OwnBuild: nil, Message: ix.Message, SayRefused: nil, SayAccepted: nil, SayTakeIn: nil, Pending: nil, ValidationAsks: nil, AskVerb: nil, // a dry run asks no validation (§713) // The registry milestone's fields: what a take-in would write on the bus stays out of a dry run, so the states of the @@ -1170,9 +1170,11 @@ func (ix *Indexer) takeInWholeBy(ctx context.Context, entries []PendingEntry, ow ix.forget(claimed...) branch, src, took := ix.takenWhat(ctx, claimed, applied) ix.logf("take-in: %d merges taken in as one revision by %s%s, oldest %s: source revision %d of %s, %d entries", len(claimed), own, byWords(by), claimed[0].Key, src, branch, len(took)) + // The revision this take-in just kept (A-448), pinned for its pipelines before any later keep can remove it (A-449a). + revision := ix.PinPipelines(ctx, branch, src, took) for _, t := range takenWaits(claimed) { t.By, t.Why = who, why - t.Branch, t.Source, t.Entries = branch, src, took + t.Branch, t.Source, t.Entries, t.Revision = branch, src, took, revision ix.sayTakeIn(ctx, t) } return applied, nil diff --git a/modules/mesh-delivery-indexer/internal/index/pending_test.go b/modules/mesh-delivery-indexer/internal/index/pending_test.go index b23be27e..f0fc55c6 100644 --- a/modules/mesh-delivery-indexer/internal/index/pending_test.go +++ b/modules/mesh-delivery-indexer/internal/index/pending_test.go @@ -7,7 +7,9 @@ import ( "fmt" "reflect" "slices" + "strconv" "strings" + "sync" "testing" "time" @@ -1000,6 +1002,8 @@ func TestTakeIn(t *testing.T) { // 1585/T3-T13 (ADR 0633) !strings.Contains(r.Answer, TakeInPendingTool) || len(b.keys()) != 1 { t.Fatalf("a drop nothing covers: %+v, pending %v", r, b.keys()) } + b.ix.Pins = newMem() + b.ix.Revisions = newMemObjects(0) // A-448: the taken event names the catalog graph revision the take-in made b.said = nil if r := b.ix.TakeInPendingByHand(ctx, takein.PendingKey(3), "lead@shanks", "the named indexer can never run"); !r.Stored { t.Fatalf("hand take-in: %+v", r) @@ -1013,6 +1017,10 @@ func TestTakeIn(t *testing.T) { // 1585/T3-T13 (ADR 0633) if got.Branch != TrunkBranch || got.Source <= 0 || len(got.Entries) != 1 || got.Entries[0].Module != "avahi" || got.Entries[0].Commit != sha('d') || got.Entries[0].Fingerprint == "" { t.Errorf("hand take-in said branch %q source %d entries %+v: want main, a source revision and avahi at its commit", got.Branch, got.Source, got.Entries) + } else if newest, any, _ := newestTrunk(ctx, b.ix.Revisions); !any || got.Revision != newest.Revision { + t.Errorf("hand take-in said revision %d, want the revision it made, %d (A-448)", got.Revision, newest.Revision) + } else if v, _, found, _ := b.ix.Pins.Get(ctx, PinKey(got.Branch, got.Revision)); !found || !strings.Contains(string(v), "pipeline."+got.Branch+"."+strconv.FormatInt(got.Source, 10)+".avahi") { + t.Errorf("the revision the take-in made is pinned %q (found %v), want the record pipeline.%s.%d.avahi (A-449a)", v, found, got.Branch, got.Source) } else if _, err := takein.EncodeTakeIn(got); err != nil { t.Errorf("the taken event is refused by its own contract: %v", err) } @@ -1160,11 +1168,32 @@ func TestTakeIn(t *testing.T) { // 1585/T3-T13 (ADR 0633) } } }) + t.Run("a registration is read at the head of its first watched branch", func(t *testing.T) { + // Design 47 G A-85: the trunk is the first watched branch's; photos is watched on nox-mesh alone (2026-11-14). + ctx := context.Background() + ix := &Indexer{Module: testSelf, Registry: &Registry{Registrations: MemoryStore()}, Logf: func(string, ...any) {}} + raw, _ := json.Marshal(meshcatalog.Registration{Module: "photos", Origin: "novox/photos", Path: "module.json", Branches: []string{"nox-mesh", "main"}}) + if err := ix.Registry.Registrations.Create(ctx, RegistrationKey("photos"), raw); err != nil { + t.Fatal(err) + } + var asked string + ix.BranchHead = func(_ context.Context, repository, branch string) (string, error) { + asked = repository + "@" + branch + return strings.Repeat("a", 40), nil + } + r, why, ok := ix.registeredAtBranch(ctx, "photos") + if !ok || why != "" || asked != "novox/photos@nox-mesh" || r.Commit != strings.Repeat("a", 40) || r.Repository != "novox/photos" || r.Path != "." { + t.Errorf("registeredAtBranch(photos) = %+v %q %v, asked %s; want novox/photos at nox-mesh's head, at its root", r, why, ok, asked) + } + if _, why, ok := ix.registeredAtBranch(ctx, "unregistered"); ok || why != "" { + t.Errorf("an unregistered module answered %q %v, want neither", why, ok) + } + }) t.Run("the dry run names every field of the indexer", func(t *testing.T) { // dry (pending.go) builds an indexer field by field: a field added to Indexer is named there, or this fails. named := map[string]bool{} for _, f := range []string{"Module", "Store", "Modules", "Manifests", "Predefined", "ConfigCandidates", "Taken", "Verdicts", "OldSections", "Unjudged", - "JudgeID", "SayRefused", "SayAccepted", "Packages", "Graph", "Files", "GoSum", "GoMod", "Now", "Builds", "Named", "Trunk", + "JudgeID", "SayRefused", "SayAccepted", "Packages", "Graph", "Files", "GoSum", "GoMod", "Now", "Builds", "Named", "Trunk", "BranchHead", "Read", "Contains", "Logf", "ReadOpen", "OwnBuild", "Message", "Pending", "SayTakeIn", "Requirements", "Findings", "SeatDefinitions", "ReadFile", "SaySeatDefinition", "Runs", "OwnBuildState", "Heard", "Placement", "RunningWhole", "Revisions", "SayCatalogRevision", "SayFill", "EntryIndex", "NamedSets", "Registry", "SeedModules", "Versions", "SayVersionReleased", "SayVersionsFilled", "Inputs", "InputObjects", "BuildEdges", "Pins", "PinsPending", "ValidationAsks", "AskVerb"} { named[f] = true @@ -1202,3 +1231,53 @@ func readPending(t *testing.T, b *takeInBed) []PendingEntry { } return entries } + +// pinsHeldUnderKeep is a pins state that counts the writes and reads made while keepMu was not held. +type pinsHeldUnderKeep struct { + *memStore + mu *sync.Mutex + outside int +} + +func (p *pinsHeldUnderKeep) seen() { + if p.mu.TryLock() { // it was free: the caller does not hold it + p.mu.Unlock() + p.outside++ + } +} + +func (p *pinsHeldUnderKeep) Get(ctx context.Context, key string) ([]byte, uint64, bool, error) { + p.seen() + return p.memStore.Get(ctx, key) +} + +func (p *pinsHeldUnderKeep) Create(ctx context.Context, key string, value []byte) error { + p.seen() + return p.memStore.Create(ctx, key, value) +} + +func (p *pinsHeldUnderKeep) Update(ctx context.Context, key string, value []byte, revision uint64) error { + p.seen() + return p.memStore.Update(ctx, key, value, revision) +} + +// A-449a: the revision a take-in made is read and pinned holding keepMu, so no other keep can remove it between the two. +func TestATakeInPinsItsRevisionHoldingKeepMu(t *testing.T) { + ctx := context.Background() + ix := &Indexer{Module: testSelf, Revisions: newMemObjects(0)} + pins := &pinsHeldUnderKeep{memStore: newMem(), mu: &ix.keepMu} + ix.Pins = pins + e := meshcatalog.CatalogEntry{Module: "reader", Repository: "novox/r", Manifest: map[string]any{}, Commit: "c1"} + if err := ix.KeepBranchEntries(ctx, "main", 5, map[string]meshcatalog.CatalogEntry{"reader": e}); err != nil { + t.Fatal(err) + } + if rev := ix.PinPipelines(ctx, "main", 5, []meshcatalog.TakeInEntry{{Module: "reader"}}); rev != 1 { + t.Fatalf("PinPipelines answered revision %d, want 1", rev) + } + if _, _, found, _ := pins.memStore.Get(ctx, PinKey("main", 1)); !found { + t.Error("the revision was not pinned") + } + if pins.outside != 0 { + t.Errorf("%d reads and writes of the pins state were made without keepMu", pins.outside) + } +} diff --git a/modules/mesh-delivery-indexer/internal/index/pins.go b/modules/mesh-delivery-indexer/internal/index/pins.go index cb49a310..a4c0f4ec 100644 --- a/modules/mesh-delivery-indexer/internal/index/pins.go +++ b/modules/mesh-delivery-indexer/internal/index/pins.go @@ -14,6 +14,7 @@ import ( mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient" "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/meshdelivery" + runner "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" stdio "git.novox.be/novox/mesh-sdk/go" "git.novox.be/novox/mesh-sdk/go/keys" "git.novox.be/novox/mesh-sdk/go/process" @@ -573,3 +574,29 @@ func ConsumerTools(st Store) []stdio.Tool { Input: map[string]any{"type": "object", "properties": map[string]any{}}, Run: func(map[string]any) (any, error) { return ReadConsumers(context.Background(), st) }}} } + +// PinPipelines pins the catalog graph revision a take-in made for each pipeline the take-in starts, under the record +// `pipeline.` (`..` of each entry, the runner's key), in the indexer's own pins state as a +// pinned of the seat mesh-delivery is applied (design 47 G §579, A-449a): so no later take-in removes the revision before +// the runner hears of it. The runner's pinned at the pipeline's start says the same record (a set), and its freed at the +// pipeline's end removes it. It reads the branch's newest revision and pins it holding keepMu, so no other keep (a verdict, a +// source, an import) can make it non-current and remove it between the two; it answers that revision, 0 when none is kept. +func (ix *Indexer) PinPipelines(ctx context.Context, branch string, source int64, entries []meshcatalog.TakeInEntry) int64 { + ix.keepMu.Lock() + defer ix.keepMu.Unlock() + revision := ix.NewestRevision(ctx, branch) + if ix.Pins == nil || revision <= 0 || len(entries) == 0 { + return revision + } + if err := ix.PinsMade(ctx); err != nil { + ix.logf("pins: the revision %d of %s is not pinned for its pipelines: %v", revision, branch, err) + return revision + } + for _, e := range entries { + record := "pipeline." + runner.PipelinesByBranchRevisionModuleKey(keys.EscapeName(branch), strconv.FormatInt(source, 10), e.Module) + if err := ix.pin(ctx, PinKey(branch, revision), record); err != nil { + ix.logf("pins: the revision %d of %s is not pinned for %s: %v", revision, branch, record, err) + } + } + return revision +} diff --git a/modules/mesh-delivery-indexer/internal/index/previews.go b/modules/mesh-delivery-indexer/internal/index/previews.go index 172f327b..45036e59 100644 --- a/modules/mesh-delivery-indexer/internal/index/previews.go +++ b/modules/mesh-delivery-indexer/internal/index/previews.go @@ -319,11 +319,11 @@ func (ix *Indexer) candidateModule(ctx context.Context, m, dir string, pv meshde published, pins = acceptedSeries(series, man, pv.Repository, published) } if len(inputs.Imports) > 0 && len(fingerprint.Resolve(pv.Repository, inputs.Imports, published).Missing) == 0 { - f := formOf(m, pv.Repository, &inputs, toolchains, trunkMod, held, published, pins, nil) + f := formOf(m, pv.Repository, &inputs, toolchains, trunkMod, held, published, pins, ix.sourceHeads(), nil) fp, none, versions = f.fp, f.none, f.versions } else { inputs.Imports, inputs.ImportForm = nil, "" - versions = candidatePackages(fingerprint.OtherPackages(inputs.Packages, pv.Repository), held, members) + versions = candidatePackages(fingerprint.OtherPackages(inputs.Packages, pv.Repository), held, members, ix.sourceHeads()) for p, v := range pins { if _, named := versions[p]; named || slices.Contains(inputs.Packages, p) { if versions == nil { @@ -352,8 +352,8 @@ func (ix *Indexer) candidateModule(ctx context.Context, m, dir string, pv meshde // candidatePackages is the version each package of a candidate's module is built against (novox/hq ADR 0573 §2, §4): the // head of the candidate's pull request whose repository publishes it (members, by repository), else its latest published -// version, as the trunk's modules hold it. A package with neither is left out, and the fingerprint is then none. -func candidatePackages(packages []string, held map[string]meshcatalog.ModulesByModuleValue, members map[string]string) sdkstep.PackageVersions { +// version, as the trunk's modules hold it, else the commit the gate's source names for its repository (heads; design 47 G A-365). A package with none is left out, and the fingerprint is then none. +func candidatePackages(packages []string, held map[string]meshcatalog.ModulesByModuleValue, members, heads map[string]string) sdkstep.PackageVersions { versions, _ := fingerprint.HeldVersionsOf(packages, held) for _, p := range packages { repository, _, _ := trunk.PackageRepository(p) @@ -362,6 +362,14 @@ func candidatePackages(packages []string, held map[string]meshcatalog.ModulesByM versions = sdkstep.PackageVersions{} } versions[p] = head + } else if _, named := versions[p]; !named { + // A package no module publishes, of a repository outside the group: the commit the gate's source names (A-365). + if head := heads[repository]; len(head) == 40 { + if versions == nil { + versions = sdkstep.PackageVersions{} + } + versions[p] = head + } } } return versions diff --git a/modules/mesh-delivery-indexer/internal/index/previews_test.go b/modules/mesh-delivery-indexer/internal/index/previews_test.go index 8f1b3a5c..61e7ee40 100644 --- a/modules/mesh-delivery-indexer/internal/index/previews_test.go +++ b/modules/mesh-delivery-indexer/internal/index/previews_test.go @@ -160,12 +160,16 @@ func TestACandidatesModuleGetsTheFingerprintATrunkModuleOfTheSameTreeHas(t *test // mesh-sdk that nothing published gives no fingerprint, and one of its own repository's comes with its tree. const sdk, own = "git.novox.be/novox/mesh-sdk/go", "git.novox.be/novox/mesh-catalog/contract" held := map[string]meshcatalog.ModulesByModuleValue{"mesh-sdk": {Repository: "novox/mesh-sdk", Path: meshcatalogclient.RootPath, Commit: trunkOld}} - if got := candidatePackages([]string{sdk}, held, map[string]string{catalogueRepo: h1}); got[sdk] != trunkOld { + if got := candidatePackages([]string{sdk}, held, map[string]string{catalogueRepo: h1}, nil); got[sdk] != trunkOld { t.Errorf("outside a group: %v, want mesh-sdk at its trunk %s", got, trunkOld) } - if got := candidatePackages([]string{sdk}, held, map[string]string{catalogueRepo: h1, "novox/mesh-sdk": mergeSha}); got[sdk] != mergeSha { + if got := candidatePackages([]string{sdk}, held, map[string]string{catalogueRepo: h1, "novox/mesh-sdk": mergeSha}, nil); got[sdk] != mergeSha { t.Errorf("in a group with mesh-sdk: %v, want its member's head %s", got, mergeSha) } + // Design 47 G A-365: a package no module publishes, of a repository outside the group, takes the commit the source names. + if got := candidatePackages([]string{sdk}, nil, map[string]string{catalogueRepo: h1}, map[string]string{"novox/mesh-sdk": strings.Repeat("9", 40)}); got[sdk] != strings.Repeat("9", 40) { + t.Errorf("an unpublished package outside the group: %v, want the source's head", got) + } m.Packages = []string{own, sdk} pv.Modules["modules/avahi"] = m pv.Merge = "8888888888888888888888888888888888888888" @@ -173,6 +177,13 @@ func TestACandidatesModuleGetsTheFingerprintATrunkModuleOfTheSameTreeHas(t *test if got := fpOf(t, cands); got.Fp2 != "" || got.None2 != fingerprint.NoPackageVersion+sdk { t.Errorf("a package nothing published: %+v", got) } + // Through the indexer's wiring (A-365): once the gate's source names mesh-sdk's head, the candidate is built against it. + if err := applyS(ix, context.Background(), 5, srcT{Group: "g", Heads: map[string]string{catalogueRepo: trunkNow, "novox/mesh-sdk": strings.Repeat("9", 40)}}); err != nil { + t.Fatal(err) + } + if got := fpOf(t, cands); got.Fp2 == "" { + t.Errorf("a package nothing published, the source naming its repository: %+v, want a fingerprint", got) + } } func TestAnUnknownToolchainLeavesTheCandidatesModuleNamingIt(t *testing.T) { // 1445/AC2 diff --git a/modules/mesh-delivery-indexer/internal/index/registered.go b/modules/mesh-delivery-indexer/internal/index/registered.go index a2903d16..ee59138f 100644 --- a/modules/mesh-delivery-indexer/internal/index/registered.go +++ b/modules/mesh-delivery-indexer/internal/index/registered.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "maps" + "path" "slices" "strings" @@ -237,11 +238,19 @@ func (ix *Indexer) TakeIn(ctx context.Context, module string) TakenIn { if again, ok := ix.takeInHeld(ctx, module); ok { return again } - if ix.Builds == nil { - out.Answer = "the indexer reads no controller's build records, so it knows no registration" - return out + var regs []Registration + if ix.Builds != nil { + regs = ix.Builds.RegistrationsOf(module) + } + if len(regs) == 0 { + if r, why, ok := ix.registeredAtBranch(ctx, module); ok { + regs = []Registration{r} + } else if why != "" { + ix.logf("take-in of %s: %s", module, why) + out.Answer = why + return out + } } - regs := ix.Builds.RegistrationsOf(module) if len(regs) == 0 { if key, err := meshcatalogclient.ModulesKey(module); err == nil && ix.Modules != nil { if _, _, found, err := ix.Modules.Get(ctx, key); err == nil && found { @@ -430,3 +439,30 @@ func (ix *Indexer) TakeInRepository(ctx context.Context, repository string) Take out.Answer = fmt.Sprintf("%s at %.12s holds no module.json: taken in as a merge that leaves none; handed over %v, dropped %v", repository, head, out.Handed, out.Dropped) return out } + +// registeredAtBranch is the module's registration (the seat mesh-catalog's, ADR 0666) read at the head of its first watched +// branch, which is its trunk (design 47 G A-85): a module from outside the indexed repositories, watched on main, master or +// a branch its owner chose (nox-mesh), is taken in from there when the controller's build records name none. why says what +// stopped it; none and not ok is no registration. +func (ix *Indexer) registeredAtBranch(ctx context.Context, module string) (Registration, string, bool) { + if ix.Registry == nil || ix.Registry.Registrations == nil || ix.BranchHead == nil { + return Registration{}, "", false + } + reg, found, err := ix.Registry.Registration(ctx, module) + if err != nil { + return Registration{}, fmt.Sprintf("the registration of %s cannot be read: %v", module, err), false + } + if !found { + return Registration{}, "", false + } + if len(reg.Branches) == 0 || reg.Origin == "" { + return Registration{}, fmt.Sprintf("the registration of %s names no repository or watched branch", module), false + } + branch := reg.Branches[0] + head, err := ix.BranchHead(ctx, reg.Origin, branch) + if err != nil || head == "" { + return Registration{}, fmt.Sprintf("the head of %s's branch %s cannot be read: %v", reg.Origin, branch, err), false + } + ix.logf("take-in of %s: registered from %s, read at the head %s of its first watched branch %s", module, reg.Origin, head, branch) + return Registration{Module: module, Repository: reg.Origin, Path: path.Dir(reg.Path), Commit: head, Ref: branch}, "", true +} diff --git a/modules/mesh-delivery-indexer/internal/index/registrations.go b/modules/mesh-delivery-indexer/internal/index/registrations.go index fb68253f..2793e6b2 100644 --- a/modules/mesh-delivery-indexer/internal/index/registrations.go +++ b/modules/mesh-delivery-indexer/internal/index/registrations.go @@ -295,7 +295,7 @@ func compose(verb string, cur meshcatalog.Registration, found bool, change json. next.Version, next.Warrant, next.By, next.At = 0, "", "", nil var lines []string if !found { - lines = append(lines, fmt.Sprintf("%s: registered from %s at %s, watching %s", next.Module, next.Origin, next.Path, strings.Join(next.Branches, ", "))) + lines = append(lines, fmt.Sprintf("%s: registered from %s, watching %s", next.Module, next.Origin, strings.Join(next.Branches, ", "))) lines = append(lines, stepLines(next.Module+" ", meshcatalog.StepStatuses{}, next.Policy.Steps)...) return next, lines, nil } @@ -537,7 +537,13 @@ func (p Proposal) composeAsk(key string) oc.Ask { if p.Why != "" { explain += "\nWhy: " + p.Why } - explain += "\nDigest " + p.Digest + // The digest's first 12 hex only: the channel refuses a long hexadecimal string as a secret; the Approve binds the + // whole digest through the option's Binds (A-400). + if d := strings.TrimPrefix(p.Digest, "sha256:"); len(d) > 12 { + explain += "\nDigest sha256:" + d[:12] + "…" + } else { + explain += "\nDigest " + p.Digest + } a := oc.Ask{ID: p.Ask, Headline: headline, Explanation: explain, Who: occ.Operator, Expires: occ.FormatTime(p.At.Add(ProposalLasts)), OnExpiry: "nothing is written; the change waits to be proposed again", About: "catalog.proposal." + key} @@ -793,10 +799,16 @@ func (r *Registry) apply(ctx context.Context, key string, p Proposal, w oc.Warra func (r *Registry) write(ctx context.Context, key string, p Proposal, next meshcatalog.Registration, w oc.Warrant) error { at := r.now() next.V, next.Version, next.Warrant, next.By, next.At = 1, p.Was+1, w.Ask, p.Caller, &at + began := time.Now() + step := func(what string) { + r.logf("registration %s version %d: %s (%s since its start)", next.Module, next.Version, what, time.Since(began).Round(time.Millisecond)) + } + step("writing") if r.History != nil { if err := r.History(ctx, next); err != nil { return fmt.Errorf("the version %d of %s is not kept on %s, so it is not written: %w", next.Version, next.Module, RegistrationHistoryStream, err) } + step("kept on " + RegistrationHistoryStream) } data, err := json.Marshal(next) if err != nil { @@ -812,16 +824,23 @@ func (r *Registry) write(ctx context.Context, key string, p Proposal, next meshc if err != nil { return err } + step("written") if r.Say != nil { + defer step("registration-changed said") if err := r.Say(ctx, meshcatalog.RegistrationChangedEvent{V: 1, Module: next.Module, Version: next.Version, Moved: p.Lines, By: p.Caller, Warrant: w.Ask, At: &at}); err != nil { r.logf("registration-changed of %s %d is not said: %v", next.Module, next.Version, err) } } - if r.Pruned != nil { + // A first registration watched no branch before, so no branch's builds are to be pruned. + if r.Pruned != nil && p.Was > 0 { + defer step("builds of unwatched branches pruned") if err := r.Pruned(ctx, next.Module, next.Branches); err != nil { r.logf("the builds of %s on the branches it no longer watches are not pruned: %v", next.Module, err) } } + if key == "" { + return nil // a write of the seed's: no proposal key of its own to end + } return r.endKey(ctx, key, p, ProposalApplied, fmt.Sprintf("applied as version %d of %s on %s", next.Version, next.Module, occ.Says(w))) } @@ -918,17 +937,28 @@ func (r *Registry) Act(ctx context.Context, a TakeInAsk, seed func(context.Conte answer = map[string]string{"answer": said} case ActSeed: var modules []SeedModule - if seed == nil { + if composed, _, found, lerr := r.load(ctx, SeedKey); lerr == nil && found && len(composed.Seed) > 0 { + // The registrations a seed key composed already are written as composed: no build seat is asked again. + r.logf("the seed: writing the %d registrations its key composed (asked by %s)", len(composed.Seed), a.By) + var said string + said, err = r.ProposeSeed(ctx, nil, act.Again, a.By) + answer = map[string]string{"answer": said} + } else if seed == nil { err = errors.New("the seed is not composed by this indexer") - } else if modules, err = seed(ctx); err == nil { - var ask string - ask, err = r.ProposeSeed(ctx, modules, act.Again, a.By) - answer = map[string]string{"ask": ask} + } else { + r.logf("the seed: composing from the module graph, asking each build seat for its steps (asked by %s)", a.By) + if modules, err = seed(ctx); err == nil { + r.logf("the seed: %d modules composed, the build seats answered", len(modules)) + var said string + said, err = r.ProposeSeed(ctx, modules, act.Again, a.By) + answer = map[string]string{"answer": said} + } } default: err = fmt.Errorf("%q is no act of the registrations", act.Verb) } if err != nil { + r.logf("the registrations' act %s ended without an answer: %v", act.Verb, err) out.Answer = err.Error() return out } diff --git a/modules/mesh-delivery-indexer/internal/index/registrations_test.go b/modules/mesh-delivery-indexer/internal/index/registrations_test.go index 69063574..26700c95 100644 --- a/modules/mesh-delivery-indexer/internal/index/registrations_test.go +++ b/modules/mesh-delivery-indexer/internal/index/registrations_test.go @@ -236,7 +236,7 @@ func TestProposalsSurviveARestartAndAreDropped(t *testing.T) { } } -func TestSeedIsOneAskAndWaitsForEveryBuildSeat(t *testing.T) { +func TestSeedWritesTheModuleGraphWithNoAskAndWaitsForEveryBuildSeat(t *testing.T) { ctx := context.Background() g := newRegRig() g.unprotect["main"] = false @@ -245,38 +245,20 @@ func TestSeedIsOneAskAndWaitsForEveryBuildSeat(t *testing.T) { t.Fatalf("an unanswered build seat did not hold the seed: %v", err) } mods[0].Artifacts[0].Answered, mods[0].Artifacts[0].Steps = true, []string{"unit"} - waits := "" - g.r.SeedWaits = func(ask string, waiting bool) { - if waiting { - waits = ask - } else { - waits = "" - } + said, err := g.r.ProposeSeed(ctx, mods, false, "indexer") + if err != nil || !strings.Contains(said, "1 registrations written") { + t.Fatalf("seed: %q, %v", said, err) } - ask, err := g.r.ProposeSeed(ctx, mods, false, "indexer") - if err != nil || ask == "" { - t.Fatalf("seed: %q, %v", ask, err) + if len(g.asks) != 0 { + t.Fatalf("the seed asked the operator: %v", g.asks) } // A step the seat answers none for is bypass; the statuses the check judged are the rest. - g.decide(t, ask, "decline") - if waits != ask { - t.Fatalf("a declined seed does not keep seed-waits: %q", waits) - } - if _, err := g.r.ProposeSeed(ctx, mods, false, "indexer"); err == nil { - t.Fatal("the seed was asked again with no indexer_seed_again") - } - g.now = g.now.Add(time.Hour) - ask, err = g.r.ProposeSeed(ctx, mods, true, "s@n") - if err != nil { - t.Fatal(err) - } - g.decide(t, ask, "approve") got, _, _ := g.r.Registration(ctx, "a") if got.Version != 1 || got.Policy.Steps.Review != "optional" || got.Policy.Steps.Approval != "bypass" || got.Policy.Artifacts["program"].Lint != "bypass" || got.Policy.Artifacts["program"].Integration != "bypass" || got.Policy.Artifacts["program"].Unit != "" { t.Fatalf("the seeded registration: %+v", got) } - if waits != "" { - t.Fatalf("seed-waits is not cleared by the warrant: %q", waits) + if _, err := g.r.ProposeSeed(ctx, mods, true, "s@n"); err == nil { + t.Fatal("the seed wrote over registrations the indexer holds") } // An unprotected default branch is left out and named. g2 := newRegRig() diff --git a/modules/mesh-delivery-indexer/internal/index/registrations_tools.go b/modules/mesh-delivery-indexer/internal/index/registrations_tools.go index 8ff28321..9baa5cf5 100644 --- a/modules/mesh-delivery-indexer/internal/index/registrations_tools.go +++ b/modules/mesh-delivery-indexer/internal/index/registrations_tools.go @@ -15,7 +15,7 @@ import ( // the indexer's own tools of the proposals (§667) and the seed (§8), served in the tools bundle. Every act is asked of the // indexer through takeins, as the indexer's other tools are (ask writes the value and waits for the answer); the proposals // are read from the state as the bundle reads it. record says a hand act in the hand-act log. -func RegistrationTools(proposals Store, ask func(key string, value []byte) (TakeInAsk, error), now func() time.Time, record func(cause, verb, what, why string) error) []stdio.Tool { +func RegistrationTools(registrations, proposals Store, ask func(key string, value []byte) (TakeInAsk, error), now func() time.Time, record func(cause, verb, what, why string) error) []stdio.Tool { act := func(verb string, withInput bool) func(map[string]any) (any, error) { return func(args map[string]any) (any, error) { var input json.RawMessage @@ -39,8 +39,31 @@ func RegistrationTools(proposals Store, ask func(key string, value []byte) (Take return answerOf(ask(key, value)) } } + // The verb registrations is a first view of the catalog half: it is answered at once from the state the registrations are kept + // in, never queued behind a running take-in (design 47 G A-370). Only a module's history is read from the stream the + // indexer keeps, so that is still asked of the indexer. + viaIndexer := act(ActRegistrations, true) return []stdio.Tool{ - {Name: meshcatalog.Seat + "." + meshcatalog.VerbRegistrations, Run: act(ActRegistrations, true)}, + {Name: meshcatalog.Seat + "." + meshcatalog.VerbRegistrations, Run: func(args map[string]any) (any, error) { + var in meshcatalog.RegistrationsInput + clean := map[string]any{} + for k, v := range args { + if k != "caller" && !strings.HasPrefix(k, "_") { + clean[k] = v + } + } + raw, err := json.Marshal(clean) + if err == nil { + err = json.Unmarshal(raw, &in) + } + if err != nil { + return nil, err + } + if in.History { + return viaIndexer(args) + } + return (&Registry{Registrations: registrations}).RegistrationsAnswer(context.Background(), in) + }}, {Name: meshcatalog.Seat + "." + meshcatalog.VerbRegister, Run: act(verbRegister, true)}, {Name: meshcatalog.Seat + "." + meshcatalog.VerbPolicy, Run: act(verbPolicy, true)}, {Name: meshcatalog.Seat + "." + meshcatalog.VerbWatch, Run: act(verbWatch, true)}, @@ -78,8 +101,8 @@ func RegistrationTools(proposals Store, ask func(key string, value []byte) (Take } return res, nil }}, - {Name: SeedAgainTool, Description: "Raise the ask of the first registrations again from the seed's key (design 47 G §8), after a Decline, an expiry or a drop " + - "ended it and while the indexer holds no registration. A hand act: who and why are said in the hand-act log.", + {Name: SeedAgainTool, Description: "Write the first registrations from the module graph the indexer holds (design 47 G §8; a module in the module graph is a " + + "registration), while the indexer holds no registration: no ask. A hand act: who and why are said in the hand-act log.", Input: map[string]any{"type": "object", "required": []string{"why"}, "properties": map[string]any{ "why": map[string]any{"type": "string", "description": "why it is asked again, in plain words"}}}, Run: func(args map[string]any) (any, error) { diff --git a/modules/mesh-delivery-indexer/internal/index/registrations_tools_test.go b/modules/mesh-delivery-indexer/internal/index/registrations_tools_test.go new file mode 100644 index 00000000..f9be83ff --- /dev/null +++ b/modules/mesh-delivery-indexer/internal/index/registrations_tools_test.go @@ -0,0 +1,44 @@ +package index + +import ( + "context" + "encoding/json" + "errors" + "testing" + "time" + + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" +) + +// Design 47 G A-370: the verb registrations answers from the state at once; it never asks the indexer (whose take-in may be +// running), but for a module's history, which the indexer reads from its stream. +func TestTheRegistrationsVerbIsAnsweredFromItsStateNotAskedOfTheIndexer(t *testing.T) { + store := MemoryStore() + data, _ := json.Marshal(meshcatalog.Registration{Module: "a"}) + if err := store.Create(context.Background(), RegistrationKey("a"), data); err != nil { + t.Fatal(err) + } + asked := 0 + ask := func(string, []byte) (TakeInAsk, error) { + asked++ + return TakeInAsk{}, errors.New("the take-in is still running") + } + var tool func(map[string]any) (any, error) + for _, tl := range RegistrationTools(store, MemoryStore(), ask, time.Now, nil) { + if tl.Name == meshcatalog.Seat+"."+meshcatalog.VerbRegistrations { + tool = tl.Run + } + } + for _, args := range []map[string]any{{}, {"module": "a"}} { + got, err := tool(args) + if err != nil || len(got.(meshcatalog.RegistrationsAnswer).Registrations) != 1 { + t.Errorf("registrations %v = %+v, %v, want the one registration", args, got, err) + } + } + if asked != 0 { + t.Errorf("the indexer was asked %d times for a read of the state", asked) + } + if _, err := tool(map[string]any{"module": "a", "history": true}); err == nil || asked != 1 { + t.Errorf("a history is asked of the indexer: err %v, asked %d", err, asked) + } +} diff --git a/modules/mesh-delivery-indexer/internal/index/revision_verb.go b/modules/mesh-delivery-indexer/internal/index/revision_verb.go index 3a0d48e0..13da59fd 100644 --- a/modules/mesh-delivery-indexer/internal/index/revision_verb.go +++ b/modules/mesh-delivery-indexer/internal/index/revision_verb.go @@ -18,11 +18,15 @@ import ( const RevisionInvoke = "seat:" + meshcatalog.Seat + "." + meshcatalog.VerbRevision // RevisionCallers are the parts the newest trunk revision's entries say declare the verb revision in their invokes, -// sorted, the holder itself never among them (ADR 0663 §2: granted to exactly the parts that declare it). +// sorted, the holder itself never among them (ADR 0663 §2: granted to exactly the parts that declare it). A single `*` +// in invokes declares every seat verb, as the grants part reads it (A-390). +// +// Lead answer A-395: every part the newest trunk revision holds may read it, and so may the tool runner, which reads the +// catalog half for each module it serves on that module's or its own account, the holder's own tools too (A-401). func RevisionCallers(entries []meshcatalog.CatalogEntry, holder string) stdio.Callers { - var out stdio.Callers + out := stdio.Callers{ToolRunner} for _, e := range entries { - if e.Module != holder && slices.Contains(e.Invokes, RevisionInvoke) { + if !slices.Contains(out, e.Module) { out = append(out, e.Module) } } @@ -30,6 +34,31 @@ func RevisionCallers(entries []meshcatalog.CatalogEntry, holder string) stdio.Ca return out } +// nodeEngineSeat is the seat whose holder's calls come as the account of a node, not of a module process. +const nodeEngineSeat = "node-engine" + +// CallerModule is the caller a callers list is checked against (design 47 G A-450; ADR 0621 §2, ADR 0663 §2): the proof of a +// node-engine's call is the account `node.` (one dot), which no list entry names, so it stands for the module whose +// entry of the revision serves the seat node-engine, the part that declares the verb. Any other caller is its own. Every verb +// of the seat mesh-catalog the indexer holds that checks its caller reads it through this one function. +func CallerModule(entries []meshcatalog.CatalogEntry, caller string) string { + machine, ok := strings.CutPrefix(caller, "node.") + if !ok || machine == "" || strings.Contains(machine, ".") { + return caller + } + for _, e := range entries { + for _, word := range e.Serves { + if strings.HasPrefix(word, "seat:"+nodeEngineSeat+".") { + return e.Module + } + } + } + return caller +} + +// ToolRunner is the module of every node's tool runner, the runtime every module's tools run in (A-395). +const ToolRunner = "node-tools" + // Revision answers the seat mesh-catalog's verb revision from the indexer's own objects (ADR 0663 §1, §3): one catalog // graph revision, the trunk's newest when the input names none, a kept trunk revision by its number, or a candidate's by // its group and heads, with one page of its entries whole, by module name. The caller is the runtime's proof: it is @@ -50,6 +79,7 @@ func Revision(ctx context.Context, o Objects, holder, caller string, in meshcata if err != nil { return out, err } + caller = CallerModule(trunkEntries, caller) if err := views.Refusal(meshcatalog.Seat+"."+meshcatalog.VerbRevision, RevisionCallers(trunkEntries, holder), caller); err != nil { return out, fmt.Errorf("%w (novox/hq ADR 0663 §2: a part reads it by declaring %s in invokes)", err, RevisionInvoke) } diff --git a/modules/mesh-delivery-indexer/internal/index/seed.go b/modules/mesh-delivery-indexer/internal/index/seed.go index c4116d63..0ea0bcba 100644 --- a/modules/mesh-delivery-indexer/internal/index/seed.go +++ b/modules/mesh-delivery-indexer/internal/index/seed.go @@ -2,7 +2,6 @@ package index import ( "context" - "encoding/json" "errors" "fmt" "slices" @@ -105,9 +104,11 @@ func (r *Registry) ComposeSeed(modules []SeedModule) (SeedProposal, error) { return out, nil } -// ProposeSeed raises the first registrations as one ask (§8), when the indexer holds no registration and the seed's key is not -// open or applied; again (indexer_seed_again) it raises the ask once more from a key a Decline, an expiry or a drop ended. -// It answers the ask's id, or why none was raised. +// ProposeSeed writes the first registrations from the module graph the indexer holds, when it holds no registration (§8): a +// module in the module graph is a registration, so they are written at once, each as version 1, with no ask (the operator, +// 2026-11-14: "a module in the module graph IS a registration"). The registrations a seed key already composed are written as +// composed; otherwise they are composed from modules. A seed key still open is ended applied. again is kept for the tool's +// form and changes nothing. It answers what it wrote. func (r *Registry) ProposeSeed(ctx context.Context, modules []SeedModule, again bool, by string) (string, error) { r.mu.Lock() defer r.mu.Unlock() @@ -115,48 +116,60 @@ func (r *Registry) ProposeSeed(ctx context.Context, modules []SeedModule, again if err != nil { return "", err } - if len(held) > 0 { + old, _, found, err := r.load(ctx, SeedKey) + if err != nil { + return "", err + } + regs := old.Seed + var left []string + if !found || len(regs) == 0 { + seed, err := r.ComposeSeed(modules) + if err != nil { + return "", err + } + if len(seed.Unanswered) > 0 { + return "", fmt.Errorf("the build seats %v have not answered steps: the seed waits for them (call-unanswered after five minutes)", seed.Unanswered) + } + regs, left = seed.Registrations, seed.Left + } + if len(regs) == 0 { + return "", errors.New("no module of the trunk revision can be registered: " + strings.Join(left, "; ")) + } + if len(held) > 0 && (!found || old.State != ProposalOpen) { return "", errors.New("the indexer holds registrations already: the seed is for the first start only") } - if old, _, found, err := r.load(ctx, SeedKey); err != nil { - return "", err - } else if found && old.State == ProposalOpen { - return old.Ask, nil - } else if found && !again { - return "", fmt.Errorf("the seed ended %s: indexer_seed_again asks it again", old.State) + // A seed that stopped part way (its key still open) writes the modules it has not written yet. + have := map[string]bool{} + for _, k := range held { + have[k] = true } - seed, err := r.ComposeSeed(modules) - if err != nil { - return "", err + w := oc.Warrant{Ask: "module-graph"} + written := 0 + for _, reg := range regs { + if have[RegistrationKey(reg.Module)] { + continue + } + p := Proposal{V: 1, Verb: verbRegister, Module: reg.Module, Caller: by, At: r.now(), State: ProposalOpen, + Lines: []string{fmt.Sprintf("%s: registered from the module graph (%s)", reg.Module, reg.Origin)}} + if err := r.write(ctx, "", p, reg, w); err != nil { + return "", err + } + written++ } - if len(seed.Unanswered) > 0 { - return "", fmt.Errorf("the build seats %v have not answered steps: the seed waits for them (call-unanswered after five minutes)", seed.Unanswered) + said := fmt.Sprintf("%d registrations written from the module graph (%d held before)", written, len(held)) + if found && old.State == ProposalOpen { + if err := r.end(ctx, SeedKey, old.Ask, ProposalApplied, said); err != nil { + r.logf("the seed key is not ended: %v", err) + } } - if len(seed.Registrations) == 0 { - return "", errors.New("no module of the trunk revision can be registered: " + strings.Join(seed.Left, "; ")) + if r.SeedWaits != nil && old.Ask != "" { + r.SeedWaits(old.Ask, false) } - change, err := json.Marshal(seed.Registrations) - if err != nil { - return "", err + for _, l := range left { + r.logf("the seed left out: %s", l) } - p := Proposal{V: 1, Verb: verbSeed, Change: change, Seed: seed.Registrations, Caller: by, At: r.now(), State: ProposalOpen} - for _, g := range seed.Registrations { - p.Lines = append(p.Lines, fmt.Sprintf("%s: registered from %s at %s, watching %s", g.Module, g.Origin, g.Path, strings.Join(g.Branches, ", "))) - } - for _, l := range seed.Left { - p.Lines = append(p.Lines, "left out: "+l) - } - if p.Digest, err = DigestOf(map[string]any{"verb": verbSeed, "change": json.RawMessage(change)}); err != nil { - return "", err - } - if err := r.keepAndAsk(ctx, SeedKey, &p); err != nil { - return "", err - } - if r.SeedWaits != nil { - // The seed waits on the operator while its ask is open; only the warrant clears the finding (design 47 G §704). - r.SeedWaits(p.Ask, true) - } - return p.Ask, nil + r.logf("the seed: %s", said) + return said, nil } // applySeed writes every registration the seed proposes, each as version 1 on the warrant, and ends the key applied. diff --git a/modules/mesh-delivery-indexer/internal/index/seed_steps.go b/modules/mesh-delivery-indexer/internal/index/seed_steps.go index 934fbe62..4fece72d 100644 --- a/modules/mesh-delivery-indexer/internal/index/seed_steps.go +++ b/modules/mesh-delivery-indexer/internal/index/seed_steps.go @@ -112,14 +112,26 @@ func (ix *Indexer) SeedModulesFrom(ctx context.Context, defs map[string]seatdef. seat := seatOf[a.Ref] sa := SeedArtifact{Name: name, Seat: seat} in := nodebuildgo.StepsInput{Module: e.Module, Artifact: nodebuildgo.DetectedStepsByModuleArtifactKey(e.Module, name), Fingerprint: e.Fp, - Fetch: &nodebuildgo.Fetch{Repository: e.Repository, Commit: e.Commit, Dir: e.Path, Paths: namedPaths(e, name), Packages: maps.Clone(e.Packages)}} + Fetch: &nodebuildgo.Fetch{Repository: e.Repository, Commit: e.Commit, Packages: maps.Clone(e.Packages)}} + // The module's directory and its named paths go together, only when the entry names its paths (ADR 0499 clause + // 4); a request without them builds from the module's directory (sdk/buildstep FetchRequest). + if paths := namedPaths(e, name); len(paths) > 0 { + in.Fetch.Dir, in.Fetch.Paths = e.Path, paths + } + if _, gone := unanswered[seat]; gone { + // the seat did not answer earlier in this seed: its later artifacts are not asked again (A-392) + m.Artifacts = append(m.Artifacts, sa) + continue + } ans, err := steps(ctx, seat, in) switch { case errors.Is(err, ErrAskClosed): // the entry is no longer held: not said unanswered (A-190) case err != nil: unanswered[seat] = err + ix.logf("seed: the seat %s did not answer steps: %v; its later artifacts are not asked in this seed", seat, err) case ans.Error != "": unanswered[seat] = fmt.Errorf("%s", ans.Error) + ix.logf("seed: the seat %s did not answer steps: %s; its later artifacts are not asked in this seed", seat, ans.Error) default: sa.Answered = true answered[seat] = true diff --git a/modules/mesh-delivery-indexer/internal/index/seed_steps_test.go b/modules/mesh-delivery-indexer/internal/index/seed_steps_test.go index 8b933ded..22c7b3a9 100644 --- a/modules/mesh-delivery-indexer/internal/index/seed_steps_test.go +++ b/modules/mesh-delivery-indexer/internal/index/seed_steps_test.go @@ -163,3 +163,51 @@ func TestTheSeedBypassesWhatTheBuilderPacksAndLeavesOutAModuleNoSeatBuilds(t *te t.Fatalf("the seed after odd left the catalogue: %v, the findings %+v", err, w.Held()) } } + +// Lead answer A-392: a seat that did not answer steps is called once in a seed; its later artifacts stay unanswered +// without a call, and an answering seat is called per artifact. +func TestTheSeedCallsAnUnansweringSeatOnce(t *testing.T) { + for _, tc := range []struct { + name string + up bool + wantCalls int + }{{"a seat that does not answer", false, 1}, {"a seat that answers", true, 3}} { + t.Run(tc.name, func(t *testing.T) { + ctx := context.Background() + ix := &Indexer{Module: testSelf, Findings: newFindings(), Heard: newMem(), Revisions: newMemObjects(1 << 20), Now: time.Now} + entries := map[string]meshcatalog.CatalogEntry{} + for _, m := range []string{"a", "b", "c"} { + entries[m] = meshcatalog.CatalogEntry{Module: m, Repository: "novox/r", Commit: "c1", Path: "mods/" + m, Fp: "src2:" + strings.Repeat("a", 64), + Manifest: map[string]any{}, Artifacts: []meshcatalog.Artifact{{Ref: m + ":program", Language: "go"}}} + } + rev, objects, err := CatalogRevisionOf(meshcatalog.CatalogRevision{Revision: 1, Kind: "trunk"}, entries) + if err != nil { + t.Fatal(err) + } + if err := KeepRevision(ctx, ix.Revisions, rev, objects); err != nil { + t.Fatal(err) + } + defs := map[string]seatdef.Definition{"node-build-go": {Acts: []seatdef.ActingRule{{Step: seatdef.StepBuild, On: "go"}}}} + calls := 0 + call := func(context.Context, string, nodebuildgo.StepsInput) (nodebuildgo.StepsAnswer, error) { + calls++ + if !tc.up { + return nodebuildgo.StepsAnswer{}, errors.New("no responders") + } + return nodebuildgo.StepsAnswer{}, nil + } + mods, err := ix.SeedModulesFrom(ctx, defs, call) + if err != nil { + t.Fatal(err) + } + if calls != tc.wantCalls { + t.Errorf("calls = %d, want %d", calls, tc.wantCalls) + } + for _, m := range mods { + if a := m.Artifacts[0]; a.Answered != tc.up || a.Seat != "node-build-go" { + t.Errorf("%s: %+v", m.Module, a) + } + } + }) + } +} diff --git a/modules/mesh-delivery-indexer/internal/index/source.go b/modules/mesh-delivery-indexer/internal/index/source.go index 19e75efd..88bb3bed 100644 --- a/modules/mesh-delivery-indexer/internal/index/source.go +++ b/modules/mesh-delivery-indexer/internal/index/source.go @@ -2,16 +2,21 @@ package index import ( "context" + "encoding/json" "errors" "fmt" "maps" + "path" "slices" "strings" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg" + "git.novox.be/novox/mesh-sdk/go/catalogue" + "git.novox.be/novox/mesh-sdk/go/keys" "git.novox.be/novox/mesh-sdk/go/process" "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/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" ) @@ -39,6 +44,13 @@ func (ix *Indexer) srcOf(repository, merge string) uint64 { return 0 } +// sourceHeads is the head the latest source seen names for each repository (a copy), nil while none has been seen. +func (ix *Indexer) sourceHeads() map[string]string { + ix.mu.Lock() + defer ix.mu.Unlock() + return maps.Clone(ix.source.heads) +} + // ApplySource takes the source revision the verb source answered in. An older revision than the latest seen is left. For each // repository the source names, each module built from it whose fingerprint was computed at the head the source names, and // that carries no Src yet, is written again with Src the revision (once: a later revision leaves it); a module computed at another commit is left (a merge heard later is stamped @@ -56,6 +68,7 @@ func (ix *Indexer) ApplySource(ctx context.Context, a meshdelivery.SourceAnswer) ix.mu.Unlock() return nil } + before := ix.source.heads ix.source = sourceNow{rev: rev, heads: maps.Clone(s.Heads)} ix.mu.Unlock() if ix.Modules == nil { @@ -108,6 +121,13 @@ func (ix *Indexer) ApplySource(ctx context.Context, a meshdelivery.SourceAnswer) return fmt.Errorf("modules.%s: %w", key, err) } } + // A module built against the commit the source named as a repository's head (a package no module publishes, A-365) is + // computed again when that head moves: the gate moves the source only after the take-in. + if movedPackages(held, before, s.Heads) { + if err := ix.Recompute(ctx); err != nil { + return err + } + } // The stamps are kept with the view (KeepView), so a restart reads them back. if err := ix.KeepView(ctx); err != nil { return err @@ -116,6 +136,19 @@ func (ix *Indexer) ApplySource(ctx context.Context, a meshdelivery.SourceAnswer) return ix.RecomputeCandidates(ctx) } +// movedPackages is whether a held module's package version is the previous head of a repository whose head the new source moved. +func movedPackages(held map[string]meshcatalog.ModulesByModuleValue, before, now map[string]string) bool { + for _, m := range held { + for p, v := range m.Packages { + repo, _, ok := trunk.PackageRepository(p) + if ok && before[repo] != "" && before[repo] == v && now[repo] != before[repo] { + return true + } + } + } + return false +} + // kickCatchUp takes the trunk in at a first start, when the objects keep no trunk revision yet (the lead's ruling A on // milestone 47/G: the catch-up path): the head the source names for every repository, by the merged message the forge // bridge gives for it, each applied as its merge, and revision 1 kept from them all at its end. Until then the revision @@ -167,6 +200,12 @@ func (ix *Indexer) takeInHeads(ctx context.Context, heads map[string]string) []s continue } f, err := ix.mergedAt(ctx, repository, head) + if err != nil && ctx.Err() == nil && ix.Read != nil { + // A head the source names that has no merged message (a branch newly watched, whose head no merge on it made) is + // read whole at that commit, as a clone does (A-401, A-93). + ix.logf("catalog graph: %s at %.12s has no merged message (%v): read whole at that commit through the seat git, as a merge of every file of its tree", repository, head, err) + f, err = ix.wholeAt(ctx, repository, head) + } if err == nil { _, err = ix.ApplyMessage(ctx, f) } @@ -229,3 +268,92 @@ func (ix *Indexer) mergedAt(ctx context.Context, repository, head string) (forge } return f, nil } + +// wholeAt is the merged message of a head that has none (A-401): the head's tree and files read through the seat git +// (Read), every module directory of it with its manifest, lock files and mesh packages, as a merge whose changed files are +// every file of that tree, so it is computed as any other head (applyMoving; A-93). +func (ix *Indexer) wholeAt(ctx context.Context, repository, head string) (forgemsg.Forge, error) { + f := forgemsg.Forge{V: keys.Version, Kind: forgemsg.ForgeMerged, Repository: repository, Merge: head, Head: head} + file := func(p string) ([]byte, error) { + if ix.ReadFile == nil { + return nil, errors.New("the indexer reads no file of the forge") + } + return ix.ReadFile(ctx, repository, head, p) + } + first, err := ix.Read(ctx, repository, head, "") + if err != nil { + return f, fmt.Errorf("the seat git could not read %s at %.12s: %w", repository, head, err) + } + f.Root, f.Trees = first.Root, maps.Clone(first.Trees) + for _, dir := range slices.Sorted(maps.Keys(first.Trees)) { + read := first + if dir != "" { + if read, err = ix.Read(ctx, repository, head, dir); err != nil { + return f, fmt.Errorf("the seat git could not read %q of %s at %.12s: %w", dir, repository, head, err) + } + } + if f.Manifests == nil { + f.Manifests = map[string]string{} + } + f.Manifests[dir] = read.Manifests[dir] + // The reader capabilities of a manifest that names templates, its templates' text too, as the forge bridge reads them + // (ADR 0632 §2): a template the forge does not have is no need, any other failure to read one is the head's. + if paths := manifestTemplatePaths(read.Manifests[dir]); len(paths) > 0 { + texts := map[string]string{} + for _, t := range paths { + content, err := file(path.Join(dir, t)) + if err != nil { + return f, fmt.Errorf("the seat git could not read the template %q of %q of %s at %.12s: %w", t, dir, repository, head, err) + } + if content != nil { + texts[t] = string(content) + } + } + if f.Needs == nil { + f.Needs = map[string][]string{} + } + f.Needs[dir], _ = catalogue.ModuleNeeds([]byte(read.Manifests[dir]), texts) + } + if l := read.Locks[dir]; len(l) > 0 { + if f.Locks == nil { + f.Locks = map[string]map[string]string{} + } + f.Locks[dir] = l + } + if p := read.Packages[dir]; len(p) > 0 { + if f.Packages == nil { + f.Packages = map[string][]string{} + } + f.Packages[dir] = p + } + } + // The catalogue's predefined list at the commit, as the forge bridge carries it (ADR 0565 §2). + if trunk.SameRepository(repository, catalogueRepository) { + raw, err := file(predefinedFile) + if err != nil { + return f, fmt.Errorf("the seat git could not read %s of %s at %.12s: %w", predefinedFile, repository, head, err) + } + if raw == nil { + f.PredefinedRead = true + } else { + f.Predefined = json.RawMessage(raw) + } + } + return f, nil +} + +// The catalogue repository and its predefined list's file, whose merged message carries the list (the forge bridge's +// CatalogRepository and PredefinedFile). +const ( + catalogueRepository = "novox/mesh-catalog" + predefinedFile = "predefined.json" +) + +// manifestTemplatePaths is the template paths a manifest names, none for one that cannot be read. +func manifestTemplatePaths(raw string) []string { + m, err := catalogue.Decode([]byte(raw)) + if err != nil { + return nil + } + return catalogue.TemplatePaths(m) +} diff --git a/modules/mesh-delivery-indexer/internal/index/source_test.go b/modules/mesh-delivery-indexer/internal/index/source_test.go index 96fc8758..995f21ee 100644 --- a/modules/mesh-delivery-indexer/internal/index/source_test.go +++ b/modules/mesh-delivery-indexer/internal/index/source_test.go @@ -3,8 +3,10 @@ package index import ( "context" "reflect" + "strings" "testing" + "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/meshdelivery" ) @@ -116,3 +118,50 @@ func TestAMergeThatNoSourceRevisionNamesIsWrittenAsToday(t *testing.T) { // 1344 t.Errorf("module a = %+v, want the new merge with Src 0", m) } } + +func TestAModuleBuiltAgainstASourceHeadIsComputedAgainWhenThatHeadMoves(t *testing.T) { // design 47 G A-365 + held := map[string]meshcatalog.ModulesByModuleValue{"a": {Packages: map[string]string{"git.novox.be/novox/mesh-contracts/go/seats/findings": otherMerge}}} + for _, row := range []struct { + name string + before, now map[string]string + want bool + }{ + {"the head its version came from moved", map[string]string{"novox/mesh-contracts": otherMerge}, map[string]string{"novox/mesh-contracts": merge}, true}, + {"the head stands", map[string]string{"novox/mesh-contracts": otherMerge}, map[string]string{"novox/mesh-contracts": otherMerge}, false}, + {"another repository's head moved", map[string]string{"novox/mesh-contracts": otherMerge}, map[string]string{"novox/mesh-contracts": otherMerge, "novox/mesh-sdk": merge}, false}, + {"no source seen before", nil, map[string]string{"novox/mesh-contracts": merge}, false}, + } { + if got := movedPackages(held, row.before, row.now); got != row.want { + t.Errorf("%s: movedPackages = %v, want %v", row.name, got, row.want) + } + } +} + +// Design 47 G A-365: through ApplySource, a held module whose package no module publishes was built against the head the source +// named; when the source moves that repository's head, the module's fingerprint is computed again against the new head. +func TestApplySourceComputesAgainTheModuleBuiltAgainstTheHeadThatMoved(t *testing.T) { + ctx := context.Background() + const pkg = "git.novox.be/novox/mesh-contracts/go/seats/findings" + ix, mods := newFormIndexer(t, mod{"avahi", catalogueManifest(t, "avahi")}) + reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1") + ix.Packages = newMem() + setPackages(t, mods, "avahi", []string{pkg}) + h1, h2 := strings.Repeat("1", 40), strings.Repeat("2", 40) + if err := applyS(ix, ctx, 1, sourceOf("novox/mesh-contracts", h1)); err != nil { + t.Fatal(err) + } + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + first, _ := moduleOf(t, mods, "avahi") + if first.Fp2 == "" || first.Packages[pkg] != h1 { + t.Fatalf("before the head moves: fp2 %q none2 %q packages %v, want a fingerprint built against %s", first.Fp2, first.None2, first.Packages, h1) + } + if err := applyS(ix, ctx, 2, sourceOf("novox/mesh-contracts", h2)); err != nil { + t.Fatal(err) + } + moved, _ := moduleOf(t, mods, "avahi") + if moved.Packages[pkg] != h2 || moved.Fp2 == first.Fp2 { + t.Errorf("after the head moves: fp2 %q (was %q) packages %v, want it computed again against %s", moved.Fp2, first.Fp2, moved.Packages, h2) + } +} diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index 68b4df02..87c225c7 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -288,11 +288,11 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc r.none = strings.Join(missing, "; ") case noToolchain != "": r.none = noToolchain - if fp, pkgs, ok := stillComputed(module, kept, k, toolchains, held, pub, pins); ok { + if fp, pkgs, ok := stillComputed(module, kept, k, toolchains, held, pub, pins, ix.sourceHeads()); ok { r = result{fp: fp, tcs: k.held.Toolchains, pkgs: pkgs} } default: - f := formOf(module, k.cur.Repository, &kept, toolchains, k.held, held, pub, pins, ix.logf) + f := formOf(module, k.cur.Repository, &kept, toolchains, k.held, held, pub, pins, ix.sourceHeads(), ix.logf) r.fp, r.none = f.fp, f.none if r.fp != "" { r.tcs, r.pkgs = toolchainsUsed(toolchains), f.versions @@ -503,7 +503,7 @@ func hasContext(m catalogue.Manifest) bool { // with the toolchains it was computed with in place of the languages agreed on none, give it again, in its form. Any // other input that moved (a merge, a base, an agreed toolchain, an imported package) gives another fingerprint, and the // module has none until they agree. -func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, k *known, agreed map[string]meshcatalogclient.Toolchain2, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions) (string, sdkstep.PackageVersions, bool) { +func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, k *known, agreed map[string]meshcatalogclient.Toolchain2, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string) (string, sdkstep.PackageVersions, bool) { if k.held.Fp2 == "" { return "", nil, false } @@ -519,7 +519,7 @@ func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, } toolchains[artifact] = meshcatalogclient.Toolchain2{Language: language, Version: used.Version, Recipe: used.Recipe} } - f := formOf(module, k.held.Repository, &kept, toolchains, k.held, held, published, pins, nil) + f := formOf(module, k.held.Repository, &kept, toolchains, k.held, held, published, pins, heads, nil) return f.fp, f.versions, f.none == "" && f.fp == k.held.Fp2 } diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go index 67fca1d2..2b1ab74e 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go @@ -608,11 +608,22 @@ func TestBasesAreComputedFirstAndNoFingerprintTakesTheBuilder(t *testing.T) { // if e, ok, err := trunkStates.State(views.MarksState).Get("graph"); err != nil || !ok || !strings.Contains(string(e.Value), `"revision":2`) { t.Errorf("the bundle's mark of graph = %+v %v (%v), want revision 2", e, ok, err) } + // A kept view reads the revision once while it stays the newest, and its first view answers in pages of values, never + // one revision read per key (about 11 s a page live, 2026-11-14). + reads := 0 + keptView := TrunkStates{Objects: first.Revisions, Under: func(string) views.Source { return nil }, Kept: &KeptTrunk{Say: func(string, ...any) { reads++ }}} + if a, err := views.FirstView(testSelf, ModulesState, keptView.State(ModulesState), keptView.State(views.MarksState), "", time.Now()); err != nil || + a.Revision != 2 || len(a.Values) != len(builderModules(t)) || a.Next != "" { + t.Errorf("the kept first view modules answered %d values at %d, next %q (%v), want every module at revision 2 in one page", len(a.Values), a.Revision, a.Next, err) + } + if _, _, err := keptView.State("graph").Get("avahi"); err != nil || reads != 1 { + t.Errorf("the kept view read the revision %d times (%v), want once", reads, err) + } if _, err := (TrunkStates{Objects: newMemObjects(0)}).State("graph").Keys(); !errors.Is(err, ErrNoRevision) { - t.Errorf("the bundle's graph with no revision kept answered %v, want it to wait", err) + t.Errorf("the bundle's graph with no revision keptView answered %v, want it to wait", err) } // W4.4, ADR 0663: the seat mesh-catalog's verb revision answers, from the indexer's own objects, exactly the parts whose - // entry in the newest trunk revision declares it, the holder refused too; a candidate's by its group and heads; none + // entry in the newest trunk revision declares it, the holder's own tools too (A-401); a candidate's by its group and heads; none // kept, everyone waits. verbObjects := newMemObjects(0) keep := func(rev meshcatalog.CatalogRevision, declares map[string]bool) { @@ -622,6 +633,9 @@ func TestBasesAreComputedFirstAndNoFingerprintTakesTheBuilder(t *testing.T) { // if declares[name] { e.Invokes = []string{RevisionInvoke} } + if name == "avahi" && rev.Kind == "trunk" { + e.Invokes = []string{"*"} // A-390: a single `*` declares every seat verb, as the grants part reads it + } data, _ := json.Marshal(e) digest := fmt.Sprintf("%s-%d-%s", rev.Kind, rev.Revision, name) entries[digest] = data @@ -636,7 +650,7 @@ func TestBasesAreComputedFirstAndNoFingerprintTakesTheBuilder(t *testing.T) { // } keep(meshcatalog.CatalogRevision{Revision: 3, Kind: "trunk"}, map[string]bool{"node-tools": true, testSelf: true}) keep(meshcatalog.CatalogRevision{Revision: 4, Kind: "candidate", Group: "feat/x", Heads: "0123456789ab"}, map[string]bool{"node-tools": true, "mesh-grants": true}) - for caller, answered := range map[string]bool{"n1.node-tools": true, "n1.mesh-grants": false, "n1." + testSelf: false, "person.someone": false, "unproven": false} { + for caller, answered := range map[string]bool{"n1.node-tools": true, "n1.avahi": true, "n1.mesh-grants": true, "n1." + testSelf: true, "person.someone": false, "unproven": false} { got, err := Revision(context.Background(), verbObjects, testSelf, caller, meshcatalog.RevisionInput{}) if (err == nil) != answered || (answered && (got.Revision.Revision != 3 || len(got.Entries) != 4 || got.Next != "")) { t.Errorf("revision to %s answered %+v (%v), want answered %v with trunk revision 3 whole", caller, got, err, answered) diff --git a/modules/mesh-delivery-indexer/internal/index/versions.go b/modules/mesh-delivery-indexer/internal/index/versions.go index 5c691424..c2a608ee 100644 --- a/modules/mesh-delivery-indexer/internal/index/versions.go +++ b/modules/mesh-delivery-indexer/internal/index/versions.go @@ -107,13 +107,24 @@ func (ix *Indexer) HearPackagePublished(ctx context.Context, p meshbuilds.Packag if _, ok := versionParts(p.Version); !ok { return fmt.Errorf("the package-published of %s names the version %q, which is no MAJOR.MINOR.PATCH", p.Artifact, p.Version) } + ix.logf("versions: heard the package-published of %s at %s (digest %s, branch %q, source %d)", p.Artifact, p.Version, p.Digest, p.Branch, p.Source) if ix.Registry != nil { - if r, found, err := ix.Registry.Registration(ctx, p.Module); err == nil && found && len(r.Branches) > 0 && r.Branches[0] != p.Branch { + r, found, err := ix.Registry.Registration(ctx, p.Module) + switch { + case err != nil: + ix.logf("versions: the registration of %s cannot be read, so %s at %s is taken as the first watched branch's: %v", p.Module, p.Artifact, p.Version, err) + case !found: + ix.logf("versions: %s has no registration, so %s at %s is taken as the first watched branch's", p.Module, p.Artifact, p.Version) + case len(r.Branches) > 0 && r.Branches[0] != p.Branch: + ix.logf("versions: %s at %s is of the branch %q, not the first watched branch %q: it releases no version, its edges are kept in build-edges", p.Artifact, p.Version, p.Branch, r.Branches[0]) return ix.hearBranchBuild(ctx, p) // releases no version; its edges are kept in build-edges (A-83) } } - if _, _, found, err := ix.Versions.Get(ctx, meshcatalog.VersionsByModuleVersionKey(p.Module, p.Version)); err != nil || found { - return err // released already: heard again + if _, _, found, err := ix.Versions.Get(ctx, meshcatalog.VersionsByModuleVersionKey(p.Module, p.Version)); err != nil { + return err + } else if found { + ix.logf("versions: %s %s is released already, so the package-published of %s is heard again and changes nothing", p.Module, p.Version, p.Artifact) + return nil } entry, err := ix.entryOf(ctx, p.Module) if err != nil { @@ -148,11 +159,16 @@ func (ix *Indexer) HearPackagePublished(ctx context.Context, p meshbuilds.Packag if err != nil { return err } + var missing []string for _, ref := range want { if _, ok := have.Artifacts[ref]; !ok { - return nil + missing = append(missing, ref) } } + if len(missing) > 0 { + ix.logf("versions: %s %s waits for the package-published of %s, which the newest trunk entry of it names (fingerprint %s); heard so far: %d", p.Module, p.Version, strings.Join(missing, ", "), entry.Fp, len(have.Artifacts)) + return nil + } return ix.releaseVersion(ctx, p, key, entry, have) } @@ -203,11 +219,17 @@ func (ix *Indexer) releaseVersion(ctx context.Context, p meshbuilds.PackagePubli if err := ix.Versions.Create(ctx, key, data); err != nil && !errors.Is(err, ErrConflict) { return err } + if late { + ix.logf("versions: %s %s is released late: %s is released already, so it is recorded and no version-released is said", p.Module, p.Version, kept[0].Version) + } else if ix.SayVersionReleased == nil { + ix.logf("versions: %s %s is released, and no version-released is said here", p.Module, p.Version) + } if !late && ix.SayVersionReleased != nil { ev := meshcatalog.VersionReleasedEvent{V: int64(keys.Version), Module: v.Module, Version: v.Version, Artifacts: v.Artifacts, Source: v.Source, At: &at} if err := ix.SayVersionReleased(ctx, ev, meshcatalog.EventVersionReleased+"-"+key); err != nil { return fmt.Errorf("version-released of %s %s is not said: %w", p.Module, p.Version, err) } + ix.logf("versions: %s %s is released and version-released is said (%d artifacts, source %d)", p.Module, p.Version, len(v.Artifacts), v.Source) } if err := ix.trimVersions(ctx, p.Module); err != nil { ix.logf("versions: %s's oldest versions are not deleted: %v", p.Module, err) diff --git a/modules/mesh-delivery-indexer/manifest_test.go b/modules/mesh-delivery-indexer/manifest_test.go index fa439b68..367e8d78 100644 --- a/modules/mesh-delivery-indexer/manifest_test.go +++ b/modules/mesh-delivery-indexer/manifest_test.go @@ -419,7 +419,7 @@ func TestEveryGiteaToolTheCodeCallsIsInInvokes(t *testing.T) { if err != nil || len(files) == 0 { t.Fatalf("no program files: %v", err) } - verbs := map[string]string{"VerbTrees": git.VerbTrees, "VerbFile": git.VerbFile, "VerbContains": git.VerbContains, "VerbOpenPulls": git.VerbOpenPulls} + verbs := map[string]string{"VerbTrees": git.VerbTrees, "VerbFile": git.VerbFile, "VerbContains": git.VerbContains, "VerbOpenPulls": git.VerbOpenPulls, "VerbBranch": git.VerbBranch} forge, asked := regexp.MustCompile(`gitea\.gitea_[a-z_]+`), regexp.MustCompile(`git\.Verb[A-Za-z]+`) seen := 0 for _, f := range files { diff --git a/modules/mesh-delivery-indexer/takein/takein.go b/modules/mesh-delivery-indexer/takein/takein.go index 7b559d64..66923591 100644 --- a/modules/mesh-delivery-indexer/takein/takein.go +++ b/modules/mesh-delivery-indexer/takein/takein.go @@ -151,9 +151,11 @@ type TakeIn struct { // Branch, Source and Entries are what a take-in took in (design 47 G §476, §493, §648): the watched branch, the source // revision it makes of that branch, and one entry per module it wrote. Every taken event of one take-in carries the same; // a taken event that ends a wait without a take-in (a group's end, a drop) carries none and starts no pipeline. - Branch string `json:"branch,omitempty"` - Source int64 `json:"source,omitempty"` - Entries []meshcatalog.TakeInEntry `json:"entries,omitempty"` + Branch string `json:"branch,omitempty"` + Source int64 `json:"source,omitempty"` + // Revision is the catalog graph revision of the branch the take-in made (A-448): the pipelines of its entries start at it. + Revision int64 `json:"revision,omitempty"` + Entries []meshcatalog.TakeInEntry `json:"entries,omitempty"` } func (t TakeIn) check() error { diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main.go index 6780b8ec..7177fb93 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main.go @@ -107,34 +107,6 @@ func HealthTool(pipelines, consumers pipeline.Kept, now func() time.Time) stdio. Run: func(map[string]any) (any, error) { return pipeline.Health(pipelines, consumers, now()), nil }} } -// WaitsTool is the runner's tool runner_waits: the pipelines held for its new version, with the fingerprint each awaits and since -// when (design 47 G §276, §539, A-195). -func WaitsTool(r pipeline.Reads) stdio.Tool { - return stdio.Tool{Name: Prefix + "_waits", - Description: "The pipelines the pipeline runner holds until its new version runs healthy: each with its pipeline, the " + - "fingerprint of the runner it awaits and since when.", - Input: map[string]any{"type": "object", "properties": map[string]any{}}, - Run: func(map[string]any) (any, error) { return r.Waits() }} -} - -// ReleaseTool is the runner's tool runner_release: it starts the pipelines held for the runner's new version with the running -// runner, through the seat's verb release, which the process that holds the pipelines answers and records in the hand-act log -// first (design 47 G §276, A-206). -func ReleaseTool(ask func(key string, body any) (json.RawMessage, error)) stdio.Tool { - return stdio.Tool{Name: Prefix + "_release", - Description: "Start now, with the running pipeline runner, the pipelines it holds until its new version runs healthy " + - "(runner_waits lists them), each wait ending released. Written in the hand-act log (mesh-hand-acts).", - Input: map[string]any{"type": "object", "required": []string{"why"}, "properties": map[string]any{ - "why": map[string]any{"type": "string", "description": "why, in plain words"}}}, - Run: func(args map[string]any) (any, error) { - in, err := as[seat.ReleaseInput](args) - if err != nil { - return nil, err - } - return ask("seat:"+seat.Seat+"."+seat.VerbRelease, in) - }} -} - // StoresFill is each of the runner's stores' fill through the bundle's calls (design 47 G §366, §623, A-214): the states // pipelines and kept by `mesh/state.info`, step-outputs by the object store's fill and step-log by the log's; the runner's // process writes nothing for it. A store whose fill cannot be read is an error naming it. @@ -177,7 +149,6 @@ func main() { func(n string) (*stdio.LogInfo, error) { return stdio.Log(n).Info() }, time.Now) r := pipeline.Reads{Pipelines: kept{stdio.State(seat.StatePipelines)}, Kept: kept{stdio.State(seat.StateKept)}, Fill: fill} tools := append(Tools(r), FirstViewTools(os.Getenv(stdio.ServedAs), stdio.State(views.StatusState), meshhandactsclient.Recorder{Ask: stdio.Ask}, time.Now)...) - tools = append(tools, WaitsTool(r), ReleaseTool(stdio.Ask)) tools = append(tools, UnloggedTools(stdio.State(seat.StatePipelines), stdio.Log(seat.StateStepLog), meshhandactsclient.Recorder{Ask: stdio.Ask}, func(f string, a ...any) { fmt.Fprintf(os.Stderr, "[mesh-delivery-pipeline-tools] "+f+"\n", a...) })...) tools = append(tools, HealthTool(r.Pipelines, kept{stdio.State(pipeline.StateConsumers)}, time.Now)) diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main_test.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main_test.go index 1e4e074c..a70454ad 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main_test.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main_test.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" - "fmt" "git.novox.be/novox/mesh-sdk/go/buscalls" "strings" "testing" @@ -34,21 +33,11 @@ func TestTools(t *testing.T) { } // RN25 (§468, §76; A-164): the health check is the bundle's runner_health. names = append(names, HealthTool(none{}, none{}, nil).Name) - // A-206: the tool runner_release asks the seat's verb release with its why. - var asked string - rel := ReleaseTool(func(key string, body any) (json.RawMessage, error) { - asked = key + fmt.Sprintf(" %+v", body) - return json.RawMessage(`{"released":1}`), nil - }) - if _, err := rel.Run(map[string]any{"why": "w"}); err != nil || asked != "seat:mesh-pipeline-runner.release {Why:w}" { - t.Errorf("runner_release asked %q, %v", asked, err) - } - names = append(names, rel.Name) // §606, §549: the unlogged entries are listed and appended by hand. for _, tl := range UnloggedTools(stdio.State("pipelines"), stdio.Log("step-log"), nil, nil) { names = append(names, tl.Name) } - want := "mesh-pipeline-runner.show mesh-pipeline-runner.list mesh-pipeline-runner.stands mesh-pipeline-runner.why-carried mesh-pipeline-runner.kept runner_first_views runner_first_view_again runner_health runner_release runner_unlogged runner_unlogged_append" + want := "mesh-pipeline-runner.show mesh-pipeline-runner.list mesh-pipeline-runner.stands mesh-pipeline-runner.why-carried mesh-pipeline-runner.kept runner_first_views runner_first_view_again runner_health runner_unlogged runner_unlogged_append" if got := strings.Join(names, " "); got != want { t.Errorf("tools %q, want %q", got, want) } diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/buildends.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/buildends.go deleted file mode 100644 index fbb5149c..00000000 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/buildends.go +++ /dev/null @@ -1,44 +0,0 @@ -package main - -import ( - "context" - - "github.com/nats-io/nats.go/jetstream" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" - "git.novox.be/novox/mesh-sdk/go/catalogue" - "git.novox.be/novox/mesh-sdk/go/process" - - "mesh-delivery-pipeline/internal/pipeline" -) - -// hearBuildEnds hears the builder's stream of build ends, kept last per subject and read whole at the start, then followed -// (design 47 G A-181, §556): when the build of the runner's new version ended is the time the wait's bound counts from, and -// each end heard for a runner held pipelines await starts their clock (§266, A-206). A stream it cannot hear is said, and the -// bound of such a wait is not armed until the runner starts again. -func hearBuildEnds(ctx context.Context, cred process.Account, js jetstream.JetStream, ends *pipeline.BuildEnds, st *pipeline.Starter, store pipeline.Updater, - logf func(string, ...any)) { - stream := catalogue.StreamBusName(builds.BuildsStream) - cc, err := cred.HearStream(ctx, js, stream, func(m jetstream.Msg) { - defer m.Ack() - md, err := m.Metadata() - if err != nil { - logf("%s has no time the stream stamped: %v", m.Subject(), err) - return - } - module, fp, ok := ends.Heard(m.Data(), md.Timestamp) - if !ok { - return - } - if n, err := st.Clocked(store, module, fp); err != nil { - logf("the clock of the %d pipelines held for %s: %v", n, fp, err) - } else if n > 0 { - logf("the build of %s ended: the bound of the %d pipelines held for it counts from it", fp, n) - } - }, logf) - if err != nil { - logf("the stream %s is not heard, so no wait for the runner's new version has its bound armed until the runner starts again: %v", stream, err) - return - } - go func() { <-ctx.Done(); cc.Stop() }() -} diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/buildends_integration_test.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/buildends_integration_test.go deleted file mode 100644 index cb17252d..00000000 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/buildends_integration_test.go +++ /dev/null @@ -1,76 +0,0 @@ -//go:build integration - -package main - -import ( - "context" - "encoding/json" - "testing" - "time" - - "github.com/nats-io/nats.go" - "github.com/nats-io/nats.go/jetstream" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" - "git.novox.be/novox/mesh-sdk/go/catalogue" - "git.novox.be/novox/mesh-sdk/go/process" - "git.novox.be/novox/mesh-sdk/go/testbus" - - "mesh-delivery-pipeline/internal/pipeline" -) - -// The runner hears the builder's stream of build ends, kept last per subject, read whole at its start: the end of its new version's -// build, published before it started, starts the clock of the pipelines held for it, counted from the time the stream stamped the end -// (design 47 G A-181, §266, A-206). -func TestTheRunnerHearsTheBuildEndOfItsNewVersionAtItsStart(t *testing.T) { - nc, err := nats.Connect(testbus.URL(t)) - if err != nil { - t.Fatal(err) - } - defer nc.Close() - js, err := jetstream.New(nc) - if err != nil { - t.Fatal(err) - } - ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) - defer cancel() - stream, subject := catalogue.StreamBusName(builds.BuildsStream), process.ModuleStreamSubject(builds.BuilderModule, builds.BuildEndedEvent+".>") - if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: stream, Subjects: []string{subject}, MaxMsgsPerSubject: 1}); err != nil { - t.Fatal(err) - } - published := time.Now().UTC() - if _, err := js.Publish(ctx, process.ModuleStreamSubject(builds.BuilderModule, builds.BuildEndedEventName("mesh-delivery-pipeline", "src2:new")), - []byte(`{"module":"mesh-delivery-pipeline","fingerprint":"src2:new","outcome":"done"}`)); err != nil { - t.Fatal(err) - } - cred := process.Account{Node: "n1", Module: "mesh-delivery-pipeline"} - durable := cred.SeatEventConsumerConfig([]string{subject}, true) - durable.DeliverPolicy = jetstream.DeliverNewPolicy - if _, err := js.CreateOrUpdateConsumer(ctx, stream, durable); err != nil { - t.Fatal(err) - } - kv, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: "pipelines", History: 1}) - if err != nil { - t.Fatal(err) - } - store := pipelineStore{ctx: ctx, kv: kv} - held, _ := json.Marshal(seat.Pipeline{Pipeline: "main.4.app", Branch: "main", Module: "app", Outcome: seat.PipelineOutcomeRunning, - Held: &seat.Held{Since: published, Fingerprint: "src2:new"}}) - if _, err := kv.Create(ctx, "main.4.app", held); err != nil { - t.Fatal(err) - } - ends := &pipeline.BuildEnds{} - armed := make(chan time.Time, 1) - st := &pipeline.Starter{Self: "mesh-delivery-pipeline", Ends: ends.At, Say: func(string, any) error { return nil }, - Hold: func(fp string, from time.Time) error { armed <- from; return nil }} - hearBuildEnds(ctx, cred, js, ends, st, store, t.Logf) - select { - case from := <-armed: - if from.Before(published.Add(-time.Minute)) || from.After(time.Now().Add(time.Second)) { - t.Errorf("the bound counts from %s, not from the end published at %s", from, published) - } - case <-ctx.Done(): - t.Fatal("the end of the new runner's build was not heard at the start") - } -} diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/findingwriter.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/findingwriter.go index adce7906..ca5860a3 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/findingwriter.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/findingwriter.go @@ -2,9 +2,6 @@ package main import ( "context" - "fmt" - "slices" - "time" "github.com/nats-io/nats.go" "github.com/nats-io/nats.go/jetstream" @@ -12,34 +9,11 @@ import ( condseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" "git.novox.be/novox/mesh-sdk/go/process" "git.novox.be/novox/mesh-sdk/go/views" - - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" ) // findingsWriter is the runner's finding writer as the mesh-sdk makes it. type findingsWriter = views.HeldWriter[condseat.Finding, condseat.FindingCleared, condseat.FindingsStated, condseat.FindingsAskedEvent] -// KindPipelineWaits is the finding of pipelines held for the runner's new version that the wait's bound started with the running -// runner (design 47 G §266, A-206). -const KindPipelineWaits = "pipeline-waits" - -// awaitedSaid opens the evidence entry of a pipeline-waits finding that names the awaited runner fingerprint, `awaited ` -// (A-276): the runner clears a finding by that entry alone, never by its summary. -const awaitedSaid = "awaited " - -// lateFinding is the finding pipeline-waits of one pipeline the bound's expiry started: scope module, id its key -// `..`, naming the fingerprint of the new runner it waited for and since when, the fingerprint also in one -// evidence entry `awaited ` (A-276). -func lateFinding(p seat.Pipeline, held seat.Held, runner, node string, at time.Time) condseat.Finding { - return condseat.Finding{Scope: views.FindingScope, ID: p.Pipeline, Kind: KindPipelineWaits, Severity: condseat.FindingSeverityWarning, - Evidence: []condseat.Evidence{{At: at, Said: awaitedSaid + held.Fingerprint}}, - Headline: "the new pipeline runner did not run healthy in time", - Summary: fmt.Sprintf("the pipeline %s was held since %s for the runner at %s to run healthy; the bound passed and the running runner runs it", - p.Pipeline, held.Since.UTC().Format(time.RFC3339), held.Fingerprint), - Source: "bound of the wait for the new runner", Observer: runner, At: at, - Subject: condseat.Subject{Scope: views.FindingScope, ID: p.Module, Machine: node}} -} - // findingWriter is the runner's mesh-sdk held finding writer (design 47 G §461, §689, A-29): the runner raises its findings // as they happen (a failed head, §33), so the writer holds what it has written and its statement says exactly that, with the // reader's open findings. The writer @@ -58,33 +32,3 @@ func findingWriter(ctx context.Context, cred process.Account, conn *nats.Conn, j } return w, nil } - -// heldFindings is what clearAwaited needs of the runner's held finding writer: what it holds and a clear. -type heldFindings interface { - Held() []condseat.Finding - Clear(ctx context.Context, scope, id, kind, why string) error -} - -// clearAwaited clears exactly the pipeline-waits findings whose evidence names fp awaited (A-218, A-276): the node-engine seat's -// running says the runner at fp runs healthy. The writer holds what its state findings hold from its start, so a finding raised -// before a restart is cleared too. It says how many it cleared, and the first clear that failed. -func clearAwaited(ctx context.Context, w heldFindings, fp string) (int, error) { - if w == nil || fp == "" { - return 0, nil - } - n := 0 - var first error - for _, f := range w.Held() { - if f.Kind != KindPipelineWaits || !slices.ContainsFunc(f.Evidence, func(e condseat.Evidence) bool { return e.Said == awaitedSaid+fp }) { - continue - } - if err := w.Clear(ctx, f.Scope, f.ID, f.Kind, "the runner at "+fp+" runs healthy"); err != nil { - if first == nil { - first = err - } - continue - } - n++ - } - return n, first -} diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/findingwriter_integration_test.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/findingwriter_integration_test.go deleted file mode 100644 index d4936c40..00000000 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/findingwriter_integration_test.go +++ /dev/null @@ -1,110 +0,0 @@ -//go:build integration - -package main - -import ( - "context" - "encoding/json" - "testing" - "time" - - "github.com/nats-io/nats.go" - "github.com/nats-io/nats.go/jetstream" - - "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" - "git.novox.be/novox/mesh-sdk/go/process" - "git.novox.be/novox/mesh-sdk/go/testbus" - - "mesh-delivery-pipeline/internal/pipeline" -) - -// Design 47 G A-218, A-276: a pipeline-waits finding raised before the runner restarted is held again by the new process's writer, -// seeded from the state findings, and is cleared when the node-engine seat's running says the awaited runner fingerprint healthy; -// the finding awaiting another fingerprint stands. -func TestAPipelineWaitsFindingIsClearedAfterARestartWhenItsAwaitedRunnerRunsHealthy(t *testing.T) { - url := testbus.URL(t) - nc, err := nats.Connect(url) - if err != nil { - t.Fatal(err) - } - defer nc.Close() - js, err := jetstream.New(nc) - if err != nil { - t.Fatal(err) - } - ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) - defer cancel() - const module = "mesh-delivery-pipeline" - states := map[string]jetstream.KeyValue{} - for _, state := range []string{"findings", "pipelines", "bounds"} { - kv, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: module + "_" + state, History: 1}) - if err != nil { - t.Fatal(err) - } - states[state] = kv - } - // Where the writer says its findings, as the bus keeps the module's events. - if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: "EVENTS", Subjects: []string{"mesh.>"}}); err != nil { - t.Fatal(err) - } - cred := process.Account{URL: url, Node: "n1", Module: module, User: "runner", Password: "x"} - conn, err := process.Connect(cred) - if err != nil { - t.Fatal(err) - } - defer conn.Close() - since := time.Now().UTC().Add(-time.Hour) - before, err := findingWriter(ctx, cred, nc, js, conn.State("findings"), t.Logf) - if err != nil { - t.Fatal(err) - } - for _, p := range []struct{ key, module, fp string }{{"main.4.app", "app", "src2:new"}, {"main.5.web", "web", "src2:newer"}} { - if err := before.Write(ctx, lateFinding(seat.Pipeline{Pipeline: p.key, Module: p.module, Branch: "main"}, - seat.Held{Since: since, Fingerprint: p.fp}, module, "n1", since.Add(30*time.Minute))); err != nil { - t.Fatal(err) - } - } - before.Close() - keys := func() map[string]bool { - out := map[string]bool{} - ks, err := states["findings"].Keys(ctx) - if err != nil && err != jetstream.ErrNoKeysFound { - t.Fatal(err) - } - for _, k := range ks { - out[k] = true - } - return out - } - app, web := "module.main.4.app.pipeline-waits", "module.main.5.web.pipeline-waits" - if k := keys(); !k[app] || !k[web] { - t.Fatalf("the state findings holds %v before the restart, want %s and %s", k, app, web) - } - - // The restart: a new process's writer holds what its state findings hold. - after, err := findingWriter(ctx, cred, nc, js, conn.State("findings"), t.Logf) - if err != nil { - t.Fatal(err) - } - defer after.Close() - if len(after.Held()) != 2 { - t.Fatalf("the writer after the restart holds %+v, want both findings", after.Held()) - } - hub := &oneHub{} - starter := &pipeline.Starter{Logf: t.Logf} - if err := hearRunning(ctx, hub, module, starter, pipelineStore{ctx: ctx, kv: states["pipelines"]}, states["bounds"], after, - func(string) (pipeline.Half, bool) { return pipeline.Half{}, false }, t.Logf); err != nil { - t.Fatal(err) - } - healthy := true - raw, _ := json.Marshal(nodeengine.Running{V: 1, Node: "n1", Module: module, Fingerprint: "src2:new", Healthy: &healthy, At: time.Now().UTC()}) - var acks []string - hub.handle(dataMsg{data: raw, acks: &acks}) - if k := keys(); k[app] || !k[web] { - t.Errorf("after the runner at src2:new runs healthy the state findings holds %v: want %s cleared and %s standing", k, app, web) - } - if held := after.Held(); len(held) != 1 || held[0].ID != "main.5.web" { - t.Errorf("the writer holds %+v, want only the finding awaiting src2:newer", held) - } -} diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/findingwriter_test.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/findingwriter_test.go deleted file mode 100644 index b6ec439b..00000000 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/findingwriter_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package main - -import ( - "context" - "slices" - "strings" - "testing" - "time" - - condseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" - "git.novox.be/novox/mesh-sdk/go/views" - - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" -) - -// The bound's expiry's finding is pipeline-waits, scope module, id the pipeline's key, naming the awaited fingerprint and since -// when (design 47 G §266, A-206); it passes the writer's own check of a finding. -func TestLateFindingIsPipelineWaitsOfTheModuleScope(t *testing.T) { - since := time.Date(2026, 11, 11, 12, 0, 0, 0, time.UTC) - f := lateFinding(seat.Pipeline{Pipeline: "main.4.app", Module: "app", Branch: "main"}, seat.Held{Since: since, Fingerprint: "src2:new"}, - "mesh-delivery-pipeline", "n1", since.Add(30*time.Minute)) - if f.Kind != "pipeline-waits" || f.Scope != views.FindingScope || f.ID != "main.4.app" || f.Severity != condseat.FindingSeverityWarning { - t.Errorf("finding %+v", f) - } - if !strings.Contains(f.Summary, "src2:new") || !strings.Contains(f.Summary, "2026-11-11T12:00:00Z") { - t.Errorf("summary %q", f.Summary) - } - if err := views.CheckFinding(f); err != nil { - t.Error(err) - } - // A-276: the awaited fingerprint is in one evidence entry, `awaited `. - if len(f.Evidence) != 1 || f.Evidence[0].Said != "awaited src2:new" { - t.Errorf("evidence %+v, want one entry `awaited src2:new`", f.Evidence) - } - // A-218, A-276: a healthy running of the runner at a fingerprint clears exactly the pipeline-waits findings whose evidence - // names it awaited: not one awaiting another, not another kind naming it, never by the summary. - other := lateFinding(seat.Pipeline{Pipeline: "main.5.web", Module: "web"}, seat.Held{Since: since, Fingerprint: "src2:newer"}, "r", "n1", since) - other.Summary = f.Summary // a summary naming src2:new is never read - kind := f - kind.Kind, kind.ID = "step-failed", "main.4.app.build" - held := &memFindings{held: []condseat.Finding{f, other, kind}} - if n, err := clearAwaited(context.Background(), held, "src2:new"); err != nil || n != 1 || !slices.Equal(held.cleared, []string{"module.main.4.app.pipeline-waits"}) { - t.Errorf("cleared %d (%v): %v, want the one pipeline-waits awaiting src2:new", n, err, held.cleared) - } -} - -// memFindings is a held finding writer's Held and Clear. -type memFindings struct { - held []condseat.Finding - cleared []string -} - -func (m *memFindings) Held() []condseat.Finding { return m.held } -func (m *memFindings) Clear(_ context.Context, scope, id, kind, _ string) error { - m.cleared = append(m.cleared, scope+"."+id+"."+kind) - return nil -} diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go index 9f442ba7..ef8ad6cf 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go @@ -95,12 +95,17 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro // A branch's view holding its first half asks again the steps placed in its running pipelines that were never asked // (§88); the starter is made after the views, so it is reached through a pointer set once it is. var resumer atomic.Pointer[func(string)] + var advancer atomic.Pointer[func(string)] var placer atomic.Pointer[func(catalog.CatalogRevisionEvent) error] var registrar atomic.Pointer[func(catalog.Registration)] rv, err := startViews(ctx, js, conn, cred, hub, calls.State("findings"), calls.Call, func(branch string) { if f := resumer.Load(); f != nil { (*f)(branch) } + }, func(branch string) { + if f := advancer.Load(); f != nil { + (*f)(branch) + } }, func(_ context.Context, ev catalog.CatalogRevisionEvent) error { if f := placer.Load(); f != nil { return (*f)(ev) @@ -125,6 +130,13 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro } hearer := newHearer(ctx, js, cred, pipelines, kept, say, logger.Printf) hearer.Asker = busAsker{conn: conn, cred: cred} + // A running pipeline keeps the catalog graph revision it runs on (A-449): said again at each start, as the gate states its + // pins, for pins said before the indexer's consumer existed. + if n, err := hearer.PinRunning(); err != nil { + logger.Printf("the running pipelines' pins are not said: %v", err) + } else { + logger.Printf("pinned the catalog graph revision of %d running pipelines", n) + } hearer.Ager = newAger(ctx, js, cred, pipelines, kept, aged, logger.Printf) // The stores' fill is said before a store is full, and a full one refuses a start (§366). fills := &pipeline.Fills{Read: storeFills(ctx, js, cred, time.Now), Logf: logger.Printf, @@ -137,20 +149,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro hearer.Failures = &pipeline.Failures{Findings: rv.Findings, Observer: cred.Module, Author: commitAuthor(calls.Call), Logf: logger.Printf} // Its asking half (§22, §24): a pipeline's steps are placed from the module's registration and each build seat is asked // for its step. - ends := &pipeline.BuildEnds{} starter := &pipeline.Starter{Pipelines: createdKV{ctx: ctx, kv: pipelines}, Logf: logger.Printf, Say: say, Registration: rv.Registrations.Registration, Steps: busStepAsker{ctx: ctx, js: js, cred: cred}, Name: cred.Module, Arm: armBound(ctx, bounds), Kept: keptReader(ctx, kept), Toolchain: toolchainReader(ctx, toolchains), - // The runner's own module and fingerprint (A-149): a take-in giving it another holds the pipelines it starts (§65, A-195). - Self: cred.Module, SelfFp: getenv("MESH_FINGERPRINT"), Awaiting: pipeline.Awaiting(pipelineStore{ctx: ctx, kv: pipelines}), - Ends: ends.At, Hold: armHeld(ctx, bounds), - // The bound's expiry writes the finding pipeline-waits for each pipeline it started (§266, A-206). - Late: func(p seat.Pipeline, held seat.Held) { - module, node := rv.Findings.ModuleNode() - if err := rv.Findings.Write(ctx, lateFinding(p, held, module, node, time.Now().UTC())); err != nil { - logger.Printf("the finding pipeline-waits of %s is not written: %v", p.Pipeline, err) - } - }, Fills: fills, Recovered: kvRecoveries{ctx, recovered}.Has} placeHalf := func(ev catalog.CatalogRevisionEvent, half pipeline.Half) error { n, err := starter.PlaceRun(ev, half, rv.Catalog.View) @@ -162,10 +163,6 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro if !ok { return } - // Pipelines held for the fingerprint this runner runs are started now: it is the new runner (§19, A-195). - if n, err := starter.Release(pipelineStore{ctx: ctx, kv: pipelines}, starter.SelfFp, "ran", rv.Catalog.View); err != nil { - logger.Printf("the pipelines held for the runner at %s: %d released, then %v", starter.SelfFp, n, err) - } // A pipeline of the branch whose registration was heard before this half was held gets its steps now (A-327). if n, err := starter.Waiting(pipelineStore{ctx: ctx, kv: pipelines}, branch, rv.Catalog.View); err != nil || n > 0 { logger.Printf("the pipelines of %s that waited on its half for their steps: %d placed (%v)", branch, n, err) @@ -178,6 +175,13 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro logger.Printf("the steps placed on %s and not yet asked: %d asked again", branch, n) } resumer.Store(&resume) + // The view reaching a newer revision places the steps of the pipelines that waited for it, and asks nothing again (A-448, §200). + advance := func(branch string) { + if n, err := starter.Waiting(pipelineStore{ctx: ctx, kv: pipelines}, branch, rv.Catalog.View); err != nil || n > 0 { + logger.Printf("the pipelines of %s that waited for a newer revision of its half: %d placed (%v)", branch, n, err) + } + } + advancer.Store(&advance) // A registration-changed places the steps of its module's pipelines started before it, from it (A-327). register := func(reg catalog.Registration) { if n, err := starter.Registered(pipelineStore{ctx: ctx, kv: pipelines}, reg, rv.Catalog.View); err != nil || n > 0 { @@ -234,23 +238,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro if err := hearAskTaken(ctx, heard, bounds, hearer.Taken, logger.Printf); err != nil { return err } - store := pipelineStore{ctx: ctx, kv: pipelines} expired := boundExpired(hearer, dropUnanswered(ctx, rv.Findings, cred.Module, time.Now), logger.Printf) - if err := watchBounds(ctx, bounds, func(key string) { - if !pipeline.IsHeldKey(key) { - expired(key) - return - } - if n, err := starter.ReleaseExpired(store, key, rv.Catalog.View); err != nil { - logger.Printf("the pipelines held for the runner, whose %s passed: %d released, then %v", key, n, err) - } else { - logger.Printf("the runner's new version did not run healthy within %s: %d held pipelines started with the running runner", pipeline.HeldBound, n) - } - }, logger.Printf); err != nil { - return err - } - hearBuildEnds(ctx, cred, js, ends, starter, store, logger.Printf) - if err := hearRunning(ctx, heard, cred.Module, starter, store, bounds, rv.Findings, rv.Catalog.View, logger.Printf); err != nil { + if err := watchBounds(ctx, bounds, expired, logger.Printf); err != nil { return err } if err := hearDecided(heard, hearer, cred.Module, logger.Printf); err != nil { @@ -275,6 +264,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro if err := hub.StartUntilBound(ctx, js, cred, nil, seats.EventsLive); err != nil { logger.Printf("the consumer %s is not bound yet (%v): bound once the bus makes it", cred.EventConsumerName(), err) } + // The steps' ends are kept seat events, each on its own stream (step-ended of the build seats, mesh-builds and + // mesh-wants), never on EVENTS: bound here, or no step of any pipeline is ever heard ending (G-1 §24). + logger.Printf("the kept seat events heard: %d streams bound", hub.StartKept(ctx, js, cred)) // The seat's write verbs are answered here, by the process that holds the pipelines (A-107). stopVerbs, err := answerVerbs(calls, seats, writeVerbs(ctx, hearer, starter, func(branch string) (pipeline.Half, bool) { return rv.Catalog.View(branch) }, calls, bounds)) if err != nil { diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/steps.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/steps.go index 813e01a5..ee7d7ded 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/steps.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/steps.go @@ -6,11 +6,9 @@ import ( "errors" "fmt" "strings" - "time" "github.com/nats-io/nats.go/jetstream" - "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" nodebuildgo "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo" @@ -178,61 +176,6 @@ func armBound(ctx context.Context, bounds jetstream.KeyValue) pipeline.Arm { } } -// armHeld is the bound of the pipelines held for the runner's new version: a key of the state bounds named for the awaited -// fingerprint, with its own time to live of 30 minutes counted from the end of that runner's build (design 47 G §266, A-195, A-77, -// A-206). -func armHeld(ctx context.Context, bounds jetstream.KeyValue) func(string, time.Time) error { - return func(fp string, from time.Time) error { - _, err := bounds.Create(ctx, pipeline.HeldKey(fp), []byte(`{"fingerprint":"`+fp+`"}`), jetstream.KeyTTL(pipeline.HeldTTL(from, time.Now()))) - if errors.Is(err, jetstream.ErrKeyExists) { - return nil - } - return err - } -} - -// hearRunning releases the pipelines held for the runner's new version when the node-engine seat says the runner's own module -// runs that fingerprint healthy, on any node (§266, §276, A-195); its bound is then deleted, and the pipeline-waits findings -// that await it are cleared (A-218, A-276). A running with no health reads as healthy (§520). Heard again when the release or -// a clear could not be written. -func hearRunning(ctx context.Context, hub handlers, self string, st *pipeline.Starter, store pipeline.Updater, bounds jetstream.KeyValue, - findings heldFindings, view func(string) (pipeline.Half, bool), logf func(string, ...any)) error { - return hub.Handle(nodeengine.SubjectRunningAll, func(m jetstream.Msg) { - var ev nodeengine.Running - if err := json.Unmarshal(m.Data(), &ev); err != nil { - logf("%s is no running: %v", m.Subject(), err) - _ = m.Term() - return - } - if ev.Module != self || ev.Stopped || ev.Fingerprint == "" || (ev.Healthy != nil && !*ev.Healthy) { - _ = m.Ack() - return - } - n, err := st.Release(store, ev.Fingerprint, "ran", view) - if err != nil { - logf("the pipelines held for %s: %d released, then %v; heard again", ev.Fingerprint, n, err) - _ = m.Nak() - return - } - if n > 0 { - logf("the runner runs %s on %s: %d held pipelines released", ev.Fingerprint, ev.Node, n) - if err := bounds.Delete(ctx, pipeline.HeldKey(ev.Fingerprint)); err != nil && !errors.Is(err, jetstream.ErrKeyNotFound) { - logf("the bound of the wait for %s is not deleted: %v", ev.Fingerprint, err) - } - } - cleared, err := clearAwaited(ctx, findings, ev.Fingerprint) - if cleared > 0 { - logf("the runner runs %s on %s: %d pipeline-waits findings cleared", ev.Fingerprint, ev.Node, cleared) - } - if err != nil { - logf("a pipeline-waits finding awaiting %s is not cleared: %v; heard again", ev.Fingerprint, err) - _ = m.Nak() - return - } - _ = m.Ack() - }) -} - // watchBounds hears the end of each ask's bound, the bus's marker of the key's expiry, and ends the step no holder took (§32, // §535, A-77), and says a drop no holder answered unanswered (A-222): no timer in the process. func watchBounds(ctx context.Context, bounds jetstream.KeyValue, expired func(key string), logf func(string, ...any)) error { diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/verbs.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/verbs.go index 4c62a4a7..27105fb6 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/verbs.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/verbs.go @@ -41,8 +41,7 @@ func answerVerbs(conn *process.Conn, seats *seatlist.Part, v pipeline.Verbs) (fu return conn.AnswerSeat(seat.Seat, seatlist.Definition(seats.Reader, seat.Seat), writeHandlers(v)) } -// writeHandlers are the seat's write verbs the process answers: run, review, rerun, accept, cancel, start, ask-again and -// release (§64, §306; RN12, RN14; A-206). +// writeHandlers are the seat's write verbs the process answers: run, review, rerun, accept, cancel, start, and ask-again. func writeHandlers(v pipeline.Verbs) map[string]process.SeatHandler { return map[string]process.SeatHandler{ seat.VerbRun: verbOf(func(c string, in seat.RunInput) (any, error) { return v.Run(c, in) }), @@ -52,7 +51,6 @@ func writeHandlers(v pipeline.Verbs) map[string]process.SeatHandler { seat.VerbCancel: verbOf(func(c string, in seat.CancelInput) (any, error) { return v.Cancel(c, in) }), seat.VerbStart: verbOf(func(c string, in seat.StartInput) (any, error) { return v.Start(c, in) }), seat.VerbAskAgain: verbOf(func(c string, in seat.AskAgainInput) (any, error) { return v.AskAgain(c, in) }), - seat.VerbRelease: verbOf(func(c string, in seat.ReleaseInput) (any, error) { return v.Release(c, in) }), } } diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/verbs_test.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/verbs_test.go index d71a8898..9e2d5d28 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/verbs_test.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/verbs_test.go @@ -23,7 +23,7 @@ func TestEveryWriteVerbIsServed(t *testing.T) { got = append(got, v) } slices.Sort(got) - want := []string{seat.VerbAccept, seat.VerbAskAgain, seat.VerbCancel, seat.VerbRerun, seat.VerbRelease, seat.VerbReview, seat.VerbStart, seat.VerbRun} + want := []string{seat.VerbAccept, seat.VerbAskAgain, seat.VerbCancel, seat.VerbRerun, seat.VerbReview, seat.VerbStart, seat.VerbRun} slices.Sort(want) if !slices.Equal(got, want) { t.Errorf("the process answers %v, want %v", got, want) diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/views.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/views.go index 4a2ed358..dac58bb4 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/views.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/views.go @@ -31,7 +31,7 @@ type runnerViews struct { // startViews wires the runner's views on hub and asks each first view; register every other handler on hub before or // after, then start hub once. func startViews(ctx context.Context, js jetstream.JetStream, conn *nats.Conn, cred process.Account, hub *process.EventHub, findingsState process.State, - call meshcatalogclient.Call, onReady func(branch string), candidate func(ctx context.Context, ev catalog.CatalogRevisionEvent) error, + call meshcatalogclient.Call, onReady, onAdvance func(branch string), candidate func(ctx context.Context, ev catalog.CatalogRevisionEvent) error, registered func(reg catalog.Registration), logf func(string, ...any)) (*runnerViews, error) { findings, err := findingWriter(ctx, cred, conn, js, findingsState, logf) if err != nil { @@ -48,14 +48,22 @@ func startViews(ctx context.Context, js jetstream.JetStream, conn *nats.Conn, cr // A branch whose first view was none yet is ready with no half; the first half held later, from a catalog-revision, // is picked up as readiness is: its pipelines started with no steps are placed then (A-327, A-336). var wired atomic.Pointer[meshcatalogclient.Catalog] - var held atomic.Bool + var ready pipeline.Readiness c, _, err := meshcatalogclient.WireCatalogProcess(reader, call, branch, func(string, json.RawMessage, bool, time.Time) { c := wired.Load() if c == nil || onReady == nil { return } - if _, ok := c.View(); ok && !held.Swap(true) { - go onReady(branch) + // Ready on the first half held (the steps placed are asked again, §88); a newer revision only places the steps of + // the pipelines that waited for it (A-448, §200). + if h, ok := c.View(); ok { + first, advanced := ready.Observe(h.Revision.Revision) + switch { + case first: + go onReady(branch) + case advanced && onAdvance != nil: + go onAdvance(branch) + } } }) if err != nil { diff --git a/modules/mesh-delivery-pipeline/go.mod b/modules/mesh-delivery-pipeline/go.mod index a55bcf38..50349fa3 100644 --- a/modules/mesh-delivery-pipeline/go.mod +++ b/modules/mesh-delivery-pipeline/go.mod @@ -9,13 +9,11 @@ require ( ) require ( - git.novox.be/novox/mesh-contracts/go/seats/nodeengine v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git v0.0.0-00010101000000-000000000000 diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/ends.go b/modules/mesh-delivery-pipeline/internal/pipeline/ends.go deleted file mode 100644 index cb7ae9e1..00000000 --- a/modules/mesh-delivery-pipeline/internal/pipeline/ends.go +++ /dev/null @@ -1,46 +0,0 @@ -package pipeline - -import ( - "encoding/json" - "sync" - "time" -) - -// BuildEnds are the done builds' ends heard from the builder's stream of build ends (event build.ended, kept last per subject -// and read whole at the start, design 47 G A-181): when each build, by module and fingerprint, ended, which is the time a held -// wait's bound counts from (§266, A-206). -type BuildEnds struct { - mu sync.Mutex - at map[string]time.Time -} - -// buildEnd is the part of the body of build.ended the runner reads. -type buildEnd struct { - Module string `json:"module"` - Fingerprint string `json:"fingerprint"` - Outcome string `json:"outcome"` -} - -// Heard keeps the end a message of the stream says, at the time the stream stamped it; a failed end, or a body naming no module -// and fingerprint, is kept for nothing. It says the module and fingerprint it kept. -func (e *BuildEnds) Heard(data []byte, at time.Time) (module, fp string, ok bool) { - var b buildEnd - if err := json.Unmarshal(data, &b); err != nil || b.Module == "" || b.Fingerprint == "" || b.Outcome == "failed" { - return "", "", false - } - e.mu.Lock() - defer e.mu.Unlock() - if e.at == nil { - e.at = map[string]time.Time{} - } - e.at[b.Module+"\x00"+b.Fingerprint] = at.UTC() - return b.Module, b.Fingerprint, true -} - -// At is when the build of the module at the fingerprint ended, false when no end was heard. -func (e *BuildEnds) At(module, fp string) (time.Time, bool) { - e.mu.Lock() - defer e.mu.Unlock() - t, ok := e.at[module+"\x00"+fp] - return t, ok -} diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/hold.go b/modules/mesh-delivery-pipeline/internal/pipeline/hold.go deleted file mode 100644 index 1b01137e..00000000 --- a/modules/mesh-delivery-pipeline/internal/pipeline/hold.go +++ /dev/null @@ -1,269 +0,0 @@ -package pipeline - -import ( - "crypto/sha256" - "encoding/hex" - "errors" - "fmt" - "slices" - "time" - - runnerclient "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient" - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" -) - -// HeldBound is how long the pipelines held for the runner's new version wait for it to run healthy (design 47 G §266: 30 -// minutes for the runner's `pipeline` step, A-195): a key of the state `bounds` with its own time to live, never a timer. -const HeldBound = 30 * time.Minute - -// HeldPrefix starts the key of a held wait's bound. -const HeldPrefix = "held-" - -// HeldKey is the bound's key for the awaited fingerprint: a fingerprint holds characters a key's name does not. -func HeldKey(fp string) string { - sum := sha256.Sum256([]byte(fp)) - return HeldPrefix + hex.EncodeToString(sum[:12]) -} - -// IsHeldKey says whether a key of the state `bounds` is a held wait's bound. -func IsHeldKey(key string) bool { - return len(key) > len(HeldPrefix) && key[:len(HeldPrefix)] == HeldPrefix -} - -// Awaiting is the awaited fingerprint of the pipelines held in store, "" and false when none is held (design 47 G §266, A-195): -// a pipeline started while one is held is held for the same version, so it never runs on the old runner. -func Awaiting(store Updater) func() (string, bool) { - return func() (string, bool) { - pkeys, err := store.Keys("*.*.*") - if err != nil { - return "", false - } - for _, key := range pkeys { - if p, _, err := store.Get(key); err == nil && p.Held != nil && p.Outcome == seat.PipelineOutcomeRunning { - return p.Held.Fingerprint, true - } - } - return "", false - } -} - -// changesSelf says whether a take-in's entry is the runner's own module at a fingerprint other than the one that runs: its -// pipelines are held for the new runner (design 47 G §65, §266, A-195). -func (s *Starter) changesSelf(module, fp string) bool { - return s.Self != "" && module == s.Self && fp != "" && fp != s.SelfFp -} - -// startHeld writes b's pipeline held for the runner's version awaiting, its steps neither placed nor asked, and says -// wait-held with step `pipeline`; pipeline-started is said when it is released (§74, §266). -func (s *Starter) startHeld(b Begin, key string, now time.Time, awaiting string) (bool, error) { - p := newPipeline(b, key, now) - p.Held = &seat.Held{Since: now, Fingerprint: awaiting} - if err := s.create(key, p); errors.Is(err, ErrExists) { - s.logf("%s is started already: this start writes nothing", key) - return false, nil - } else if err != nil { - return false, fmt.Errorf("the pipeline %s is not written: %w", key, err) - } - from := s.clockOf(awaiting) - if from != nil && s.Hold != nil { - if err := s.Hold(awaiting, *from); err != nil { - s.logf("the bound of the wait for the runner at %s is not armed: %v", awaiting, err) - } - } - w := s.waitOf(p, now, "") - w.ClockFrom = from - if err := s.Say(runnerclient.Subject(seat.EventWaitHeld, b.Module, b.Branch, commitOrGroup(p)), w); err != nil { - s.logf("wait-held of %s is not said: %v", key, err) - } - return true, nil -} - -// clockOf is when the build of the runner at fp ended, the time the bound counts from, nil while it has not (§266, A-181, A-206). -func (s *Starter) clockOf(fp string) *time.Time { - if s.Ends == nil { - return nil - } - if at, ok := s.Ends(s.Self, fp); ok { - return &at - } - return nil -} - -// Clocked starts the clock of the pipelines held for the runner at fp, the end of whose build was heard: it arms the bound from that -// end and says wait-held again for each with `clock-from`, so the watchman times it by the bound (§269, A-206). It says how many -// pipelines it said, and nothing when none is held for fp or the end is not known. -func (s *Starter) Clocked(store Updater, module, fp string) (int, error) { - if module != s.Self { - return 0, nil - } - from := s.clockOf(fp) - if from == nil { - return 0, nil - } - pkeys, err := store.Keys("*.*.*") - if err != nil { - return 0, fmt.Errorf("the pipelines are not listed: %w", err) - } - said := 0 - var first error - for _, key := range pkeys { - p, _, err := store.Get(key) - if err != nil || p.Held == nil || p.Outcome != seat.PipelineOutcomeRunning || p.Held.Fingerprint != fp { - continue - } - if said == 0 && s.Hold != nil { - if err := s.Hold(fp, *from); err != nil { - first = fmt.Errorf("the bound of the wait for the runner at %s is not armed: %w", fp, err) - } - } - w := s.waitOf(p, p.Held.Since, "") - w.ClockFrom = from - if err := s.Say(runnerclient.Subject(seat.EventWaitHeld, p.Module, p.Branch, commitOrGroup(p)), w); err != nil && first == nil { - first = fmt.Errorf("wait-held of %s is not said: %w", key, err) - } - said++ - } - return said, first -} - -func commitOrGroup(p seat.Pipeline) string { - if p.Group != "" { - return p.Group - } - return p.Commit -} - -func (s *Starter) waitOf(p seat.Pipeline, since time.Time, how string) seat.Wait { - return seat.Wait{V: 1, Pipeline: p.Pipeline, Branch: p.Branch, Module: p.Module, Commit: p.Commit, Fingerprint: p.Fingerprint, Group: p.Group, - Revision: p.Revision, Source: p.Source, Step: seat.WaitStepPipeline, On: seat.WaitOnRunnerVersion, Since: since, How: how} -} - -// Release starts the pipelines held for fingerprint fp ("" for every held one) as the new runner running healthy lets -// them, or the bound's expiry or a hand release (how: `ran` or `released`; §266, §276): each has its steps placed and asked and -// says wait-ended and pipeline-started. A pipeline whose branch has no view yet stays held, and the first error is returned -// so the event is heard again. It says how many it started. -func (s *Starter) Release(store Updater, fp, how string, view func(branch string) (Half, bool)) (int, error) { - pkeys, err := store.Keys("*.*.*") - if err != nil { - return 0, fmt.Errorf("the pipelines are not listed: %w", err) - } - now := time.Now().UTC() - if s.Now != nil { - now = s.Now().UTC() - } - started := 0 - var first error - note := func(err error) { - if first == nil { - first = err - } - } - for _, key := range pkeys { - p, rev, err := store.Get(key) - if err != nil || p.Held == nil || p.Outcome != seat.PipelineOutcomeRunning || (fp != "" && p.Held.Fingerprint != fp) { - continue - } - half, ok := view(p.Branch) - if !ok { - note(fmt.Errorf("the catalog half of %s is not held yet: %s stays held", p.Branch, key)) - continue - } - held := *p.Held - p.Held = nil - var asks []Asked - if s.Registration != nil { - if reg, ok := s.Registration(p.Module); ok { - p.Steps, asks = Place(p, reg, half.Entries, now, s.Name) - } - } - if _, err := store.Update(key, p, rev); err != nil { - note(fmt.Errorf("the held pipeline %s is not released: %w", key, err)) - continue - } - started++ - if err := s.Say(runnerclient.Subject(seat.EventWaitEnded, p.Module, p.Branch, commitOrGroup(p)), s.waitOf(p, held.Since, how)); err != nil { - s.logf("wait-ended of %s is not said: %v", key, err) - } - ev := seat.PipelineStarted{V: 1, At: &now, Pipeline: key, Branch: p.Branch, Source: p.Source, Module: p.Module, Commit: p.Commit, - Fingerprint: p.Fingerprint, Group: p.Group, Revision: p.Revision} - if err := s.Say(runnerclient.Subject(seat.EventPipelineStarted, p.Module, p.Branch, commitOrGroup(p)), ev); err != nil { - s.logf("pipeline-started of %s is not said: %v", key, err) - } - if s.Steps != nil && len(asks) > 0 { - s.carry(key, asks) - if err := askAll(s.Steps, s.Arm, key, asks, s.recovered(key, p.Commit)); err != nil { - note(err) - } - } - } - return started, first -} - -// ReleaseExpired starts the pipelines held for the fingerprint whose bound key expired (§266, A-195): the 30 minutes passed -// without the new runner running healthy, so the running runner runs them, and each started is said late through Late (A-206). -func (s *Starter) ReleaseExpired(store Updater, key string, view func(branch string) (Half, bool)) (int, error) { - pkeys, err := store.Keys("*.*.*") - if err != nil { - return 0, fmt.Errorf("the pipelines are not listed: %w", err) - } - fp := "" - held := map[string]seat.Held{} - for _, k := range pkeys { - if p, _, err := store.Get(k); err == nil && p.Held != nil && p.Outcome == seat.PipelineOutcomeRunning && HeldKey(p.Held.Fingerprint) == key { - fp, held[k] = p.Held.Fingerprint, *p.Held - } - } - if fp == "" { - return 0, nil - } - n, err := s.Release(store, fp, "released", view) - for k, h := range held { - if p, _, gerr := store.Get(k); gerr == nil && p.Held == nil && s.Late != nil { - s.Late(p, h) - } - } - return n, err -} - -// heldFingerprints are the fingerprints of the runner the held pipelines in store await, each once. -func heldFingerprints(store Updater) []string { - pkeys, err := store.Keys("*.*.*") - if err != nil { - return nil - } - var fps []string - for _, key := range pkeys { - if p, _, err := store.Get(key); err == nil && p.Held != nil && p.Outcome == seat.PipelineOutcomeRunning && !slices.Contains(fps, p.Held.Fingerprint) { - fps = append(fps, p.Held.Fingerprint) - } - } - return fps -} - -// Release starts by hand the pipelines held for the runner's new version with the running runner, recorded in the hand-act -// log first (§276, A-206): each says wait-ended `released` and pipeline-started, and the bound of each wait is dropped. It -// says how many it started. -func (v Verbs) Release(_ string, in seat.ReleaseInput) (seat.ReleaseAnswer, error) { - if v.Starter == nil || v.View == nil { - return seat.ReleaseAnswer{}, errors.New("the runner cannot release a pipeline: it holds no starter or no catalog half") - } - if err := v.record(seat.VerbRelease, "started the pipelines held for the new runner by hand", in.Why); err != nil { - return seat.ReleaseAnswer{}, err - } - fps := heldFingerprints(v.Hearer.Store) - n, err := v.Starter.Release(v.Hearer.Store, "", "released", v.View) - if n > 0 && v.Drop != nil { - for _, fp := range fps { - if derr := v.Drop(HeldKey(fp)); derr != nil && err == nil { - err = fmt.Errorf("the bound of the wait for %s is not dropped: %w", fp, derr) - } - } - } - return seat.ReleaseAnswer{Released: int64(n)}, err -} - -// HeldTTL is how long the bound of a wait that counts from the build end at from still has to run at now: the 30 minutes less what passed since -// the end, at least a second, the least a key's time to live holds (design 47 G §266, A-206). -func HeldTTL(from, now time.Time) time.Duration { - return max(HeldBound-now.Sub(from), time.Second) -} diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/hold_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/hold_test.go deleted file mode 100644 index 39149241..00000000 --- a/modules/mesh-delivery-pipeline/internal/pipeline/hold_test.go +++ /dev/null @@ -1,245 +0,0 @@ -package pipeline - -import ( - "encoding/json" - "strings" - "testing" - "time" - - catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" -) - -// memCreated is memStore with the Create a start writes through. -type memCreated struct{ memStore } - -func (m memCreated) Create(key string, value []byte) error { - if _, ok := m.memStore[key]; ok { - return ErrExists - } - var p seat.Pipeline - if err := json.Unmarshal(value, &p); err != nil { - return err - } - m.memStore[key] = struct { - p seat.Pipeline - rev uint64 - }{p, 1} - return nil -} - -// A take-in giving the runner's own module a new fingerprint holds every pipeline it starts, a later take-in's too while one is -// held, with no step asked; the new runner running healthy releases them, placing and asking their steps (design 47 G §65, §266, -// §276, §534; A-195). -func TestPipelinesAreHeldForTheNewRunnerAndReleasedWhenItRuns(t *testing.T) { - reg, entries := placeFixture() - entries["runner"] = catalog.CatalogEntry{Module: "runner"} - store := memCreated{memStore{}} - asks := &stepAsks{} - var said []string - var bounds []string - s := &Starter{Pipelines: store, Steps: asks, Name: "the-runner", Self: "runner", SelfFp: "src2:old", - Awaiting: Awaiting(store.memStore), Ends: func(string, string) (time.Time, bool) { return time.Unix(9, 0), true }, - Hold: func(fp string, _ time.Time) error { bounds = append(bounds, fp); return nil }, - Registration: func(m string) (catalog.Registration, bool) { return reg, m == "app" }, - Say: func(subject string, _ any) error { - said = append(said, subject[strings.Index(subject, ".event.")+7:]) - return nil - }} - view := func(string) (Half, bool) { return Half{Entries: entries}, true } - n, err := s.TakenIn(catalog.TakeInTaken{Key: "m.1", Branch: "main", Source: 4, Entries: []catalog.TakeInEntry{ - {Module: "app", Commit: "c1", Fingerprint: "src2:aa"}, {Module: "runner", Commit: "c2", Fingerprint: "src2:new"}}}, view) - if err != nil || n != 2 { - t.Fatalf("take-in = %d, %v", n, err) - } - p, _, _ := store.Get("main.4.app") - if p.Held == nil || p.Held.Fingerprint != "src2:new" || len(p.Steps) != 0 || len(asks.asks) != 0 { - t.Fatalf("held = %+v, steps %d, asks %d", p.Held, len(p.Steps), len(asks.asks)) - } - // The runner's own pipeline is never held: it runs on the running runner, so its pass lets the new runner be wanted (A-328). - if p, _, _ := store.Get("main.4.runner"); p.Held != nil || p.Outcome != seat.PipelineOutcomeRunning { - t.Errorf("the runner's own pipeline is held %+v, want it running on the running runner", p.Held) - } - if strings.Join(said, "|") != "wait-held.app.main.c1|pipeline-started.runner.main.c2" || len(bounds) != 1 || bounds[0] != "src2:new" { - t.Errorf("said %v, bounds %v", said, bounds) - } - // A later take-in of the runner's own module while one is held is not held either (A-328). - if n, err := s.TakenIn(catalog.TakeInTaken{Key: "m.3", Branch: "main", Source: 6, Entries: []catalog.TakeInEntry{{Module: "runner", Commit: "c4", Fingerprint: "src2:new"}}}, view); err != nil || n != 1 { - t.Fatalf("a take-in of the runner alone = %d, %v", n, err) - } - if p, _, _ := store.Get("main.6.runner"); p.Held != nil { - t.Errorf("the runner's own later pipeline is held %+v", p.Held) - } - // A later take-in not naming the runner is held for the same version. - if n, err := s.TakenIn(catalog.TakeInTaken{Key: "m.2", Branch: "main", Source: 5, Entries: []catalog.TakeInEntry{{Module: "app", Commit: "c3", Fingerprint: "src2:bb"}}}, view); err != nil || n != 1 { - t.Fatalf("second take-in = %d, %v", n, err) - } - if p, _, _ := store.Get("main.5.app"); p.Held == nil || len(asks.asks) != 0 { - t.Fatalf("the later pipeline is not held: %+v", p.Held) - } - // Another fingerprint's release starts nothing. - if n, err := s.Release(store.memStore, "src2:other", "ran", view); err != nil || n != 0 { - t.Fatalf("release of another version = %d, %v", n, err) - } - said = nil - n, err = s.Release(store.memStore, "src2:new", "ran", view) - if err != nil || n != 2 { - t.Fatalf("release = %d, %v", n, err) - } - p, _, _ = store.Get("main.4.app") - if p.Held != nil || len(p.Steps) == 0 || len(asks.asks) == 0 { - t.Errorf("after the release: held %+v, steps %d, asks %d", p.Held, len(p.Steps), len(asks.asks)) - } - if !strings.Contains(strings.Join(said, "|"), "wait-ended.app.main.c1|pipeline-started.app.main.c1") { - t.Errorf("said %v", said) - } - if _, held := Awaiting(store.memStore)(); held { - t.Error("a pipeline is still held") - } -} - -// The verb release starts the held pipelines by hand, recorded in the hand-act log first, saying why and ending each wait -// `released`, and drops the bound of the wait; a release with no why does nothing (design 47 G §276, A-206). -func TestReleaseVerbStartsTheHeldPipelinesByHand(t *testing.T) { - reg, entries := placeFixture() - entries["runner"] = catalog.CatalogEntry{Module: "runner"} - store := memCreated{memStore{}} - asks := &stepAsks{} - var said []string - s := &Starter{Pipelines: store, Steps: asks, Name: "the-runner", Self: "runner", SelfFp: "src2:old", Awaiting: Awaiting(store.memStore), - Registration: func(m string) (catalog.Registration, bool) { return reg, m == "app" }, - Say: func(subject string, _ any) error { - said = append(said, subject[strings.Index(subject, ".event.")+7:]) - return nil - }} - view := func(string) (Half, bool) { return Half{Entries: entries}, true } - if _, err := s.TakenIn(catalog.TakeInTaken{Key: "m.1", Branch: "main", Source: 4, Entries: []catalog.TakeInEntry{ - {Module: "app", Commit: "c1", Fingerprint: "src2:aa"}, {Module: "runner", Commit: "c2", Fingerprint: "src2:new"}}}, view); err != nil { - t.Fatal(err) - } - acts, dropped := &actLog{}, []string{} - v := Verbs{Hearer: &Hearer{Store: store.memStore}, Starter: s, View: view, Acts: acts, - Drop: func(k string) error { dropped = append(dropped, k); return nil }} - if _, err := v.Release("operator", seat.ReleaseInput{}); err == nil || len(*acts) != 0 { - t.Fatalf("a release saying no why: %v, acts %v", err, *acts) - } - said = nil - a, err := v.Release("operator", seat.ReleaseInput{Why: "the new runner will not come"}) - if err != nil || a.Released != 1 { // the runner's own pipeline was never held (A-328) - t.Fatalf("release = %+v, %v", a, err) - } - if p, _, _ := store.Get("main.4.app"); p.Held != nil || len(p.Steps) == 0 || len(asks.asks) == 0 { - t.Errorf("after the release: held %+v, steps %d", p.Held, len(p.Steps)) - } - if len(*acts) != 1 || !strings.HasPrefix((*acts)[0], "mesh-pipeline-runner.release: ") || len(dropped) != 1 || dropped[0] != HeldKey("src2:new") { - t.Errorf("acts %v, dropped %v", *acts, dropped) - } - if !strings.Contains(strings.Join(said, "|"), "wait-ended.app.main.c1") { - t.Errorf("said %v", said) - } -} - -// The bound's expiry starts the held pipelines and says each as late through the starter's Late, with the awaited fingerprint and -// since when; a pipeline that stays held (no view) is not said (design 47 G §266, A-206). -func TestExpiredBoundSaysEachReleasedPipelineLate(t *testing.T) { - reg, entries := placeFixture() - store := memCreated{memStore{}} - since := time.Date(2026, 11, 11, 12, 0, 0, 0, time.UTC) - for _, k := range []string{"main.4.app", "dev.4.app"} { - store.memStore[k] = struct { - p seat.Pipeline - rev uint64 - }{seat.Pipeline{Pipeline: k, Branch: strings.Split(k, ".")[0], Module: "app", Outcome: seat.PipelineOutcomeRunning, - Held: &seat.Held{Since: since, Fingerprint: "src2:new"}}, 1} - } - var late []string - s := &Starter{Pipelines: store, Steps: &stepAsks{}, Name: "the-runner", Say: func(string, any) error { return nil }, - Registration: func(string) (catalog.Registration, bool) { return reg, true }, - Late: func(p seat.Pipeline, h seat.Held) { - late = append(late, p.Pipeline+"@"+h.Fingerprint+"@"+h.Since.Format(time.RFC3339)) - }} - view := func(b string) (Half, bool) { return Half{Entries: entries}, b == "main" } - if n, err := s.ReleaseExpired(store.memStore, HeldKey("src2:new"), view); err == nil || n != 1 { - t.Fatalf("release = %d, %v (the pipeline of a branch with no view stays held, an error)", n, err) - } - if len(late) != 1 || late[0] != "main.4.app@src2:new@2026-11-11T12:00:00Z" { - t.Errorf("late %v", late) - } -} - -// A wait of the step pipeline waits on the runner version (design 47 G §534, A-206). -func TestHeldWaitIsOnTheRunnerVersion(t *testing.T) { - w := (&Starter{}).waitOf(seat.Pipeline{Pipeline: "main.4.app", Branch: "main", Module: "app"}, time.Unix(1, 0), "") - if w.Step != seat.WaitStepPipeline || w.On != "runner version" { - t.Errorf("wait %+v", w) - } -} - -// The wait of a held pipeline counts from the build end of the awaited runner: wait-held says it as `clock-from` and the bound is -// armed from it; while that build has not ended nothing is armed, and hearing its end arms the bound and says wait-held again -// with `clock-from`; a failed end starts no clock (design 47 G §266, §269, A-181, A-206). -func TestHeldWaitCountsFromTheBuildEndOfTheAwaitedRunner(t *testing.T) { - reg, entries := placeFixture() - store := memCreated{memStore{}} - ends := &BuildEnds{} - var waits []seat.Wait - var armed []string - s := &Starter{Pipelines: store, Steps: &stepAsks{}, Name: "the-runner", Self: "runner", SelfFp: "src2:old", Awaiting: Awaiting(store.memStore), - Ends: ends.At, Hold: func(fp string, from time.Time) error { - armed = append(armed, fp+"@"+from.Format(time.RFC3339)) - return nil - }, - Registration: func(string) (catalog.Registration, bool) { return reg, true }, - Say: func(subject string, body any) error { - if w, ok := body.(seat.Wait); ok && strings.Contains(subject, ".wait-held.") { - waits = append(waits, w) - } - return nil - }} - view := func(string) (Half, bool) { return Half{Entries: entries}, true } - taken := catalog.TakeInTaken{Key: "m.1", Branch: "main", Source: 4, Entries: []catalog.TakeInEntry{ - {Module: "app", Commit: "c1", Fingerprint: "src2:aa"}, {Module: "runner", Commit: "c2", Fingerprint: "src2:new"}}} - end := time.Date(2026, 11, 11, 12, 0, 0, 0, time.UTC) - // The runner's build has not ended: held, no clock, no bound. - if _, err := s.TakenIn(taken, view); err != nil { - t.Fatal(err) - } - if len(waits) != 1 || waits[0].ClockFrom != nil || len(armed) != 0 { // the runner's own pipeline is never held (A-328) - t.Fatalf("waits %+v, armed %v", waits, armed) - } - // A failed end starts no clock; a done end does. - if _, _, ok := ends.Heard([]byte(`{"module":"runner","fingerprint":"src2:new","outcome":"failed"}`), end); ok { - t.Error("a failed end was kept") - } - if m, fp, ok := ends.Heard([]byte(`{"module":"runner","fingerprint":"src2:new","outcome":"done"}`), end); !ok || m != "runner" || fp != "src2:new" { - t.Fatalf("heard %q %q %v", m, fp, ok) - } - waits = nil - if n, err := s.Clocked(store.memStore, "runner", "src2:new"); err != nil || n != 1 { - t.Fatalf("clocked = %d, %v", n, err) - } - if len(waits) != 1 || waits[0].ClockFrom == nil || !waits[0].ClockFrom.Equal(end) || len(armed) != 1 || armed[0] != "src2:new@2026-11-11T12:00:00Z" { - t.Errorf("waits %+v, armed %v", waits, armed) - } - // A pipeline held after the end is known says the clock at once. - waits = nil - taken.Key, taken.Source = "m.2", 5 - if _, err := s.TakenIn(taken, view); err != nil { - t.Fatal(err) - } - if len(waits) == 0 || waits[0].ClockFrom == nil || !waits[0].ClockFrom.Equal(end) { - t.Errorf("waits %+v", waits) - } -} - -// The bound counts from the build end: the 30 minutes less what passed since, never under a second. -func TestHeldTTLCountsFromTheBuildEnd(t *testing.T) { - end := time.Date(2026, 11, 11, 12, 0, 0, 0, time.UTC) - for _, c := range []struct { - after, want time.Duration - }{{0, 30 * time.Minute}, {10 * time.Minute, 20 * time.Minute}, {45 * time.Minute, time.Second}} { - if got := HeldTTL(end, end.Add(c.after)); got != c.want { - t.Errorf("after %s the bound has %s, want %s", c.after, got, c.want) - } - } -} diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/pins.go b/modules/mesh-delivery-pipeline/internal/pipeline/pins.go new file mode 100644 index 00000000..918c4e37 --- /dev/null +++ b/modules/mesh-delivery-pipeline/internal/pipeline/pins.go @@ -0,0 +1,67 @@ +package pipeline + +import ( + "strconv" + + delivery "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" + seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" +) + +// PinRecord is the record id a pipeline pins its catalog graph revision under: `pipeline.` (design 47 G §153, §579, +// A-449), as a delivery record pins its revisions under its own id, so the indexer keeps the revision while any pipeline +// runs on it. +func PinRecord(key string) string { return "pipeline." + key } + +// pinned says whether a pipeline pins a revision: a branch's pipeline that names its catalog graph revision. A run on +// request reads its candidate's revision, which the indexer keeps while the candidate is open, never a branch's. +func pinned(p seat.Pipeline) bool { return p.Run == "" && p.Branch != "" && p.Revision > 0 } + +// sayPin says the seat mesh-delivery's pinned or freed for p's catalog graph revision, in the form the gate says them and +// the indexer applies them (a set of record ids per revision, so a repeat changes nothing). +func sayPin(say func(subject string, body any) error, subject string, p seat.Pipeline) error { + if say == nil || !pinned(p) { + return nil + } + return say(subject, delivery.Pins{Record: PinRecord(p.Pipeline), Milestone: "pipeline " + strconv.FormatInt(p.Source, 10), + Catalog: []delivery.PinsCatalogItem{{Branch: p.Branch, Revision: p.Revision}}}) +} + +// Pin says pinned for the catalog graph revision of a running pipeline (A-449). +func (s *Starter) pin(p seat.Pipeline) { + if err := sayPin(s.Say, delivery.SubjectPinned, p); err != nil { + s.logf("%s does not pin its catalog graph revision %d, so the indexer may remove it: %v", p.Pipeline, p.Revision, err) + } +} + +// pin and free say it for a pipeline the hearer reopens or ends (A-449). +func (h *Hearer) pin(p seat.Pipeline) { + if err := sayPin(h.Say, delivery.SubjectPinned, p); err != nil { + h.logf("%s does not pin its catalog graph revision %d, so the indexer may remove it: %v", p.Pipeline, p.Revision, err) + } +} + +func (h *Hearer) free(p seat.Pipeline) { + if err := sayPin(h.Say, delivery.SubjectFreed, p); err != nil { + h.logf("%s does not free its catalog graph revision %d, which the indexer keeps while it is pinned: %v", p.Pipeline, p.Revision, err) + } +} + +// PinRunning says pinned again for every running pipeline at the runner's start, as the gate states its pins at each +// start: pins said before the indexer's consumer existed, or older than the stream keeps, are heard again, and the set +// form absorbs the repeats. It says how many it said. +func (h *Hearer) PinRunning() (int, error) { + pkeys, err := h.Store.Keys("*.*.*") + if err != nil { + return 0, err + } + n := 0 + for _, key := range pkeys { + p, _, err := h.Store.Get(key) + if err != nil || p.Outcome != seat.PipelineOutcomeRunning || !pinned(p) { + continue + } + h.pin(p) + n++ + } + return n, nil +} diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/pins_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/pins_test.go new file mode 100644 index 00000000..bee58513 --- /dev/null +++ b/modules/mesh-delivery-pipeline/internal/pipeline/pins_test.go @@ -0,0 +1,223 @@ +package pipeline + +import ( + "errors" + "testing" + + catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + delivery "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" + seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" +) + +type saidPin struct { + subject string + pins delivery.Pins +} + +// A-449 (design 47 G §153, §579): a pipeline pins its catalog graph revision as a delivery record does, under the record id +// pipeline., when it starts, again at each start of the runner while it runs, and frees it when it ends, by any +// outcome (superseded included); a run on request, which reads its candidate's revision, pins none. +func TestAPipelinePinsItsCatalogRevisionWhileItRuns(t *testing.T) { + var said []saidPin + say := func(subject string, body any) error { + if p, ok := body.(delivery.Pins); ok { + said = append(said, saidPin{subject, p}) + } + return nil + } + want := func(i int, subject, record string, revision int64) { + t.Helper() + if i >= len(said) { + t.Fatalf("said %d pins, want one more (%s %s %d)", len(said), subject, record, revision) + } + p := said[i] + if p.subject != subject || p.pins.Record != record || len(p.pins.Catalog) != 1 || p.pins.Catalog[0].Branch != "main" || p.pins.Catalog[0].Revision != revision { + t.Errorf("pin %d = %+v, want %s of %s at main %d", i, p, subject, record, revision) + } + } + // At its start. + s := &Starter{Pipelines: created{}, Say: say} + if ok, err := s.Start(Begin{Branch: "main", Source: 7, Module: "a", Commit: "c1", Revision: 12}); !ok || err != nil { + t.Fatalf("start: %v %v", ok, err) + } + want(0, delivery.SubjectPinned, "pipeline.main.7.a", 12) + // A start that names no revision pins nothing; one written already says nothing more. + said = nil + if _, err := s.Start(Begin{Branch: "main", Source: 8, Module: "a", Commit: "c1"}); err != nil || len(said) != 0 { + t.Errorf("a start with no revision said %v (%v)", said, err) + } + if ok, _ := s.Start(Begin{Branch: "main", Source: 7, Module: "a", Commit: "c1", Revision: 12}); ok || len(said) != 0 { + t.Errorf("a start written already said %v", said) + } + // At the runner's start, for the running pipelines alone; a run on request pins none. + h, store, _, _, _, _ := fixture() + h.Say = say + p := store[pkey] + p.p.Revision = 12 + store[pkey] = p + store["main.4.old"] = struct { + p seat.Pipeline + rev uint64 + }{seat.Pipeline{Pipeline: "main.4.old", Branch: "main", Revision: 11, Outcome: seat.PipelineOutcomePassed}, 1} + store["main.r1.app"] = struct { + p seat.Pipeline + rev uint64 + }{seat.Pipeline{Pipeline: "main.r1.app", Branch: "main", Revision: 13, Run: "r1", Outcome: seat.PipelineOutcomeRunning}, 1} + said = nil + if n, err := h.PinRunning(); n != 1 || err != nil { + t.Fatalf("PinRunning said %d (%v), want the running pipeline's alone", n, err) + } + want(0, delivery.SubjectPinned, "pipeline."+pkey, 12) + // Its end frees it, and so does a supersede. + said = nil + if err := h.said(store[pkey].p, false, true); err != nil { + t.Fatal(err) + } + want(0, delivery.SubjectFreed, "pipeline."+pkey, 12) + said = nil + if n, err := h.Supersede(seat.Pipeline{Pipeline: "main.6.app", Branch: "main", Source: 6, Module: "app", Commit: "c2", Fingerprint: "src2:bb", Outcome: seat.PipelineOutcomeRunning}, nil, nil); n != 1 || err != nil { + t.Fatalf("supersede %d (%v)", n, err) + } + want(0, delivery.SubjectFreed, "pipeline."+pkey, 12) + if len(said) != 1 { + t.Errorf("a supersede said %d pins, want the one freed (through its end, once)", len(said)) + } +} + +// A-448 (§200, §476): a pipeline of a take-in starts at the revision the take-in made, never at the one the runner's own view +// holds; while the view holds an older one it starts with no step and places none, and the view reaching the revision places +// them. An event that names no revision starts at the view's, as before. +func TestATakeInStartsItsPipelinesAtItsOwnRevisionAndWaitsForTheView(t *testing.T) { + reg, entries := placeFixture() + store := memCreated{memStore{}} + asks := &stepAsks{} + s := &Starter{Pipelines: store, Steps: asks, Name: "the-runner", Say: func(string, any) error { return nil }, + Registration: func(m string) (catalog.Registration, bool) { return reg, m == "app" }} + viewRevision := int64(356) + view := func(string) (Half, bool) { return Half{Revision: viewRevision, Entries: entries}, true } + taken := catalog.TakeInTaken{Key: "m.1", Branch: "main", Source: 947, Revision: 357, + Entries: []catalog.TakeInEntry{{Module: "app", Commit: "c1", Fingerprint: "src2:aa"}}} + if n, err := s.TakenIn(taken, view); n != 1 || err != nil { + t.Fatalf("the take-in started %d (%v)", n, err) + } + p, _, _ := store.Get("main.947.app") + if p.Revision != 357 || len(p.Steps) != 0 || len(asks.asks) != 0 { + t.Fatalf("a take-in of revision 357 with the view at 356 started %+v with %d asks, want revision 357 and no step", p, len(asks.asks)) + } + if n, err := s.Waiting(store.memStore, "main", view); n != 0 || err != nil || len(asks.asks) != 0 { + t.Errorf("the view at 356 placed %d (%v) of the pipeline waiting for 357", n, err) + } + viewRevision = 357 + n, err := s.Waiting(store.memStore, "main", view) + p, _, _ = store.Get("main.947.app") + if n != 1 || err != nil || len(p.Steps) == 0 || len(asks.asks) == 0 || p.Revision != 357 { + t.Errorf("the view reaching 357 placed %d (%v): %d steps, %d asks at revision %d", n, err, len(p.Steps), len(asks.asks), p.Revision) + } + // An event of before A-448 names no revision: the view's. + taken = catalog.TakeInTaken{Key: "m.2", Branch: "main", Source: 948, Entries: []catalog.TakeInEntry{{Module: "app", Commit: "c2", Fingerprint: "src2:bb"}}} + if n, err := s.TakenIn(taken, view); n != 1 || err != nil { + t.Fatalf("the old take-in started %d (%v)", n, err) + } + if p, _, _ := store.Get("main.948.app"); p.Revision != 357 || len(p.Steps) == 0 { + t.Errorf("a take-in naming no revision started %+v, want the view's revision 357 with its steps", p) + } +} + +// A-448: the view is read before the starts write; a view that reaches the revision meanwhile places the held-back pipelines at +// once, not at an advance that already came. +func TestAViewThatReachesTheRevisionDuringTheStartsPlacesTheHeldBackPipelines(t *testing.T) { + reg, entries := placeFixture() + store := memCreated{memStore{}} + asks := &stepAsks{} + s := &Starter{Pipelines: store, Steps: asks, Name: "the-runner", Say: func(string, any) error { return nil }, + Registration: func(m string) (catalog.Registration, bool) { return reg, m == "app" }} + s.Store = store.memStore + reads := 0 + view := func(string) (Half, bool) { + reads++ + if reads > 1 { // the first read is before the starts wrote; the view reaches 357 after it + return Half{Revision: 357, Entries: entries}, true + } + return Half{Revision: 356, Entries: entries}, true + } + taken := catalog.TakeInTaken{Key: "m.1", Branch: "main", Source: 947, Revision: 357, Entries: []catalog.TakeInEntry{{Module: "app", Commit: "c1", Fingerprint: "src2:aa"}}} + if n, err := s.TakenIn(taken, view); n != 1 || err != nil { + t.Fatalf("started %d (%v)", n, err) + } + if p, _, _ := store.Get("main.947.app"); len(p.Steps) == 0 || len(asks.asks) == 0 { + t.Errorf("the pipeline has %d steps and %d asks after the view reached 357 during the start, want them placed", len(p.Steps), len(asks.asks)) + } +} + +// A-448 (§200): the first half a view holds is Ready, which asks again the steps placed (§88); a newer revision is an advance, +// which only places the steps of pipelines that waited for it and asks nothing again. +func TestReadinessSaysTheFirstHoldAndEachNewerRevisionApart(t *testing.T) { + var r Readiness + for i, c := range []struct { + rev int64 + first, advanced bool + }{{356, true, false}, {356, false, false}, {355, false, false}, {357, false, true}, {357, false, false}, {360, false, true}} { + if first, advanced := r.Observe(c.rev); first != c.first || advanced != c.advanced { + t.Errorf("observation %d of revision %d: first %v advanced %v, want %v %v", i, c.rev, first, advanced, c.first, c.advanced) + } + } +} + +// A-448: placing the steps of a pipeline that waited asks nothing again of the running steps of the others. +func TestPlacingAWaitingPipelineAsksNoRunningStepAgain(t *testing.T) { + reg, entries := placeFixture() + store := memCreated{memStore{}} + asks := &stepAsks{} + s := &Starter{Pipelines: store, Steps: asks, Name: "the-runner", Say: func(string, any) error { return nil }, + Registration: func(m string) (catalog.Registration, bool) { return reg, m == "app" }} + view := func(string) (Half, bool) { return Half{Revision: 357, Entries: entries}, true } + if n, err := s.TakenIn(catalog.TakeInTaken{Key: "m.1", Branch: "main", Source: 1, Revision: 357, Entries: []catalog.TakeInEntry{{Module: "app", Commit: "c1", Fingerprint: "src2:aa"}}}, view); n != 1 || err != nil { + t.Fatalf("started %d (%v)", n, err) + } + before := len(asks.asks) + late := func(string) (Half, bool) { return Half{Revision: 358, Entries: entries}, true } + if n, err := s.Waiting(store.memStore, "main", late); n != 0 || err != nil || len(asks.asks) != before { + t.Errorf("an advance placed %d (%v) and asked %d steps again, want nothing", n, err, len(asks.asks)-before) + } +} + +// A-449: the pipeline-ended's widens read the pipeline's revision while it is still pinned; the pin is freed after the end is +// said, also when saying it fails. +func TestThePinIsFreedAfterTheEndAndItsWidensAreRead(t *testing.T) { + h, store, _, _, _, _ := fixture() + p := store[pkey] + p.p.Revision = 12 + store[pkey] = p + freed, readWhileFreed, bodies := false, false, 0 + h.Say = func(subject string, body any) error { + switch body.(type) { + case delivery.Pins: + freed = freed || subject == delivery.SubjectFreed + default: + bodies++ + } + return nil + } + h.Widens = func(seat.Pipeline) []seat.Widening { + readWhileFreed = freed // the revision is gone once the freed is said + return nil + } + if err := h.said(store[pkey].p, false, true); err != nil { + t.Fatal(err) + } + if readWhileFreed || !freed || bodies == 0 { + t.Errorf("widens read after the freed %v, freed %v, %d other events: want the widens read first and the pin freed after the end", readWhileFreed, freed, bodies) + } + // An end that cannot be said still frees the pin. + freed = false + h.Say = func(subject string, body any) error { + if _, ok := body.(delivery.Pins); ok { + freed = freed || subject == delivery.SubjectFreed + return nil + } + return errors.New("bus away") + } + if err := h.said(store[pkey].p, false, true); err == nil || !freed { + t.Errorf("an end not said: err %v, freed %v, want the error and the pin freed", err, freed) + } +} diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/place.go b/modules/mesh-delivery-pipeline/internal/pipeline/place.go index b4037762..653ca3a3 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/place.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/place.go @@ -159,7 +159,12 @@ type Asked struct { } func stepAsk(p seat.Pipeline, e catalog.CatalogEntry, a catalog.Artifact, step, id, asker string, now time.Time) nodebuildgo.StepAsk { + // A step is for its module alone (principle 10, A-447): the fetch always names the module's directory, and the + // artifact's named paths in it when the entry has them. fetch := nodebuildgo.Fetch{Repository: p.Repository, Commit: p.Commit, Dir: e.Path} + if paths := artifactPaths(e, a.Ref); len(paths) > 0 { + fetch.Paths = paths + } return nodebuildgo.StepAsk{V: 1, ID: id, Asker: asker, Kind: "step", Language: a.Language, At: &now, Step: &nodebuildgo.StepRun{Artifact: a.Ref, Branch: p.Branch, Commit: p.Commit, Fetch: fetch, Fingerprint: p.Fingerprint, Module: p.Module, Pipeline: p.Pipeline, Revision: p.Source, Step: step}} @@ -192,3 +197,15 @@ func askAll(asker StepAsker, arm Arm, key string, asks []Asked, recovery bool) e } return first } + +// artifactPaths are the named paths the entry keeps for the artifact, by its reference or its name. +func artifactPaths(e catalog.CatalogEntry, ref string) []string { + if e.Inputs == nil { + return nil + } + if p, ok := e.Inputs.Paths[ref]; ok { + return p + } + _, name, _ := strings.Cut(ref, ":") + return e.Inputs.Paths[name] +} diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go index 8f3d93eb..5336fef0 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go @@ -45,7 +45,7 @@ func placeFixture() (catalog.Registration, map[string]catalog.CatalogEntry) { }} return reg, map[string]catalog.CatalogEntry{ "app": {Module: "app", Path: "modules/app", Artifacts: []catalog.Artifact{{Ref: "app:program", Language: "go"}, {Ref: "app:tools", Language: "go"}, - {Ref: "app:web", Language: "rust"}}}, + {Ref: "app:web", Language: "rust"}}, Inputs: &catalog.EntryInputs{Paths: map[string][]string{"app:program": {"cmd/app"}}}}, "mesh-build-go": {Module: "mesh-build-go", Acts: []catalog.ActingRule{{Seat: "node-build-go", Step: "build", On: "go"}}}, } } @@ -100,9 +100,16 @@ func TestStartPlacesTheStepsThePolicyNamesAndAsksEachBuildSeat(t *testing.T) { a := asks.asks[1].(nodebuildgo.StepAsk) if asks.at[1] != "mesh.seat.node-build-go.accept.check.mesh-pipeline-runner" || a.Kind != "step" || a.Asker != "the-runner" || a.ID != p.Steps[1].Ask || asks.ids[1] != a.ID || a.Step.Commit != "c1" || a.Step.Fingerprint != "src2:aa" || a.Step.Pipeline != "main.4.app" || a.Step.Artifact != "app:program" || - a.Step.Step != "lint" || a.Step.Fetch.Repository != "o/app" || a.Step.Fetch.Dir != "modules/app" || a.Step.Revision != 4 { + a.Step.Step != "lint" || a.Step.Fetch.Repository != "o/app" || a.Step.Fetch.Dir != "modules/app" || a.Step.Revision != 4 || + len(a.Step.Fetch.Paths) != 1 || a.Step.Fetch.Paths[0] != "cmd/app" { t.Errorf("the ask = %+v at %s", a, asks.at[1]) } + // An artifact that names no paths still fetches its module alone: the directory with no paths (principle 10, A-447). + for _, x := range asks.asks[2:] { + if b, ok := x.(nodebuildgo.StepAsk); ok && b.Step != nil && b.Step.Artifact == "app:tools" && (b.Step.Fetch.Dir != "modules/app" || len(b.Step.Fetch.Paths) != 0) { + t.Errorf("the tools ask fetches %+v, want the module's directory and no paths", b.Step.Fetch) + } + } // A second start of the revision asks nothing. if ok, err := s.Start(Begin{Branch: "main", Source: 4, Module: "app", Commit: "c1", Entries: entries}); ok || err != nil || len(asks.asks) != 7 { t.Errorf("second start = %v, %v, %d asks", ok, err, len(asks.asks)) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/read.go b/modules/mesh-delivery-pipeline/internal/pipeline/read.go index a01da243..b244afbb 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/read.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/read.go @@ -107,25 +107,6 @@ func (r Reads) Stands() (seat.StandsAnswer, error) { return seat.StandsAnswer{Stands: out}, nil } -// Waits is the pipelines held for the runner's new version, each as the wait of step `pipeline` it says (design 47 G §266, §276, -// §534, A-195): the acting part awaited by its fingerprint, since when, and the pipeline. -func (r Reads) Waits() (seat.StandsAnswer, error) { - all, err := r.pipelines() - if err != nil { - return seat.StandsAnswer{}, err - } - out := []seat.Wait{} - for _, p := range all { - if p.Held == nil || p.Outcome != seat.PipelineOutcomeRunning { - continue - } - out = append(out, seat.Wait{Pipeline: p.Pipeline, Module: p.Module, Branch: p.Branch, Commit: p.Commit, Group: p.Group, Source: p.Source, - Revision: p.Revision, Fingerprint: p.Held.Fingerprint, Step: seat.WaitStepPipeline, On: seat.WaitOnBuildNode, Since: p.Held.Since, V: 1}) - } - sort.SliceStable(out, func(i, j int) bool { return out[i].Since.Before(out[j].Since) }) - return seat.StandsAnswer{Stands: out}, nil -} - // WhyCarried is where a step's result was carried from (§25, §83): the pipeline it names. func (r Reads) WhyCarried(in seat.WhyCarriedInput) (seat.WhyCarriedAnswer, error) { p, ok, err := r.pipeline(in.Pipeline) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go index 3666f396..20c544ab 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go @@ -129,22 +129,6 @@ func TestReads(t *testing.T) { } } -// runner_waits lists the pipelines held for the runner's new version as waits of step `pipeline` (design 47 G §276, A-195). -func TestWaitsListTheHeldPipelines(t *testing.T) { - since := time.Date(2026, 11, 12, 6, 0, 0, 0, time.UTC) - held := seat.Pipeline{Pipeline: "main.4.app", Module: "app", Branch: "main", Commit: "c1", Source: 4, Outcome: seat.PipelineOutcomeRunning, - Held: &seat.Held{Since: since, Fingerprint: "src2:new"}} - plain := seat.Pipeline{Pipeline: "main.3.app", Module: "app", Branch: "main", Outcome: seat.PipelineOutcomeRunning} - pipes := memKept{} - put(t, pipes, held.Pipeline, held) - put(t, pipes, plain.Pipeline, plain) - r := Reads{Pipelines: pipes, Kept: memKept{}} - got, err := r.Waits() - if err != nil || len(got.Stands) != 1 || got.Stands[0].Step != seat.WaitStepPipeline || got.Stands[0].Fingerprint != "src2:new" || !got.Stands[0].Since.Equal(since) { - t.Fatalf("waits = %+v, %v", got, err) - } -} - // show carries each store's fill (pipelines, step-outputs, kept, step-log) and kept the kept store's, read through the bundle's state // call, never counted from the keys; a fill that cannot be read is an error, not an answer without it (design 47 G §366, §623, A-214). func TestShowAndKeptCarryTheStoresFill(t *testing.T) { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/registrations.go b/modules/mesh-delivery-pipeline/internal/pipeline/registrations.go index 91073caf..a2a2db7b 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/registrations.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/registrations.go @@ -187,3 +187,28 @@ func (v *Views) HearRevision(ctx context.Context, data []byte) error { } return first } + +// Readiness tells, from the revisions a branch's view is seen holding, when the view first holds a half and when it reaches +// a newer revision: the first hold asks again the steps already placed (§88's restart pickup), a newer revision only places +// the steps of pipelines that waited for it (A-448, §200). It is safe for concurrent use. +type Readiness struct { + mu sync.Mutex + held bool + rev int64 +} + +// Observe notes that the view holds revision rev: first is true once, at the first hold; advanced is true when rev is newer +// than any seen before and it is not the first. +func (r *Readiness) Observe(rev int64) (first, advanced bool) { + r.mu.Lock() + defer r.mu.Unlock() + if !r.held { + r.held, r.rev = true, rev + return true, false + } + if rev > r.rev { + r.rev = rev + return false, true + } + return false, false +} diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/start.go b/modules/mesh-delivery-pipeline/internal/pipeline/start.go index cde61cce..b95dfc29 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/start.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/start.go @@ -35,8 +35,6 @@ type Begin struct { Group string Repository string Revision int64 - // Await is the fingerprint of the runner's own module this pipeline is held for (§266, A-195); empty when it is not held. - Await string // Entries are the catalog half's entries of the pipeline's branch: the steps' artifacts and build seats are read from them. Entries map[string]catalog.CatalogEntry // Published is the package's publish that started the pipeline, nil for any other start (A-202). @@ -76,16 +74,6 @@ type Starter struct { Toolchain func(language string) (*nodebuildgo.ToolchainUsed, error) // Arm arms the bound of an ask put on a build seat's work queue (§535, §647); nil arms none. Arm Arm - // Self is the runner's own module and SelfFp the fingerprint it runs (A-149); a take-in giving Self another fingerprint - // holds its pipelines for the new runner (§65, §266, A-195). Awaiting is the fingerprint the held pipelines await, while - // any is held; Hold arms the bound of that wait (HeldBound) counting from the time the awaited build ended. All nil: nothing is held. - Self, SelfFp string - Awaiting func() (string, bool) - Hold func(fp string, from time.Time) error - // Ends says when the build of a module at a fingerprint ended (BuildEnds.At): the clock of the wait's bound (A-181, A-206). - Ends func(module, fp string) (time.Time, bool) - // Late says a pipeline the bound's expiry started with the running runner (A-206): the finding pipeline-waits. - Late func(p seat.Pipeline, held seat.Held) // Fills refuses a start while a store of the runner is full (§366); nil refuses none. Fills *Fills // Recovered says whether a commit is named a recovery (§81, §86): its steps are asked on the build seats' stream delivery. @@ -124,19 +112,6 @@ func (s *Starter) Start(b Begin) (bool, error) { if err := s.Fills.refuseStart(key); err != nil { return false, err } - // The runner's own pipeline is never held: it runs on the running runner, as a build module's running version builds its - // successor (§270, A-328), so its pass lets the new runner be wanted (§29). - if b.Module != "" && b.Module == s.Self { - b.Await = "" - } - if b.Await == "" && s.Awaiting != nil && b.Module != s.Self { - if fp, ok := s.Awaiting(); ok { - b.Await = fp - } - } - if b.Await != "" { - return s.startHeld(b, key, now, b.Await) - } p := newPipeline(b, key, now) var asks []Asked if b.unheld { @@ -154,6 +129,7 @@ func (s *Starter) Start(b Begin) (bool, error) { } else if err != nil { return false, fmt.Errorf("the pipeline %s is not written: %w", key, err) } + s.pin(p) // the catalog graph revision it runs on is kept while it runs (A-449) ev := seat.PipelineStarted{V: 1, At: &now, Pipeline: key, Branch: b.Branch, Source: b.Source, Module: b.Module, Commit: b.Commit, Fingerprint: b.Fp, Group: b.Group, Revision: b.Revision, Published: b.Published} commitOrGroup := b.Commit @@ -265,7 +241,7 @@ func (s *Starter) Waiting(store Updater, branch string, view func(branch string) }, view, "the registration held when its branch's half or the registrations became held") } -// placeWaiting places the steps of each running pipeline under pattern that has none, is neither held nor a run on request, +// placeWaiting places the steps of each running pipeline under pattern that has none and is not a run on request, // and whose registration reg names, from that registration and its branch's catalog half (Registered, Waiting). func (s *Starter) placeWaiting(store Updater, pattern string, reg func(seat.Pipeline) (catalog.Registration, bool), view func(branch string) (Half, bool), from string) (int, error) { pkeys, err := store.Keys(pattern) @@ -289,7 +265,7 @@ func (s *Starter) placeWaiting(store Updater, pattern string, reg func(seat.Pipe note(fmt.Errorf("the pipeline %s is not read: %w", key, err)) continue } - if p.Outcome != seat.PipelineOutcomeRunning || p.Held != nil || p.Run != "" || len(p.Steps) > 0 { + if p.Outcome != seat.PipelineOutcomeRunning || p.Run != "" || len(p.Steps) > 0 { continue } r, ok := reg(p) @@ -301,6 +277,10 @@ func (s *Starter) placeWaiting(store Updater, pattern string, reg func(seat.Pipe s.logf("the catalog half of %s is not held yet: %s waits on it for its steps, placed once it is held", p.Branch, key) continue } + if p.Revision > 0 && half.Revision < p.Revision { + s.logf("the catalog half of %s holds revision %d: %s waits for revision %d, which its take-in made, to place its steps (§200)", p.Branch, half.Revision, key, p.Revision) + continue + } var asks []Asked p.Steps, asks = Place(p, r, half.Entries, now, s.Name) if _, err := store.Update(key, p, rev); err != nil { @@ -309,6 +289,15 @@ func (s *Starter) placeWaiting(store Updater, pattern string, reg func(seat.Pipe } placed++ s.logf("%s: %d steps placed from %s (A-327)", key, len(p.Steps), from) + // A pipeline whose steps were never asked is started by this placing, one a runner before this one set aside included + // (A-446a); the pipeline-started of its start, said already, is said again harmlessly. + if s.Say != nil { + ev := seat.PipelineStarted{V: 1, At: &now, Pipeline: key, Branch: p.Branch, Source: p.Source, Module: p.Module, + Commit: p.Commit, Fingerprint: p.Fingerprint, Group: p.Group, Revision: p.Revision, Published: p.Published} + if err := s.Say(runnerclient.Subject(seat.EventPipelineStarted, p.Module, p.Branch, commitOrGroup(p)), ev); err != nil { + s.logf("pipeline-started of %s is not said: %v", key, err) + } + } if s.Steps != nil && len(asks) > 0 { s.carry(key, asks) if err := askAll(s.Steps, s.Arm, key, asks, s.recovered(key, p.Commit)); err != nil { @@ -447,19 +436,22 @@ func (s *Starter) TakenIn(ev catalog.TakeInTaken, view func(branch string) (Half // A take-in heard before its branch's half is held starts its pipelines with no steps, never placed from empty entries // (§200, A-336); Waiting places them once the half is held. half, held := view(ev.Branch) + // The pipelines start at the revision the take-in made, never at the one the runner's own view holds (A-448): while the + // view holds an older one they start with no step, which Waiting places once the view reaches it (§200). An event with + // no revision (said before A-448) starts at the view's, as it did, and says so. + revision := ev.Revision + if revision <= 0 { + revision = half.Revision + s.logf("the take-in %s of %s names no catalog graph revision: its pipelines start at the revision the runner's view holds, %d", ev.Key, ev.Branch, revision) + } else if held && half.Revision < revision { + s.logf("the take-in %s of %s made revision %d and the runner's view holds %d: its pipelines start with no step, placed once the view reaches it (§200)", ev.Key, ev.Branch, revision, half.Revision) + held = false + } started := 0 var first error - // A take-in giving the runner's own module a new fingerprint holds every other pipeline it starts for that runner (§65, - // A-195, A-328); the runner's own runs now (Start). - await := "" - for _, e := range ev.Entries { - if s.changesSelf(e.Module, e.Fingerprint) { - await = e.Fingerprint - } - } for _, e := range ev.Entries { ok, err := s.Start(Begin{Branch: ev.Branch, Source: ev.Source, Module: e.Module, Commit: e.Commit, Fp: e.Fingerprint, - Group: ev.Group, Repository: e.Repository, Revision: half.Revision, Entries: half.Entries, Await: await, unheld: !held}) + Group: ev.Group, Repository: e.Repository, Revision: revision, Entries: half.Entries, unheld: !held}) if err != nil && first == nil { first = err } @@ -467,5 +459,21 @@ func (s *Starter) TakenIn(ev catalog.TakeInTaken, view func(branch string) (Half started++ } } + // The view was read before the starts wrote: when pipelines were held back for it and it has reached the revision since, + // they are placed now, not left for an advance that already came (A-448, §200). + if !held && started > 0 && revision > 0 && s.Store != nil { + if again, ok := view(ev.Branch); ok && again.Revision >= revision { + if _, err := s.Waiting(s.Store, ev.Branch, view); err != nil && first == nil { + first = err + } + } + } return started, first } + +func commitOrGroup(p seat.Pipeline) string { + if p.Group != "" { + return p.Group + } + return p.Commit +} diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go index ac0d68b3..b8a999e1 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go @@ -8,6 +8,7 @@ import ( builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + delivery "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" ) @@ -29,7 +30,10 @@ func TestStarts(t *testing.T) { var said []string var superseding []string s := &Starter{Pipelines: store, Say: func(subject string, body any) error { - ev := body.(seat.PipelineStarted) + ev, started := body.(seat.PipelineStarted) + if !started { // a pipeline's pin of its catalog graph revision (A-449) is no pipeline-started + return nil + } said = append(said, subject+" "+ev.Pipeline) if ev.Published == nil || ev.Published.Artifact != "mesh-sdk:go" || ev.Published.Version != "0.1.16" { t.Errorf("pipeline-started of %s says the publish %+v (A-202)", ev.Pipeline, ev.Published) @@ -91,6 +95,24 @@ func TestStarts(t *testing.T) { } } +// memCreated is memStore with the Create a start writes through. +type memCreated struct{ memStore } + +func (m memCreated) Create(key string, value []byte) error { + if _, ok := m.memStore[key]; ok { + return ErrExists + } + var p seat.Pipeline + if err := json.Unmarshal(value, &p); err != nil { + return err + } + m.memStore[key] = struct { + p seat.Pipeline + rev uint64 + }{p, 1} + return nil +} + type failing struct{} func (failing) Create(string, []byte) error { return errors.New("bus away") } @@ -100,7 +122,12 @@ func (failing) Create(string, []byte) error { return errors.New("bus away") } func TestTakenInStarts(t *testing.T) { store := created{} var said []string - s := &Starter{Pipelines: store, Say: func(subject string, body any) error { said = append(said, subject); return nil }} + s := &Starter{Pipelines: store, Say: func(subject string, body any) error { + if _, pins := body.(delivery.Pins); !pins { + said = append(said, subject) + } + return nil + }} view := func(string) (Half, bool) { return Half{Revision: 12}, true } ev := catalog.TakeInTaken{Kind: "taken", Branch: "main", Source: 7, Group: "g1", Entries: []catalog.TakeInEntry{ {Module: "a", Commit: "c1", Fingerprint: "src2:aa", Repository: "o/a"}, {Module: "b", Commit: "c2", Fingerprint: "src2:bb"}}} @@ -134,7 +161,8 @@ func TestAPipelineStartedBeforeItsRegistrationIsPlacedWhenItArrives(t *testing.T store := memCreated{memStore{}} asks := &stepAsks{} registered := false - s := &Starter{Pipelines: store, Steps: asks, Name: "the-runner", Say: func(string, any) error { return nil }, + var said []string + s := &Starter{Pipelines: store, Steps: asks, Name: "the-runner", Say: func(subject string, _ any) error { said = append(said, subject); return nil }, Registration: func(m string) (catalog.Registration, bool) { return reg, registered && m == "app" }} view := func(string) (Half, bool) { return Half{Entries: entries}, true } taken := catalog.TakeInTaken{Key: "m.1", Branch: "main", Source: 4, Entries: []catalog.TakeInEntry{{Module: "app", Commit: "c1", Fingerprint: "src2:aa"}}} @@ -216,4 +244,25 @@ func TestAPipelineStartedBeforeItsRegistrationIsPlacedWhenItArrives(t *testing.T if n != 1 || err != nil || len(p.Steps) == 0 { t.Errorf("the half of next placed %d (%v): %d steps, want the publish's pipeline placed", n, err, len(p.Steps)) } + + // A-446: a pipeline an earlier runner left set aside for its new version (the record keeps a `held` field, outcome running, + // no step placed) is placed and asked as a newly started one when the half is held; no hold is read any more. + var old seat.Pipeline + if err := json.Unmarshal([]byte(`{"pipeline":"main.940.app","branch":"main","module":"app","commit":"c9","source":940,"outcome":"running",`+ + `"held":{"since":"2026-11-15T18:05:00Z","fingerprint":"src2:new"}}`), &old); err != nil { + t.Fatal(err) + } + store.memStore["main.940.app"] = struct { + p seat.Pipeline + rev uint64 + }{old, 1} + before, saidBefore := len(asks.asks), len(said) + n, err = s.Waiting(store.memStore, "main", late) + p, _, _ = store.Get("main.940.app") + if len(said) != saidBefore+1 || !strings.HasPrefix(said[saidBefore], "mesh.seat.mesh-pipeline-runner.event.pipeline-started.app.main.c9") { + t.Errorf("placing the set-aside pipeline said %v, want its pipeline-started (A-446a)", said[saidBefore:]) + } + if n != 1 || err != nil || len(p.Steps) == 0 || len(asks.asks) == before { + t.Errorf("the pipeline a runner before this one set aside: placed %d (%v), %d steps, %d asks more, want it started as a newly started one", n, err, len(p.Steps), len(asks.asks)-before) + } } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go index e8518f84..a1c7a3c2 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go @@ -225,6 +225,9 @@ func (h *Hearer) said(p seat.Pipeline, asked, ended bool) error { } } if ended { + // The end is said first, with its widens, which read the revision the pipeline pinned; only then is the pin freed (A-449), + // and also when saying the end fails. + defer h.free(p) if err := h.say(seat.EventPipelineEnded, p, nil); err != nil { return fmt.Errorf("pipeline %s ended but %s is not said: %w", p.Pipeline, seat.EventPipelineEnded, err) } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go b/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go index a0118b68..6966b6f6 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go @@ -286,6 +286,7 @@ func (v Verbs) Rerun(caller string, in seat.RerunInput) (seat.RerunAnswer, error if err != nil { return seat.RerunAnswer{}, err } + v.Hearer.pin(p) // a pipeline that runs again keeps its revision again (A-449) if ask != nil { v.Starter.carry(in.Pipeline, []Asked{*ask}) if err := askAll(v.Starter.Steps, v.Starter.Arm, in.Pipeline, []Asked{*ask}, v.Starter.recovered(in.Pipeline, p.Commit)); err != nil { @@ -423,5 +424,6 @@ func (v Verbs) AskAgain(caller string, in seat.AskAgainInput) (seat.AskAgainAnsw if err != nil { return seat.AskAgainAnswer{}, err } + v.Hearer.pin(p) return seat.AskAgainAnswer{Result: p.Steps[i]}, nil } diff --git a/modules/mesh-delivery-pipeline/manifest_test.go b/modules/mesh-delivery-pipeline/manifest_test.go index 784a16b3..80d88e8a 100644 --- a/modules/mesh-delivery-pipeline/manifest_test.go +++ b/modules/mesh-delivery-pipeline/manifest_test.go @@ -76,9 +76,9 @@ func TestManifest(t *testing.T) { {"sent-objects 256 MiB", objectMiB[catalogue.SentObjectsLocal] == 256}, // §333, §54, §44, §53, §376, §24, §37, §4, §77: what the runner hears. {"consumes", equalSets(m.Consumes, []string{ - "mesh-delivery-indexer.take-in.taken", "mesh-builds.package-published", "mesh-builds.toolchain-agreed", "mesh-builds.step-ended", "mesh-delivery-builder.build.ended.**", + "mesh-delivery-indexer.take-in.taken", "mesh-builds.package-published", "mesh-builds.toolchain-agreed", "mesh-builds.step-ended", "operator-channel.decided", "node-build-go.step-ended", "node-build-node.step-ended", - "node-build-image.step-ended", "node-build-go.ask-taken", "node-build-node.ask-taken", "node-build-image.ask-taken", "node-engine.running", "mesh-wants.step-ended", "mesh-catalog.registration-changed", + "node-build-image.step-ended", "node-build-go.ask-taken", "node-build-node.ask-taken", "node-build-image.ask-taken", "mesh-wants.step-ended", "mesh-catalog.registration-changed", "mesh-catalog.catalog-revision", "mesh-conditions.findings-asked", "mesh-delivery.recovery-merged", // A-186: the seat list its write verbs' callers are checked against, heard as it changes. "mesh-catalog.seat-definition-changed", "mesh-catalog.seat-definition-removed"})}, @@ -107,7 +107,7 @@ func TestManifest(t *testing.T) { "seat:node-build-node.accept.delivery", "seat:node-build-image.accept.check", "seat:node-build-image.accept.delivery"})}, {"uses operator-channel", equalSets(m.Uses, []string{"operator-channel"})}, // RN25 (§539): the runner's tools carry the prefix runner_. - {"first-view tools", equalSets(m.Tools, []string{"runner_first_views", "runner_first_view_again", "runner_health", "runner_waits", "runner_release", "runner_unlogged", "runner_unlogged_append"})}, + {"first-view tools", equalSets(m.Tools, []string{"runner_first_views", "runner_first_view_again", "runner_health", "runner_unlogged", "runner_unlogged_append"})}, // A-305 (ADR 0227 rule 8, ADR 0240 rule 2): the process is judged by its unit, as every process of mesh-delivery, // never by a tool of its own; runner_health stays a tool. {"health is the unit", healthTool(raw) == "unit"}, diff --git a/modules/mesh-delivery-pipeline/module.json b/modules/mesh-delivery-pipeline/module.json index 5a61a86c..9198f2fa 100644 --- a/modules/mesh-delivery-pipeline/module.json +++ b/modules/mesh-delivery-pipeline/module.json @@ -18,8 +18,7 @@ "rerun", "accept", "cancel", - "ask-again", - "release" + "ask-again" ] } ], @@ -27,8 +26,6 @@ "runner_first_views", "runner_first_view_again", "runner_health", - "runner_waits", - "runner_release", "runner_unlogged", "runner_unlogged_append" ], @@ -37,7 +34,6 @@ "mesh-builds.package-published", "mesh-builds.toolchain-agreed", "mesh-builds.step-ended", - "mesh-delivery-builder.build.ended.**", "operator-channel.decided", "node-build-go.step-ended", "node-build-node.step-ended", @@ -45,7 +41,6 @@ "node-build-go.ask-taken", "node-build-node.ask-taken", "node-build-image.ask-taken", - "node-engine.running", "mesh-wants.step-ended", "mesh-catalog.registration-changed", "mesh-catalog.catalog-revision", diff --git a/modules/mesh-delivery-sdk/buildstep/request.go b/modules/mesh-delivery-sdk/buildstep/request.go index 9cc961ff..5ea272b0 100644 --- a/modules/mesh-delivery-sdk/buildstep/request.go +++ b/modules/mesh-delivery-sdk/buildstep/request.go @@ -19,8 +19,9 @@ var ( // // **The paths come from the builder, not from a manifest** (ADR 0495 clause 1; the lead's decision L8 of R4e): the // builder fills Dir and Paths from the indexer's Module value (Path, and KeptInputs2.Paths' keys), and the build module -// gives the build and test steps a workspace holding those paths, the manifest and its lock files. A request without -// them builds from the module's directory, as before. +// gives the build and test steps a workspace holding those paths, the manifest and its lock files. A request with a directory and no +// paths builds from the module's directory, which a Go build resolves with the Go modules it replaces alone (A-447); +// one without either builds the whole tree. type FetchRequest struct { Repository string `json:"repository"` Commit string `json:"commit"` @@ -138,11 +139,9 @@ func (r FetchRequest) Check() error { if r.Base != "" && !requestCommitOK.MatchString(r.Base) { return fmt.Errorf("%q is not a trunk commit (40 hex digits)", r.Base) } - switch { - case len(r.Paths) > 0 && r.Dir == "": + // A module directory alone is a request for that module's Go modules alone (design 47 G, A-447); paths need it. + if len(r.Paths) > 0 && r.Dir == "" { return fmt.Errorf("the request names paths and names no module directory (dir) they are relative to") - case len(r.Paths) == 0 && r.Dir != "": - return fmt.Errorf("the request names a module directory and no path") } if r.Dir != "" && (outside(r.Dir) || strings.HasPrefix(r.Dir, "/")) { return fmt.Errorf("the module directory %q leaves the repository", r.Dir) diff --git a/modules/mesh-delivery-sdk/buildstep/request_test.go b/modules/mesh-delivery-sdk/buildstep/request_test.go index 7732329f..fbd79d55 100644 --- a/modules/mesh-delivery-sdk/buildstep/request_test.go +++ b/modules/mesh-delivery-sdk/buildstep/request_test.go @@ -33,6 +33,10 @@ func TestAFetchRequestCarriesTheNamedPathsThroughTheToolCall(t *testing.T) { } ok := map[string]any{"repository": "novox/x", "commit": strings.Repeat("b", 40)} + // A module directory with no paths is a request (design 47 G, A-447). + if dirOnly, err := ParseFetchRequest(map[string]any{"repository": "novox/x", "commit": strings.Repeat("b", 40), "dir": "modules/a"}); err != nil || dirOnly.Dir != "modules/a" || dirOnly.Paths != nil { + t.Fatalf("a directory with no paths: %+v, %v", dirOnly, err) + } for _, c := range []struct { set map[string]any says string @@ -45,7 +49,6 @@ func TestAFetchRequestCarriesTheNamedPathsThroughTheToolCall(t *testing.T) { {map[string]any{"dir": "modules/a", "paths": []any{"../b"}}, "leaves the module's directory"}, {map[string]any{"dir": "../a", "paths": []any{"src"}}, "leaves the repository"}, {map[string]any{"dir": "modules/a", "paths": []any{3}}, "paths is a list of strings"}, - {map[string]any{"dir": "modules/a"}, "names a module directory and no path"}, {map[string]any{"packages": map[string]any{"git.novox.be/novox/mesh-sdk/go": "main"}}, "neither a full commit nor a Go semantic version"}, {map[string]any{"packages": map[string]any{"a b": strings.Repeat("d", 40)}}, "no module path"}, {map[string]any{"packages": []any{"x"}}, "packages is an object"}, diff --git a/modules/mesh-delivery-sdk/steprun/askers.go b/modules/mesh-delivery-sdk/steprun/askers.go index 3a59a9be..5013765a 100644 --- a/modules/mesh-delivery-sdk/steprun/askers.go +++ b/modules/mesh-delivery-sdk/steprun/askers.go @@ -6,6 +6,7 @@ import ( "slices" "strings" "sync/atomic" + "time" buildrun "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildrun" sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" @@ -118,33 +119,86 @@ func (p *Puller) refuseAsker(msg *Pulled, ask sdkstep.StepAsk, why string) { _ = msg.Term() } -// giveBack hands an ask back to be judged again a little later, once the seat list says more. +// giveBack hands an ask back to be judged again a little later, once the seat list says more. Why it cannot be judged is +// said once per change by the callers (SeatListCallers), not once per ask. func (p *Puller) giveBack(msg *Pulled, ask sdkstep.StepAsk) { - p.logf("the ask %s is given back on %s: the seat list holds no definition of its kind yet", ask.ID, p.Node) if msg.NakAfter != nil && msg.NakAfter(DefaultPullWait) == nil { return } _ = msg.Nak() } +// Seat list start retries: the first wait and its cap (a failed start is tried again, 1s doubling to 1 minute). +const ( + seatListRetryFirst = time.Second + seatListRetryMax = time.Minute +) + +// startSeatList tries start until it succeeds: each failure is said with its next try, the success once. wait is the +// pause a test replaces; the reader is returned once started (design 47 G §543, A-163, lead-47 2026-11-15: the reader's +// start is retried). +func startSeatList(start func() (*seatlist.Reader, error), wait func(time.Duration), logf func(format string, args ...any)) *seatlist.Reader { + if logf == nil { + logf = func(string, ...any) {} + } + delay := seatListRetryFirst + for { + r, err := start() + if err == nil { + logf("the seat list is followed") + return r + } + logf("following the seat list: %v; the asks are given back, the next try in %s", err, delay) + wait(delay) + delay = min(delay*2, seatListRetryMax) + } +} + // SeatListCallers is a Puller.Callers that follows the seat list: it starts the reader once the runtime serves // (seatlist.Start through the runtime's own way in) and answers from its definitions, found false until it has read them. -// A reader that cannot start is said and the asks are given back until it can (design 47 G §543, A-163). +// A reader that cannot start is said and tried again with backoff while the asks are given back (design 47 G §543, A-163); +// why an ask is given back (reader not started, definition of the seat not held, kind not in it) is said once per change. func SeatListCallers(language string, logf func(format string, args ...any)) func(kind string) ([]string, bool) { var reader atomic.Pointer[seatlist.Reader] go func() { <-stdio.Served() - r, err := seatlist.Start(seatlist.Config{Bus: seatlist.StdioBus(), Bootstrap: seatlist.Bootstrapped()}) - if err != nil && logf != nil { - logf("following the seat list: %v", err) - } - reader.Store(r) + reader.Store(startSeatList(func() (*seatlist.Reader, error) { + return seatlist.Start(seatlist.Config{Bus: seatlist.StdioBus(), Bootstrap: seatlist.Bootstrapped()}) + }, time.Sleep, logf)) }() + return callersOf(language, reader.Load, logf) +} + +// callersOf answers from the reader once started, saying once per change why a kind is not found. +func callersOf(language string, reader func() *seatlist.Reader, logf func(format string, args ...any)) func(kind string) ([]string, bool) { + var said atomic.Value // the last reason said + say := func(why string) { + if prev, _ := said.Swap(why).(string); prev != why && logf != nil { + logf("the asks are given back: %s", why) + } + } return func(kind string) ([]string, bool) { - r := reader.Load() + r := reader() if r == nil { + say("the seat list reader is not started yet") return nil, false } - return CallersFromDefinitions(language, r.Definitions)(kind) + defs := r.Definitions() + seat, err := sdkstep.BuildSeat(language) + if err != nil { + say("the build seat of " + language + " is unknown: " + err.Error()) + return nil, false + } + if _, ok := defs[seat]; !ok { + say("the seat list holds no definition of the seat " + seat) + return nil, false + } + callers, found := CallersFromDefinitions(language, func() map[string]seatdef.Definition { return defs })(kind) + if !found { + say("the definition of " + seat + " does not accept the kind " + kind) + } else { + said.Store("") + } + return callers, found } } diff --git a/modules/mesh-delivery-sdk/steprun/askers_test.go b/modules/mesh-delivery-sdk/steprun/askers_test.go index d88584a3..f928ccd3 100644 --- a/modules/mesh-delivery-sdk/steprun/askers_test.go +++ b/modules/mesh-delivery-sdk/steprun/askers_test.go @@ -2,12 +2,14 @@ package steprun import ( "context" + "fmt" "strings" "testing" "time" sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" "git.novox.be/novox/mesh-sdk/go/seatdef" + "git.novox.be/novox/mesh-sdk/go/seatlist" ) func callersFor(table map[string][]string) func(string) ([]string, bool) { @@ -95,3 +97,40 @@ func TestCallersFromDefinitionsReadsTheSeatsCallers(t *testing.T) { t.Fatal("a kind the definition does not list is found") } } + +func TestStartSeatListRetriesWithBackoffAndSaysIt(t *testing.T) { + var lines []string + var waits []time.Duration + tries := 0 + start := func() (*seatlist.Reader, error) { + tries++ + if tries <= 8 { + return nil, fmt.Errorf("binding the consumer: context deadline exceeded") + } + return &seatlist.Reader{}, nil + } + r := startSeatList(start, func(d time.Duration) { waits = append(waits, d) }, func(f string, a ...any) { lines = append(lines, fmt.Sprintf(f, a...)) }) + if r == nil || tries != 9 || len(waits) != 8 { + t.Fatalf("reader %v tries %d waits %v", r, tries, waits) + } + if waits[0] != time.Second || waits[1] != 2*time.Second || waits[7] != time.Minute { + t.Fatalf("waits = %v, want 1s doubling to 1m", waits) + } + if len(lines) != 9 || !strings.Contains(lines[0], "next try in 1s") || lines[8] != "the seat list is followed" { + t.Fatalf("lines = %q", lines) + } +} + +func TestCallersOfSaysWhyOncePerChange(t *testing.T) { + var lines []string + var r *seatlist.Reader + c := callersOf(sdkstep.AskGo, func() *seatlist.Reader { return r }, func(f string, a ...any) { lines = append(lines, fmt.Sprintf(f, a...)) }) + for range 3 { + if _, ok := c("step"); ok { + t.Fatal("found without a reader") + } + } + if len(lines) != 1 || !strings.Contains(lines[0], "not started yet") { + t.Fatalf("lines = %q", lines) + } +} diff --git a/modules/mesh-delivery-sdk/steprun/askrun.go b/modules/mesh-delivery-sdk/steprun/askrun.go index a0b95356..17693494 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun.go +++ b/modules/mesh-delivery-sdk/steprun/askrun.go @@ -374,7 +374,7 @@ func (s AskSteps) level(ctx context.Context, job sdkstep.CheckJob, level string, if s.Digest == nil { // A module with no digest (Node) tests each module directory of the tree, those whose tests changed first. for _, priority := range []bool{true, false} { - for _, dir := range f.Modules { + for _, dir := range modulesOf(f.Modules, job.Fetch.Dir) { if changesTestIn(f.Changed, dir) != priority { continue } @@ -424,6 +424,23 @@ func (s AskSteps) level(ctx context.Context, job sdkstep.CheckJob, level string, return all, nil } +// modulesOf are the module directories a fetch answered that a step for the module in dir tests: that directory's and +// those under it, never another module's of the repository (design 47 G, A-447c); all of them when the ask names no +// directory, or the root. +func modulesOf(modules []string, dir string) []string { + dir = strings.Trim(path.Clean(dir), "/") + if dir == "" || dir == "." { + return modules + } + var out []string + for _, m := range modules { + if m == dir || strings.HasPrefix(m, dir+"/") { + out = append(out, m) + } + } + return out +} + // release removes an ask's workspace, saying a failure: the module's sweep removes it later. func (s AskSteps) release(workspace string) { if workspace == "" || s.Release == nil { diff --git a/modules/mesh-delivery-sdk/steprun/askrun_test.go b/modules/mesh-delivery-sdk/steprun/askrun_test.go index 3662862d..c2c89ee1 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun_test.go +++ b/modules/mesh-delivery-sdk/steprun/askrun_test.go @@ -296,6 +296,16 @@ func TestRunAskChecksNodeModulesAndConflicts(t *testing.T) { if fmt.Sprint(r.calls[1:]) != `[test {"level":"unit","module":"b","workspace":"/w"} test {"level":"unit","module":"a","workspace":"/w"}]` { t.Fatalf("calls %v", r.calls) } + // A check asked for the module in a directory tests that directory's modules alone (A-447c). + r = &recorder{fetch: map[string]any{"workspace": "/w", "modules": []string{"a", "b", "b/c"}}, tests: map[string]bool{"b": true, "b/c": true}} + s = r.steps() + s.Digest = nil + if _, err := RunAsk(context.Background(), s, ask(sdkstep.CheckJob{Levels: []string{sdkstep.LevelUnit}, Fetch: sdkstep.Fetch{Repository: "novox/x", Commit: runCommit, Dir: "b"}})); err != nil { + t.Fatal(err) + } + if fmt.Sprint(r.calls[1:]) != `[test {"level":"unit","module":"b","workspace":"/w"} test {"level":"unit","module":"b/c","workspace":"/w"}]` { + t.Fatalf("a check for the module b: calls %v", r.calls) + } r = &recorder{fetch: map[string]any{"workspace": "/w", "conflicts": []string{"go.mod"}}} out, err := RunAsk(context.Background(), r.steps(), ask(sdkstep.CheckJob{Levels: []string{sdkstep.LevelUnit}, Fetch: sdkstep.Fetch{Repository: "novox/x", Commit: runCommit}})) if err != nil || len(r.calls) != 1 || len(out.(sdkstep.CheckAnswer).Levels) != 0 { diff --git a/modules/mesh-delivery-sdk/steprun/pull.go b/modules/mesh-delivery-sdk/steprun/pull.go index a4c167b7..88d2cd87 100644 --- a/modules/mesh-delivery-sdk/steprun/pull.go +++ b/modules/mesh-delivery-sdk/steprun/pull.go @@ -169,6 +169,8 @@ type Puller struct { // declined are the kinds whose worker handed an ask this node declined, left out of the pulls without a wait until // the next pull's wait ends. declined map[string]bool + // turn is the kind the next pull asks first (next): the kinds take turns, so a queue that never empties holds back none. + turn int } func (p *Puller) init() { @@ -519,21 +521,30 @@ func (p *Puller) Pull(ctx context.Context) error { } } -// next is one ask from the workers in their order: one already waiting on delivery, check or recheck, and when none -// waits, a pull of the delivery worker that waits for one. +// next is one ask from the workers, the kinds taking turns: the pull starts at the kind after the one the last ask came +// from and takes one already waiting on delivery, check or recheck, and when none waits, a pull of the delivery worker +// that waits for one. A fixed order let 89 waiting deliveries hold every pipeline's check back (lead-47, 2026-11-15; the +// operator's yes at 18:3x): with turns, neither kind starves the other. // // A kind whose worker handed an ask this node declined is left out until that wait ended (issue 890): the pull's own // wait, no timer of its own. func (p *Puller) next(ctx context.Context, wait time.Duration) (*Pulled, error) { p.mu.Lock() - declined := p.declined + declined, start := p.declined, p.turn p.mu.Unlock() - for _, kind := range sdkstep.AskKinds { + for i := range sdkstep.AskKinds { + at := (start + i) % len(sdkstep.AskKinds) + kind := sdkstep.AskKinds[at] if declined[kind] { continue } msg, err := p.Source.Next(ctx, kind, 0) if err != nil || msg != nil { + if msg != nil { + p.mu.Lock() + p.turn = (at + 1) % len(sdkstep.AskKinds) + p.mu.Unlock() + } return withKind(msg, kind), err } } @@ -805,8 +816,8 @@ func (p *Puller) run(ctx context.Context, msg *Pulled, ask sdkstep.StepAsk, key } else { p.sayEnded(msg, ask, sdkstep.OutcomePassed, "", result, written.OutputObject) } - p.logf("the %s ask %s ended on %s after %s, in its phase %q; %s", ask.Kind, ask.ID, p.Node, - now().Sub(step.Started).Round(time.Second), step.Phase, outcome) + p.logf("the %s ask %s ended on %s after %s, in its phase %q; %s%s", ask.Kind, ask.ID, p.Node, + now().Sub(step.Started).Round(time.Second), step.Phase, outcome, stepOutcomeWords(result)) if aerr := msg.Ack(); aerr != nil { p.logf("the ask %s ended on %s and its acknowledgement failed: %v", ask.ID, p.Node, aerr) } @@ -1044,3 +1055,28 @@ func runAnswerOf(ask sdkstep.StepAsk, result any) (sdkstep.RunAnswer, bool) { } return runAnswerIn(result) } + +// stepOutcomeWords is a pipeline step's own outcome, as its step-ended says it, for the line that says the ask ended: the ask +// passing only says its end was said, which a step that could not run or had nothing to run also does (lead-47, 2026-11-15: +// steps "passed" in 0 s and nobody could read what they did). Empty for an ask that is no pipeline step. +func stepOutcomeWords(result any) string { + a, ok := result.(StepAnswer) + if !ok { + return "" + } + words := "; the step's outcome: " + a.Ended.Outcome + if a.Ended.Said != "" { + said := a.Ended.Said + if len(said) > 300 { + said = said[:300] + "..." + } + words += " (" + said + ")" + } + if t := a.Ended.Tests; t != nil { + words += fmt.Sprintf(", %d unit and %d integration tests", t.Unit, t.Integration) + } + if len(a.Ended.Carried) > 0 { + words += fmt.Sprintf(", %d carried from an earlier run", len(a.Ended.Carried)) + } + return words +} diff --git a/modules/mesh-delivery-sdk/steprun/pull_test.go b/modules/mesh-delivery-sdk/steprun/pull_test.go index 88dfb77f..5fc90720 100644 --- a/modules/mesh-delivery-sdk/steprun/pull_test.go +++ b/modules/mesh-delivery-sdk/steprun/pull_test.go @@ -106,6 +106,35 @@ func TestPullTakesDeliveryBeforeCheck(t *testing.T) { } } +// The kinds take turns (lead-47, 2026-11-15): with two deliveries and a check waiting and one slot, the check runs second, +// never held back until every delivery is done. +func TestPullKindsTakeTurns(t *testing.T) { + src, st := NewFakeAsks(), newSteps() + for _, a := range []sdkstep.StepAsk{testAsk(sdkstep.AskDelivery), testAsk(sdkstep.AskDelivery), testAsk(sdkstep.AskCheck)} { + if err := src.PublishAsk(a); err != nil { + t.Fatal(err) + } + } + var mu sync.Mutex + var order []string + p := &Puller{Source: src, Language: sdkstep.AskGo, Node: "shanks", Put: st.put, Capacity: func() int { return 1 }, + PullWait: 10 * time.Millisecond, Run: func(ctx context.Context, a sdkstep.StepAsk) (any, error) { + mu.Lock() + order = append(order, a.Kind) + mu.Unlock() + return map[string]string{"ran": a.ID}, nil + }} + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + go p.Pull(ctx) + waitFor(t, "three asks acked", func() bool { a, _, _ := src.Fates(); return len(a) == 3 }) + mu.Lock() + defer mu.Unlock() + if want := []string{sdkstep.AskDelivery, sdkstep.AskCheck, sdkstep.AskDelivery}; len(order) != 3 || order[0] != want[0] || order[1] != want[1] || order[2] != want[2] { + t.Fatalf("order = %v, want %v", order, want) + } +} + // 1887/A2a, 1887/AC-pull: given capacity 2 and three asks waiting, two run and the third waits, and it starts when // one ends, with no timer. Issue 1806's follow-up: the 2 is the CPU's, a configured 3 bounded by a 12-core slice at 6 // cores a step, said once in capacity.; and issue 1890: a run's phase is written to its step key and logged with @@ -598,3 +627,18 @@ func TestPullAnswersAnAskItCannotRead(t *testing.T) { t.Fatalf("the unread ask's step = %+v (%v)", s, ok) } } + +// A pipeline step's own outcome is said beside the ask's end, so a step that had nothing to run never reads as a plain pass. +func TestTheStepsOwnOutcomeIsSaid(t *testing.T) { + got := stepOutcomeWords(StepAnswer{Ended: sdkstep.StepEnded{Outcome: sdkstep.OutcomeNothingToRun}}) + if !strings.Contains(got, sdkstep.OutcomeNothingToRun) { + t.Errorf("words = %q", got) + } + got = stepOutcomeWords(StepAnswer{Ended: sdkstep.StepEnded{Outcome: sdkstep.OutcomePassed, Tests: &sdkstep.TestCounts{Unit: 12}}}) + if !strings.Contains(got, "12 unit") { + t.Errorf("words = %q", got) + } + if stepOutcomeWords(map[string]string{"ran": "x"}) != "" { + t.Error("an ask that is no step named an outcome") + } +} diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller-tools/main.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller-tools/main.go index 27a6035a..fb0f0a76 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller-tools/main.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller-tools/main.go @@ -32,10 +32,9 @@ func Tools(ask asker, now func() time.Time) []stdio.Tool { return []stdio.Tool{ {Name: ends.Tool, Description: "End one open ask the delivery teller holds at the operator channel, by hand, saying why: the teller " + - "cancels it at the router, which frees one of the three places the router gives the teller, or drops it from the " + - "teller's wait for room. For an ask whose question is gone but whose key was never taken away (a merge ask of a pull " + - "request merged by another path, a backup ask about a backup no longer failing), which otherwise holds its place " + - "until it lapses, so a newer ask is refused for want of room. Name the ask by its router id (as " + + "cancels it at the router, or drops it from the asks it could not hand the router. For an ask whose question is gone " + + "but whose key was never taken away (a backup ask about a backup no longer failing), which otherwise stays offered " + + "until it lapses. Name the ask by its router id (as " + "operator-channel's asks show it) or by the key of the gate's or the assigner's asks. Answers which ask it found, " + "whether it ended it, and what it did; an ask answered, lapsed or ended already is left and said so.", Input: map[string]any{"type": "object", "required": []string{"ask", "why"}, "properties": map[string]any{ diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks.go index 9b48d69e..63b5b9ac 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks.go @@ -1,15 +1,12 @@ package main import ( - "encoding/json" "fmt" - "slices" + "time" occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient" oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel" - stdio "git.novox.be/novox/mesh-sdk/go" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-assigner/asks" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-teller/tellerevents" @@ -24,69 +21,18 @@ import ( // under the ask's own key in the bucket answers, which the assigner reads (mesh-delivery-assigner pass.go answeredWith); none // of these asks needs proof of who answered (mesh-sdk go/delivery AskNeedsProof). -// mostAssignerOpen is how many of the assigner's asks the teller keeps open at the router at once. The router keeps at most -// occ.MostOpen open asks of one asker, and a burst of holds (seven at once on 2026-10-25) would take all the room; one place -// stays free (it was left for the merge ask, which went with the Approve per merge, design 47 G §653). An assigner ask beyond -// these waits in the wait for room and is asked when one of them ends. -const mostAssignerOpen = occ.MostOpen - 1 +// The operator channel keeps no count of an asker's open asks and holds none back for room (design 47 G A-424): the teller asks +// each of the assigner's asks when the assigner writes it, as many as there are. The record `room` keeps only the asks the +// teller could not hand the router (a transport fault, a word not heard), asked again at the next end and at the start. -// assignerOpenRecord is the key of the router ids of the assigner's asks the teller asked. -const assignerOpenRecord = "assigner.open" - -// assignerOpen is the router ids of the assigner's asks open now: those asked whose ask is neither answered nor ended. An id -// that ended is dropped from the record as it is read. -func (t *Teller) assignerOpen() ([]string, *stdio.StateEntry) { - e, err := t.Store.Get(assignerOpenRecord) - if err != nil || e == nil { - return nil, e - } - var ids []string - if err := json.Unmarshal(e.Value, &ids); err != nil { - t.logf("the record %s cannot be read: %v", assignerOpenRecord, err) - return nil, e - } - return slices.DeleteFunc(ids, func(id string) bool { - k, _, err := t.keptOf(id) - return err == nil && !open(k) - }), e -} - -// assignerRoom says whether another of the assigner's asks may be asked now. -func (t *Teller) assignerRoom() bool { - ids, _ := t.assignerOpen() - return len(ids) < mostAssignerOpen -} - -// assignerAsked keeps that the assigner's ask with this router id is asked. -func (t *Teller) assignerAsked(id string) { - ids, e := t.assignerOpen() - if !slices.Contains(ids, id) { - ids = append(ids, id) - } - var err error - if e == nil { - _, err = t.Store.Create(assignerOpenRecord, ids) - } else { - _, err = t.Store.Update(assignerOpenRecord, ids, e.Revision) - } - if err != nil { - t.logf("the record %s could not be kept: %v", assignerOpenRecord, err) - } -} - -// waitForAssignerRoom puts an assigner ask in the wait for room, once. -func (t *Teller) waitForAssignerRoom(key, id string) { - ws, rec, err := t.waiting() - if err != nil { - t.logf("%v", err) - return - } - if slices.ContainsFunc(ws, func(x waitingAsk) bool { return x.ID == id }) { - return - } - if t.keepWaiting(append(ws, waitingAsk{Key: key, ID: id}), rec) == nil { - t.logf("%s: the assigner's ask %s waits: %d of the assigner's asks are open, the most the teller keeps open so a merge ask always has room", key, id, mostAssignerOpen) +// lapsed says whether the assigner's ask lapsed: past the expiry its words name. A lapsed ask is asked of nobody: its proposal or +// question has ended, and the router would let it lapse at once (A-424: an ask lapses at its expiry). +func lapsed(a oc.Ask, now time.Time) (time.Time, bool) { + at, err := time.Parse(time.RFC3339, a.Expires) + if err != nil || at.IsZero() { + return time.Time{}, false } + return at, !now.Before(at) } // isAssignerKey says whether an ask key is one of the assigner's, not the merge ask's key of before the Approve per merge went. @@ -187,10 +133,6 @@ func (t *Teller) raiseAssignerAsk(key string) (catchUp string) { t.logf("%s: the record of the ask %s could not be kept, so it is not raised: %v", key, id, err) return } - if !t.assignerRoom() { - t.waitForAssignerRoom(key, id) - return - } if err := t.Asker.Ask(a.Ask); err != nil { // Kept but not published (a transport fault, the router restarting): nothing writes the key again, so the ask is not // forgotten but waits, kept on the bus, to be asked again at the next end and at the teller's start (issue 1966, @@ -199,7 +141,6 @@ func (t *Teller) raiseAssignerAsk(key string) (catchUp string) { t.unheard(id) return } - t.assignerAsked(id) t.logf("%s: the assigner's ask %s is asked of the operator (%s)", key, id, a.Ask.Headline) return } diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks_test.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks_test.go index fe7ca68d..d82198e2 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks_test.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks_test.go @@ -184,25 +184,40 @@ func TestAnAssignerAskWaitsForRoomAndARefusalIsSaidAsADeliveryAsk(t *testing.T) // ackFor is the router's warrant for an option of level acknowledge, as the assigner's asks offer. func ackFor(a oc.Ask, option string) oc.Warrant { return warrantFor(a, option) } -// 1906/H5: given seven holds at once (as on 2026-10-25), when they are raised, then at most mostAssignerOpen are open at the -// router, and each hold answered lets the next waiting one be asked. -func TestABurstOfHoldsAsksNoMoreThanTheMostOpenAndTheNextWhenOneEnds(t *testing.T) { +// Design 47 G A-424 (was 1906/H5): given seven holds at once (as on 2026-10-25), when they are raised, then every one is asked of +// the operator at once: the channel keeps no count of open asks and the teller waits for no room. +func TestABurstOfHoldsIsAskedAtOnce(t *testing.T) { b := newBed(t) var held []oc.Ask for n := 0; n < 7; n++ { _, ask := b.holdOf(t, n, 1) held = append(held, ask) } - if got := b.askedIDs(); len(got) != mostAssignerOpen || got[0] != held[0].ID || got[1] != held[1].ID { - t.Fatalf("asked %v, want the first %d holds only; log:\n%s", got, mostAssignerOpen, b.logs.String()) - } - if len(b.dropped) != 0 || len(b.conds) != 0 { - t.Errorf("router dropped %v, conditions %+v", b.dropped, b.conds) - } - b.deliver(t, ackFor(held[0], "release")) got := b.askedIDs() - if len(got) != mostAssignerOpen+1 || got[len(got)-1] != held[2].ID { - t.Fatalf("asked %v after a hold was answered, want the third hold asked next; log:\n%s", got, b.logs.String()) + if len(got) != len(held) { + t.Fatalf("asked %v, want all %d holds; log:\n%s", got, len(held), b.logs.String()) + } + for i, a := range held { + if got[i] != a.ID { + t.Errorf("asked %v, want %s in the order raised", got, a.ID) + } + } + if len(b.dropped) != 0 || len(b.conds) != 0 || strings.Contains(b.logs.String(), "waits") { + t.Errorf("router dropped %v, conditions %+v, log:\n%s", b.dropped, b.conds, b.logs.String()) + } + // A-424: a key whose ask lapsed (its proposal ended) and a key of no kind the teller knows are dropped with a line, never asked. + key, _, ask := holdAskAt(t, 8, 1) + ask.Expires = "2000-01-01T00:00:00Z" + value, err := asks.EncodeAsk(key, asks.Ask{Ask: rawAsk(t, ask), Asking: 1}) + if err != nil { + t.Fatal(err) + } + b.assigner[key] = value + b.t.OnAssignerAsk(key) + b.t.OnAssignerAsk("placement.p-1") + if got := b.askedIDs(); len(got) != len(held) || !strings.Contains(b.logs.String(), key+" is dropped: its ask "+ask.ID+" lapsed at 2000-01-01T00:00:00Z") || + !strings.Contains(b.logs.String(), "placement.p-1 is dropped: it is no ask key of a kind the teller knows") { + t.Errorf("asked %v; log:\n%s", got, b.logs.String()) } } diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller.go index 561444db..b990a67e 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller.go @@ -314,9 +314,10 @@ func (t *Teller) said(h occ.Handled, w oc.Warrant, err error) { } } if h == occ.Acted || h == occ.Recorded || h == occ.Done { - // One of the teller's asks ended at the router, so it has room for one more: the first ask waiting is asked again. + // One of the teller's asks ended at the router: the asks it could not hand the router are asked again (A-424: no room + // is waited for). t.endWait(w.Ask) - t.askWaiting(1) + t.askWaiting() } } @@ -403,7 +404,7 @@ func (t *Teller) clear(askID string) { _ = t.Store.Delete(condKey(id)) } -// Room at the router (issue 1610). The router holds at most occ.MostOpen open asks of one asker and refuses another at once +// Room at the router (issue 1610; design 47 G A-424 took the limit away). The router held at most three open asks of one asker and refused another at once // in words, keeping no record of it (mesh-catalog modules/messenger cmd/messenger/asks.go:524-531, refuseAsk), so the // same router id may be asked again. Merges come in bursts: on 2026-10-21 at 11:21 a fourth merge ask was refused so, and // nothing asked it again, so the operator was never asked. Now an ask refused for want of room waits in the record @@ -524,7 +525,7 @@ func (t *Teller) endWait(id string) { // // An ask asked again whose word the teller did not hear (the router's warrants come on a plain subscription) waits once // more when the router holds no record of it: the router keeps none of a refused ask (review of 38116fe0). Up to -// occ.MostOpen are asked, the most the router can have room for. +// Every one waiting is asked: the channel holds no room to wait for (A-424). func (t *Teller) OnCurrent() { // The router's records are read outside the teller's lock (as catchUp's): a read that waits on the bus holds no warrant. t.mu.Lock() @@ -565,7 +566,7 @@ func (t *Teller) OnCurrent() { if changed && t.keepWaiting(ws, rec) != nil { return } - t.askWaiting(occ.MostOpen) + t.askWaiting() } // unheard puts an ask the teller holds open and the router holds no record of in the wait for room, once. @@ -584,9 +585,10 @@ func (t *Teller) unheard(id string) { } } -// askWaiting asks again the first n asks that wait for room and are not asked yet, dropping on the way every one the assigner -// no longer asks. One at an end: one ask ended, so there is room for one. -func (t *Teller) askWaiting(n int) { +// askWaiting asks again every ask that waits and is not asked yet, dropping on the way every one the assigner no longer asks: the +// channel holds no room to wait for (design 47 G A-424), so a wait is only an ask the router did not take or whose word was not +// heard, and one kept waiting before the change is asked at the next end or start. +func (t *Teller) askWaiting() { ws, rec, err := t.waiting() if err != nil { t.logf("%v", err) @@ -607,10 +609,6 @@ func (t *Teller) askWaiting(n int) { i++ continue } - if isAssignerKey(x.Key) && !t.assignerRoom() { - i++ // the assigner's asks hold their most open: it waits - continue - } a, why := t.stillAsked(x) if why != "" { t.logf("%s: the ask %s, waiting for room, is not asked again: %s", x.Key, x.ID, why) @@ -623,11 +621,7 @@ func (t *Teller) askWaiting(n int) { return } ws[i].Asked = true - t.assignerAsked(x.ID) t.logf("%s: the ask %s is asked of the operator again (refused %d times for want of room)", x.Key, x.ID, x.Refusals) - if n--; n <= 0 { - return - } i++ } } diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller_test.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller_test.go index 9ddb8565..f64c4a38 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller_test.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller_test.go @@ -277,8 +277,8 @@ func TestAnAssignersKeyBecomesOneRouterAskAndDeletingItCancelsIt(t *testing.T) { if n := len(b.askedOf(oc.AcceptSubjectCancel(tellerModule))); n != 1 { t.Errorf("the ask was cancelled %d times", n) } - // Issue 774: teller_end_ask ends one by hand, named by its key or its router id; the router's word that it ended asks the - // one waiting for room again (the assigner's asks hold at most mostAssignerOpen places, the third waits). + // Issue 774: teller_end_ask ends one by hand, named by its key or its router id; nothing waits for room behind it (design 47 + // G A-424: every ask is asked at once). for _, c := range []struct { name string by func(key string, ask oc.Ask) string @@ -290,32 +290,34 @@ func TestAnAssignersKeyBecomesOneRouterAskAndDeletingItCancelsIt(t *testing.T) { b := newBed(t) k1, first := b.holdOf(t, 1, 1) b.holdOf(t, 2, 1) - _, third := b.holdOf(t, 3, 1) + b.holdOf(t, 3, 1) + _, third := b.holdOf(t, 4, 1) r := b.t.EndAsk(c.by(k1, first), "the hold no longer holds", "lead@shanks") cancels := b.askedOf(oc.AcceptSubjectCancel(tellerModule)) if !r.Ended || r.ID != first.ID || r.Key != k1 || len(cancels) != 1 || string(cancels[0].body) != `{"id":"`+first.ID+`"}` { t.Fatalf("end = %+v, cancels %+v", r, cancels) } b.deliver(t, oc.Warrant{Ask: first.ID, Asker: tellerModule, Outcome: occ.OutcomeCancelled, At: occ.FormatTime(now), AskDigest: occ.Digest(first)}) - if got := b.askedIDs(); len(got) != 3 || got[2] != third.ID { - t.Errorf("asks = %v, want the waiting %s asked once the ask ended by hand left", got, third.ID) + if got := b.askedIDs(); len(got) != 4 || got[3] != third.ID { + t.Errorf("asks = %v, want all four asked at once, %s the last, and none asked again", got, third.ID) } if again := b.t.EndAsk(k1, "again", "lead@shanks"); again.Ended || len(b.askedOf(oc.AcceptSubjectCancel(tellerModule))) != 1 { t.Errorf("a second end = %+v: an ended ask is left", again) } }) } - t.Run("774: an ask waiting for room is dropped from the wait; a name the teller holds no ask under is said", func(t *testing.T) { + t.Run("774: the fourth ask of one asker is open and ended by hand at the router; a name the teller holds no ask under is said", func(t *testing.T) { b := newBed(t) _, first := b.holdOf(t, 1, 1) b.holdOf(t, 2, 1) - _, third := b.holdOf(t, 3, 1) - if r := b.t.EndAsk(third.ID, "asked about what no longer holds", "lead@shanks"); !r.Ended || len(b.askedOf(oc.AcceptSubjectCancel(tellerModule))) != 0 { - t.Fatalf("end of a waiting ask = %+v", r) + b.holdOf(t, 3, 1) + _, third := b.holdOf(t, 4, 1) + if r := b.t.EndAsk(third.ID, "asked about what no longer holds", "lead@shanks"); !r.Ended || len(b.askedOf(oc.AcceptSubjectCancel(tellerModule))) != 1 { + t.Fatalf("end of the fourth ask = %+v", r) } b.deliver(t, warrantFor(first, "keep")) - if got := b.askedIDs(); len(got) != 2 { - t.Errorf("asks = %v: the ask ended while it waited was asked again", got) + if got := b.askedIDs(); len(got) != 4 { + t.Errorf("asks = %v: an ask was asked again after an end", got) } if r := b.t.EndAsk("hold.nothing.here", "a typo", "lead@shanks"); r.Ended || !strings.Contains(r.Says, "holds no ask") { t.Errorf("end of an unknown ask = %+v", r) diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/viewanswers.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/viewanswers.go index 5673e82e..81b026c1 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/viewanswers.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/viewanswers.go @@ -42,11 +42,20 @@ func (t *Teller) OnAssignerAsk(key string) { func (t *Teller) onAssignerAsk(key string) string { t.mu.Lock() defer t.mu.Unlock() - if _, err := viewstate.ViewAnswerKey(key); err != nil { - t.logf("the assigner's key %s is left and never answered from the view: %v", key, err) + if !isAssignerKey(key) { + t.logf("the assigner's key %s is dropped: it is no ask key of a kind the teller knows, so it is asked of nobody", key) return "" } - t.fillFromView(key) + if a, found, err := t.assignerAsk(key); err == nil && found { + if at, gone := lapsed(a.Ask, t.now()); gone { + t.logf("the assigner's key %s is dropped: its ask %s lapsed at %s (what it asked about has ended), so it is asked of nobody", key, a.Ask.ID, at.UTC().Format(time.RFC3339)) + return "" + } + } + // The view only fills an answer already given there; one it cannot read never holds the raise back (design 47 G A-424). + if _, err := viewstate.ViewAnswerKey(key); err == nil { + t.fillFromView(key) + } return t.raiseAssignerAsk(key) } @@ -66,7 +75,7 @@ func (t *Teller) fillFromView(askKey string) { } rawAnswer, at, found, err := t.viewAnswer(viewKey) if err != nil { - t.logf("%s: the view's answer could not be read, so the ask is left: %v", askKey, err) + t.logf("%s: the view's answer could not be read, so none is filled from it; the ask is raised all the same: %v", askKey, err) return } if !found { diff --git a/modules/mesh-delivery-teller/internal/ends/ends.go b/modules/mesh-delivery-teller/internal/ends/ends.go index a6f56eb3..718238e8 100644 --- a/modules/mesh-delivery-teller/internal/ends/ends.go +++ b/modules/mesh-delivery-teller/internal/ends/ends.go @@ -1,8 +1,7 @@ // Package ends is the teller's recovery tool teller_end_ask and the value it writes (issue 774; the instruction "tools are -// how a module is spoken to"). An ask the teller holds open at the router keeps one of the three places the router gives -// its asker (asks.MostOpen) until it is answered, it lapses, or the gate or the assigner takes its key away. When that last -// never comes (on 2026-10-31 two merge asks of pull requests merged by another path held two places for a day, and a -// assignments ask was refused for want of room), a person ends the ask by hand. The teller's process serves no request +// how a module is spoken to"). An ask the teller holds open at the router stays offered until it is answered, it lapses, or the +// assigner takes its key away; the channel holds no places to keep (design 47 G A-424). When the question it asks is gone and its +// key never goes, a person ends the ask by hand. The teller's process serves no request // subject (ADR 0437 §4), so the tool writes an end into the teller's state ends, which the teller watches, carries out // and answers there, as the indexer answers indexer_take_in. package ends diff --git a/modules/mesh-grants/cmd/mesh-grants/main.go b/modules/mesh-grants/cmd/mesh-grants/main.go index 31f13c01..7c7c68af 100644 --- a/modules/mesh-grants/cmd/mesh-grants/main.go +++ b/modules/mesh-grants/cmd/mesh-grants/main.go @@ -177,7 +177,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro return err } fv.Assignment = assignment - f.Part = &grants.Part{Read: fv, Call: conn, Store: ownStore{conn}, Emit: emitting{conn}, Views: fv, FirstViewContext: ctx, + f.Part = &grants.Part{Read: fv, Call: conn, Store: grants.BigValues(ownStore{conn}, sealedObjects{ctx: ctx, js: js}), Emit: emitting{conn}, Views: fv, FirstViewContext: ctx, Create: creating{ctx: ctx, js: js}, Consumers: creating{ctx: ctx, js: js}, NamedPurge: creating{ctx: ctx, js: js}, Objects: sealedObjects{ctx: ctx, js: js}, Purging: ownPurging{ctx: ctx, js: js, module: account.Module}, Logf: logger.Printf, Bus: grants.BusAddress{URL: account.URL, Fingerprint: account.Fingerprint}} diff --git a/modules/mesh-grants/cmd/mesh-grants/sealed.go b/modules/mesh-grants/cmd/mesh-grants/sealed.go index ab0cf73b..d1d16683 100644 --- a/modules/mesh-grants/cmd/mesh-grants/sealed.go +++ b/modules/mesh-grants/cmd/mesh-grants/sealed.go @@ -53,3 +53,14 @@ func (o sealedObjects) DeleteObject(name string) error { } return nil } + +// GetObject reads one object of the bucket whole: what the keys `list` and `pass` of the state user-list name (design 47 G A-373). +func (o sealedObjects) GetObject(name string) ([]byte, error) { + ctx, cancel := context.WithTimeout(o.ctx, requestWithin) + defer cancel() + s, err := o.store(ctx) + if err != nil { + return nil, err + } + return s.GetBytes(ctx, name) +} diff --git a/modules/mesh-grants/cmd/mesh-grants/tools.go b/modules/mesh-grants/cmd/mesh-grants/tools.go index c71b8a54..94955e71 100644 --- a/modules/mesh-grants/cmd/mesh-grants/tools.go +++ b/modules/mesh-grants/cmd/mesh-grants/tools.go @@ -320,7 +320,7 @@ func recordHandActAs(cause string) func(what, why string) error { func serveTools() error { tv := &toolViews{} gate := newSeatGate() - p := &grants.Part{Read: runtimeReader{views: tv}, Call: runtimeBus{}, Store: runtimeStore{}, Emit: runtimeBus{}, SeatList: gate} + p := &grants.Part{Read: runtimeReader{views: tv}, Call: runtimeBus{}, Store: grants.BigValues(runtimeStore{}, nil), Emit: runtimeBus{}, SeatList: gate} // The reader asks through the runtime, which serves once Serve has its channel. go func() { <-stdio.Served() diff --git a/modules/mesh-grants/grants_test.go b/modules/mesh-grants/grants_test.go index 00e7835d..ce7f8560 100644 --- a/modules/mesh-grants/grants_test.go +++ b/modules/mesh-grants/grants_test.go @@ -1817,7 +1817,7 @@ func TestGrants(t *testing.T) { a, err := p.AssertOne("mod-x") am, _ := a.(map[string]any) as, _ := am["assertion"].(grants.Assertion) - if err != nil || as.Asserted || as.Says != grants.ShadowAsserts || len(as.Items) != 3 || am["asked"] == nil { + if err != nil || as.Asserted || as.Says != grants.ShadowAsserts || len(as.Items) != 4 || am["asked"] == nil { t.Fatalf("assert = %+v, %v", a, err) } for _, it := range as.Items { @@ -2162,7 +2162,7 @@ func TestGrants(t *testing.T) { return a } first := p.Compose() - if !slices.Equal(b.creates, []string{"LOG_mod-x_history", "THINGS"}) || len(first.Asserted) != 1 || + if !slices.Equal(b.creates, []string{"LOG_mod-x_history", "OBJ_mod-x_kept-objects", "THINGS"}) || len(first.Asserted) != 1 || !strings.HasPrefix(first.Asserted[0], "mod-x at ") || !slices.Contains(b.events, grants.EventAsserted) { t.Fatalf("the first pass created %v, said %v, events %v", b.creates, first.Asserted, b.events) } @@ -2185,7 +2185,7 @@ func TestGrants(t *testing.T) { } } } - if again := p.Compose(); len(again.Asserted) != 0 || len(b.creates) != 2 { + if again := p.Compose(); len(again.Asserted) != 0 || len(b.creates) != 3 { t.Errorf("a pass with everything held created again: %v, %v", again.Asserted, b.creates) } // THINGS deleted since: not made again at the same manifest, said; a hand assert (the tool, asking the process) @@ -2194,11 +2194,11 @@ func TestGrants(t *testing.T) { b.streams = slices.DeleteFunc(b.streams, func(s map[string]any) bool { return s["name"] == "THINGS" }) b.mu.Unlock() gone := p.Compose() - if len(b.creates) != 2 || !strings.Contains(strings.Join(gone.NotAsserted, " "), "THINGS: created at this manifest and gone since") { + if len(b.creates) != 3 || !strings.Contains(strings.Join(gone.NotAsserted, " "), "THINGS: created at this manifest and gone since") { t.Errorf("a stream gone since was made again by itself, or not said: %v, %v", b.creates, gone.NotAsserted) } tool := partOn(b) - if got, err := tool.AssertOne("mod-x"); err != nil || fmt.Sprint(got) == "" || len(b.creates) != 2 { + if got, err := tool.AssertOne("mod-x"); err != nil || fmt.Sprint(got) == "" || len(b.creates) != 3 { t.Fatalf("the tool = %v, %v, creates %v: it asks, and creates nothing itself", got, err, b.creates) } if hand := p.Compose(); len(hand.Asserted) != 1 || b.creates[len(b.creates)-1] != "THINGS" { @@ -4106,7 +4106,7 @@ func TestGrants(t *testing.T) { p.Consumers = b b.consumers = map[string][]map[string]any{"EVENTS": {{"name": "b_other", "filters": []string{"x"}, "max_deliver": 5}}} res := p.Compose() - if res.Consumers == nil || !slices.Equal(res.Consumers.Created, []string{"EVENTS.b_mod-c"}) { + if res.Consumers == nil || !slices.Equal(res.Consumers.Created, []string{"EVENTS.b_mod-c", "EVENTS.b_mod-c_tools"}) { t.Fatalf("with no lease key: %+v", res.Consumers) } var made map[string]any @@ -4119,7 +4119,7 @@ func TestGrants(t *testing.T) { t.Errorf("b_mod-c was made as %v, not as the controller makes it", made) } res = p.Compose() - if len(res.Consumers.Created) != 0 || len(res.Consumers.Missing) != 0 || len(b.consumerCreates) != 1 { + if len(res.Consumers.Created) != 0 || len(res.Consumers.Missing) != 0 || len(b.consumerCreates) != 2 { t.Errorf("a consumer the bus holds was asked again: %+v, %v", res.Consumers, b.consumerCreates) } // A held consumer that differs is never changed by a pass: it is raised as a condition naming it, and brought to @@ -5082,13 +5082,14 @@ func TestASeatNamedViewIsResolvedToItsHolder(t *testing.T) { holder string consumes []string want []string + asks []string // the holder's first-view tools the view grants beside its events }{ - {"resolved to the holder on record", "mesh-delivery-assigner", []string{"seat:mesh-module-assigner.views.assignments", "mesh-vault.node-logins"}, - []string{"mesh-delivery-assigner.views.assignments", "mesh-vault.node-logins"}}, + {"resolved to the holder on record", "mesh-delivery-assigner", []string{"seat:mesh-module-assigner.views.assignments", "some-provider.node-logins"}, + []string{"mesh-delivery-assigner.views.assignments", "some-provider.node-logins"}, []string{"mesh-delivery-assigner.assignments"}}, {"a new holder is granted with no change of the manifest", "assigner-two", []string{"seat:mesh-module-assigner.views.seat-holders"}, - []string{"assigner-two.views.seat-holders"}}, + []string{"assigner-two.views.seat-holders"}, []string{"assigner-two.seat-holders"}}, {"no holder on record stays as written", "", []string{"seat:mesh-module-assigner.views.assignments"}, - []string{"seat:mesh-module-assigner.views.assignments"}}, + []string{"seat:mesh-module-assigner.views.assignments"}, nil}, } { t.Run(row.name, func(t *testing.T) { in := holder(row.holder) @@ -5097,13 +5098,18 @@ func TestASeatNamedViewIsResolvedToItsHolder(t *testing.T) { } in.Manifests = map[string]catalogue.Manifest{"mod-t": consumer(row.consumes...)} recs, _ := grants.ListRecords(in) - var got []string + var got, asks []string for _, d := range recs.Assigned["a"] { - got = d.Consumes + got, asks = d.Consumes, d.Invokes } if !slices.Equal(got, row.want) { t.Errorf("consumes = %v, want %v", got, row.want) } + for _, a := range row.asks { + if !slices.Contains(asks, a) { + t.Errorf("invokes = %v, want %s among them: the reader's first view is asked of the holder's tool", asks, a) + } + } }) } } @@ -5207,3 +5213,553 @@ func (h heldHalf) Revision() (meshwants.AssignmentRevision, bool) { } return *h.rev, true } + +// TestPassBeforeTheCatalogHalfComposesFromTheTrunkToo is design 47 G A-363: while the catalog half is unread, each account is composed +// from the manifest the indexer's `modules` first view names for its module (the trunk's) in union with what its want's entry gives, never +// from the list in force alone, so the first parts of a new build get their subjects before any of them serves. +func TestPassBeforeTheCatalogHalfComposesFromTheTrunkToo(t *testing.T) { + older := strings.Replace(xManifest, `{"name":"kept","history":3}`, `{"name":"older"}`, 1) + rows := []struct { + name string + entry bool // the want's entry is answered (the older build); else it is not answered + wantsOld bool + newest string // "entry": the want names a newest build whose entry is answered; "none": it names one with no entry + }{ + {"the want's entry is not answered", false, false, ""}, + {"the want names an entry that is asked", false, false, ""}, + {"the want's entry is an older build", true, true, ""}, + // A-414: a running build with no entry composes from its want's newest build's entry; with neither entry it carries as today. + {"no entry for the fingerprint but one for newest", false, true, "entry"}, + {"neither entry", false, false, "none"}, + } + for _, row := range rows { + t.Run(row.name, func(t *testing.T) { + b := fixture() + if strings.Contains(row.name, "asked") { + b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: "src2:" + strings.Repeat("cd", 32), Composed: "sha256:" + strings.Repeat("ef", 32)}) + b.put(grants.ReadHave, "a.mod-x", nodeengine.HaveByNodeModuleValue{V: keys.Version, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK, + Fp: "src2:" + strings.Repeat("cd", 32)}) + b.entriesAsked = true + } + if row.entry { + digest := meshcatalogclient.ManifestDigest([]byte(older)) + b.put(grants.ReadManifests, digest, meshcatalog.ManifestsByDigestValue{V: keys.Version, Module: "mod-x", Manifest: older}) + fp := "src2:" + strings.Repeat("cd", 32) + b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: fp, Composed: "sha256:" + strings.Repeat("ef", 32)}) + b.entry(fp, digest) + } + if row.newest != "" { + fp, newest := "src2:"+strings.Repeat("cd", 32), "src2:"+strings.Repeat("ab", 32) + b.put(grants.ReadWants, "want.a.mod-x", meshwantsclient.Want{V: keys.Version, Fp: fp, Newest: newest, Rule: meshwantsclient.RuleStep, Composed: "sha256:" + strings.Repeat("ef", 32)}) + if row.newest == "entry" { + digest := meshcatalogclient.ManifestDigest([]byte(older)) + b.put(grants.ReadManifests, digest, meshcatalog.ManifestsByDigestValue{V: keys.Version, Module: "mod-x", Manifest: older}) + b.entry(newest, digest) + } + } + b.mu.Lock() + b.catalogWaited = []string{"the catalog half of the branch main"} + b.mu.Unlock() + in := grants.ReadInputs(b, &grants.Manifests{}) + if in.CatalogUnread == "" { + t.Fatal("the catalog half is not unread") + } + if row.newest == "none" && !slices.ContainsFunc(in.Gaps, func(g grants.Gap) bool { + return g.Input == "wanted manifests" && strings.Contains(g.Why, "newest build is not held") + }) { + t.Errorf("no gap says why the want's newest build was not taken: %+v", in.Gaps) + } + // An entry asked and not answered is no failed read while the catalog half is unread: the trunk's manifest composes the + // account and the list is not held for it. + if f := in.ReadFailed(); len(f) > 0 { + t.Errorf("the unread catalog half's asked entry is a failed read: %v", f) + } + recs, _ := grants.ListRecords(in) + users, err := grants.ComposeUsers(recs) + if err != nil { + t.Fatal(err) + } + var got []string + for _, u := range users { + if u.User == "a.mod-x" { + got = append(got, u.Publish...) + got = append(got, u.Subscribe...) + } + } + if !slices.ContainsFunc(got, func(s string) bool { return strings.Contains(s, "kept") }) { + t.Errorf("a.mod-x is not granted the trunk manifest's state kept: %v", got) + } + if row.wantsOld && !slices.ContainsFunc(got, func(s string) bool { return strings.Contains(s, "older") }) { + t.Errorf("a.mod-x is not granted its want's entry's state older: %v", got) + } + }) + } +} + +// Design 47 G A-371: a seat stream the part reads whole at its start, that it creates itself and the bus does not hold yet, has an +// empty first view and is no wait: with the catalog half unread and the stream's read waiting, a list that changes is sealed and not +// held for a failed read; with the stream held on the bus it still waits. +func TestAStreamThePartCreatesAndTheBusLacksIsAnEmptyFirstView(t *testing.T) { + const stream = "SEAT_node-engine_running" + days, mib := 7, 64 + gate := keptGate{seatdef.Definition{Seat: "node-engine", Events: []seatdef.Message{ + {Name: "running", Keep: &seatdef.Keep{Object: true, MaxAgeDays: &days, MaxMiB: &mib}}}}} + for _, row := range []struct { + name string + held bool // the bus holds the stream, so the read is a wait + }{{"the bus lacks the stream", false}, {"the bus holds the stream", true}} { + t.Run(row.name, func(t *testing.T) { + b := fixture() + busKey, err := seal.GenerateKeyPair() + if err != nil { + t.Fatal(err) + } + b.put(grants.ReadHave, "a.nats", nodeengine.HaveByNodeModuleValue{V: keys.Version, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK, + UserList: &nodeengine.UserListWritten{Source: grantsstate.GrantsUserListSource, Revision: 8, Wanted: "sha256:aa", Digest: "sha256:aa", Users: 5, + Key: busKey.PublicKey, Follows: grantsstate.FollowGrants}}) + for _, u := range shadowOf(t, b) { + b.put(grants.ReadAccounts, u.User, map[string]any{"user": u.User, "hash": "$2a$10$x", "generation": 1, "fingerprint": "sha256:1"}) + } + p := partOn(b) + p.Bus = grants.BusAddress{URL: "nats://a.mesh:4222", Fingerprint: "ab"} + p.Objects = &fakeObjects{} + p.Compose() + if g, _, _ := p.Sealed(); g.Digest == "" { + t.Fatal("no list in force sealed") + } + // Now the catalog half is unread, the read of the stream waits, and the list changes (mod-x runs on b too). + b.mu.Lock() + b.catalogWaited = []string{"the catalog half of the branch main"} + if row.held { + b.streams = append(b.streams, map[string]any{"name": stream, "subjects": []string{}, "retention": "limits"}) + } + b.mu.Unlock() + p.SeatList = gate + p.ReadingRunning(stream) + b.assign("b", "mod-x") + res := p.Compose() + if res.Sealed == nil { + t.Fatal("the pass says nothing of the sealed list") + } + reads := p.StreamReads() + if absent := len(res.StreamsAbsent) == 1 && len(reads) == 1 && reads[0].Absent != "" && reads[0].State == "waiting"; absent == row.held { + t.Errorf("the stream said absent = %v (pass %v, status %+v), want %v", absent, res.StreamsAbsent, reads, !row.held) + } + if held := strings.Contains(res.Sealed.Why, "a read of this pass failed"); held != row.held { + t.Errorf("held for a failed read = %v, want %v: %q", held, row.held, res.Sealed.Why) + } + }) + } +} + +type keptObjects map[string][]byte + +func (m keptObjects) PutObject(name string, data []byte) error { m[name] = data; return nil } +func (m keptObjects) GetObject(name string) ([]byte, error) { return m[name], nil } + +// Design 47 G A-373: with the list kept as an object the tools bundle cannot open, the seat verb withheld still answers, from the small key +// the process keeps beside it. +func TestWithheldIsAnsweredWhileTheListIsAnObject(t *testing.T) { + b := fixture() + process := partOn(b) + process.Store = grants.BigValues(ownStore{b}, keptObjects{}) + process.Compose() + tools := partOn(b) + tools.Store = grants.BigValues(ownStore{b}, nil) + if got, err := tools.WithheldOn("a"); err != nil || got.Node != "a" { + t.Errorf("withheld from the tools = %+v, %v", got, err) + } +} + +// Design 47 G A-383: a right every account carries (the streams' names, A-382) is written to every account of a list, one kept or held +// from the list in force included: a held module's account of a pass before the catalog half is read gains it and loses nothing. +func TestAKeptAccountGainsTheRightEveryAccountCarries(t *testing.T) { + const names = "$JS.API.STREAM.NAMES" + b := fixture() + busKey, err := seal.GenerateKeyPair() + if err != nil { + t.Fatal(err) + } + b.put(grants.ReadHave, "a.nats", nodeengine.HaveByNodeModuleValue{V: keys.Version, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK, + UserList: &nodeengine.UserListWritten{Source: grantsstate.GrantsUserListSource, Revision: 8, Wanted: "sha256:aa", Digest: "sha256:aa", Users: 5, + Key: busKey.PublicKey, Follows: grantsstate.FollowGrants}}) + for _, u := range shadowOf(t, b) { + b.put(grants.ReadAccounts, u.User, map[string]any{"user": u.User, "hash": "$2a$10$x", "generation": 1, "fingerprint": "sha256:1"}) + } + p := partOn(b) + p.Bus = grants.BusAddress{URL: "nats://a.mesh:4222", Fingerprint: "ab"} + p.Objects = &fakeObjects{} + p.Compose() + first, _, _ := p.Sealed() + if first.Digest == "" { + t.Fatal("no list in force sealed") + } + // The list in force lacks the right for b.mod-y (written before the rule). + key := grants.SealedUserKey(first.Digest, "b.mod-y") + var u grants.User + if err := json.Unmarshal(b.own[grants.StateUserList][key], &u); err != nil { + t.Fatal(err) + } + u.Publish = slices.DeleteFunc(slices.Clone(u.Publish), func(s string) bool { return s == names }) + b.own[grants.StateUserList][key], _ = json.Marshal(u) + // Its manifest is now held, the catalog half is unread, and the list changes (mod-x runs on b too). + b.refuse("mod-y", yManifest, "held for the test") + b.mu.Lock() + b.catalogWaited = []string{"the catalog half of the branch main"} + b.mu.Unlock() + b.assign("b", "mod-x") + p.Compose() + next, _, _ := p.Sealed() + if next.Digest == first.Digest { + t.Fatal("the list did not change: the pass kept the list in force") + } + var got grants.User + if err := json.Unmarshal(b.own[grants.StateUserList][grants.SealedUserKey(next.Digest, "b.mod-y")], &got); err != nil { + t.Fatal(err) + } + if !slices.Contains(got.Publish, names) { + t.Errorf("the kept account b.mod-y lacks %s: %v", names, got.Publish) + } + for _, s := range u.Publish { + if !slices.Contains(got.Publish, s) { + t.Errorf("the kept account lost %s", s) + } + } +} + +// Design 47 G A-385: an account kept beyond a pass, a tool runner's included, is the union of the list in force and what the pass composes +// for it (here from the manifest the held runner's running build was judged on), never the list in force alone: before the catalog half is +// read, a held runner carrying a module with a state gains that state's rights (a bound ledger's state is the same kind) and loses nothing. +func TestAHeldRunnerIsWrittenAsTheUnionOfTheListInForceAndWhatIsComposed(t *testing.T) { + const runner = `{"module":"node-tools","version":"1","tool-runner":true,"own-secrets":{"broker":"/var/lib/nt/broker"}}` + const carried = `{"module":"mod-c","version":"1","tools":["t"],"state":["kept"]}` + b := fixture() + b.manifestOf("node-tools", runner) + b.manifestOf("mod-c", carried) + b.assign("a", "node-tools") + b.assign("a", "mod-c") + busKey, err := seal.GenerateKeyPair() + if err != nil { + t.Fatal(err) + } + b.put(grants.ReadHave, "a.nats", nodeengine.HaveByNodeModuleValue{V: keys.Version, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK, + UserList: &nodeengine.UserListWritten{Source: grantsstate.GrantsUserListSource, Revision: 8, Wanted: "sha256:aa", Digest: "sha256:aa", Users: 5, + Key: busKey.PublicKey, Follows: grantsstate.FollowGrants}}) + for _, u := range shadowOf(t, b) { + b.put(grants.ReadAccounts, u.User, map[string]any{"user": u.User, "hash": "$2a$10$x", "generation": 1, "fingerprint": "sha256:1"}) + } + p := partOn(b) + p.Bus = grants.BusAddress{URL: "nats://a.mesh:4222", Fingerprint: "ab"} + p.Objects = &fakeObjects{} + p.Compose() + first, _, _ := p.Sealed() + key := grants.SealedUserKey(first.Digest, "a.node-tools") + var was grants.User + if err := json.Unmarshal(b.own[grants.StateUserList][key], &was); err != nil { + t.Fatal(err) + } + isLedger := func(s string) bool { return strings.Contains(s, "mod-c_kept") } + if !slices.ContainsFunc(was.Publish, isLedger) { + t.Fatalf("the runner of a composes no right on the state of its carried module mod-c: %v", was.Publish) + } + // The list in force holds the runner without the ledger (written before the carried module had one), the runner's manifest is held, + // its running build's manifest is what its have names, and the catalog half is unread. + was.Publish = slices.DeleteFunc(slices.Clone(was.Publish), isLedger) + b.own[grants.StateUserList][key], _ = json.Marshal(was) + digest := meshcatalogclient.ManifestDigest([]byte(runner)) + fp := "src2:" + strings.Repeat("cd", 32) + b.put(grants.ReadHave, "a.node-tools", nodeengine.HaveByNodeModuleValue{V: keys.Version, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK, Fp: fp}) + b.entry(fp, digest) + b.refuse("node-tools", runner, "held for the test") + b.mu.Lock() + b.catalogWaited = []string{"the catalog half of the branch main"} + b.mu.Unlock() + b.assign("b", "mod-x") // the list changes + p.Compose() + next, _, _ := p.Sealed() + if next.Digest == first.Digest { + t.Fatal("the list did not change: the pass kept the list in force") + } + var got grants.User + if err := json.Unmarshal(b.own[grants.StateUserList][grants.SealedUserKey(next.Digest, "a.node-tools")], &got); err != nil { + t.Fatal(err) + } + if !slices.ContainsFunc(got.Publish, isLedger) { + t.Errorf("the held runner lacks its carried module's state rights: %v", got.Publish) + } + for _, s := range was.Publish { + if !slices.Contains(got.Publish, s) { + t.Errorf("the held runner lost %s", s) + } + } +} + +// Design 47 G A-385 (their bindings): a runner carrying a module with a bound ledger reads that ledger's state, its indexes, its history +// and its snapshots on its own connection, and writes its state; it publishes on no history (only the ledger account does, ADR 0597 §9). +func TestARunnerCarryingABoundLedgerReadsItsStateHistoryAndSnapshots(t *testing.T) { + const runner = `{"module":"node-tools","version":"1","tool-runner":true,"own-secrets":{"broker":"/var/lib/nt/broker"}}` + const carried = `{"module":"mod-c","version":"1","tools":["t"],"requires":[{"name":"records","storage":"ledger","template":"ledger",` + + `"types":[{"name":"decision","schema":{},"operations":[{"name":"propose","effect":"set-fields"}]}]}]}` + b := fixture() + b.manifestOf("node-tools", runner) + b.manifestOf("mod-c", carried) + b.assign("a", "node-tools") + b.assign("a", "mod-c") + busKey, err := seal.GenerateKeyPair() + if err != nil { + t.Fatal(err) + } + b.put(grants.ReadHave, "a.nats", nodeengine.HaveByNodeModuleValue{V: keys.Version, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK, + UserList: &nodeengine.UserListWritten{Source: grantsstate.GrantsUserListSource, Revision: 8, Wanted: "sha256:aa", Digest: "sha256:aa", Users: 5, + Key: busKey.PublicKey, Follows: grantsstate.FollowGrants}}) + for _, u := range shadowOf(t, b) { + b.put(grants.ReadAccounts, u.User, map[string]any{"user": u.User, "hash": "$2a$10$x", "generation": 1, "fingerprint": "sha256:1"}) + } + p := partOn(b) + p.Bus = grants.BusAddress{URL: "nats://a.mesh:4222", Fingerprint: "ab"} + p.Objects = &fakeObjects{} + binding := membership.BusBinding{Local: "records", Storage: "ledger", Template: "ledger", Stream: "mod-c_records", History: "mod-c_records", + Subject: "mesh.ledger.mod-c.records.history", State: "mod-c_records_state", Snapshot: "mesh.ledger.mod-c.records.snapshot"} + p.Compose() // the pass that learns the bus module is the broker + body, _ := json.Marshal(grants.BrokerEvent{V: 1, Module: "mod-c", Local: "records", Storage: "ledger", Template: "ledger", Binding: binding}) + if _, err := p.HearBroker("mesh.seat.mesh-broker.event.created", body, p.Brokers()); err != nil { + t.Fatal(err) + } + p.Compose() + sealed, _, _ := p.Sealed() + var got grants.User + if err := json.Unmarshal(b.own[grants.StateUserList][grants.SealedUserKey(sealed.Digest, "a.node-tools")], &got); err != nil { + t.Fatal(err) + } + for _, want := range []string{ + "$JS.API.STREAM.INFO.KV_mod-c_records_state", "$JS.API.DIRECT.GET.KV_mod-c_records_state.>", "$KV.mod-c_records_state.>", + "$JS.API.CONSUMER.CREATE.KV_mod-c_records_state.>", "$JS.API.DIRECT.GET.mod-c_records.>", "$JS.API.CONSUMER.CREATE.mod-c_records.>", + "$JS.API.DIRECT.GET.mod-c_records_snapshot.>"} { + if !slices.Contains(got.Publish, want) { + t.Errorf("the runner of a lacks %s", want) + } + } + for _, no := range []string{"mesh.ledger.mod-c.records.history.>", "mesh.ledger.mod-c.records.snapshot.>"} { + if slices.Contains(got.Publish, no) { + t.Errorf("the runner may publish on the ledger's %s", no) + } + } +} + +// A-386: a runner kept as it runs (no manifest placed on its node says it is one) gains what its carried modules' bindings give, and loses nothing. +func TestARunnerKeptAsItRunsGainsWhatItsCarriedModulesBindingsGive(t *testing.T) { + const runner = `{"module":"node-tools","version":"1","tool-runner":true,"own-secrets":{"broker":"/var/lib/nt/broker"}}` + const carried = `{"module":"mod-c","version":"1","tools":["t"],"requires":[{"name":"records","storage":"ledger","template":"ledger",` + + `"types":[{"name":"decision","schema":{},"operations":[{"name":"propose","effect":"set-fields"}]}]}]}` + b := fixture() + b.manifestOf("node-tools", runner) + b.manifestOf("mod-c", carried) + b.assign("a", "node-tools") + b.assign("a", "mod-c") + busKey, err := seal.GenerateKeyPair() + if err != nil { + t.Fatal(err) + } + b.put(grants.ReadHave, "a.nats", nodeengine.HaveByNodeModuleValue{V: keys.Version, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK, + UserList: &nodeengine.UserListWritten{Source: grantsstate.GrantsUserListSource, Revision: 8, Wanted: "sha256:aa", Digest: "sha256:aa", Users: 5, + Key: busKey.PublicKey, Follows: grantsstate.FollowGrants}}) + for _, u := range shadowOf(t, b) { + b.put(grants.ReadAccounts, u.User, map[string]any{"user": u.User, "hash": "$2a$10$x", "generation": 1, "fingerprint": "sha256:1"}) + } + p := partOn(b) + p.Bus = grants.BusAddress{URL: "nats://a.mesh:4222", Fingerprint: "ab"} + p.Objects = &fakeObjects{} + binding := membership.BusBinding{Local: "records", Storage: "ledger", Template: "ledger", Stream: "mod-c_records", History: "mod-c_records", + Subject: "mesh.ledger.mod-c.records.history", State: "mod-c_records_state", Snapshot: "mesh.ledger.mod-c.records.snapshot"} + p.Compose() // the pass that learns the bus module is the broker + body, _ := json.Marshal(grants.BrokerEvent{V: 1, Module: "mod-c", Local: "records", Storage: "ledger", Template: "ledger", Binding: binding}) + if _, err := p.HearBroker("mesh.seat.mesh-broker.event.created", body, p.Brokers()); err != nil { + t.Fatal(err) + } + p.Compose() + first, _, _ := p.Sealed() + key := grants.SealedUserKey(first.Digest, "a.node-tools") + var was grants.User + if err := json.Unmarshal(b.own[grants.StateUserList][key], &was); err != nil { + t.Fatal(err) + } + isLedger := func(s string) bool { return strings.Contains(s, "mod-c_records") } + if !slices.ContainsFunc(was.Publish, isLedger) || !slices.Contains(was.Publish, "mesh.control.a.tools-alive") { + t.Fatalf("the runner of a composes no ledger rights, or is no runner: %v", was.Publish) + } + // The list in force holds the runner without them (the pre-G runner's), and now no manifest placed on a says it is the tool + // runner: the pass keeps it as it runs (ADR 0601 §4), and the list changes. + was.Publish = slices.DeleteFunc(slices.Clone(was.Publish), isLedger) + b.own[grants.StateUserList][key], _ = json.Marshal(was) + b.manifestOf("node-tools", strings.Replace(runner, `"tool-runner":true,`, "", 1)) + b.assign("b", "mod-x") + p.Compose() + sealed, _, _ := p.Sealed() + if sealed.Digest == first.Digest { + t.Fatal("the list did not change") + } + var got grants.User + if err := json.Unmarshal(b.own[grants.StateUserList][grants.SealedUserKey(sealed.Digest, "a.node-tools")], &got); err != nil { + t.Fatal(err) + } + for _, want := range []string{ + "$JS.API.STREAM.INFO.KV_mod-c_records_state", "$JS.API.DIRECT.GET.KV_mod-c_records_state.>", "$KV.mod-c_records_state.>", + "$JS.API.CONSUMER.CREATE.KV_mod-c_records_state.>", "$JS.API.DIRECT.GET.mod-c_records.>", "$JS.API.CONSUMER.CREATE.mod-c_records.>", + "$JS.API.DIRECT.GET.mod-c_records_snapshot.>"} { + if !slices.Contains(got.Publish, want) { + t.Errorf("the runner of a lacks %s", want) + } + } + for _, s := range was.Publish { + if !slices.Contains(got.Publish, s) { + t.Errorf("the kept runner lost %s", s) + } + } + for _, no := range []string{"mesh.ledger.mod-c.records.history.>", "mesh.ledger.mod-c.records.snapshot.>"} { + if slices.Contains(got.Publish, no) { + t.Errorf("the runner may publish on the ledger's %s", no) + } + } +} + +// A-386 live: the module a runner carries has no manifest the pass can read (the gate's), only the bindings kept for it: the kept runner still +// gains the ledger's rights from them. +func TestAKeptRunnerCarriesAModuleKnownOnlyByItsBindings(t *testing.T) { + const runner = `{"module":"node-tools","version":"1","tool-runner":true,"own-secrets":{"broker":"/var/lib/nt/broker"}}` + b := fixture() + b.manifestOf("node-tools", runner) + b.assign("a", "node-tools") + b.assign("a", "mod-c") + busKey, err := seal.GenerateKeyPair() + if err != nil { + t.Fatal(err) + } + b.put(grants.ReadHave, "a.nats", nodeengine.HaveByNodeModuleValue{V: keys.Version, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK, + UserList: &nodeengine.UserListWritten{Source: grantsstate.GrantsUserListSource, Revision: 8, Wanted: "sha256:aa", Digest: "sha256:aa", Users: 5, + Key: busKey.PublicKey, Follows: grantsstate.FollowGrants}}) + for _, u := range shadowOf(t, b) { + b.put(grants.ReadAccounts, u.User, map[string]any{"user": u.User, "hash": "$2a$10$x", "generation": 1, "fingerprint": "sha256:1"}) + } + p := partOn(b) + p.Bus = grants.BusAddress{URL: "nats://a.mesh:4222", Fingerprint: "ab"} + p.Objects = &fakeObjects{} + binding := membership.BusBinding{Local: "records", Storage: "ledger", Template: "ledger", Stream: "mod-c_records", History: "mod-c_records", + Subject: "mesh.ledger.mod-c.records.history", State: "mod-c_records_state", Snapshot: "mesh.ledger.mod-c.records.snapshot"} + p.Compose() // the pass that learns the bus module is the broker + body, _ := json.Marshal(grants.BrokerEvent{V: 1, Module: "mod-c", Local: "records", Storage: "ledger", Template: "ledger", Binding: binding}) + if _, err := p.HearBroker("mesh.seat.mesh-broker.event.created", body, p.Brokers()); err != nil { + t.Fatal(err) + } + p.Compose() + first, _, _ := p.Sealed() + key := grants.SealedUserKey(first.Digest, "a.node-tools") + var was grants.User + if err := json.Unmarshal(b.own[grants.StateUserList][key], &was); err != nil { + t.Fatal(err) + } + isLedger := func(s string) bool { return strings.Contains(s, "mod-c_records") } + was.Publish = append(slices.DeleteFunc(slices.Clone(was.Publish), isLedger), "mesh.control.a.tools-alive") + b.own[grants.StateUserList][key], _ = json.Marshal(was) + b.manifestOf("node-tools", strings.Replace(runner, `"tool-runner":true,`, "", 1)) + b.assign("b", "mod-x") + p.Compose() + sealed, _, _ := p.Sealed() + if sealed.Digest == first.Digest { + t.Fatal("the list did not change") + } + var got grants.User + if err := json.Unmarshal(b.own[grants.StateUserList][grants.SealedUserKey(sealed.Digest, "a.node-tools")], &got); err != nil { + t.Fatal(err) + } + for _, want := range []string{ + "$JS.API.STREAM.INFO.KV_mod-c_records_state", "$JS.API.DIRECT.GET.KV_mod-c_records_state.>", "$KV.mod-c_records_state.>", + "$JS.API.CONSUMER.CREATE.KV_mod-c_records_state.>", "$JS.API.DIRECT.GET.mod-c_records.>", "$JS.API.CONSUMER.CREATE.mod-c_records.>", + "$JS.API.DIRECT.GET.mod-c_records_snapshot.>"} { + if !slices.Contains(got.Publish, want) { + t.Errorf("the runner of a lacks %s", want) + } + } + for _, s := range was.Publish { + if !slices.Contains(got.Publish, s) { + t.Errorf("the kept runner lost %s", s) + } + } + for _, no := range []string{"mesh.ledger.mod-c.records.history.>", "mesh.ledger.mod-c.records.snapshot.>"} { + if slices.Contains(got.Publish, no) { + t.Errorf("the runner may publish on the ledger's %s", no) + } + } +} + +// A-386 live: a runner account left out for want of a manifest (the node's runner is another module's) is written as the union of the list in +// force and a carrying runner's grants. +func TestARunnerLeftOutForWantOfAManifestIsComposedAsACarryingRunner(t *testing.T) { + const runner = `{"module":"node-tools","version":"1","tool-runner":true,"own-secrets":{"broker":"/var/lib/nt/broker"}}` + b := fixture() + b.manifestOf("node-tools", runner) + b.assign("a", "node-tools") + b.assign("a", "mod-c") + busKey, err := seal.GenerateKeyPair() + if err != nil { + t.Fatal(err) + } + b.put(grants.ReadHave, "a.nats", nodeengine.HaveByNodeModuleValue{V: keys.Version, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK, + UserList: &nodeengine.UserListWritten{Source: grantsstate.GrantsUserListSource, Revision: 8, Wanted: "sha256:aa", Digest: "sha256:aa", Users: 5, + Key: busKey.PublicKey, Follows: grantsstate.FollowGrants}}) + for _, u := range shadowOf(t, b) { + b.put(grants.ReadAccounts, u.User, map[string]any{"user": u.User, "hash": "$2a$10$x", "generation": 1, "fingerprint": "sha256:1"}) + } + p := partOn(b) + p.Bus = grants.BusAddress{URL: "nats://a.mesh:4222", Fingerprint: "ab"} + p.Objects = &fakeObjects{} + binding := membership.BusBinding{Local: "records", Storage: "ledger", Template: "ledger", Stream: "mod-c_records", History: "mod-c_records", + Subject: "mesh.ledger.mod-c.records.history", State: "mod-c_records_state", Snapshot: "mesh.ledger.mod-c.records.snapshot"} + p.Compose() // the pass that learns the bus module is the broker + body, _ := json.Marshal(grants.BrokerEvent{V: 1, Module: "mod-c", Local: "records", Storage: "ledger", Template: "ledger", Binding: binding}) + if _, err := p.HearBroker("mesh.seat.mesh-broker.event.created", body, p.Brokers()); err != nil { + t.Fatal(err) + } + p.Compose() + first, _, _ := p.Sealed() + key := grants.SealedUserKey(first.Digest, "a.node-tools") + var was grants.User + if err := json.Unmarshal(b.own[grants.StateUserList][key], &was); err != nil { + t.Fatal(err) + } + isLedger := func(s string) bool { return strings.Contains(s, "mod-c_records") } + was.Publish = append(slices.DeleteFunc(slices.Clone(was.Publish), isLedger), "mesh.control.a.tools-alive") + b.own[grants.StateUserList][key], _ = json.Marshal(was) + // Its manifest is gone, and another module placed on a says it is the tool runner: no kept runner by what runs, and the account + // of the list in force has no principal of the pass's. + delete(b.states[grants.ReadModules], "node-tools") + b.manifestOf("other-runner", strings.Replace(runner, "node-tools", "other-runner", 1)) + b.assign("a", "other-runner") + b.assign("b", "mod-x") + p.Compose() + sealed, _, _ := p.Sealed() + if sealed.Digest == first.Digest { + t.Fatal("the list did not change") + } + var got grants.User + if err := json.Unmarshal(b.own[grants.StateUserList][grants.SealedUserKey(sealed.Digest, "a.node-tools")], &got); err != nil { + t.Fatal(err) + } + for _, want := range []string{ + "$JS.API.STREAM.INFO.KV_mod-c_records_state", "$JS.API.DIRECT.GET.KV_mod-c_records_state.>", "$KV.mod-c_records_state.>", + "$JS.API.CONSUMER.CREATE.KV_mod-c_records_state.>", "$JS.API.DIRECT.GET.mod-c_records.>", "$JS.API.CONSUMER.CREATE.mod-c_records.>", + "$JS.API.DIRECT.GET.mod-c_records_snapshot.>"} { + if !slices.Contains(got.Publish, want) { + t.Errorf("the runner of a lacks %s", want) + } + } + for _, s := range was.Publish { + if !slices.Contains(got.Publish, s) { + t.Errorf("the kept runner lost %s", s) + } + } + for _, no := range []string{"mesh.ledger.mod-c.records.history.>", "mesh.ledger.mod-c.records.snapshot.>"} { + if slices.Contains(got.Publish, no) { + t.Errorf("the runner may publish on the ledger's %s", no) + } + } +} diff --git a/modules/mesh-grants/internal/buscompose/askstreams_test.go b/modules/mesh-grants/internal/buscompose/askstreams_test.go new file mode 100644 index 00000000..a9239286 --- /dev/null +++ b/modules/mesh-grants/internal/buscompose/askstreams_test.go @@ -0,0 +1,22 @@ +package buscompose + +import ( + "slices" + "testing" +) + +// The grants part may create each seat's ask stream it makes (AskStreamsOf), by its name alone (lead-47, 2026-11-15: the bus +// refused SEAT_MESH_BUILDS's create because the part's account named no such stream). +func TestTheGrantsPartMayCreateTheSeatsAskStreams(t *testing.T) { + got := declaredStreamsOf(Records{AskStreams: []string{"SEAT_MESH_BUILDS"}}) + if !slices.Contains(got, "SEAT_MESH_BUILDS") { + t.Fatalf("declared streams %v lack the builds seat's ask stream", got) + } + perms, err := PermissionsFor(Principal{Kind: KindModule, Node: "one", Module: GrantsModule, CreatesStreams: got}) + if err != nil { + t.Fatal(err) + } + if !MayPublish(perms, "$JS.API.STREAM.CREATE.SEAT_MESH_BUILDS") || MayPublish(perms, "$JS.API.STREAM.CREATE.SEAT_OTHER") { + t.Errorf("the grants part's creates: %v", perms.Publish) + } +} diff --git a/modules/mesh-grants/internal/buscompose/buscompose_test.go b/modules/mesh-grants/internal/buscompose/buscompose_test.go index 66b265d2..d37475b0 100644 --- a/modules/mesh-grants/internal/buscompose/buscompose_test.go +++ b/modules/mesh-grants/internal/buscompose/buscompose_test.go @@ -203,7 +203,7 @@ func TestTheCopiedComposerComposesAsTheControllers(t *testing.T) { for subject, want := range map[string]bool{ "mesh.seat.operator-channel.accept.ask.node-engine-one": true, "mesh.seat.operator-channel.accept.cancel.node-engine-one": true, - "mesh.seat.operator-channel.accept.ask.node-engine-two": false, + "mesh.seat.operator-channel.accept.ask.node-engine-two": true, // any ask (principle 6) "$JS.API.DIRECT.GET.KV_messenger_asks.$KV.messenger_asks.node-engine-one.hand-over-1": true, "$JS.API.DIRECT.GET.KV_messenger_asks.$KV.messenger_asks.node-engine-two.hand-over-1": false, "mesh.seat." + EngineSeat + ".event.done.one": true, @@ -1050,9 +1050,10 @@ func everyNodesCompositions(t *testing.T) { t.Errorf("node one writes %s: %v", bucket, node != "one") } } + // Every account lists the streams' names (design 47 G A-382); only the view hears the creation of a node's bucket. if !MayPublish(view, "$JS.API.STREAM.NAMES") || !MaySubscribe(view, "$JS.EVENT.ADVISORY.STREAM.CREATED.KV_composed-three") || - MayPublish(plex, "$JS.API.STREAM.NAMES") { - t.Error("the view cannot find a node's bucket, or a module not named lists the streams") + !MayPublish(plex, "$JS.API.STREAM.NAMES") || MaySubscribe(plex, "$JS.EVENT.ADVISORY.STREAM.CREATED.KV_composed-three") { + t.Error("the view cannot find a node's bucket, or a module lacks the streams' names, or one not named hears its creation") } if MayPublish(view, "$JS.API.DIRECT.GET.KV_mesh-host_composed.x") { t.Error("the read is granted as one bucket mesh-host_composed") @@ -1427,6 +1428,7 @@ func chunkSubjectsFollowTheAnswerer(t *testing.T) { {Module: "recovery", Invokes: []string{"seat:mesh-broker.snapshot-get"}, Processes: []ProcessPrincipal{{Process: "recover", Invokes: []string{"seat:mesh-broker.snapshot-get"}}}}, {Module: "admin-ish", Invokes: []string{"*"}}, {Module: "plain-serve", ServesOwn: []string{"seat:mesh-broker.snapshot-get"}}, + {Module: "claim-only", Holds: []Seat{{Name: meshbroker.Seat, Serves: []string{"snapshot-get"}}}}, {Module: "mod-x", Streams: []ModuleStream{{Module: "mod-x", Name: "SECRETS", Events: []string{"sealed"}, Restricted: true}, {Module: "mod-x", Name: "PLAIN", Events: []string{"plain"}}}}, }}} @@ -1455,16 +1457,20 @@ func chunkSubjectsFollowTheAnswerer(t *testing.T) { !has(m.Publish, chunks) || !has(m.Subscribe, servedAcks) { t.Errorf("the module account of a bus-less serving process may not answer the verb and send chunks: %v / %v", m.Publish, m.Subscribe) } + // A module holding the seat sends the chunks of its verb on its own account, though no process repeats it in `serves`. + if m := perms["a.claim-only"]; !has(m.Publish, chunks) || !has(m.Subscribe, servedAcks) { + t.Errorf("the module account holding the seat may not send its verb's chunks: %v / %v", m.Publish, m.Subscribe) + } if rec := perms["a.recovery"]; !has(rec.Subscribe, chunks) || !has(rec.Publish, acks) || has(rec.Publish, chunks) { t.Errorf("the account naming the verb may not hear chunks and send acks, or may send chunks: %v / %v", rec.Publish, rec.Subscribe) } if rec := perms["a.recovery.recover"]; !has(rec.Subscribe, chunks) || !has(rec.Publish, acks) { t.Errorf("the process naming the verb may not hear chunks and send acks") } - for _, u := range []string{"a.admin-ish", "a.nats"} { - if p := perms[u]; has(p.Subscribe, chunks) || has(p.Publish, chunks) || has(p.Publish, acks) { - t.Errorf("%s, naming no chunked verb, is granted chunk subjects: %v / %v", u, p.Publish, p.Subscribe) - } + // Principle 6 (the operator, 2026-11-15): an account naming no chunked verb still hears its chunks and sends their acks; it + // never sends the chunks, which are the answering account's. + if p := perms["a.admin-ish"]; !has(p.Subscribe, chunks) || !has(p.Publish, acks) || has(p.Publish, chunks) { + t.Errorf("a.admin-ish may not hear chunks and send acks, or may send chunks: %v / %v", p.Publish, p.Subscribe) } keeper := perms["a.nats.keeper"] if !MayPublish(keeper, "$JS.API.STREAM.RESTORE.SECRETS") || !MayPublish(keeper, "$JS.SNAPSHOT.RESTORE.SECRETS.abc") { @@ -1640,3 +1646,60 @@ func aRuntimeWithholdsTheMarks(t *testing.T) { } } } + +// A watched seat event whose definition gives a subject with parts (mesh-catalog's `catalog-revision.`) is heard on +// each part as `*`, for a seat of any scope: the consumer's filter and the subscribe grant both, since the bare subject +// matches no event the holder says. +func TestWatchedEventSubjectTakesTheDefinitionsParts(t *testing.T) { + for _, row := range []struct { + name string + seat Seat + event string + want string + }{ + {"mesh seat, bare name", Seat{Name: "mesh-catalog", Scope: "mesh", EventSubjects: map[string]string{"catalog-revision.*": "catalog-revision."}}, + "catalog-revision", "mesh.seat.mesh-catalog.event.catalog-revision.*"}, + {"mesh seat, local name", Seat{Name: "mesh-catalog", Scope: "mesh", EventSubjects: map[string]string{"catalog-revision.*": "catalog-revision."}}, + "catalog-revision.*", "mesh.seat.mesh-catalog.event.catalog-revision.*"}, + {"several parts", Seat{Name: "mesh-pipeline-runner", Scope: "mesh", EventSubjects: map[string]string{"group-ended.*.*": "group-ended.."}}, + "group-ended", "mesh.seat.mesh-pipeline-runner.event.group-ended.*.*"}, + {"a part between words", Seat{Name: "mesh-pipeline-runner", Scope: "mesh", EventSubjects: map[string]string{"milestone.*.asked": "milestone..asked"}}, + "milestone.asked", "mesh.seat.mesh-pipeline-runner.event.milestone.*.asked"}, + {"event without parts", Seat{Name: "mesh-catalog", Scope: "mesh", EventSubjects: map[string]string{"catalog-revision.*": "catalog-revision."}}, + "registration-changed", "mesh.seat.mesh-catalog.event.registration-changed"}, + {"another event sharing a prefix", Seat{Name: "mesh-catalog", Scope: "mesh", EventSubjects: map[string]string{"catalog-revision.*": "catalog-revision."}}, + "catalog", "mesh.seat.mesh-catalog.event.catalog"}, + } { + p := Principal{Kind: KindModule, Node: "novox", Module: "node-tools"} + row.seat.Emits = []string{row.event} + p.Watches = []Seat{row.seat} + consumer, ok := ConsumerFor(p) + if !ok || !slices.Contains(consumer.Filters, row.want) { + t.Errorf("%s: consumer filters %v (%v), want %s", row.name, consumer.Filters, ok, row.want) + } + // The bus module's process hears the same event on the same filter (keeperConsumer). + keeper, kok := keeperConsumer(Principal{Kind: KindModule, Node: "novox", Module: "node-tools", Process: "keeper", Watches: p.Watches}) + if !kok || !slices.Contains(keeper.Filters, row.want) { + t.Errorf("%s: keeper consumer filters %v (%v), want %s", row.name, keeper.Filters, kok, row.want) + } + perms, err := PermissionsFor(p) + if err != nil || !MaySubscribe(perms, strings.Replace(row.want, "*", "main", 1)) { + t.Errorf("%s: the watcher may not subscribe %s (%v)", row.name, row.want, err) + } + } +} + +// TestEveryMeshAccountMayDoEverything is the operator's word of 2026-11-15 23:12 CET: a mesh account publishes and subscribes on +// every subject, the approval mark's denies kept; an enrolling node keeps its few subjects. +func TestEveryMeshAccountMayDoEverything(t *testing.T) { + EveryAccountMayDoEverything = true + defer func() { EveryAccountMayDoEverything = false }() + m, err := PermissionsFor(Principal{Kind: KindModule, Node: "a", Module: "plain"}) + if err != nil || !slices.Equal(m.Publish, []string{AllSubjects}) || !slices.Equal(m.Subscribe, []string{AllSubjects}) { + t.Fatalf("a module account = %v / %v (%v), want every subject both ways", m.Publish, m.Subscribe, err) + } + e, err := PermissionsFor(Principal{Kind: KindEnrolment, Node: "new"}) + if err == nil && slices.Contains(e.Publish, AllSubjects) { + t.Errorf("an enrolling node is granted every subject: %v", e.Publish) + } +} diff --git a/modules/mesh-grants/internal/buscompose/busstate.go b/modules/mesh-grants/internal/buscompose/busstate.go index d9874c45..2007988c 100644 --- a/modules/mesh-grants/internal/buscompose/busstate.go +++ b/modules/mesh-grants/internal/buscompose/busstate.go @@ -67,6 +67,10 @@ func BusStateStreams(module string, e catalogue.BusStateEntry) []string { switch e.Storage { case catalogue.StorageKeyValue: out = []string{"KV_" + base} + // And a state's object store beside it, `-objects`, which the bus module makes with it (design 47 G §58). + if e.Template == catalogue.TemplateState { + out = append(out, "OBJ_"+module+"_"+catalogue.StateObjectsName(e.Name)) + } case catalogue.StorageObjectStore: out = []string{"OBJ_" + base} case catalogue.StorageLedger: @@ -101,10 +105,7 @@ func keeperConsumer(p Principal) (Consumer, bool) { continue } for _, e := range w.Emits { - if pattern, ok := machineEvent(w, e); ok { - e = anyMachine(pattern) - } - filters = append(filters, seatSubject(w, "event", e)) + filters = append(filters, watchedEventSubject(w, e)) } } // And the events of the seats its module uses that are said to it by name, the operator channel's `decided` for its own @@ -231,6 +232,8 @@ func withoutActing(served []string) []string { // `state` is; the bus names of its object stores, granted as an old `objects` is; and what its streams (events, work // queue, log, bare) are published and read on. A ledger has its own account (ledger.go) and is not among them. type boundGrants struct { + // Ledgers are the runner's grants on a bound ledger (ledgerReaderGrants). + Ledgers []string States, Objects, Streams []string } @@ -269,6 +272,8 @@ func boundOn(module, node string, bindings []membership.BusBinding) boundGrants if b.ObjectStore == base { g.Objects = append(g.Objects, base) } + case catalogue.StorageLedger: + g.Ledgers = append(g.Ledgers, ledgerReaderGrants(base, b)...) case catalogue.StorageStream: if b.Stream != base || b.Subject != "mesh.bus."+module+"."+b.Local { continue @@ -284,3 +289,35 @@ func boundOn(module, node string, bindings []membership.BusBinding) boundGrants } return g } + +// ledgerReaderGrants are what the tool runner carrying a module with a bound ledger is granted on it, for the runner reads the ledger +// on its own connection (design 47 G A-385): its state bucket and each index bucket read and written (the instances' latest state), its +// history stream and its snapshots' stream read. Never a publish on a history or a snapshot subject: only the module's ledger account +// does (ADR 0597 §9). Each name is the one the module's ledger derives; a binding naming another is granted nothing. +func ledgerReaderGrants(base string, b membership.BusBinding) []string { + var out []string + kv := func(bucket string) { + stream := "KV_" + bucket + out = append(out, "$KV."+bucket+".>", "$JS.API.STREAM.INFO."+stream, "$JS.API.DIRECT.GET."+stream+".>", + "$JS.API.CONSUMER.CREATE."+stream+".>", "$JS.API.CONSUMER.DELETE."+stream+".>", "$JS.FC."+stream+".>") + } + read := func(stream string) { + out = append(out, "$JS.API.STREAM.INFO."+stream, "$JS.API.STREAM.MSG.GET."+stream, "$JS.API.DIRECT.GET."+stream+".>", + "$JS.API.CONSUMER.CREATE."+stream+".>", "$JS.API.CONSUMER.DELETE."+stream+".>", "$JS.FC."+stream+".>") + } + if b.State == base+"_state" { + kv(b.State) + } + for name, bucket := range b.Indexes { + if safeSubject.MatchString(name) && bucket == base+"_index-"+name { + kv(bucket) + } + } + if b.History == base { + read(base) + } + if b.Snapshot != "" { + read(base + "_snapshot") + } + return out +} diff --git a/modules/mesh-grants/internal/buscompose/chunks.go b/modules/mesh-grants/internal/buscompose/chunks.go index b7bb2ae9..e9c8e53c 100644 --- a/modules/mesh-grants/internal/buscompose/chunks.go +++ b/modules/mesh-grants/internal/buscompose/chunks.go @@ -50,16 +50,27 @@ func chunkGrants(p Principal) (pub, sub []string) { return nil, nil } for _, c := range p.Chunked { - if (p.Kind == KindProcess || p.Kind == KindModule) && slices.Contains(p.AnswersSeat, "seat:"+c.Seat+"."+c.Verb) { + // The module's own account sends the chunks of a verb of a seat it holds too: its claim says it serves the verb, and a + // process with no bus of its own answers it on that account, whether or not its resource repeats it in `serves` (A-115; + // the indexer's input and the assigner's wants input were refused their chunks for that line alone). + if (p.Kind == KindProcess || p.Kind == KindModule) && slices.Contains(p.AnswersSeat, "seat:"+c.Seat+"."+c.Verb) || p.Kind == KindModule && holdsVerb(p.Holds, c) { pub, sub = append(pub, chunkSubject(c)), append(sub, ackServed(c)) } - if slices.Contains(p.Invokes, "seat:"+c.Seat+"."+c.Verb) { + // Any account of a module, its processes, its node or the tool runner may receive a verb's chunks, invoked or not + // (principle 6; the operator, 2026-11-15: no fine-grained permissions inside the mesh): a check program on a build seat + // asks seat:mesh-catalog.input and no manifest of the seat's holder names it. + if slices.Contains(p.Invokes, "seat:"+c.Seat+"."+c.Verb) || slices.Contains([]Kind{KindModule, KindProcess, KindNodeTools, KindNode}, p.Kind) { sub, pub = append(sub, chunkSubject(c)), append(pub, ackSubject(c)) } } return pub, sub } +// holdsVerb says one of the seats held serves the chunked verb. +func holdsVerb(holds []Seat, c ChunkVerb) bool { + return slices.ContainsFunc(holds, func(s Seat) bool { return s.Name == c.Seat && slices.Contains(s.Serves, c.Verb) }) +} + // restoreGrants are the keeper's standing grant of the bus's stream restore subjects and their chunk subjects, for the bus names // of the streams ADR 0436 §3 restricts and only those (design 47 G §681, A-60): the restore request of each and the chunks the // snapshot is sent to. diff --git a/modules/mesh-grants/internal/buscompose/creates_streams_test.go b/modules/mesh-grants/internal/buscompose/creates_streams_test.go index 04e4ba73..d50c54e2 100644 --- a/modules/mesh-grants/internal/buscompose/creates_streams_test.go +++ b/modules/mesh-grants/internal/buscompose/creates_streams_test.go @@ -87,6 +87,14 @@ func theGrantsPartCreatesOnlyDeclaredStreams(t *testing.T) { {"novox.node-tools", "$KV.mesh-host_acts.novox.act.hand-over-1", false}, // The runner never carries the engine (issue 774): its health report is the node's own key alone. {"novox.node-tools", "$KV.mesh-host_health.novox", false}, + // A-384: the runner hears a new event of a seat through an ordered consumer of its own on the stream that carries it. + {"novox.node-tools", "$JS.API.CONSUMER.CREATE.EVENTS.abc", true}, + {"novox.node-tools", "$JS.API.CONSUMER.CREATE.EVENTS.abc.mesh.seat.mesh-conditions.event.findings-asked", true}, + {"novox.node-tools", "$JS.API.CONSUMER.INFO.EVENTS.abc", true}, + {"novox.node-tools", "$JS.API.CONSUMER.DELETE.EVENTS.abc", true}, + {"novox.node-tools", "$JS.FC.EVENTS.abc.def.ghi", true}, + {"novox.node-tools", "$JS.API.CONSUMER.CREATE.ASSIGNMENTS.abc", false}, + {"mesh-delivery-builder", "$JS.API.CONSUMER.CREATE.EVENTS.abc", false}, {"novox.node-tools", "$KV.mesh-host_acts.novox.ask.x", false}, {"node.novox", "$KV.mesh-host_health.novox", true}, {"node.novox", "$KV.mesh-host_health.ace", false}, @@ -94,6 +102,15 @@ func theGrantsPartCreatesOnlyDeclaredStreams(t *testing.T) { {GrantsModule, "$JS.API.STREAM.CREATE.OBJ_mesh-grants-user-list", true}, {GrantsModule, "$O.mesh-grants-user-list.C.abc", true}, {GrantsModule, "$JS.API.STREAM.PURGE.OBJ_mesh-grants-user-list", true}, + // A-373: the part reads back what it keeps in its own bucket, as the node-engine does (an ordered consumer), and no other bucket. + {GrantsModule, "$JS.API.CONSUMER.CREATE.OBJ_mesh-grants-user-list.abc.$O.mesh-grants-user-list.C.abc", true}, + {GrantsModule, "$JS.API.CONSUMER.DELETE.OBJ_mesh-grants-user-list.abc", true}, + {GrantsModule, "$JS.FC.OBJ_mesh-grants-user-list.abc.def.ghi", true}, + {GrantsModule, "$JS.API.CONSUMER.CREATE.OBJ_declaration-files-novox.abc.$O.declaration-files-novox.C.abc", false}, + // A-381, A-382: every account asks the names of the bus's streams, as a client finds the stream that carries a subject. + {GrantsModule, "$JS.API.STREAM.NAMES", true}, + {"mesh-delivery-builder", "$JS.API.STREAM.NAMES", true}, + {"novox.node-tools", "$JS.API.STREAM.NAMES", true}, {GrantsModule, "$O.declaration-files-novox.C.abc", false}, {GrantsModule, "$JS.API.STREAM.DELETE.OBJ_mesh-grants-user-list", false}, {"mesh-delivery-builder", "$O.mesh-grants-user-list.C.abc", false}, diff --git a/modules/mesh-grants/internal/buscompose/derived.go b/modules/mesh-grants/internal/buscompose/derived.go index d655a408..ddc633d8 100644 --- a/modules/mesh-grants/internal/buscompose/derived.go +++ b/modules/mesh-grants/internal/buscompose/derived.go @@ -214,13 +214,18 @@ func ConsumersOf(users []Principal) []ModuleConsumer { } seen[key] = true if needed { - out = append(out, ModuleConsumer{Node: p.Node, Module: p.Module, Consumer: c}) + // Each with the tool runner's twin beside it (A-397). + for _, tc := range withToolsTwin(c) { + out = append(out, ModuleConsumer{Node: p.Node, Module: p.Module, Consumer: tc}) + } // And one on each module stream it hears (novox/hq ADR 0363 §5). for _, h := range p.Hears { if len(h.Filters) == 0 { continue } - out = append(out, ModuleConsumer{Node: p.Node, Module: p.Module, Consumer: heardConsumer(p, h)}) + for _, tc := range withToolsTwin(heardConsumer(p, h)) { + out = append(out, ModuleConsumer{Node: p.Node, Module: p.Module, Consumer: tc}) + } } } // And the one durable consumer of each of its own work-queue streams, for the one process its @@ -304,6 +309,19 @@ func AccountConsumers(users []Principal) []ModuleConsumer { out = append(out, mc) } } + // A build seat's named workers (design 47 G §544, A-413): the seat traffic of each composed holder names them, and the part makes + // them, never only names them in a membership. Main's workers are held already; only the named ones are made here. + made := map[string]bool{} + for _, p := range users { + _, cs := SeatTrafficObjects([]Principal{p}) + for _, c := range cs { + if !strings.HasSuffix(c.Name, "_named_worker") || made[c.Stream+"."+c.Name] { + continue + } + made[c.Stream+"."+c.Name] = true + out = append(out, ModuleConsumer{Node: p.Node, Module: p.Module, Consumer: c}) + } + } return out } diff --git a/modules/mesh-grants/internal/buscompose/kept.go b/modules/mesh-grants/internal/buscompose/kept.go index 6ba943f6..3734f6f9 100644 --- a/modules/mesh-grants/internal/buscompose/kept.go +++ b/modules/mesh-grants/internal/buscompose/kept.go @@ -124,3 +124,28 @@ func SplitKept(kept []KeptEvent, consumes []string) (rest []string, hears []Hear } return rest, hears } + +// AskStreamsOf is the work-queue stream of each seat of the seat list that accepts work (SeatStreams' rule, design 47 G §544): +// `SEAT_` on `mesh.seat..accept.>`, kept seven days, so an ask is held until one holder takes it, and a JetStream +// publish of an ask is answered by the bus. Before G the controller made these; a seat whose queues came with G (mesh-builds, +// mesh-wants) had none, so every ask to it timed out unanswered (lead-47, 2026-11-15). Sorted by stream. +func AskStreamsOf(defs map[string]seatdef.Definition) []jetstream.StreamConfig { + var seats []DeclaredSeat + for _, d := range defs { + if len(d.Accepts) == 0 || !safeSubject.MatchString(d.Seat) { + continue + } + var accepts []string + for _, a := range d.Accepts { + accepts = append(accepts, a.Name) + } + seats = append(seats, DeclaredSeat{Name: d.Seat, Accepts: accepts}) + } + var out []jetstream.StreamConfig + for _, st := range SeatStreams(seats) { + out = append(out, jetstream.StreamConfig{Name: st.Name, Description: st.Why, Subjects: st.Subjects, + Retention: jetstream.WorkQueuePolicy, Storage: jetstream.FileStorage, Replicas: 1, + MaxAge: time.Duration(st.MaxAge) * time.Second}) + } + return out +} diff --git a/modules/mesh-grants/internal/buscompose/modstreams.go b/modules/mesh-grants/internal/buscompose/modstreams.go index 1d62e70c..032c37f3 100644 --- a/modules/mesh-grants/internal/buscompose/modstreams.go +++ b/modules/mesh-grants/internal/buscompose/modstreams.go @@ -249,6 +249,35 @@ func heardConsumer(p Principal, h Heard) Consumer { } } +// ToolsSuffix ends the name of the tool runner's own durable consumer beside a module's: each process that hears events reads +// under a name of its own, since only a work queue shares one (lead answer A-397; mesh-tools bus.ToolsConsumerOf). +const ToolsSuffix = "_tools" + +// readerGrants are what a reader publishes to ask about, pull from and acknowledge a durable consumer on a stream: for the +// module's program's name and for its tool runner's twin (A-397). +func readerGrants(stream, durable string) []string { + var out []string + for _, d := range []string{durable, durable + ToolsSuffix} { + out = append(out, "$JS.API.CONSUMER.INFO."+stream+"."+d, "$JS.API.CONSUMER.MSG.NEXT."+stream+"."+d, "$JS.ACK."+stream+"."+d+".>") + } + return out +} + +// withToolsTwin is a module's consumer and, beside it, the tool runner's twin of it: the same filters under its own name (A-397). +func withToolsTwin(c Consumer) []Consumer { + twin := c + twin.Name += ToolsSuffix + twin.Filters = append([]string(nil), c.Filters...) + // The events given up on and delivered again to one consumer alone are named by it: the twin's are its own. + for i, f := range twin.Filters { + if f == AgainFilter(c.Name) { + twin.Filters[i] = AgainFilter(twin.Name) + } + } + twin.Why = c.Why + "; the tool runner's own, beside the program's (lead answer A-397)" + return []Consumer{c, twin} +} + // heardGrants are what a principal publishes to read and acknowledge the consumers it hears module streams // through: asking about each, pulling from it, acknowledging it — its own name on each stream, no other's. func heardGrants(p Principal, hears []Heard) []string { @@ -258,10 +287,7 @@ func heardGrants(p Principal, hears []Heard) []string { if !safeSubject.MatchString(h.Stream) || len(h.Filters) == 0 { continue } - out = append(out, - "$JS.API.CONSUMER.INFO."+h.Stream+"."+durable, - "$JS.API.CONSUMER.MSG.NEXT."+h.Stream+"."+durable, - "$JS.ACK."+h.Stream+"."+durable+".>") + out = append(out, readerGrants(h.Stream, durable)...) seatKept := strings.HasPrefix(h.Stream, seatdef.KeptStreamPrefix) if seatKept || h.LastPerSubject { // A seat's kept event, and a module's own stream kept last per subject, are heard through process.HearSeatEvents and diff --git a/modules/mesh-grants/internal/buscompose/named_asks_test.go b/modules/mesh-grants/internal/buscompose/named_asks_test.go index 74ff72cf..1767bade 100644 --- a/modules/mesh-grants/internal/buscompose/named_asks_test.go +++ b/modules/mesh-grants/internal/buscompose/named_asks_test.go @@ -1,9 +1,12 @@ package buscompose -import "testing" +import ( + "strings" + "testing" +) -// Design 47 G §543, §544, §600: a build seat's ask names its asker, each queue has a named worker beside main's, an asker -// is granted the queues of its kinds under its own seat's name alone, and main's subject is the checker's and the builder's. +// Design 47 G §543, §544, §600: a build seat's ask names its asker and each queue has a named worker beside main's; any module may +// put any ask (principle 6, the operator 2026-11-15). func TestNamedAsks(t *testing.T) { build := Seat{Name: "node-build-go", Scope: "node", Accepts: []string{"delivery", "check", "recheck"}, PulledByKind: true, AcceptCallers: map[string][]string{ @@ -19,29 +22,18 @@ func TestNamedAsks(t *testing.T) { return p } const base = "mesh.seat.node-build-go.accept." - for _, c := range []struct { - who Principal - want map[string]bool - }{ - {asker("runner-module", "mesh-pipeline-runner"), map[string]bool{ - base + "check.mesh-pipeline-runner": true, base + "delivery.mesh-pipeline-runner": false, - base + "check.mesh-catalog": false, base + "check": false, base + "delivery": false}}, - {asker("an-indexer", "mesh-catalog"), map[string]bool{ - base + "check.mesh-catalog": true, base + "check.mesh-pipeline-runner": false, base + "recheck.mesh-catalog": false}}, - {asker("the-builder", "mesh-builds"), map[string]bool{ - base + "delivery.mesh-builds": true, base + "delivery": true, base + "check": true, base + "check.mesh-builds": false}}, - {asker("the-checker", "mesh-delivery-checker"), map[string]bool{ - base + "check.mesh-delivery-checker": true, base + "recheck.mesh-delivery-checker": true, base + "recheck": true, - base + "delivery.mesh-delivery-checker": false}}, - {asker("a-stranger"), map[string]bool{base + "check": false, base + "delivery": false, base + "check.a-stranger": false}}, - } { - perms, err := PermissionsFor(c.who) + // Principle 6 (the operator, 2026-11-15): every module's account may put an ask on any queue of any seat, under any asker's + // name or none (AnySeatSubject); the callers lists withhold nothing. + for _, who := range []Principal{asker("runner-module", "mesh-pipeline-runner"), asker("an-indexer", "mesh-catalog"), + asker("the-builder", "mesh-builds"), asker("the-checker", "mesh-delivery-checker"), asker("a-stranger")} { + perms, err := PermissionsFor(who) if err != nil { t.Fatal(err) } - for subject, want := range c.want { - if got := MayPublish(perms, subject); got != want { - t.Errorf("%s may publish %s: %v, want %v", c.who.Module, subject, got, want) + for _, subject := range []string{base + "check", base + "delivery", base + "check.mesh-catalog", base + "recheck.mesh-delivery-checker", + base + "check." + who.Module} { + if !MayPublish(perms, subject) { + t.Errorf("%s may not publish %s", who.Module, subject) } } } @@ -66,6 +58,16 @@ func TestNamedAsks(t *testing.T) { if len(consumers) != 4 { t.Errorf("the work queue's consumers: %d, want 4 (a main and a named worker for each of two queues)", len(consumers)) } + // A-413: the part makes the named workers (AccountConsumers), never only names them in a membership. + named := 0 + for _, mc := range AccountConsumers([]Principal{{Kind: KindModule, Node: "one", Module: "go-module", Holds: []Seat{held}}}) { + if strings.HasSuffix(mc.Consumer.Name, "_named_worker") { + named++ + } + } + if named != 2 { + t.Errorf("account consumers hold %d named workers, want 2", named) + } } // Design 47 G §610, A-179 (test 60's case of §271): a user of a seat is granted a verb's call subject only where the verb's @@ -137,3 +139,44 @@ func TestTheGrantsPartAlonePurgesTheNamedAsks(t *testing.T) { } } } + +// Design 47 G, lead answer A-393: a verb of a node-scoped seat asked with no machine is answered by any one holder, so each +// holder is granted the verb's subject without the machine (tool and call forms) beside its machine's, and a caller of the +// verb may publish on it; a verb of a seat held once for the mesh gains nothing, and a stranger is granted nothing. +func TestANodeSeatVerbIsAlsoGrantedWithoutTheMachine(t *testing.T) { + build := Seat{Name: "node-build-go", Scope: "node", Serves: []string{"steps"}, + VerbCallers: map[string][]string{"steps": {"invokers"}}} + holder := Principal{Kind: KindModule, Node: "shanks", Module: "mesh-build-go", Holds: []Seat{build}} + caller := Principal{Kind: KindModule, Node: "shanks", Module: "an-indexer", Uses: []Seat{build}, + Invokes: []string{"seat:node-build-go.steps"}} + stranger := Principal{Kind: KindModule, Node: "shanks", Module: "a-stranger", Uses: []Seat{build}} + const tool = "mesh.seat.node-build-go.tool.steps" + call := "mesh.seat.node-build-go.call.steps." + for _, c := range []struct { + name string + who Principal + subject string + sub bool + want bool + }{ + {"holder hears its machine's", holder, tool + ".shanks", true, true}, + {"holder hears the node-less tool", holder, tool, true, true}, + {"holder hears the node-less call", holder, call + "someone", true, true}, + {"caller asks the node-less tool", caller, tool, false, true}, + {"caller asks a machine's", caller, tool + ".shanks", false, true}, + {"caller asks the node-less call in its name", caller, call + CallerToken(caller.Username()), false, true}, + {"stranger asks the node-less tool", stranger, tool, false, false}, + } { + perms, err := PermissionsFor(c.who) + if err != nil { + t.Fatal(err) + } + got := MayPublish(perms, c.subject) + if c.sub { + got = MaySubscribe(perms, c.subject) + } + if got != c.want { + t.Errorf("%s: %v, want %v", c.name, got, c.want) + } + } +} diff --git a/modules/mesh-grants/internal/buscompose/nats.go b/modules/mesh-grants/internal/buscompose/nats.go index 12a388f0..a0e7ebe9 100644 --- a/modules/mesh-grants/internal/buscompose/nats.go +++ b/modules/mesh-grants/internal/buscompose/nats.go @@ -203,6 +203,9 @@ type Principal struct { // seat's verbs on this node — derived from the same declarations the modules' own principals // are, so the runtime can serve nothing a module could not have served for itself. Carries []Declared + // NewEventStreams are the streams whose events the runner's bundles may hear from the next message on, each through an ordered + // consumer of its own (mesh-tools node-tools SubscribeNew; design 47 G A-384): the shared events stream and each kept seat stream. + NewEventStreams []string // Withholds says this node's tool runner does not honour the approval mark (design 46 approval mark §6), for a // KindNodeTools principal: every marked subject of what it carries is denied it (MarksWithheld). Withholds bool @@ -497,7 +500,9 @@ func machineEvent(s Seat, e string) (string, bool) { return "", false case perMachineEvents[e]: return strings.TrimSuffix(e, "*") + nodeToken, true - case s.HeldByTheEngine: + case s.HeldByTheEngine || strings.Contains(s.EventSubjects[e], nodeToken): + // The node-engine's seats, and any node seat whose definition names `` in an event's subject (a build seat's + // `step-ended.`, `toolchain-reported.`; lead answer A-399). if subject, ok := s.EventSubjects[e]; ok { toks := strings.Split(subject, ".") found := false @@ -519,6 +524,30 @@ func machineEvent(s Seat, e string) (string, bool) { return "", false } +// pulledSeatEvents are the events a holder of a seat pulled by kind (and not kinded) says: each the seat emits and no caller +// names, on its own machine where the event names one (machineEvent), node "" giving any machine's (the membership's form). +func pulledSeatEvents(s Seat, node string) []string { + if !s.PulledByKind || s.Kinded { + return nil + } + var out []string + for _, e := range s.Emits { + if namesVerb(s.ByCaller, e) { + continue + } + if pattern, ok := machineEvent(s, e); ok { + if node == "" { + out = append(out, seatSubject(s, "event", anyMachine(pattern))) + } else { + out = append(out, seatSubject(s, "event", onMachine(pattern, node))) + } + continue + } + out = append(out, seatSubject(s, "event", e)) + } + return out +} + // anyMachine is a machineEvent pattern a watcher hears: every machine's. func anyMachine(pattern string) string { return strings.ReplaceAll(pattern, nodeToken, "*") } @@ -682,6 +711,19 @@ var BusSnapshotGrants = struct{ Publish []string }{Publish: []string{ // PermissionsFor derives a principal's authority. Pure, and the only place authority is decided: // a permission that cannot be derived from a declaration is a permission nobody can explain. func PermissionsFor(p Principal) (Permissions, error) { + perms, err := scopedPermissionsFor(p) + // **Every account of the mesh may do everything** (the operator, 2026-11-15 23:12 CET: "the mesh accounts should have all the + // permissions, otherwise it will become a mess"; "the operator can do everything, always"): publish and subscribe on every + // subject. The denies stay: they are the approval mark's and the desk's, not permissions. An enrolling node is not of the mesh + // yet and keeps its few subjects. Until the research after G replaces the accounts themselves (mesh, agent, operator). + if err == nil && EveryAccountMayDoEverything && p.Kind != KindEnrolment { + perms.Publish, perms.Subscribe = []string{AllSubjects}, []string{AllSubjects} + } + return perms, err +} + +// scopedPermissionsFor is each account's own subjects, as composed before every account was given every subject. +func scopedPermissionsFor(p Principal) (Permissions, error) { perms, err := permissionsFor(p) if err != nil || p.SnapshotsTheBus && p.Kind == KindModule { return perms, err @@ -698,9 +740,70 @@ func PermissionsFor(p Principal) (Permissions, error) { sub = append(sub, answered...) } perms.Publish, perms.Subscribe = append(perms.Publish, pub...), append(perms.Subscribe, sub...) + if p.Kind == KindNodeTools { + perms.Publish = append(perms.Publish, NewEventGrants(p.NewEventStreams)...) + } + // Every account of a module, its processes, its node and the tool runner (not a ledger's or an enrolling node's, which publish on a few subjects alone) asks the names of the bus's streams: a client finds the stream that carries a subject by it (the tool runner's + // subscription to a seat's event, the grants part's creation of a kept stream; design 47 G A-381, A-382). + if slices.Contains([]Kind{KindModule, KindNodeTools, KindNode, KindProcess}, p.Kind) && !slices.Contains(perms.Publish, StreamNamesSubject) { + perms.Publish = append(perms.Publish, StreamNamesSubject) + } + // The same accounts may put an ask on any seat (AnySeatSubject, principle 6), in the list's order. + if slices.Contains([]Kind{KindModule, KindNodeTools, KindNode, KindProcess}, p.Kind) && !slices.Contains(perms.Publish, AnySeatSubject) { + perms.Publish = append(perms.Publish, AnySeatSubject) + sort.Strings(perms.Publish) + } return perms, nil } +// AllSubjects is every subject of the bus. +const AllSubjects = ">" + +// EveryAccountMayDoEverything widens every account but an enrolling node's to AllSubjects. On in the part; the tests of each +// account's own subjects turn it off in their TestMain, since that composition still runs beneath it. +var EveryAccountMayDoEverything = true + +// NewEventGrants are what hearing a new event on each stream through an ordered consumer needs, in the forms the client library +// sends: the create of a consumer the client names itself (with its filter or without, as it has one filter subject or several), its +// info and its delete, the next-message fetch, and the flow control (design 47 G A-384). The whole of each stream's subjects: inside the mesh +// every module is trusted (principle 6). +func NewEventGrants(streams []string) []string { + var out []string + for _, s := range streams { + if !safeSubject.MatchString(s) { + continue + } + out = append(out, "$JS.API.CONSUMER.CREATE."+s+".*", "$JS.API.CONSUMER.CREATE."+s+".*.>", "$JS.API.CONSUMER.INFO."+s+".*", + "$JS.API.CONSUMER.DELETE."+s+".*", "$JS.API.CONSUMER.MSG.NEXT."+s+".*", "$JS.FC."+s+".>") + } + return out +} + +// RunnerNewEventGrants are, by the runner's user, what NewEventGrants gives its account: for a pass that keeps a runner's account +// from the list in force and would not compose them (A-383's kind of copy). +func RunnerNewEventGrants(r Records) map[string][]string { + users, err := Users(r) + if err != nil { + return nil + } + out := map[string][]string{} + for _, u := range users { + if u.Kind == KindNodeTools { + out[u.Username()] = NewEventGrants(u.NewEventStreams) + } + } + return out +} + +// StreamNamesSubject is the request for the names of the bus's streams, granted to every account. +const StreamNamesSubject = "$JS.API.STREAM.NAMES" + +// AnySeatSubject is every seat's asks: each queue of each seat, named by any asker or none. Inside the mesh every module is trusted +// (principle 6), so every account of a module, its processes, its node and the tool runner may put an ask on any seat, and no seat +// definition's callers list or manifest's invokes withholds one (the operator, 2026-11-15 about 18:10 CET, until the research after +// G on dropping fine-grained permissions decides the whole shape). A seat's events and its verbs keep their own rules. +const AnySeatSubject = "mesh.seat.*.accept.>" + func permissionsFor(p Principal) (Permissions, error) { for _, part := range []struct{ what, value string }{ {"node", p.Node}, {"module", p.Module}, {"process", p.Process}, @@ -1054,9 +1157,7 @@ func permissionsFor(p Principal) (Permissions, error) { // controller and the hosts are pushed to. Named here rather than through ConsumerFor, // which asks for these permissions to build the consumer and would ask forever. A // subject for a consumer that turns out not to exist grants nothing anybody can use. - pub = append(pub, - "$JS.API.CONSUMER.INFO."+consumerStream(p)+"."+consumerDurable(p), - "$JS.API.CONSUMER.MSG.NEXT."+consumerStream(p)+"."+consumerDurable(p)) + pub = append(pub, readerGrants(consumerStream(p), consumerDurable(p))...) // 3. Seats it holds: full participation. But mesh-broker's acting verbs, which nobody serves on the bus (busstate.go). for _, s := range p.Holds { @@ -1066,8 +1167,11 @@ func permissionsFor(p Principal) (Permissions, error) { if s.isNewTraffic() { // Composed by SeatTrafficOf below, worker and all; only its tools are served here. for _, t := range s.Serves { - sub = append(sub, seatToolSubject(s, t, p.Node)) + sub = append(sub, seatToolSubjects(s, t, p.Node)...) } + // And a seat pulled by kind says its own events, as any held seat does, its machine's alone (lead answer A-399: + // a build seat's step-ended and toolchain-reported were granted to nobody). + pub = append(pub, pulledSeatEvents(s, p.Node)...) continue } // Taking work from the role's queue: the worker consumer every holder shares (asked @@ -1095,7 +1199,7 @@ func permissionsFor(p Principal) (Permissions, error) { pub = append(pub, seatSubject(s, "event", e)) } for _, t := range s.Serves { - sub = append(sub, seatToolSubject(s, t, p.Node)) + sub = append(sub, seatToolSubjects(s, t, p.Node)...) } } @@ -1109,7 +1213,7 @@ func permissionsFor(p Principal) (Permissions, error) { for _, t := range s.Serves { // Only a verb whose effective callers name this module (design 47 G A-179, §610). if callerOf(p, s, t) { - pub = append(pub, seatToolSubject(s, t, "*")) + pub = append(pub, seatToolSubjects(s, t, "*")...) } } } @@ -1172,7 +1276,7 @@ func permissionsFor(p Principal) (Permissions, error) { s.Serves = withoutActing(s.Serves) } for _, t := range s.Serves { - sub = append(sub, seatToolSubject(s, t, p.Node)) + sub = append(sub, seatToolSubjects(s, t, p.Node)...) } } } @@ -1218,11 +1322,7 @@ func permissionsFor(p Principal) (Permissions, error) { if _, consumes := ConsumerFor(own); !consumes { continue } - stream, durable := consumerStream(own), consumerDurable(own) - pub = append(pub, - "$JS.API.CONSUMER.INFO."+stream+"."+durable, - "$JS.API.CONSUMER.MSG.NEXT."+stream+"."+durable, - "$JS.ACK."+stream+"."+durable+".>") + pub = append(pub, readerGrants(consumerStream(own), consumerDurable(own))...) } // **And it keeps and reads state for the modules it carries** (novox/hq ADR 0201): the union // of what each may do with a bucket — an owner's write, a reader's read. That one module's code @@ -1235,6 +1335,7 @@ func permissionsFor(p Principal) (Permissions, error) { PerMachine: perMachineNames(d.State), ReadOnly: readOnlyNames(d.State), Reads: d.Reads, KeyedReads: d.KeyedReads, Nodes: p.Nodes})...) pub = append(pub, objectGrants(append(objectNames(d.Objects), bound.Objects...), d.ReadsObjects)...) pub = append(pub, bound.Streams...) + pub = append(pub, bound.Ledgers...) // A bundle reads every node's compositions on the runtime's own connection (ADR 0593 §6), which hears a node's // bucket made later by any stream's creation. if slices.Contains(d.Reads, ComposedRead) && !slices.Contains(sub, familyCreatedAdvisory) { @@ -1450,6 +1551,17 @@ func seatToolSubject(s Seat, verb, node string) string { return base } +// seatToolSubjects are seatToolSubject and, for a verb of a node-scoped seat, the subject without the machine, where a verb +// asked of no machine is answered by any one holder in a queue group (design 47 G, lead answer A-393). Its call form +// follows from the tool grant (callerNamed). +func seatToolSubjects(s Seat, verb, node string) []string { + out := []string{seatToolSubject(s, verb, node)} + if s.Scope == "node" && node != "" { + out = append(out, seatToolSubject(s, verb, "")) + } + return out +} + // consumerStream and consumerDurable are the two halves of a consumer's identity, and they are // two functions because conflating them was a real bug. // @@ -1790,15 +1902,48 @@ func watchedEvents(watches []Seat) []string { continue } for _, e := range w.Emits { - if pattern, ok := machineEvent(w, e); ok { - e = anyMachine(pattern) - } - out = append(out, seatSubject(w, "event", e)) + out = append(out, watchedEventSubject(w, e)) } } return out } +// watchedEventSubject is the subject a watcher of the seat w hears its event e on: an event naming its holder's machine from +// every machine (machineEvent), and any other event whose definition gives a subject with parts (`catalog-revision.` +// of mesh-catalog's seat.json) on that subject with each part as `*`, whatever the seat's scope, since a consume names the +// event by its bare name and the bare subject matches no event the holder says (the same rule as mesh-sdk's +// buscompose EventSubjects). +func watchedEventSubject(w Seat, e string) string { + if pattern, ok := machineEvent(w, e); ok { + return seatSubject(w, "event", anyMachine(pattern)) + } + for local, subject := range w.EventSubjects { + if local != e && localName(local) != e { + continue + } + toks := strings.Split(subject, ".") + for i, t := range toks { + if len(t) > 2 && t[0] == '<' && t[len(t)-1] == '>' { + toks[i] = "*" + } + } + return seatSubject(w, "event", strings.Join(toks, ".")) + } + return seatSubject(w, "event", e) +} + +// localName is an event's name from its local form: the tokens that are not a part (`*`), so `milestone.*.asked` is +// `milestone.asked` and `catalog-revision.*` is `catalog-revision`. +func localName(local string) string { + var words []string + for _, t := range strings.Split(local, ".") { + if t != "*" { + words = append(words, t) + } + } + return strings.Join(words, ".") +} + // invokedSubjects is the publish side of a grant to call tools: one subject per `.`, // or the whole tool namespace for `*`. A person's authority and a module's `invokes` are both this // (novox/hq ADR 0152), so a malformed entry is refused in one place, before it could be widened into diff --git a/modules/mesh-grants/internal/buscompose/pulledevents_test.go b/modules/mesh-grants/internal/buscompose/pulledevents_test.go new file mode 100644 index 00000000..dd3b7891 --- /dev/null +++ b/modules/mesh-grants/internal/buscompose/pulledevents_test.go @@ -0,0 +1,27 @@ +package buscompose + +import ( + "slices" + "testing" +) + +// A-399: the holder of a seat pulled by kind says the seat's own events on its machine (a build seat's step-ended and +// toolchain-reported, `.`); on 2026-11-14 they were granted to nobody, so the builder never heard a toolchain. +func TestAPulledSeatsHolderSaysItsEvents(t *testing.T) { + held := Seat{Name: "node-build-go", Scope: "node", Accepts: []string{"delivery"}, PulledByKind: true, + Emits: []string{"step-ended", "toolchain-reported"}, + EventSubjects: map[string]string{"step-ended": "step-ended.", "toolchain-reported": "toolchain-reported."}} + perms, err := PermissionsFor(Principal{Kind: KindModule, Node: "shanks", Module: "mesh-build-go", Holds: []Seat{held}}) + if err != nil { + t.Fatal(err) + } + for _, want := range []string{"mesh.seat.node-build-go.event.step-ended.shanks", "mesh.seat.node-build-go.event.toolchain-reported.shanks"} { + if !slices.Contains(perms.Publish, want) { + t.Errorf("the holder's account is not granted %s", want) + } + } + tr := SeatTrafficOf("mesh-build-go", []Seat{held}, nil, nil) + if !slices.Contains(tr.Publish, "mesh.seat.node-build-go.event.toolchain-reported.*") { + t.Errorf("the membership does not list toolchain-reported: %v", tr.Publish) + } +} diff --git a/modules/mesh-grants/internal/buscompose/seats_main_test.go b/modules/mesh-grants/internal/buscompose/seats_main_test.go index 76f0e6f5..74b375f4 100644 --- a/modules/mesh-grants/internal/buscompose/seats_main_test.go +++ b/modules/mesh-grants/internal/buscompose/seats_main_test.go @@ -11,5 +11,7 @@ import ( // TestMain gives catalogue the seat list a host reads (ADR 0636 §1): none is compiled into mesh-sdk. func TestMain(m *testing.M) { catalogue.UseSeats(catalogue.SeatsFromDefinitions(seatlisttest.Definitions())) + // These tests read each account's own subjects, which the part composes beneath the wide grant. + EveryAccountMayDoEverything = false os.Exit(m.Run()) } diff --git a/modules/mesh-grants/internal/buscompose/seattraffic.go b/modules/mesh-grants/internal/buscompose/seattraffic.go index fc34cfe9..1c8c0853 100644 --- a/modules/mesh-grants/internal/buscompose/seattraffic.go +++ b/modules/mesh-grants/internal/buscompose/seattraffic.go @@ -5,6 +5,7 @@ import ( "maps" "slices" "sort" + "strings" ) // What a module may say and take on the seats it holds, uses and watches, beyond tools (novox/hq ADR @@ -119,6 +120,30 @@ func namesVerb(list []string, s string) bool { return false } +// NamedAsksGranted says some declaration of the records is granted to publish a named ask of a build seat's queue, +// `accept..` (design 47 G §544, A-413): read from the same seat traffic the grants are composed from. +func NamedAsksGranted(r Records) bool { + for _, ds := range r.Assigned { + for _, d := range ds { + t := SeatTrafficOf(d.Module, d.Holds, d.Uses, d.Watches) + for _, s := range d.Uses { + if !s.PulledByKind { + continue + } + for _, q := range s.Accepts { + prefix := seatSubject(s, "accept", q+".") + for _, p := range t.Publish { + if strings.HasPrefix(p, prefix) { + return true + } + } + } + } + } + } + return false +} + // SeatTrafficOf derives one module's seat traffic from the seats it holds, uses and watches. Only seats // carrying one of the rules above are read: every other seat is composed as it always was. func SeatTrafficOf(module string, holds, uses, watches []Seat) SeatTraffic { @@ -184,6 +209,8 @@ func SeatTrafficOf(module string, holds, uses, watches []Seat) SeatTraffic { t.Publish = append(t.Publish, seatSubject(s, "event", e+".*")) } } + // A seat pulled by kind: its own events, so the runtime carrying the holder may say them (A-399). + t.Publish = append(t.Publish, pulledSeatEvents(s, "")...) if kind != "" { for _, v := range s.Proofs { t.Publish = append(t.Publish, seatSubject(s, "proof", v+"."+kind)) diff --git a/modules/mesh-grants/internal/buscompose/state_objects_test.go b/modules/mesh-grants/internal/buscompose/state_objects_test.go index 4277f2c7..974fd962 100644 --- a/modules/mesh-grants/internal/buscompose/state_objects_test.go +++ b/modules/mesh-grants/internal/buscompose/state_objects_test.go @@ -1,6 +1,7 @@ package buscompose import ( + "slices" "testing" "git.novox.be/novox/mesh-sdk/go/catalogue" @@ -27,6 +28,22 @@ func TestStateObjectsAndSentStores(t *testing.T) { t.Errorf("another module may publish %s", subject) } } + // The bus module may make the store beside a state asked by the template state: it is among the streams it keeps. + if got := BusStateStreams("shop", catalogue.BusStateEntry{Name: "orders", Storage: catalogue.StorageKeyValue, Template: catalogue.TemplateState}); !slices.Contains(got, "OBJ_shop_orders-objects") { + t.Errorf("the bus module's streams of the state orders = %v, want its object store among them", got) + } + // A state of the field state has its store beside it too, its owner's (A-237: the indexer's and the assigner's inputs), as + // the grants part makes and grants a module's own object buckets. + stated, err := PermissionsFor(Principal{Kind: KindModule, Node: "novox", Module: "mesh-delivery-indexer", State: []string{"inputs"}, + Objects: []string{"mesh-delivery-indexer_inputs-objects"}}) + if err != nil { + t.Fatal(err) + } + for _, subject := range []string{"$JS.API.STREAM.INFO.OBJ_mesh-delivery-indexer_inputs-objects", "$O.mesh-delivery-indexer_inputs-objects.C.x"} { + if !MayPublish(stated, subject) { + t.Errorf("the indexer may not publish %s", subject) + } + } reader, err := PermissionsFor(Principal{Kind: KindModule, Node: "one", Module: "bank", ReadsObjects: []string{"shop_sent-objects"}}) if err != nil { t.Fatal(err) diff --git a/modules/mesh-grants/internal/buscompose/testdata/composed.conf b/modules/mesh-grants/internal/buscompose/testdata/composed.conf index b5da159c..167db687 100644 --- a/modules/mesh-grants/internal/buscompose/testdata/composed.conf +++ b/modules/mesh-grants/internal/buscompose/testdata/composed.conf @@ -33,12 +33,12 @@ accounts { subscribe: { allow: ["_INBOX.enrol.one.>"] } } } { user: "node.one", password: "$2a$11$nnnnnnnnnnnnnnnnnnnnnn", permissions: { - publish: { allow: ["$JS.ACK.NODES.one.>", "$JS.API.CONSUMER.CREATE.KV_composed-one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.one", "$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.one", "$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.one.>", "$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node", "$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.one.>", "$JS.API.CONSUMER.CREATE.OBJ_declaration-files-one.*.$O.declaration-files-one.C.*", "$JS.API.CONSUMER.DELETE.KV_composed-one.>", "$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_data.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_health.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.>", "$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.>", "$JS.API.CONSUMER.DELETE.KV_node-engine_have.>", "$JS.API.CONSUMER.DELETE.OBJ_declaration-files-one.*", "$JS.API.CONSUMER.INFO.NODES.one", "$JS.API.DIRECT.GET.KV_composed-one.>", "$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.one.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.one.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.>", "$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.one.>", "$JS.API.DIRECT.GET.KV_mesh-host_bounds.>", "$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.one.>", "$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.one.>", "$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.one", "$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.one", "$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.one.>", "$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node", "$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.one.>", "$JS.API.DIRECT.GET.OBJ_declaration-files-one.$O.declaration-files-one.M.*", "$JS.API.STREAM.INFO.KV_composed-one", "$JS.API.STREAM.INFO.KV_mesh-config_resolved", "$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments", "$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates", "$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants", "$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts", "$JS.API.STREAM.INFO.KV_mesh-host_acts", "$JS.API.STREAM.INFO.KV_mesh-host_bounds", "$JS.API.STREAM.INFO.KV_mesh-host_data", "$JS.API.STREAM.INFO.KV_mesh-host_findings", "$JS.API.STREAM.INFO.KV_mesh-host_health", "$JS.API.STREAM.INFO.KV_mesh-host_packages", "$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions", "$JS.API.STREAM.INFO.KV_node-engine_have", "$JS.FC.KV_composed-one.>", "$JS.FC.KV_mesh-config_resolved.>", "$JS.FC.KV_mesh-delivery-assigner_assignments.>", "$JS.FC.KV_mesh-delivery-assigner_candidates.>", "$JS.FC.KV_mesh-delivery-assigner_wants.>", "$JS.FC.KV_mesh-delivery-builder_builds.>", "$JS.FC.KV_mesh-delivery-indexer_candidates.>", "$JS.FC.KV_mesh-delivery-indexer_manifests.>", "$JS.FC.KV_mesh-delivery-indexer_modules.>", "$JS.FC.KV_mesh-delivery-indexer_verdicts.>", "$JS.FC.KV_mesh-host_acts.>", "$JS.FC.KV_mesh-host_bounds.>", "$JS.FC.KV_mesh-host_data.>", "$JS.FC.KV_mesh-host_findings.>", "$JS.FC.KV_mesh-host_health.>", "$JS.FC.KV_mesh-host_packages.>", "$JS.FC.KV_mesh-provisioner_provisions.>", "$JS.FC.KV_node-engine_have.>", "$JS.FC.OBJ_declaration-files-one.>", "$KV.composed-one.>", "$KV.mesh-host_acts.one.>", "$KV.mesh-host_bounds.>", "$KV.mesh-host_data.one.>", "$KV.mesh-host_findings.machine.one.>", "$KV.mesh-host_health.one", "$KV.mesh-host_packages.one", "$KV.node-engine_have.one.>", "$SRV.INFO", "$SRV.INFO.>", "$SRV.PING", "$SRV.PING.*.one", "$SRV.PING.>", "mesh.control.one.>", "mesh.seat.node-backup.call.backed-up.one.node~one", "mesh.seat.node-backup.call.now.one.node~one", "mesh.seat.node-backup.tool.backed-up.one", "mesh.seat.node-backup.tool.now.one", "mesh.seat.node-engine.event.*.one"] } + publish: { allow: ["$JS.ACK.NODES.one.>", "$JS.API.CONSUMER.CREATE.KV_composed-one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.>", "$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.one.>", "$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.one", "$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.one", "$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.one.>", "$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node", "$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.one.>", "$JS.API.CONSUMER.CREATE.OBJ_declaration-files-one.*.$O.declaration-files-one.C.*", "$JS.API.CONSUMER.DELETE.KV_composed-one.>", "$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.>", "$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_data.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_health.>", "$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.>", "$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.>", "$JS.API.CONSUMER.DELETE.KV_node-engine_have.>", "$JS.API.CONSUMER.DELETE.OBJ_declaration-files-one.*", "$JS.API.CONSUMER.INFO.NODES.one", "$JS.API.DIRECT.GET.KV_composed-one.>", "$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.one.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.one.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.>", "$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.>", "$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.one.>", "$JS.API.DIRECT.GET.KV_mesh-host_bounds.>", "$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.one.>", "$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.one.>", "$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.one", "$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.one", "$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.one.>", "$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node", "$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.one.>", "$JS.API.DIRECT.GET.OBJ_declaration-files-one.$O.declaration-files-one.M.*", "$JS.API.STREAM.INFO.KV_composed-one", "$JS.API.STREAM.INFO.KV_mesh-config_resolved", "$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments", "$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates", "$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants", "$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules", "$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts", "$JS.API.STREAM.INFO.KV_mesh-host_acts", "$JS.API.STREAM.INFO.KV_mesh-host_bounds", "$JS.API.STREAM.INFO.KV_mesh-host_data", "$JS.API.STREAM.INFO.KV_mesh-host_findings", "$JS.API.STREAM.INFO.KV_mesh-host_health", "$JS.API.STREAM.INFO.KV_mesh-host_packages", "$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions", "$JS.API.STREAM.INFO.KV_node-engine_have", "$JS.API.STREAM.NAMES", "$JS.FC.KV_composed-one.>", "$JS.FC.KV_mesh-config_resolved.>", "$JS.FC.KV_mesh-delivery-assigner_assignments.>", "$JS.FC.KV_mesh-delivery-assigner_candidates.>", "$JS.FC.KV_mesh-delivery-assigner_wants.>", "$JS.FC.KV_mesh-delivery-builder_builds.>", "$JS.FC.KV_mesh-delivery-indexer_candidates.>", "$JS.FC.KV_mesh-delivery-indexer_manifests.>", "$JS.FC.KV_mesh-delivery-indexer_modules.>", "$JS.FC.KV_mesh-delivery-indexer_verdicts.>", "$JS.FC.KV_mesh-host_acts.>", "$JS.FC.KV_mesh-host_bounds.>", "$JS.FC.KV_mesh-host_data.>", "$JS.FC.KV_mesh-host_findings.>", "$JS.FC.KV_mesh-host_health.>", "$JS.FC.KV_mesh-host_packages.>", "$JS.FC.KV_mesh-provisioner_provisions.>", "$JS.FC.KV_node-engine_have.>", "$JS.FC.OBJ_declaration-files-one.>", "$KV.composed-one.>", "$KV.mesh-host_acts.one.>", "$KV.mesh-host_bounds.>", "$KV.mesh-host_data.one.>", "$KV.mesh-host_findings.machine.one.>", "$KV.mesh-host_health.one", "$KV.mesh-host_packages.one", "$KV.node-engine_have.one.>", "$SRV.INFO", "$SRV.INFO.>", "$SRV.PING", "$SRV.PING.*.one", "$SRV.PING.>", "mesh.control.one.>", "mesh.seat.*.accept.>", "mesh.seat.node-backup.call.backed-up.one.node~one", "mesh.seat.node-backup.call.now.one.node~one", "mesh.seat.node-backup.tool.backed-up.one", "mesh.seat.node-backup.tool.now.one", "mesh.seat.node-engine.event.*.one"] } subscribe: { allow: ["$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments", "$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates", "$SRV.INFO", "$SRV.INFO.node-engine", "$SRV.INFO.node-engine.>", "$SRV.PING", "$SRV.PING.node-engine", "$SRV.PING.node-engine.>", "$SRV.STATS", "$SRV.STATS.node-engine", "$SRV.STATS.node-engine.>", "_DELIVER.one", "_DELIVER.one.>", "_INBOX.node.one.>", "mesh.node.one.ask.access-act", "mesh.node.one.ask.hand-over", "mesh.node.one.ask.judge-directories", "mesh.node.one.ask.move-secret", "mesh.node.one.ask.report", "mesh.node.one.ask.setuid-search", "mesh.node.one.declare", "mesh.seat.node-engine.call.*.one.*", "mesh.seat.node-engine.tool.*.one"] } allow_responses: { max: 1, ttl: "1m" } } } { user: "one.mesh-delivery-watchman", password: "$2a$11$wwwwwwwwwwwwwwwwwwwwww", permissions: { - publish: { allow: ["$JS.ACK.DEAD_LETTER_NOTICES.mesh-delivery-watchman.>", "$JS.ACK.EVENTS.one_mesh-delivery-watchman.>", "$JS.API.CONSUMER.CREATE.DEAD_LETTER_NOTICES.mesh-delivery-watchman", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.mesh-delivery-watchman", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.DEAD_LETTER_NOTICES.controller", "$JS.API.CONSUMER.INFO.DEAD_LETTER_NOTICES.mesh-delivery-watchman", "$JS.API.CONSUMER.INFO.EVENTS.one_mesh-delivery-watchman", "$JS.API.CONSUMER.MSG.NEXT.DEAD_LETTER_NOTICES.mesh-delivery-watchman", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-delivery-watchman", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.mesh-delivery-watchman", "$JS.API.DIRECT.GET.PROV_APPLIED.>", "$JS.API.STREAM.INFO.DEAD_LETTERS", "$JS.API.STREAM.INFO.DEAD_LETTER_NOTICES", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.API.STREAM.INFO.PROV_APPLIED", "$JS.API.STREAM.MSG.GET.DEAD_LETTERS", "$JS.API.STREAM.MSG.GET.PROV_APPLIED", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.bus.connz", "mesh.events.dead.>"] } + publish: { allow: ["$JS.ACK.DEAD_LETTER_NOTICES.mesh-delivery-watchman.>", "$JS.ACK.EVENTS.one_mesh-delivery-watchman.>", "$JS.ACK.EVENTS.one_mesh-delivery-watchman_tools.>", "$JS.API.CONSUMER.CREATE.DEAD_LETTER_NOTICES.mesh-delivery-watchman", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.mesh-delivery-watchman", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.DEAD_LETTER_NOTICES.controller", "$JS.API.CONSUMER.INFO.DEAD_LETTER_NOTICES.mesh-delivery-watchman", "$JS.API.CONSUMER.INFO.EVENTS.one_mesh-delivery-watchman", "$JS.API.CONSUMER.INFO.EVENTS.one_mesh-delivery-watchman_tools", "$JS.API.CONSUMER.MSG.NEXT.DEAD_LETTER_NOTICES.mesh-delivery-watchman", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-delivery-watchman", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-delivery-watchman_tools", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.mesh-delivery-watchman", "$JS.API.DIRECT.GET.PROV_APPLIED.>", "$JS.API.STREAM.INFO.DEAD_LETTERS", "$JS.API.STREAM.INFO.DEAD_LETTER_NOTICES", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.API.STREAM.INFO.PROV_APPLIED", "$JS.API.STREAM.MSG.GET.DEAD_LETTERS", "$JS.API.STREAM.MSG.GET.PROV_APPLIED", "$JS.API.STREAM.NAMES", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.bus.connz", "mesh.events.dead.>", "mesh.seat.*.accept.>"] } subscribe: { allow: ["$JS.EVENT.ADVISORY.CONSUMER.DELETED.>", "$SRV.INFO", "$SRV.INFO.mesh-delivery-watchman", "$SRV.INFO.mesh-delivery-watchman.>", "$SRV.PING", "$SRV.PING.mesh-delivery-watchman", "$SRV.PING.mesh-delivery-watchman.>", "$SRV.STATS", "$SRV.STATS.mesh-delivery-watchman", "$SRV.STATS.mesh-delivery-watchman.>", "_INBOX.one.mesh-delivery-watchman.>", "mesh.bus.connect", "mesh.bus.disconnect", "mesh.control.*.tools-alive", "mesh.events.dead.>", "mesh.mod.*.event.provisioner.failing", "mesh.mod.*.event.provisioner.recovered", "mesh.mod.mesh-delivery-watchman.call.>", "mesh.mod.mesh-delivery-watchman.tool.>", "mesh.mod.nats.event.bus.connection-closed", "mesh.mod.nats.event.bus.slow-consumer", "mesh.mod.power.event.*", "mesh.seat.mesh-self-check.event.checked", "prov.applied.>"] } allow_responses: { max: 1, ttl: "1m" } } } @@ -47,17 +47,17 @@ accounts { subscribe: { allow: ["_INBOX.one.nats.>"] } } } { user: "one.telegram", password: "$2a$11$tttttttttttttttttttttt", permissions: { - publish: { allow: ["$JS.ACK.EVENTS.one_telegram.>", "$JS.ACK.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker.>", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.telegram", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.EVENTS.one_telegram", "$JS.API.CONSUMER.INFO.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram", "$JS.API.CONSUMER.MSG.NEXT.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.telegram", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.seat.telegram-sender.event.delivered", "mesh.seat.telegram-sender.event.failed"] } + publish: { allow: ["$JS.ACK.EVENTS.one_telegram.>", "$JS.ACK.EVENTS.one_telegram_tools.>", "$JS.ACK.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker.>", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.telegram", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.EVENTS.one_telegram", "$JS.API.CONSUMER.INFO.EVENTS.one_telegram_tools", "$JS.API.CONSUMER.INFO.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram_tools", "$JS.API.CONSUMER.MSG.NEXT.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.telegram", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.API.STREAM.NAMES", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.seat.*.accept.>", "mesh.seat.telegram-sender.event.delivered", "mesh.seat.telegram-sender.event.failed"] } subscribe: { allow: ["$SRV.INFO", "$SRV.INFO.telegram", "$SRV.INFO.telegram.>", "$SRV.PING", "$SRV.PING.telegram", "$SRV.PING.telegram.>", "$SRV.STATS", "$SRV.STATS.telegram", "$SRV.STATS.telegram.>", "_INBOX.one.telegram.>", "mesh.mod.telegram.call.>", "mesh.mod.telegram.tool.>", "mesh.seat.telegram-sender.accept.send"] } allow_responses: { max: 1, ttl: "1m" } } } { user: "two.audit", password: "$2a$11$aaaaaaaaaaaaaaaaaaaaaa", permissions: { - publish: { allow: ["$JS.ACK.EVENTS.two_audit.>", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.audit", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.EVENTS.two_audit", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_audit", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.audit", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.FC.KV_mesh-grants_memberships.>"] } + publish: { allow: ["$JS.ACK.EVENTS.two_audit.>", "$JS.ACK.EVENTS.two_audit_tools.>", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.audit", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.EVENTS.two_audit", "$JS.API.CONSUMER.INFO.EVENTS.two_audit_tools", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_audit", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_audit_tools", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.audit", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.API.STREAM.NAMES", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.seat.*.accept.>"] } subscribe: { allow: ["$SRV.INFO", "$SRV.INFO.audit", "$SRV.INFO.audit.>", "$SRV.PING", "$SRV.PING.audit", "$SRV.PING.audit.>", "$SRV.STATS", "$SRV.STATS.audit", "$SRV.STATS.audit.>", "_INBOX.two.audit.>", "mesh.mod.audit.call.>", "mesh.mod.audit.tool.>", "mesh.mod.shop.event.order.placed"] } allow_responses: { max: 1, ttl: "1m" } } } { user: "two.shop", password: "$2a$11$ssssssssssssssssssssss", permissions: { - publish: { allow: ["$JS.ACK.EVENTS.two_shop.>", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.shop", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.EVENTS.two_shop", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.shop", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.mod.shop.event.order.placed", "mesh.seat.telegram-sender.accept.send"] } + publish: { allow: ["$JS.ACK.EVENTS.two_shop.>", "$JS.ACK.EVENTS.two_shop_tools.>", "$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.shop", "$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.>", "$JS.API.CONSUMER.INFO.EVENTS.two_shop", "$JS.API.CONSUMER.INFO.EVENTS.two_shop_tools", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop", "$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop_tools", "$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.shop", "$JS.API.STREAM.INFO.KV_mesh-grants_memberships", "$JS.API.STREAM.NAMES", "$JS.FC.KV_mesh-grants_memberships.>", "mesh.mod.shop.event.order.placed", "mesh.seat.*.accept.>", "mesh.seat.telegram-sender.accept.send"] } subscribe: { allow: ["$SRV.INFO", "$SRV.INFO.shop", "$SRV.INFO.shop.>", "$SRV.PING", "$SRV.PING.shop", "$SRV.PING.shop.>", "$SRV.STATS", "$SRV.STATS.shop", "$SRV.STATS.shop.>", "_INBOX.two.shop.>", "mesh.mod.shop.call.>", "mesh.mod.shop.tool.>"] } allow_responses: { max: 1, ttl: "1m" } } } diff --git a/modules/mesh-grants/internal/buscompose/testdata/user-lists.json b/modules/mesh-grants/internal/buscompose/testdata/user-lists.json index 63b8be2d..d3ebf49f 100644 --- a/modules/mesh-grants/internal/buscompose/testdata/user-lists.json +++ b/modules/mesh-grants/internal/buscompose/testdata/user-lists.json @@ -8,7 +8,7 @@ }, { "Name": "the controller's someRecords", - "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"node.one\", password: \"$2a$11$node.onenode.onenode.ofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.one.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-one.*.$O.declaration-files-one.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-one.*\", \"$JS.API.CONSUMER.INFO.NODES.one\", \"$JS.API.DIRECT.GET.KV_composed-one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.one\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.one\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.one.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-one.$O.declaration-files-one.M.*\", \"$JS.API.STREAM.INFO.KV_composed-one\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.FC.KV_composed-one.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-one.\u003e\", \"$KV.composed-one.\u003e\", \"$KV.mesh-host_acts.one.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.one.\u003e\", \"$KV.mesh-host_findings.machine.one.\u003e\", \"$KV.mesh-host_health.one\", \"$KV.mesh-host_packages.one\", \"$KV.node-engine_have.one.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.one\", \"$SRV.PING.\u003e\", \"mesh.control.one.\u003e\", \"mesh.seat.node-backup.call.backed-up.one.node~one\", \"mesh.seat.node-backup.call.now.one.node~one\", \"mesh.seat.node-backup.tool.backed-up.one\", \"mesh.seat.node-backup.tool.now.one\", \"mesh.seat.node-engine.event.*.one\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.one\", \"_DELIVER.one.\u003e\", \"_INBOX.node.one.\u003e\", \"mesh.node.one.ask.access-act\", \"mesh.node.one.ask.hand-over\", \"mesh.node.one.ask.judge-directories\", \"mesh.node.one.ask.move-secret\", \"mesh.node.one.ask.report\", \"mesh.node.one.ask.setuid-search\", \"mesh.node.one.declare\", \"mesh.seat.node-engine.call.*.one.*\", \"mesh.seat.node-engine.tool.*.one\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.two\", password: \"$2a$11$node.twonode.twonode.tfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.two.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-two.*.$O.declaration-files-two.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-two.*\", \"$JS.API.CONSUMER.INFO.NODES.two\", \"$JS.API.DIRECT.GET.KV_composed-two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.two\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.two\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.two.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-two.$O.declaration-files-two.M.*\", \"$JS.API.STREAM.INFO.KV_composed-two\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.FC.KV_composed-two.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-two.\u003e\", \"$KV.composed-two.\u003e\", \"$KV.mesh-host_acts.two.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.two.\u003e\", \"$KV.mesh-host_findings.machine.two.\u003e\", \"$KV.mesh-host_health.two\", \"$KV.mesh-host_packages.two\", \"$KV.node-engine_have.two.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.two\", \"$SRV.PING.\u003e\", \"mesh.control.two.\u003e\", \"mesh.seat.node-backup.call.backed-up.two.node~two\", \"mesh.seat.node-backup.call.now.two.node~two\", \"mesh.seat.node-backup.tool.backed-up.two\", \"mesh.seat.node-backup.tool.now.two\", \"mesh.seat.node-engine.event.*.two\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.two\", \"_DELIVER.two.\u003e\", \"_INBOX.node.two.\u003e\", \"mesh.node.two.ask.access-act\", \"mesh.node.two.ask.hand-over\", \"mesh.node.two.ask.judge-directories\", \"mesh.node.two.ask.move-secret\", \"mesh.node.two.ask.report\", \"mesh.node.two.ask.setuid-search\", \"mesh.node.two.declare\", \"mesh.seat.node-engine.call.*.two.*\", \"mesh.seat.node-engine.tool.*.two\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.telegram\", password: \"$2a$11$one.telegramone.telegrfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_telegram.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.one_telegram\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.telegram\", \"$SRV.INFO.telegram.\u003e\", \"$SRV.PING\", \"$SRV.PING.telegram\", \"$SRV.PING.telegram.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.telegram\", \"$SRV.STATS.telegram.\u003e\", \"_INBOX.one.telegram.\u003e\", \"mesh.mod.telegram.call.\u003e\", \"mesh.mod.telegram.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"person.ada\", password: \"$2a$11$person.adaperson.adapefixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.\u003e\", \"mesh.mod.mesh-catalog.call.catalog_tools.*.person~ada\", \"mesh.mod.mesh-catalog.call.catalog_tools.person~ada\", \"mesh.mod.mesh-catalog.tool.catalog_tools\", \"mesh.mod.mesh-catalog.tool.catalog_tools.*\"] }\n subscribe: { allow: [\"_INBOX.person.ada.\u003e\"] }\n } }\n { user: \"two.shop\", password: \"$2a$11$two.shoptwo.shoptwo.shfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.two_shop.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.two_shop\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.mod.shop.event.order.placed\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.shop\", \"$SRV.INFO.shop.\u003e\", \"$SRV.PING\", \"$SRV.PING.shop\", \"$SRV.PING.shop.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.shop\", \"$SRV.STATS.shop.\u003e\", \"_INBOX.two.shop.\u003e\", \"mesh.mod.shop.call.\u003e\", \"mesh.mod.shop.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", + "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"node.one\", password: \"$2a$11$node.onenode.onenode.ofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.one.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-one.*.$O.declaration-files-one.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-one.*\", \"$JS.API.CONSUMER.INFO.NODES.one\", \"$JS.API.DIRECT.GET.KV_composed-one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.one\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.one\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.one.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-one.$O.declaration-files-one.M.*\", \"$JS.API.STREAM.INFO.KV_composed-one\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-one.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-one.\u003e\", \"$KV.composed-one.\u003e\", \"$KV.mesh-host_acts.one.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.one.\u003e\", \"$KV.mesh-host_findings.machine.one.\u003e\", \"$KV.mesh-host_health.one\", \"$KV.mesh-host_packages.one\", \"$KV.node-engine_have.one.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.one\", \"$SRV.PING.\u003e\", \"mesh.control.one.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.one.node~one\", \"mesh.seat.node-backup.call.now.one.node~one\", \"mesh.seat.node-backup.tool.backed-up.one\", \"mesh.seat.node-backup.tool.now.one\", \"mesh.seat.node-engine.event.*.one\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.one\", \"_DELIVER.one.\u003e\", \"_INBOX.node.one.\u003e\", \"mesh.node.one.ask.access-act\", \"mesh.node.one.ask.hand-over\", \"mesh.node.one.ask.judge-directories\", \"mesh.node.one.ask.move-secret\", \"mesh.node.one.ask.report\", \"mesh.node.one.ask.setuid-search\", \"mesh.node.one.declare\", \"mesh.seat.node-engine.call.*.one.*\", \"mesh.seat.node-engine.tool.*.one\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.two\", password: \"$2a$11$node.twonode.twonode.tfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.two.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-two.*.$O.declaration-files-two.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-two.*\", \"$JS.API.CONSUMER.INFO.NODES.two\", \"$JS.API.DIRECT.GET.KV_composed-two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.two\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.two\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.two.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-two.$O.declaration-files-two.M.*\", \"$JS.API.STREAM.INFO.KV_composed-two\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-two.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-two.\u003e\", \"$KV.composed-two.\u003e\", \"$KV.mesh-host_acts.two.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.two.\u003e\", \"$KV.mesh-host_findings.machine.two.\u003e\", \"$KV.mesh-host_health.two\", \"$KV.mesh-host_packages.two\", \"$KV.node-engine_have.two.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.two\", \"$SRV.PING.\u003e\", \"mesh.control.two.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.two.node~two\", \"mesh.seat.node-backup.call.now.two.node~two\", \"mesh.seat.node-backup.tool.backed-up.two\", \"mesh.seat.node-backup.tool.now.two\", \"mesh.seat.node-engine.event.*.two\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.two\", \"_DELIVER.two.\u003e\", \"_INBOX.node.two.\u003e\", \"mesh.node.two.ask.access-act\", \"mesh.node.two.ask.hand-over\", \"mesh.node.two.ask.judge-directories\", \"mesh.node.two.ask.move-secret\", \"mesh.node.two.ask.report\", \"mesh.node.two.ask.setuid-search\", \"mesh.node.two.declare\", \"mesh.seat.node-engine.call.*.two.*\", \"mesh.seat.node-engine.tool.*.two\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.telegram\", password: \"$2a$11$one.telegramone.telegrfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_telegram.\u003e\", \"$JS.ACK.EVENTS.one_telegram_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.one_telegram\", \"$JS.API.CONSUMER.INFO.EVENTS.one_telegram_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.telegram\", \"$SRV.INFO.telegram.\u003e\", \"$SRV.PING\", \"$SRV.PING.telegram\", \"$SRV.PING.telegram.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.telegram\", \"$SRV.STATS.telegram.\u003e\", \"_INBOX.one.telegram.\u003e\", \"mesh.mod.telegram.call.\u003e\", \"mesh.mod.telegram.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"person.ada\", password: \"$2a$11$person.adaperson.adapefixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.\u003e\", \"mesh.mod.mesh-catalog.call.catalog_tools.*.person~ada\", \"mesh.mod.mesh-catalog.call.catalog_tools.person~ada\", \"mesh.mod.mesh-catalog.tool.catalog_tools\", \"mesh.mod.mesh-catalog.tool.catalog_tools.*\"] }\n subscribe: { allow: [\"_INBOX.person.ada.\u003e\"] }\n } }\n { user: \"two.shop\", password: \"$2a$11$two.shoptwo.shoptwo.shfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.two_shop.\u003e\", \"$JS.ACK.EVENTS.two_shop_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.two_shop\", \"$JS.API.CONSUMER.INFO.EVENTS.two_shop_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.mod.shop.event.order.placed\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.shop\", \"$SRV.INFO.shop.\u003e\", \"$SRV.PING\", \"$SRV.PING.shop\", \"$SRV.PING.shop.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.shop\", \"$SRV.STATS.shop.\u003e\", \"_INBOX.two.shop.\u003e\", \"mesh.mod.shop.call.\u003e\", \"mesh.mod.shop.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", "Missing": null, "Err": "", "Memberships": { @@ -46,7 +46,7 @@ }, { "Name": "seats, consumers, people and a hashless user", - "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"node.one\", password: \"$2a$11$node.onenode.onenode.ofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_user-list.*.$KV.mesh-grants_user-list.sealed\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.one.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-one.*.$O.declaration-files-one.C.*\", \"$JS.API.CONSUMER.CREATE.OBJ_mesh-grants-user-list.*.$O.mesh-grants-user-list.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_user-list.*\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-one.*\", \"$JS.API.CONSUMER.DELETE.OBJ_mesh-grants-user-list.*\", \"$JS.API.CONSUMER.INFO.NODES.one\", \"$JS.API.DIRECT.GET.KV_composed-one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_user-list.$KV.mesh-grants_user-list.sealed\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.one\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.one\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.one.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-one.$O.declaration-files-one.M.*\", \"$JS.API.DIRECT.GET.OBJ_mesh-grants-user-list.$O.mesh-grants-user-list.M.*\", \"$JS.API.STREAM.INFO.KV_composed-one\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-grants_user-list\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.FC.KV_composed-one.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-grants_user-list.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-one.\u003e\", \"$JS.FC.OBJ_mesh-grants-user-list.\u003e\", \"$KV.composed-one.\u003e\", \"$KV.mesh-host_acts.one.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.one.\u003e\", \"$KV.mesh-host_findings.machine.one.\u003e\", \"$KV.mesh-host_health.one\", \"$KV.mesh-host_packages.one\", \"$KV.node-engine_have.one.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.one\", \"$SRV.PING.\u003e\", \"mesh.control.one.\u003e\", \"mesh.seat.node-backup.call.backed-up.one.node~one\", \"mesh.seat.node-backup.call.now.one.node~one\", \"mesh.seat.node-backup.tool.backed-up.one\", \"mesh.seat.node-backup.tool.now.one\", \"mesh.seat.node-engine.event.*.one\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.one\", \"_DELIVER.one.\u003e\", \"_INBOX.node.one.\u003e\", \"mesh.node.one.ask.access-act\", \"mesh.node.one.ask.hand-over\", \"mesh.node.one.ask.judge-directories\", \"mesh.node.one.ask.move-secret\", \"mesh.node.one.ask.report\", \"mesh.node.one.ask.setuid-search\", \"mesh.node.one.declare\", \"mesh.seat.node-engine.call.*.one.*\", \"mesh.seat.node-engine.tool.*.one\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.two\", password: \"$2a$11$node.twonode.twonode.tfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.two.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-two.*.$O.declaration-files-two.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-two.*\", \"$JS.API.CONSUMER.INFO.NODES.two\", \"$JS.API.DIRECT.GET.KV_composed-two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.two\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.two\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.two.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-two.$O.declaration-files-two.M.*\", \"$JS.API.STREAM.INFO.KV_composed-two\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.FC.KV_composed-two.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-two.\u003e\", \"$KV.composed-two.\u003e\", \"$KV.mesh-host_acts.two.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.two.\u003e\", \"$KV.mesh-host_findings.machine.two.\u003e\", \"$KV.mesh-host_health.two\", \"$KV.mesh-host_packages.two\", \"$KV.node-engine_have.two.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.two\", \"$SRV.PING.\u003e\", \"mesh.control.two.\u003e\", \"mesh.seat.node-backup.call.backed-up.two.node~two\", \"mesh.seat.node-backup.call.now.two.node~two\", \"mesh.seat.node-backup.tool.backed-up.two\", \"mesh.seat.node-backup.tool.now.two\", \"mesh.seat.node-engine.event.*.two\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.two\", \"_DELIVER.two.\u003e\", \"_INBOX.node.two.\u003e\", \"mesh.node.two.ask.access-act\", \"mesh.node.two.ask.hand-over\", \"mesh.node.two.ask.judge-directories\", \"mesh.node.two.ask.move-secret\", \"mesh.node.two.ask.report\", \"mesh.node.two.ask.setuid-search\", \"mesh.node.two.declare\", \"mesh.seat.node-engine.call.*.two.*\", \"mesh.seat.node-engine.tool.*.two\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.mesh-grants\", password: \"$2a$11$one.mesh-grantsone.mesfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_mesh-grants.\u003e\", \"$JS.API.CONSUMER.CREATE.EVENTS.two_audit\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.mesh-grants\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.one_mesh-grants\", \"$JS.API.CONSUMER.INFO.EVENTS.two_audit\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-grants\", \"$JS.API.DIRECT.GET.ASSIGNMENTS.mesh.assignment.*.*\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.mesh-grants\", \"$JS.API.DIRECT.GET.OBJ_mesh-grants-user-list.\u003e\", \"$JS.API.STREAM.CREATE.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.MSG.GET.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.PURGE.OBJ_mesh-grants-user-list\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"$O.mesh-grants-user-list.\u003e\", \"mesh.assignment.*.*\", \"mesh.mod.mesh-grants.event.membership-changed\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.mesh-grants\", \"$SRV.INFO.mesh-grants.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-grants\", \"$SRV.PING.mesh-grants.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-grants\", \"$SRV.STATS.mesh-grants.\u003e\", \"_INBOX.one.mesh-grants.\u003e\", \"mesh.mod.mesh-grants.call.\u003e\", \"mesh.mod.mesh-grants.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.mesh-watchman\", password: \"$2a$11$one.mesh-watchmanone.mfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_mesh-watchman.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.mesh-watchman\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.one_mesh-watchman\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-watchman\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.mesh-watchman\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.mesh-watchman\", \"$SRV.INFO.mesh-watchman.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-watchman\", \"$SRV.PING.mesh-watchman.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-watchman\", \"$SRV.STATS.mesh-watchman.\u003e\", \"_INBOX.one.mesh-watchman.\u003e\", \"mesh.mod.mesh-watchman.call.\u003e\", \"mesh.mod.mesh-watchman.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.nats\", password: \"$2a$11$one.natsone.natsone.nafixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.API.STREAM.INFO.*\", \"$JS.API.STREAM.NAMES\", \"$JS.API.STREAM.SNAPSHOT.*\", \"$JS.SNAPSHOT.ACK.\u003e\"] }\n subscribe: { allow: [\"_INBOX.one.nats.\u003e\"] }\n } }\n { user: \"one.telegram\", password: \"$2a$11$one.telegramone.telegrfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_telegram.\u003e\", \"$JS.ACK.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.one_telegram\", \"$JS.API.CONSUMER.INFO.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram\", \"$JS.API.CONSUMER.MSG.NEXT.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.telegram-sender.event.delivered\", \"mesh.seat.telegram-sender.event.failed\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.telegram\", \"$SRV.INFO.telegram.\u003e\", \"$SRV.PING\", \"$SRV.PING.telegram\", \"$SRV.PING.telegram.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.telegram\", \"$SRV.STATS.telegram.\u003e\", \"_INBOX.one.telegram.\u003e\", \"mesh.mod.telegram.call.\u003e\", \"mesh.mod.telegram.tool.\u003e\", \"mesh.seat.telegram-sender.accept.send\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"person.ada\", password: \"$2a$11$person.adaperson.adapefixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.\u003e\", \"mesh.mod.*.call.*.*.person~ada\", \"mesh.mod.*.call.*.person~ada\", \"mesh.mod.*.tool.\u003e\", \"mesh.seat.*.call.*.*.person~ada\", \"mesh.seat.*.call.*.person~ada\", \"mesh.seat.*.tool.\u003e\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.mod.*.tool.node-launcher.secret\", \"mesh.mod.*.tool.node-launcher.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.mod.*.call.node-launcher.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"_INBOX.person.ada.\u003e\"] }\n } }\n { user: \"person.bob\", password: \"$2a$11$person.bobperson.bobpefixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.\u003e\", \"mesh.mod.shop.call.status.*.person~bob\", \"mesh.mod.shop.call.status.person~bob\", \"mesh.mod.shop.tool.status\", \"mesh.mod.shop.tool.status.*\"] }\n subscribe: { allow: [\"_INBOX.person.bob.\u003e\"] }\n } }\n { user: \"two.shop\", password: \"$2a$11$two.shoptwo.shoptwo.shfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.two_shop.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.two_shop\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.mod.shop.event.order.placed\", \"mesh.seat.telegram-sender.accept.send\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.shop\", \"$SRV.INFO.shop.\u003e\", \"$SRV.PING\", \"$SRV.PING.shop\", \"$SRV.PING.shop.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.shop\", \"$SRV.STATS.shop.\u003e\", \"_INBOX.two.shop.\u003e\", \"mesh.mod.shop.call.\u003e\", \"mesh.mod.shop.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", + "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"node.one\", password: \"$2a$11$node.onenode.onenode.ofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_user-list.*.$KV.mesh-grants_user-list.sealed\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.one\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.one.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-one.*.$O.declaration-files-one.C.*\", \"$JS.API.CONSUMER.CREATE.OBJ_mesh-grants-user-list.*.$O.mesh-grants-user-list.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-one.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_user-list.*\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-one.*\", \"$JS.API.CONSUMER.DELETE.OBJ_mesh-grants-user-list.*\", \"$JS.API.CONSUMER.INFO.NODES.one\", \"$JS.API.DIRECT.GET.KV_composed-one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_user-list.$KV.mesh-grants_user-list.sealed\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.one.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.one\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.one\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.one.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.one.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-one.$O.declaration-files-one.M.*\", \"$JS.API.DIRECT.GET.OBJ_mesh-grants-user-list.$O.mesh-grants-user-list.M.*\", \"$JS.API.STREAM.INFO.KV_composed-one\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-grants_user-list\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-one.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-grants_user-list.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-one.\u003e\", \"$JS.FC.OBJ_mesh-grants-user-list.\u003e\", \"$KV.composed-one.\u003e\", \"$KV.mesh-host_acts.one.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.one.\u003e\", \"$KV.mesh-host_findings.machine.one.\u003e\", \"$KV.mesh-host_health.one\", \"$KV.mesh-host_packages.one\", \"$KV.node-engine_have.one.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.one\", \"$SRV.PING.\u003e\", \"mesh.control.one.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.one.node~one\", \"mesh.seat.node-backup.call.now.one.node~one\", \"mesh.seat.node-backup.tool.backed-up.one\", \"mesh.seat.node-backup.tool.now.one\", \"mesh.seat.node-engine.event.*.one\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.one\", \"_DELIVER.one.\u003e\", \"_INBOX.node.one.\u003e\", \"mesh.node.one.ask.access-act\", \"mesh.node.one.ask.hand-over\", \"mesh.node.one.ask.judge-directories\", \"mesh.node.one.ask.move-secret\", \"mesh.node.one.ask.report\", \"mesh.node.one.ask.setuid-search\", \"mesh.node.one.declare\", \"mesh.seat.node-engine.call.*.one.*\", \"mesh.seat.node-engine.tool.*.one\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.two\", password: \"$2a$11$node.twonode.twonode.tfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.two\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.two.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-two.*.$O.declaration-files-two.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-two.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-two.*\", \"$JS.API.CONSUMER.INFO.NODES.two\", \"$JS.API.DIRECT.GET.KV_composed-two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.two.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.two\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.two\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.two.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.two.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-two.$O.declaration-files-two.M.*\", \"$JS.API.STREAM.INFO.KV_composed-two\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-two.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-two.\u003e\", \"$KV.composed-two.\u003e\", \"$KV.mesh-host_acts.two.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.two.\u003e\", \"$KV.mesh-host_findings.machine.two.\u003e\", \"$KV.mesh-host_health.two\", \"$KV.mesh-host_packages.two\", \"$KV.node-engine_have.two.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.two\", \"$SRV.PING.\u003e\", \"mesh.control.two.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.two.node~two\", \"mesh.seat.node-backup.call.now.two.node~two\", \"mesh.seat.node-backup.tool.backed-up.two\", \"mesh.seat.node-backup.tool.now.two\", \"mesh.seat.node-engine.event.*.two\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.two\", \"_DELIVER.two.\u003e\", \"_INBOX.node.two.\u003e\", \"mesh.node.two.ask.access-act\", \"mesh.node.two.ask.hand-over\", \"mesh.node.two.ask.judge-directories\", \"mesh.node.two.ask.move-secret\", \"mesh.node.two.ask.report\", \"mesh.node.two.ask.setuid-search\", \"mesh.node.two.declare\", \"mesh.seat.node-engine.call.*.two.*\", \"mesh.seat.node-engine.tool.*.two\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.mesh-grants\", password: \"$2a$11$one.mesh-grantsone.mesfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_mesh-grants.\u003e\", \"$JS.ACK.EVENTS.one_mesh-grants_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.EVENTS.two_audit\", \"$JS.API.CONSUMER.CREATE.EVENTS.two_audit_tools\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.mesh-grants\", \"$JS.API.CONSUMER.CREATE.OBJ_mesh-grants-user-list.*.$O.mesh-grants-user-list.C.*\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_mesh-grants-user-list.*\", \"$JS.API.CONSUMER.INFO.EVENTS.one_mesh-grants\", \"$JS.API.CONSUMER.INFO.EVENTS.one_mesh-grants_tools\", \"$JS.API.CONSUMER.INFO.EVENTS.two_audit\", \"$JS.API.CONSUMER.INFO.EVENTS.two_audit_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-grants\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-grants_tools\", \"$JS.API.DIRECT.GET.ASSIGNMENTS.mesh.assignment.*.*\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.mesh-grants\", \"$JS.API.DIRECT.GET.OBJ_mesh-grants-user-list.\u003e\", \"$JS.API.STREAM.CREATE.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.MSG.GET.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.NAMES\", \"$JS.API.STREAM.PURGE.OBJ_mesh-grants-user-list\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"$JS.FC.OBJ_mesh-grants-user-list.\u003e\", \"$O.mesh-grants-user-list.\u003e\", \"mesh.assignment.*.*\", \"mesh.mod.mesh-grants.event.membership-changed\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.mesh-grants\", \"$SRV.INFO.mesh-grants.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-grants\", \"$SRV.PING.mesh-grants.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-grants\", \"$SRV.STATS.mesh-grants.\u003e\", \"_INBOX.one.mesh-grants.\u003e\", \"mesh.mod.mesh-grants.call.\u003e\", \"mesh.mod.mesh-grants.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.mesh-watchman\", password: \"$2a$11$one.mesh-watchmanone.mfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_mesh-watchman.\u003e\", \"$JS.ACK.EVENTS.one_mesh-watchman_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.mesh-watchman\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.one_mesh-watchman\", \"$JS.API.CONSUMER.INFO.EVENTS.one_mesh-watchman_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-watchman\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_mesh-watchman_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.mesh-watchman\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.mesh-watchman\", \"$SRV.INFO.mesh-watchman.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-watchman\", \"$SRV.PING.mesh-watchman.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-watchman\", \"$SRV.STATS.mesh-watchman.\u003e\", \"_INBOX.one.mesh-watchman.\u003e\", \"mesh.mod.mesh-watchman.call.\u003e\", \"mesh.mod.mesh-watchman.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"one.nats\", password: \"$2a$11$one.natsone.natsone.nafixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.API.STREAM.INFO.*\", \"$JS.API.STREAM.NAMES\", \"$JS.API.STREAM.SNAPSHOT.*\", \"$JS.SNAPSHOT.ACK.\u003e\"] }\n subscribe: { allow: [\"_INBOX.one.nats.\u003e\"] }\n } }\n { user: \"one.telegram\", password: \"$2a$11$one.telegramone.telegrfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.one_telegram.\u003e\", \"$JS.ACK.EVENTS.one_telegram_tools.\u003e\", \"$JS.ACK.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.one_telegram\", \"$JS.API.CONSUMER.INFO.EVENTS.one_telegram_tools\", \"$JS.API.CONSUMER.INFO.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.one_telegram_tools\", \"$JS.API.CONSUMER.MSG.NEXT.SEAT_TELEGRAM_SENDER.SEAT_TELEGRAM_SENDER_worker\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.one.telegram\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.telegram-sender.event.delivered\", \"mesh.seat.telegram-sender.event.failed\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.telegram\", \"$SRV.INFO.telegram.\u003e\", \"$SRV.PING\", \"$SRV.PING.telegram\", \"$SRV.PING.telegram.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.telegram\", \"$SRV.STATS.telegram.\u003e\", \"_INBOX.one.telegram.\u003e\", \"mesh.mod.telegram.call.\u003e\", \"mesh.mod.telegram.tool.\u003e\", \"mesh.seat.telegram-sender.accept.send\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"person.ada\", password: \"$2a$11$person.adaperson.adapefixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.\u003e\", \"mesh.mod.*.call.*.*.person~ada\", \"mesh.mod.*.call.*.person~ada\", \"mesh.mod.*.tool.\u003e\", \"mesh.seat.*.call.*.*.person~ada\", \"mesh.seat.*.call.*.person~ada\", \"mesh.seat.*.tool.\u003e\"], deny: [\"mesh.seat.node-launcher.tool.secret\", \"mesh.seat.node-launcher.tool.secret.*\", \"mesh.mod.*.tool.node-launcher.secret\", \"mesh.mod.*.tool.node-launcher.secret.*\", \"mesh.seat.node-launcher.call.secret.\u003e\", \"mesh.mod.*.call.node-launcher.secret.\u003e\", \"mesh.seat.mesh-broker.call.apply.\u003e\", \"mesh.seat.mesh-broker.call.create.\u003e\", \"mesh.seat.mesh-broker.call.drop.\u003e\", \"mesh.seat.mesh-broker.call.recreate.\u003e\", \"mesh.seat.mesh-broker.tool.apply\", \"mesh.seat.mesh-broker.tool.create\", \"mesh.seat.mesh-broker.tool.drop\", \"mesh.seat.mesh-broker.tool.recreate\"] }\n subscribe: { allow: [\"_INBOX.person.ada.\u003e\"] }\n } }\n { user: \"person.bob\", password: \"$2a$11$person.bobperson.bobpefixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.\u003e\", \"mesh.mod.shop.call.status.*.person~bob\", \"mesh.mod.shop.call.status.person~bob\", \"mesh.mod.shop.tool.status\", \"mesh.mod.shop.tool.status.*\"] }\n subscribe: { allow: [\"_INBOX.person.bob.\u003e\"] }\n } }\n { user: \"two.shop\", password: \"$2a$11$two.shoptwo.shoptwo.shfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.two_shop.\u003e\", \"$JS.ACK.EVENTS.two_shop_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.two_shop\", \"$JS.API.CONSUMER.INFO.EVENTS.two_shop_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.two_shop_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.two.shop\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.mod.shop.event.order.placed\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.telegram-sender.accept.send\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.shop\", \"$SRV.INFO.shop.\u003e\", \"$SRV.PING\", \"$SRV.PING.shop\", \"$SRV.PING.shop.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.shop\", \"$SRV.STATS.shop.\u003e\", \"_INBOX.two.shop.\u003e\", \"mesh.mod.shop.call.\u003e\", \"mesh.mod.shop.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", "Missing": [ "two.audit" ], @@ -152,7 +152,7 @@ }, { "Name": "state, logs, streams, queues and processes", - "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"ace.plex\", password: \"$2a$11$ace.plexace.plexace.plfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.ace_plex.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.ace.plex\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_plex\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_plex\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.ace.plex\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.plex\", \"$SRV.INFO.plex.\u003e\", \"$SRV.PING\", \"$SRV.PING.plex\", \"$SRV.PING.plex.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.plex\", \"$SRV.STATS.plex.\u003e\", \"_INBOX.ace.plex.\u003e\", \"mesh.mod.plex.call.\u003e\", \"mesh.mod.plex.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.ace\", password: \"$2a$11$node.acenode.acenode.afixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-ace.*.$O.declaration-files-ace.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-ace.*\", \"$JS.API.CONSUMER.INFO.NODES.ace\", \"$JS.API.DIRECT.GET.KV_composed-ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.ace\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.ace\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.ace.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-ace.$O.declaration-files-ace.M.*\", \"$JS.API.STREAM.INFO.KV_composed-ace\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.FC.KV_composed-ace.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-ace.\u003e\", \"$KV.composed-ace.\u003e\", \"$KV.mesh-host_acts.ace.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.ace.\u003e\", \"$KV.mesh-host_findings.machine.ace.\u003e\", \"$KV.mesh-host_health.ace\", \"$KV.mesh-host_packages.ace\", \"$KV.node-engine_have.ace.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.ace\", \"$SRV.PING.\u003e\", \"mesh.control.ace.\u003e\", \"mesh.mod.plex.call.plex_status.ace.node~ace\", \"mesh.mod.plex.tool.plex_status.ace\", \"mesh.seat.node-backup.call.backed-up.ace.node~ace\", \"mesh.seat.node-backup.call.now.ace.node~ace\", \"mesh.seat.node-backup.tool.backed-up.ace\", \"mesh.seat.node-backup.tool.now.ace\", \"mesh.seat.node-engine.event.*.ace\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.ace\", \"_DELIVER.ace.\u003e\", \"_INBOX.node.ace.\u003e\", \"mesh.node.ace.ask.access-act\", \"mesh.node.ace.ask.hand-over\", \"mesh.node.ace.ask.judge-directories\", \"mesh.node.ace.ask.move-secret\", \"mesh.node.ace.ask.report\", \"mesh.node.ace.ask.setuid-search\", \"mesh.node.ace.declare\", \"mesh.seat.node-engine.call.*.ace.*\", \"mesh.seat.node-engine.tool.*.ace\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.novox\", password: \"$2a$11$node.novoxnode.novoxnofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-novox.*.$O.declaration-files-novox.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-novox.*\", \"$JS.API.CONSUMER.INFO.NODES.novox\", \"$JS.API.DIRECT.GET.KV_composed-novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.novox\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.novox\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.novox.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-novox.$O.declaration-files-novox.M.*\", \"$JS.API.STREAM.INFO.KV_composed-novox\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.FC.KV_composed-novox.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-novox.\u003e\", \"$KV.composed-novox.\u003e\", \"$KV.mesh-host_acts.novox.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.novox.\u003e\", \"$KV.mesh-host_findings.machine.novox.\u003e\", \"$KV.mesh-host_health.novox\", \"$KV.mesh-host_packages.novox\", \"$KV.node-engine_have.novox.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.novox\", \"$SRV.PING.\u003e\", \"mesh.control.novox.\u003e\", \"mesh.seat.node-backup.call.backed-up.novox.node~novox\", \"mesh.seat.node-backup.call.now.novox.node~novox\", \"mesh.seat.node-backup.tool.backed-up.novox\", \"mesh.seat.node-backup.tool.now.novox\", \"mesh.seat.node-engine.event.*.novox\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.novox\", \"_DELIVER.novox.\u003e\", \"_INBOX.node.novox.\u003e\", \"mesh.node.novox.ask.access-act\", \"mesh.node.novox.ask.hand-over\", \"mesh.node.novox.ask.judge-directories\", \"mesh.node.novox.ask.move-secret\", \"mesh.node.novox.ask.report\", \"mesh.node.novox.ask.setuid-search\", \"mesh.node.novox.declare\", \"mesh.seat.node-engine.call.*.novox.*\", \"mesh.seat.node-engine.tool.*.novox\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-delivery-builder\", password: \"$2a$11$novox.mesh-delivery-bufixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-delivery-builder.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_presence.*.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_presence.*.$KV.mesh-delivery-builder_presence.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-delivery-builder\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-builder\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-builder\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_presence.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_presence.$KV.mesh-delivery-builder_presence.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-delivery-builder\", \"$JS.API.DIRECT.GET.LOG_mesh-delivery-builder_builds\", \"$JS.API.DIRECT.GET.LOG_mesh-delivery-builder_builds.\u003e\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_NODE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_NODE\", \"$JS.FC.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"$KV.mesh-delivery-builder_presence.novox\", \"$KV.mesh-delivery-builder_presence.novox.\u003e\", \"$KV.mesh-delivery-builder_steps.\u003e\", \"mesh.log.mesh-delivery-builder.builds.\u003e\", \"mesh.mod.gitea.call.gitea_commit.*.novox~mesh-delivery-builder\", \"mesh.mod.gitea.call.gitea_commit.novox~mesh-delivery-builder\", \"mesh.mod.gitea.tool.gitea_commit\", \"mesh.mod.gitea.tool.gitea_commit.*\", \"mesh.mod.mesh-delivery-builder.event.built\", \"mesh.mod.mesh-delivery-builder.event.states\", \"mesh.stream.mesh-delivery-builder.event.ask\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_presence\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_steps\", \"$SRV.INFO\", \"$SRV.INFO.mesh-delivery-builder\", \"$SRV.INFO.mesh-delivery-builder.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-delivery-builder\", \"$SRV.PING.mesh-delivery-builder.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-delivery-builder\", \"$SRV.STATS.mesh-delivery-builder.\u003e\", \"_INBOX.novox.mesh-delivery-builder.\u003e\", \"mesh.mod.mesh-delivery-builder.call.\u003e\", \"mesh.mod.mesh-delivery-builder.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-delivery-builder.worker\", password: \"$2a$11$novox.mesh-delivery-bufixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.asks.novox_mesh-delivery-builder_worker.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.INFO.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.CONSUMER.MSG.NEXT.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.FC.KV_mesh-delivery-builder_steps.\u003e\", \"$KV.mesh-delivery-builder_steps.\u003e\", \"mesh.mod.gitea.call.gitea_commit.*.novox~mesh-delivery-builder~worker\", \"mesh.mod.gitea.call.gitea_commit.novox~mesh-delivery-builder~worker\", \"mesh.mod.gitea.tool.gitea_commit\", \"mesh.mod.gitea.tool.gitea_commit.*\", \"mesh.mod.mesh-delivery-builder.event.built\", \"mesh.mod.mesh-delivery-builder.event.states\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_steps\", \"_INBOX.novox.mesh-delivery-builder.worker.\u003e\"] }\n } }\n { user: \"novox.mesh-delivery-view\", password: \"$2a$11$novox.mesh-delivery-vifixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-delivery-view.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_presence.*.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-delivery-view\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-view\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_CHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_DELIVERY_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_RECHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_IMAGE.SEAT_NODE_BUILD_IMAGE_CHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_IMAGE.SEAT_NODE_BUILD_IMAGE_DELIVERY_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_IMAGE.SEAT_NODE_BUILD_IMAGE_RECHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_NODE.SEAT_NODE_BUILD_NODE_CHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_NODE.SEAT_NODE_BUILD_NODE_DELIVERY_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_NODE.SEAT_NODE_BUILD_NODE_RECHECK_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-view\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_presence.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-delivery-view\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_NODE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_NODE\", \"$JS.FC.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_presence\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_steps\", \"$SRV.INFO\", \"$SRV.INFO.mesh-delivery-view\", \"$SRV.INFO.mesh-delivery-view.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-delivery-view\", \"$SRV.PING.mesh-delivery-view.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-delivery-view\", \"$SRV.STATS.mesh-delivery-view.\u003e\", \"_INBOX.novox.mesh-delivery-view.\u003e\", \"mesh.mod.mesh-delivery-view.call.\u003e\", \"mesh.mod.mesh-delivery-view.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-grants\", password: \"$2a$11$novox.mesh-grantsnovoxfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-grants.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_assertions.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-grants\", \"$JS.API.CONSUMER.CREATE.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_assertions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-grants\", \"$JS.API.CONSUMER.INFO.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-grants\", \"$JS.API.DIRECT.GET.ASSIGNMENTS.mesh.assignment.*.*\", \"$JS.API.DIRECT.GET.KV_mesh-grants_assertions.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-grants\", \"$JS.API.DIRECT.GET.OBJ_mesh-grants-user-list.\u003e\", \"$JS.API.STREAM.CREATE.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.CREATE.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.CREATE.KV_mesh-grants_assertions\", \"$JS.API.STREAM.CREATE.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.CREATE.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.CREATE.asks\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.INFO.KV_mesh-grants_assertions\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.INFO.asks\", \"$JS.API.STREAM.MSG.GET.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.PURGE.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.UPDATE.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.UPDATE.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.UPDATE.KV_mesh-grants_assertions\", \"$JS.API.STREAM.UPDATE.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.UPDATE.asks\", \"$JS.FC.KV_mesh-grants_assertions.\u003e\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"$KV.mesh-grants_assertions.\u003e\", \"$O.mesh-grants-user-list.\u003e\", \"mesh.assignment.*.*\", \"mesh.mod.mesh-grants.event.membership-changed\", \"mesh.mod.mesh-grants.event.states\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-grants_assertions\", \"$SRV.INFO\", \"$SRV.INFO.mesh-grants\", \"$SRV.INFO.mesh-grants.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-grants\", \"$SRV.PING.mesh-grants.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-grants\", \"$SRV.STATS.mesh-grants.\u003e\", \"_INBOX.novox.mesh-grants.\u003e\", \"mesh.mod.mesh-grants.call.\u003e\", \"mesh.mod.mesh-grants.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", + "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"ace.plex\", password: \"$2a$11$ace.plexace.plexace.plfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.ace_plex.\u003e\", \"$JS.ACK.EVENTS.ace_plex_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.ace.plex\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_plex\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_plex_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_plex\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_plex_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.ace.plex\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.plex\", \"$SRV.INFO.plex.\u003e\", \"$SRV.PING\", \"$SRV.PING.plex\", \"$SRV.PING.plex.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.plex\", \"$SRV.STATS.plex.\u003e\", \"_INBOX.ace.plex.\u003e\", \"mesh.mod.plex.call.\u003e\", \"mesh.mod.plex.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.ace\", password: \"$2a$11$node.acenode.acenode.afixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-ace.*.$O.declaration-files-ace.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-ace.*\", \"$JS.API.CONSUMER.INFO.NODES.ace\", \"$JS.API.DIRECT.GET.KV_composed-ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.ace\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.ace\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.ace.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-ace.$O.declaration-files-ace.M.*\", \"$JS.API.STREAM.INFO.KV_composed-ace\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-ace.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-ace.\u003e\", \"$KV.composed-ace.\u003e\", \"$KV.mesh-host_acts.ace.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.ace.\u003e\", \"$KV.mesh-host_findings.machine.ace.\u003e\", \"$KV.mesh-host_health.ace\", \"$KV.mesh-host_packages.ace\", \"$KV.node-engine_have.ace.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.ace\", \"$SRV.PING.\u003e\", \"mesh.control.ace.\u003e\", \"mesh.mod.plex.call.plex_status.ace.node~ace\", \"mesh.mod.plex.tool.plex_status.ace\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.ace.node~ace\", \"mesh.seat.node-backup.call.now.ace.node~ace\", \"mesh.seat.node-backup.tool.backed-up.ace\", \"mesh.seat.node-backup.tool.now.ace\", \"mesh.seat.node-engine.event.*.ace\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.ace\", \"_DELIVER.ace.\u003e\", \"_INBOX.node.ace.\u003e\", \"mesh.node.ace.ask.access-act\", \"mesh.node.ace.ask.hand-over\", \"mesh.node.ace.ask.judge-directories\", \"mesh.node.ace.ask.move-secret\", \"mesh.node.ace.ask.report\", \"mesh.node.ace.ask.setuid-search\", \"mesh.node.ace.declare\", \"mesh.seat.node-engine.call.*.ace.*\", \"mesh.seat.node-engine.tool.*.ace\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.novox\", password: \"$2a$11$node.novoxnode.novoxnofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-novox.*.$O.declaration-files-novox.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-novox.*\", \"$JS.API.CONSUMER.INFO.NODES.novox\", \"$JS.API.DIRECT.GET.KV_composed-novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.novox\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.novox\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.novox.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-novox.$O.declaration-files-novox.M.*\", \"$JS.API.STREAM.INFO.KV_composed-novox\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-novox.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-novox.\u003e\", \"$KV.composed-novox.\u003e\", \"$KV.mesh-host_acts.novox.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.novox.\u003e\", \"$KV.mesh-host_findings.machine.novox.\u003e\", \"$KV.mesh-host_health.novox\", \"$KV.mesh-host_packages.novox\", \"$KV.node-engine_have.novox.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.novox\", \"$SRV.PING.\u003e\", \"mesh.control.novox.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.novox.node~novox\", \"mesh.seat.node-backup.call.now.novox.node~novox\", \"mesh.seat.node-backup.tool.backed-up.novox\", \"mesh.seat.node-backup.tool.now.novox\", \"mesh.seat.node-engine.event.*.novox\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.novox\", \"_DELIVER.novox.\u003e\", \"_INBOX.node.novox.\u003e\", \"mesh.node.novox.ask.access-act\", \"mesh.node.novox.ask.hand-over\", \"mesh.node.novox.ask.judge-directories\", \"mesh.node.novox.ask.move-secret\", \"mesh.node.novox.ask.report\", \"mesh.node.novox.ask.setuid-search\", \"mesh.node.novox.declare\", \"mesh.seat.node-engine.call.*.novox.*\", \"mesh.seat.node-engine.tool.*.novox\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-delivery-builder\", password: \"$2a$11$novox.mesh-delivery-bufixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-delivery-builder.\u003e\", \"$JS.ACK.EVENTS.novox_mesh-delivery-builder_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_presence.*.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_presence.*.$KV.mesh-delivery-builder_presence.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-delivery-builder\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-builder\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-builder_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-builder\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-builder_tools\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_presence.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_presence.$KV.mesh-delivery-builder_presence.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-delivery-builder\", \"$JS.API.DIRECT.GET.LOG_mesh-delivery-builder_builds\", \"$JS.API.DIRECT.GET.LOG_mesh-delivery-builder_builds.\u003e\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_NODE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_NODE\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"$KV.mesh-delivery-builder_presence.novox\", \"$KV.mesh-delivery-builder_presence.novox.\u003e\", \"$KV.mesh-delivery-builder_steps.\u003e\", \"mesh.log.mesh-delivery-builder.builds.\u003e\", \"mesh.mod.gitea.call.gitea_commit.*.novox~mesh-delivery-builder\", \"mesh.mod.gitea.call.gitea_commit.novox~mesh-delivery-builder\", \"mesh.mod.gitea.tool.gitea_commit\", \"mesh.mod.gitea.tool.gitea_commit.*\", \"mesh.mod.mesh-delivery-builder.event.built\", \"mesh.mod.mesh-delivery-builder.event.states\", \"mesh.seat.*.accept.\u003e\", \"mesh.stream.mesh-delivery-builder.event.ask\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_presence\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_steps\", \"$SRV.INFO\", \"$SRV.INFO.mesh-delivery-builder\", \"$SRV.INFO.mesh-delivery-builder.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-delivery-builder\", \"$SRV.PING.mesh-delivery-builder.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-delivery-builder\", \"$SRV.STATS.mesh-delivery-builder.\u003e\", \"_INBOX.novox.mesh-delivery-builder.\u003e\", \"mesh.mod.mesh-delivery-builder.call.\u003e\", \"mesh.mod.mesh-delivery-builder.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-delivery-builder.worker\", password: \"$2a$11$novox.mesh-delivery-bufixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.asks.novox_mesh-delivery-builder_worker.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.INFO.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.CONSUMER.MSG.NEXT.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-delivery-builder_steps.\u003e\", \"$KV.mesh-delivery-builder_steps.\u003e\", \"mesh.mod.gitea.call.gitea_commit.*.novox~mesh-delivery-builder~worker\", \"mesh.mod.gitea.call.gitea_commit.novox~mesh-delivery-builder~worker\", \"mesh.mod.gitea.tool.gitea_commit\", \"mesh.mod.gitea.tool.gitea_commit.*\", \"mesh.mod.mesh-delivery-builder.event.built\", \"mesh.mod.mesh-delivery-builder.event.states\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_steps\", \"_INBOX.novox.mesh-delivery-builder.worker.\u003e\"] }\n } }\n { user: \"novox.mesh-delivery-view\", password: \"$2a$11$novox.mesh-delivery-vifixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-delivery-view.\u003e\", \"$JS.ACK.EVENTS.novox_mesh-delivery-view_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_presence.*.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-delivery-view\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-view\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-view_tools\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_CHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_DELIVERY_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_RECHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_IMAGE.SEAT_NODE_BUILD_IMAGE_CHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_IMAGE.SEAT_NODE_BUILD_IMAGE_DELIVERY_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_IMAGE.SEAT_NODE_BUILD_IMAGE_RECHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_NODE.SEAT_NODE_BUILD_NODE_CHECK_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_NODE.SEAT_NODE_BUILD_NODE_DELIVERY_worker\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_NODE.SEAT_NODE_BUILD_NODE_RECHECK_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-view\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-view_tools\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_presence.$KV.mesh-delivery-builder_presence.novox\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-delivery-view\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_NODE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_GO\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_IMAGE\", \"$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_NODE\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-delivery-builder_presence.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_steps.\u003e\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_presence\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-builder_steps\", \"$SRV.INFO\", \"$SRV.INFO.mesh-delivery-view\", \"$SRV.INFO.mesh-delivery-view.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-delivery-view\", \"$SRV.PING.mesh-delivery-view.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-delivery-view\", \"$SRV.STATS.mesh-delivery-view.\u003e\", \"_INBOX.novox.mesh-delivery-view.\u003e\", \"mesh.mod.mesh-delivery-view.call.\u003e\", \"mesh.mod.mesh-delivery-view.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-grants\", password: \"$2a$11$novox.mesh-grantsnovoxfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-grants.\u003e\", \"$JS.ACK.EVENTS.novox_mesh-grants_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_assertions.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-grants\", \"$JS.API.CONSUMER.CREATE.OBJ_mesh-grants-user-list.*.$O.mesh-grants-user-list.C.*\", \"$JS.API.CONSUMER.CREATE.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_assertions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_mesh-grants-user-list.*\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-grants\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-grants_tools\", \"$JS.API.CONSUMER.INFO.asks.novox_mesh-delivery-builder_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-grants\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-grants_tools\", \"$JS.API.DIRECT.GET.ASSIGNMENTS.mesh.assignment.*.*\", \"$JS.API.DIRECT.GET.KV_mesh-grants_assertions.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-grants\", \"$JS.API.DIRECT.GET.OBJ_mesh-grants-user-list.\u003e\", \"$JS.API.STREAM.CREATE.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.CREATE.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.CREATE.KV_mesh-grants_assertions\", \"$JS.API.STREAM.CREATE.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.CREATE.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.CREATE.asks\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.INFO.KV_mesh-grants_assertions\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.INFO.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.INFO.asks\", \"$JS.API.STREAM.MSG.GET.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.NAMES\", \"$JS.API.STREAM.PURGE.OBJ_mesh-grants-user-list\", \"$JS.API.STREAM.UPDATE.KV_mesh-delivery-builder_presence\", \"$JS.API.STREAM.UPDATE.KV_mesh-delivery-builder_steps\", \"$JS.API.STREAM.UPDATE.KV_mesh-grants_assertions\", \"$JS.API.STREAM.UPDATE.LOG_mesh-delivery-builder_builds\", \"$JS.API.STREAM.UPDATE.asks\", \"$JS.FC.KV_mesh-grants_assertions.\u003e\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"$JS.FC.OBJ_mesh-grants-user-list.\u003e\", \"$KV.mesh-grants_assertions.\u003e\", \"$O.mesh-grants-user-list.\u003e\", \"mesh.assignment.*.*\", \"mesh.mod.mesh-grants.event.membership-changed\", \"mesh.mod.mesh-grants.event.states\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-grants_assertions\", \"$SRV.INFO\", \"$SRV.INFO.mesh-grants\", \"$SRV.INFO.mesh-grants.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-grants\", \"$SRV.PING.mesh-grants.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-grants\", \"$SRV.STATS.mesh-grants.\u003e\", \"_INBOX.novox.mesh-grants.\u003e\", \"mesh.mod.mesh-grants.call.\u003e\", \"mesh.mod.mesh-grants.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", "Missing": null, "Err": "", "Memberships": { @@ -288,7 +288,7 @@ }, { "Name": "a node-engine that consumes", - "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"ace.web\", password: \"$2a$11$ace.webace.webace.webafixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.ace_web.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.ace.web\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_web\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_web\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.ace.web\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.web\", \"$SRV.INFO.web.\u003e\", \"$SRV.PING\", \"$SRV.PING.web\", \"$SRV.PING.web.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.web\", \"$SRV.STATS.web.\u003e\", \"_INBOX.ace.web.\u003e\", \"mesh.mod.web.call.\u003e\", \"mesh.mod.web.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.ace\", password: \"$2a$11$node.acenode.acenode.afixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-ace.*.$O.declaration-files-ace.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-ace.*\", \"$JS.API.CONSUMER.INFO.NODES.ace\", \"$JS.API.DIRECT.GET.KV_composed-ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.ace\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.ace\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.ace.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-ace.$O.declaration-files-ace.M.*\", \"$JS.API.STREAM.INFO.KV_composed-ace\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.FC.KV_composed-ace.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-ace.\u003e\", \"$KV.composed-ace.\u003e\", \"$KV.mesh-host_acts.ace.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.ace.\u003e\", \"$KV.mesh-host_findings.machine.ace.\u003e\", \"$KV.mesh-host_health.ace\", \"$KV.mesh-host_packages.ace\", \"$KV.node-engine_have.ace.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.ace\", \"$SRV.PING.\u003e\", \"mesh.control.ace.\u003e\", \"mesh.seat.node-backup.call.backed-up.ace.node~ace\", \"mesh.seat.node-backup.call.now.ace.node~ace\", \"mesh.seat.node-backup.tool.backed-up.ace\", \"mesh.seat.node-backup.tool.now.ace\", \"mesh.seat.node-engine.event.*.ace\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.ace\", \"_DELIVER.ace.\u003e\", \"_INBOX.node.ace.\u003e\", \"mesh.mod.mesh-catalog.event.seat-definition-changed\", \"mesh.mod.mesh-catalog.event.seat-definition-removed\", \"mesh.mod.mesh-delivery-view.event.settled\", \"mesh.mod.restic.event.backed-up\", \"mesh.node.ace.ask.access-act\", \"mesh.node.ace.ask.hand-over\", \"mesh.node.ace.ask.judge-directories\", \"mesh.node.ace.ask.move-secret\", \"mesh.node.ace.ask.report\", \"mesh.node.ace.ask.setuid-search\", \"mesh.node.ace.declare\", \"mesh.seat.node-engine.call.*.ace.*\", \"mesh.seat.node-engine.tool.*.ace\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", + "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"ace.web\", password: \"$2a$11$ace.webace.webace.webafixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.ace_web.\u003e\", \"$JS.ACK.EVENTS.ace_web_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.ace.web\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_web\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_web_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_web\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_web_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.ace.web\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.web\", \"$SRV.INFO.web.\u003e\", \"$SRV.PING\", \"$SRV.PING.web\", \"$SRV.PING.web.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.web\", \"$SRV.STATS.web.\u003e\", \"_INBOX.ace.web.\u003e\", \"mesh.mod.web.call.\u003e\", \"mesh.mod.web.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.ace\", password: \"$2a$11$node.acenode.acenode.afixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-ace.*.$O.declaration-files-ace.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-ace.*\", \"$JS.API.CONSUMER.INFO.NODES.ace\", \"$JS.API.DIRECT.GET.KV_composed-ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.ace\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.ace\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.ace.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-ace.$O.declaration-files-ace.M.*\", \"$JS.API.STREAM.INFO.KV_composed-ace\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-ace.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-ace.\u003e\", \"$KV.composed-ace.\u003e\", \"$KV.mesh-host_acts.ace.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.ace.\u003e\", \"$KV.mesh-host_findings.machine.ace.\u003e\", \"$KV.mesh-host_health.ace\", \"$KV.mesh-host_packages.ace\", \"$KV.node-engine_have.ace.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.ace\", \"$SRV.PING.\u003e\", \"mesh.control.ace.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.ace.node~ace\", \"mesh.seat.node-backup.call.now.ace.node~ace\", \"mesh.seat.node-backup.tool.backed-up.ace\", \"mesh.seat.node-backup.tool.now.ace\", \"mesh.seat.node-engine.event.*.ace\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.ace\", \"_DELIVER.ace.\u003e\", \"_INBOX.node.ace.\u003e\", \"mesh.mod.mesh-catalog.event.seat-definition-changed\", \"mesh.mod.mesh-catalog.event.seat-definition-removed\", \"mesh.mod.mesh-delivery-view.event.settled\", \"mesh.mod.restic.event.backed-up\", \"mesh.node.ace.ask.access-act\", \"mesh.node.ace.ask.hand-over\", \"mesh.node.ace.ask.judge-directories\", \"mesh.node.ace.ask.move-secret\", \"mesh.node.ace.ask.report\", \"mesh.node.ace.ask.setuid-search\", \"mesh.node.ace.declare\", \"mesh.seat.node-engine.call.*.ace.*\", \"mesh.seat.node-engine.tool.*.ace\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", "Missing": null, "Err": "", "Memberships": { @@ -311,7 +311,7 @@ }, { "Name": "a node seat's events, by machine and flat", - "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"ace.pause\", password: \"$2a$11$ace.pauseace.pauseace.fixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.ace_pause.\u003e\", \"$JS.ACK.SEAT_NODE_POWER.SEAT_NODE_POWER_worker.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.ace.pause\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_pause\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_POWER.SEAT_NODE_POWER_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_pause\", \"$JS.API.CONSUMER.MSG.NEXT.SEAT_NODE_POWER.SEAT_NODE_POWER_worker\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.ace.pause\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.node-power.event.paused.ace\", \"mesh.seat.node-power.event.slept\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.pause\", \"$SRV.INFO.pause.\u003e\", \"$SRV.PING\", \"$SRV.PING.pause\", \"$SRV.PING.pause.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.pause\", \"$SRV.STATS.pause.\u003e\", \"_INBOX.ace.pause.\u003e\", \"mesh.mod.pause.call.\u003e\", \"mesh.mod.pause.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.ace\", password: \"$2a$11$node.acenode.acenode.afixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-ace.*.$O.declaration-files-ace.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-ace.*\", \"$JS.API.CONSUMER.INFO.NODES.ace\", \"$JS.API.DIRECT.GET.KV_composed-ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.ace\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.ace\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.ace.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-ace.$O.declaration-files-ace.M.*\", \"$JS.API.STREAM.INFO.KV_composed-ace\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.FC.KV_composed-ace.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-ace.\u003e\", \"$KV.composed-ace.\u003e\", \"$KV.mesh-host_acts.ace.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.ace.\u003e\", \"$KV.mesh-host_findings.machine.ace.\u003e\", \"$KV.mesh-host_health.ace\", \"$KV.mesh-host_packages.ace\", \"$KV.node-engine_have.ace.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.ace\", \"$SRV.PING.\u003e\", \"mesh.control.ace.\u003e\", \"mesh.seat.node-backup.call.backed-up.ace.node~ace\", \"mesh.seat.node-backup.call.now.ace.node~ace\", \"mesh.seat.node-backup.tool.backed-up.ace\", \"mesh.seat.node-backup.tool.now.ace\", \"mesh.seat.node-engine.event.*.ace\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.ace\", \"_DELIVER.ace.\u003e\", \"_INBOX.node.ace.\u003e\", \"mesh.node.ace.ask.access-act\", \"mesh.node.ace.ask.hand-over\", \"mesh.node.ace.ask.judge-directories\", \"mesh.node.ace.ask.move-secret\", \"mesh.node.ace.ask.report\", \"mesh.node.ace.ask.setuid-search\", \"mesh.node.ace.declare\", \"mesh.seat.node-engine.call.*.ace.*\", \"mesh.seat.node-engine.tool.*.ace\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.novox\", password: \"$2a$11$node.novoxnode.novoxnofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-novox.*.$O.declaration-files-novox.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-novox.*\", \"$JS.API.CONSUMER.INFO.NODES.novox\", \"$JS.API.DIRECT.GET.KV_composed-novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.novox\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.novox\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.novox.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-novox.$O.declaration-files-novox.M.*\", \"$JS.API.STREAM.INFO.KV_composed-novox\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.FC.KV_composed-novox.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-novox.\u003e\", \"$KV.composed-novox.\u003e\", \"$KV.mesh-host_acts.novox.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.novox.\u003e\", \"$KV.mesh-host_findings.machine.novox.\u003e\", \"$KV.mesh-host_health.novox\", \"$KV.mesh-host_packages.novox\", \"$KV.node-engine_have.novox.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.novox\", \"$SRV.PING.\u003e\", \"mesh.control.novox.\u003e\", \"mesh.seat.node-backup.call.backed-up.novox.node~novox\", \"mesh.seat.node-backup.call.now.novox.node~novox\", \"mesh.seat.node-backup.tool.backed-up.novox\", \"mesh.seat.node-backup.tool.now.novox\", \"mesh.seat.node-engine.event.*.novox\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.novox\", \"_DELIVER.novox.\u003e\", \"_INBOX.node.novox.\u003e\", \"mesh.node.novox.ask.access-act\", \"mesh.node.novox.ask.hand-over\", \"mesh.node.novox.ask.judge-directories\", \"mesh.node.novox.ask.move-secret\", \"mesh.node.novox.ask.report\", \"mesh.node.novox.ask.setuid-search\", \"mesh.node.novox.declare\", \"mesh.seat.node-engine.call.*.novox.*\", \"mesh.seat.node-engine.tool.*.novox\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-delivery-assigner\", password: \"$2a$11$novox.mesh-delivery-asfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-delivery-assigner.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-delivery-assigner\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-assigner\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-assigner\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-delivery-assigner\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.mesh-delivery-assigner\", \"$SRV.INFO.mesh-delivery-assigner.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-delivery-assigner\", \"$SRV.PING.mesh-delivery-assigner.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-delivery-assigner\", \"$SRV.STATS.mesh-delivery-assigner.\u003e\", \"_INBOX.novox.mesh-delivery-assigner.\u003e\", \"mesh.mod.mesh-delivery-assigner.call.\u003e\", \"mesh.mod.mesh-delivery-assigner.tool.\u003e\", \"mesh.seat.node-engine.event.manifest-reads-changed.*\", \"mesh.seat.node-power.event.slept\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", + "List": "# The mesh's users, composed by the grants part. Do not edit: the next\n# composition overwrites it. Permissions are derived from what each module\n# declares and nothing else (novox/hq ADR 0043, design 29 §2).\n\naccounts {\n MESH {\n jetstream: enabled\n imports = [\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.CONNECT\" }, to: \"mesh.bus.connect\" }\n { stream: { account: \"$SYS\", subject: \"$SYS.ACCOUNT.MESH.DISCONNECT\" }, to: \"mesh.bus.disconnect\" }\n { service: { account: \"$SYS\", subject: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\" }, to: \"mesh.bus.connz\" }\n ]\n users = [\n { user: \"ace.pause\", password: \"$2a$11$ace.pauseace.pauseace.fixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.ace_pause.\u003e\", \"$JS.ACK.EVENTS.ace_pause_tools.\u003e\", \"$JS.ACK.SEAT_NODE_POWER.SEAT_NODE_POWER_worker.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.ace.pause\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_pause\", \"$JS.API.CONSUMER.INFO.EVENTS.ace_pause_tools\", \"$JS.API.CONSUMER.INFO.SEAT_NODE_POWER.SEAT_NODE_POWER_worker\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_pause\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.ace_pause_tools\", \"$JS.API.CONSUMER.MSG.NEXT.SEAT_NODE_POWER.SEAT_NODE_POWER_worker\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.ace.pause\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-power.event.paused.ace\", \"mesh.seat.node-power.event.slept\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.pause\", \"$SRV.INFO.pause.\u003e\", \"$SRV.PING\", \"$SRV.PING.pause\", \"$SRV.PING.pause.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.pause\", \"$SRV.STATS.pause.\u003e\", \"_INBOX.ace.pause.\u003e\", \"mesh.mod.pause.call.\u003e\", \"mesh.mod.pause.tool.\u003e\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.ace\", password: \"$2a$11$node.acenode.acenode.afixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.ace\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.ace.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-ace.*.$O.declaration-files-ace.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-ace.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-ace.*\", \"$JS.API.CONSUMER.INFO.NODES.ace\", \"$JS.API.DIRECT.GET.KV_composed-ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.ace\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.ace\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.ace.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.ace.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-ace.$O.declaration-files-ace.M.*\", \"$JS.API.STREAM.INFO.KV_composed-ace\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-ace.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-ace.\u003e\", \"$KV.composed-ace.\u003e\", \"$KV.mesh-host_acts.ace.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.ace.\u003e\", \"$KV.mesh-host_findings.machine.ace.\u003e\", \"$KV.mesh-host_health.ace\", \"$KV.mesh-host_packages.ace\", \"$KV.node-engine_have.ace.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.ace\", \"$SRV.PING.\u003e\", \"mesh.control.ace.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.ace.node~ace\", \"mesh.seat.node-backup.call.now.ace.node~ace\", \"mesh.seat.node-backup.tool.backed-up.ace\", \"mesh.seat.node-backup.tool.now.ace\", \"mesh.seat.node-engine.event.*.ace\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.ace\", \"_DELIVER.ace.\u003e\", \"_INBOX.node.ace.\u003e\", \"mesh.node.ace.ask.access-act\", \"mesh.node.ace.ask.hand-over\", \"mesh.node.ace.ask.judge-directories\", \"mesh.node.ace.ask.move-secret\", \"mesh.node.ace.ask.report\", \"mesh.node.ace.ask.setuid-search\", \"mesh.node.ace.declare\", \"mesh.seat.node-engine.call.*.ace.*\", \"mesh.seat.node-engine.tool.*.ace\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"node.novox\", password: \"$2a$11$node.novoxnode.novoxnofixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.NODES.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-config_resolved.*.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-assigner_wants.*.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_acts.*.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_data.*.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_findings.*.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_health.*.$KV.mesh-host_health.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-host_packages.*.$KV.mesh-host_packages.novox\", \"$JS.API.CONSUMER.CREATE.KV_mesh-provisioner_provisions.*.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.*.node\", \"$JS.API.CONSUMER.CREATE.KV_node-engine_have.*.$KV.node-engine_have.novox.\u003e\", \"$JS.API.CONSUMER.CREATE.OBJ_declaration-files-novox.*.$O.declaration-files-novox.C.*\", \"$JS.API.CONSUMER.DELETE.KV_composed-novox.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-config_resolved.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_acts.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_bounds.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_data.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_findings.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_health.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-host_packages.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_mesh-provisioner_provisions.\u003e\", \"$JS.API.CONSUMER.DELETE.KV_node-engine_have.\u003e\", \"$JS.API.CONSUMER.DELETE.OBJ_declaration-files-novox.*\", \"$JS.API.CONSUMER.INFO.NODES.novox\", \"$JS.API.DIRECT.GET.KV_composed-novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-config_resolved.$KV.mesh-config_resolved.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-assigner_wants.$KV.mesh-delivery-assigner_wants.want.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_acts.$KV.mesh-host_acts.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_bounds.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_data.$KV.mesh-host_data.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_findings.$KV.mesh-host_findings.machine.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_mesh-host_health.$KV.mesh-host_health.novox\", \"$JS.API.DIRECT.GET.KV_mesh-host_packages.$KV.mesh-host_packages.novox\", \"$JS.API.DIRECT.GET.KV_mesh-provisioner_provisions.$KV.mesh-provisioner_provisions.novox.\u003e\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.*.node\", \"$JS.API.DIRECT.GET.KV_node-engine_have.$KV.node-engine_have.novox.\u003e\", \"$JS.API.DIRECT.GET.OBJ_declaration-files-novox.$O.declaration-files-novox.M.*\", \"$JS.API.STREAM.INFO.KV_composed-novox\", \"$JS.API.STREAM.INFO.KV_mesh-config_resolved\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_assignments\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-assigner_wants\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-builder_builds\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_candidates\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_manifests\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_modules\", \"$JS.API.STREAM.INFO.KV_mesh-delivery-indexer_verdicts\", \"$JS.API.STREAM.INFO.KV_mesh-host_acts\", \"$JS.API.STREAM.INFO.KV_mesh-host_bounds\", \"$JS.API.STREAM.INFO.KV_mesh-host_data\", \"$JS.API.STREAM.INFO.KV_mesh-host_findings\", \"$JS.API.STREAM.INFO.KV_mesh-host_health\", \"$JS.API.STREAM.INFO.KV_mesh-host_packages\", \"$JS.API.STREAM.INFO.KV_mesh-provisioner_provisions\", \"$JS.API.STREAM.INFO.KV_node-engine_have\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_composed-novox.\u003e\", \"$JS.FC.KV_mesh-config_resolved.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_assignments.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-assigner_wants.\u003e\", \"$JS.FC.KV_mesh-delivery-builder_builds.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_candidates.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_manifests.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_modules.\u003e\", \"$JS.FC.KV_mesh-delivery-indexer_verdicts.\u003e\", \"$JS.FC.KV_mesh-host_acts.\u003e\", \"$JS.FC.KV_mesh-host_bounds.\u003e\", \"$JS.FC.KV_mesh-host_data.\u003e\", \"$JS.FC.KV_mesh-host_findings.\u003e\", \"$JS.FC.KV_mesh-host_health.\u003e\", \"$JS.FC.KV_mesh-host_packages.\u003e\", \"$JS.FC.KV_mesh-provisioner_provisions.\u003e\", \"$JS.FC.KV_node-engine_have.\u003e\", \"$JS.FC.OBJ_declaration-files-novox.\u003e\", \"$KV.composed-novox.\u003e\", \"$KV.mesh-host_acts.novox.\u003e\", \"$KV.mesh-host_bounds.\u003e\", \"$KV.mesh-host_data.novox.\u003e\", \"$KV.mesh-host_findings.machine.novox.\u003e\", \"$KV.mesh-host_health.novox\", \"$KV.mesh-host_packages.novox\", \"$KV.node-engine_have.novox.\u003e\", \"$SRV.INFO\", \"$SRV.INFO.\u003e\", \"$SRV.PING\", \"$SRV.PING.*.novox\", \"$SRV.PING.\u003e\", \"mesh.control.novox.\u003e\", \"mesh.seat.*.accept.\u003e\", \"mesh.seat.node-backup.call.backed-up.novox.node~novox\", \"mesh.seat.node-backup.call.now.novox.node~novox\", \"mesh.seat.node-backup.tool.backed-up.novox\", \"mesh.seat.node-backup.tool.now.novox\", \"mesh.seat.node-engine.event.*.novox\"] }\n subscribe: { allow: [\"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_assignments\", \"$JS.EVENT.ADVISORY.STREAM.CREATED.KV_mesh-delivery-assigner_candidates\", \"$SRV.INFO\", \"$SRV.INFO.node-engine\", \"$SRV.INFO.node-engine.\u003e\", \"$SRV.PING\", \"$SRV.PING.node-engine\", \"$SRV.PING.node-engine.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.node-engine\", \"$SRV.STATS.node-engine.\u003e\", \"_DELIVER.novox\", \"_DELIVER.novox.\u003e\", \"_INBOX.node.novox.\u003e\", \"mesh.node.novox.ask.access-act\", \"mesh.node.novox.ask.hand-over\", \"mesh.node.novox.ask.judge-directories\", \"mesh.node.novox.ask.move-secret\", \"mesh.node.novox.ask.report\", \"mesh.node.novox.ask.setuid-search\", \"mesh.node.novox.declare\", \"mesh.seat.node-engine.call.*.novox.*\", \"mesh.seat.node-engine.tool.*.novox\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n { user: \"novox.mesh-delivery-assigner\", password: \"$2a$11$novox.mesh-delivery-asfixturefixturefixturefixture00\", permissions: {\n publish: { allow: [\"$JS.ACK.EVENTS.novox_mesh-delivery-assigner.\u003e\", \"$JS.ACK.EVENTS.novox_mesh-delivery-assigner_tools.\u003e\", \"$JS.API.CONSUMER.CREATE.KV_mesh-grants_memberships.*.$KV.mesh-grants_memberships.novox.mesh-delivery-assigner\", \"$JS.API.CONSUMER.DELETE.KV_mesh-grants_memberships.\u003e\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-assigner\", \"$JS.API.CONSUMER.INFO.EVENTS.novox_mesh-delivery-assigner_tools\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-assigner\", \"$JS.API.CONSUMER.MSG.NEXT.EVENTS.novox_mesh-delivery-assigner_tools\", \"$JS.API.DIRECT.GET.KV_mesh-grants_memberships.$KV.mesh-grants_memberships.novox.mesh-delivery-assigner\", \"$JS.API.STREAM.INFO.KV_mesh-grants_memberships\", \"$JS.API.STREAM.NAMES\", \"$JS.FC.KV_mesh-grants_memberships.\u003e\", \"mesh.seat.*.accept.\u003e\"] }\n subscribe: { allow: [\"$SRV.INFO\", \"$SRV.INFO.mesh-delivery-assigner\", \"$SRV.INFO.mesh-delivery-assigner.\u003e\", \"$SRV.PING\", \"$SRV.PING.mesh-delivery-assigner\", \"$SRV.PING.mesh-delivery-assigner.\u003e\", \"$SRV.STATS\", \"$SRV.STATS.mesh-delivery-assigner\", \"$SRV.STATS.mesh-delivery-assigner.\u003e\", \"_INBOX.novox.mesh-delivery-assigner.\u003e\", \"mesh.mod.mesh-delivery-assigner.call.\u003e\", \"mesh.mod.mesh-delivery-assigner.tool.\u003e\", \"mesh.seat.node-engine.event.manifest-reads-changed.*\", \"mesh.seat.node-power.event.slept\"] }\n allow_responses: { max: 1, ttl: \"1m\" }\n } }\n ]\n }\n \"$SYS\" {\n exports = [\n { stream: \"$SYS.ACCOUNT.MESH.CONNECT\", accounts: [\"MESH\"] }\n { stream: \"$SYS.ACCOUNT.MESH.DISCONNECT\", accounts: [\"MESH\"] }\n { service: \"$SYS.REQ.ACCOUNT.MESH.CONNZ\", accounts: [\"MESH\"] }\n ]\n }\n}\n", "Missing": null, "Err": "", "Memberships": { diff --git a/modules/mesh-grants/internal/buscompose/twins_test.go b/modules/mesh-grants/internal/buscompose/twins_test.go new file mode 100644 index 00000000..edf97d77 --- /dev/null +++ b/modules/mesh-grants/internal/buscompose/twins_test.go @@ -0,0 +1,22 @@ +package buscompose + +import ( + "slices" + "testing" +) + +// A-397: beside each module's durable consumer the tool runner's twin, with the same filters under its own name, and the +// events delivered again to one consumer named by the twin itself. +func TestTheRunnersTwinBesideTheModulesConsumer(t *testing.T) { + c := Consumer{Name: "ace_mod", Stream: "EVENTS", Filters: []string{"mesh.mod.x.event.y", AgainFilter("ace_mod")}} + got := withToolsTwin(c) + if len(got) != 2 || got[0].Name != "ace_mod" || got[1].Name != "ace_mod_tools" { + t.Fatalf("consumers = %+v, want ace_mod and ace_mod_tools", got) + } + if !slices.Equal(got[1].Filters, []string{"mesh.mod.x.event.y", AgainFilter("ace_mod_tools")}) { + t.Errorf("twin filters = %v", got[1].Filters) + } + if !slices.Equal(got[0].Filters, c.Filters) { + t.Errorf("the module's filters changed: %v", got[0].Filters) + } +} diff --git a/modules/mesh-grants/internal/buscompose/userlist_switch.go b/modules/mesh-grants/internal/buscompose/userlist_switch.go index 708656a8..b5d4a8b9 100644 --- a/modules/mesh-grants/internal/buscompose/userlist_switch.go +++ b/modules/mesh-grants/internal/buscompose/userlist_switch.go @@ -65,6 +65,11 @@ func GrantsUserListWrites() []string { "$JS.API.DIRECT.GET." + s + ".>", "$JS.API.STREAM.MSG.GET." + s, "$O." + obj + ".>", + // And reads back an object of its own bucket, as the node-engine does (an ordered consumer; design 47 G A-373): what it keeps + // as the objects the keys `list` and `pass` name. + "$JS.API.CONSUMER.CREATE." + s + ".*.$O." + obj + ".C.*", + "$JS.API.CONSUMER.DELETE." + s + ".*", + "$JS.FC." + s + ".>", } } diff --git a/modules/mesh-grants/internal/buscompose/users.go b/modules/mesh-grants/internal/buscompose/users.go index c5458d52..7da32139 100644 --- a/modules/mesh-grants/internal/buscompose/users.go +++ b/modules/mesh-grants/internal/buscompose/users.go @@ -176,6 +176,8 @@ type Records struct { // Kept is every seat event kept in a stream of its own (kept.go): the grants part makes each stream, so its principal is // granted the create of each by name. Kept []KeptEvent + // AskStreams are the seats' ask streams the grants part makes where the bus lacks them (AskStreamsOf), each its to create. + AskStreams []string // Chunked is every verb the seat definitions say sends chunks (chunks.go, design 47 G §681): their subjects are granted to the // principal that answers the verb and to an account naming it in `invokes`. Chunked []ChunkVerb @@ -386,7 +388,8 @@ func Users(r Records) ([]Principal, error) { // approval mark §6). reading, read := r.Readings[node] out = append(out, Principal{Kind: KindNodeTools, Node: node, Module: runner, Carries: carried, - Withholds: Withholds(reading, read, r.Running[node+"."+runner])}) + NewEventStreams: newEventStreams(r.Kept), + Withholds: Withholds(reading, read, r.Running[node+"."+runner])}) } } // A node enrols through the seat mesh-enrolment alone (ADR 0587 §6, ADR 0590): while no holder serves redeem, an @@ -640,6 +643,9 @@ func declaredStreamsOf(r Records) []string { for _, k := range r.Kept { seen[k.Stream] = true } + for _, a := range r.AskStreams { + seen[a] = true + } placed := [][]Declared{} for _, mods := range r.Assigned { placed = append(placed, mods) @@ -711,3 +717,31 @@ func keptOfSeat(kept []KeptEvent, seat string) []KeptEvent { } return out } + +// newEventStreams are the streams a runner's bundles hear new events on: the shared events stream and each kept seat stream. +func newEventStreams(kept []KeptEvent) []string { + out := []string{EventsStream} + for _, k := range kept { + if !slices.Contains(out, k.Stream) { + out = append(out, k.Stream) + } + } + return out +} + +// KeptRunnerGrants are the grants a tool runner that a pass keeps as it runs (no placed manifest says it is one, ADR 0601 §4) is composed +// as a carrying runner for: what the modules placed on its node that a runner carries, with their bindings and events, give it (design 47 +// G A-386), never as a plain module. runner is the module the kept user is named for; byBindings are the modules placed on the node +// whose manifest the pass cannot read, declared by the bindings kept for them alone (they carry nothing else). +func KeptRunnerGrants(r Records, node, runner string, byBindings []Declared) (Permissions, error) { + logs := DeclaredLogs(r) + var carried []Declared + for _, d := range append(slices.Clone(r.Assigned[node]), byBindings...) { + if CarriedByRunner(d) { + d = withReadLogs(withAnnouncedReads(d, r.Announced), logs) + d.Hears = ComposedHears(d) + carried = append(carried, d) + } + } + return PermissionsFor(Principal{Kind: KindNodeTools, Node: node, Module: runner, Carries: carried, NewEventStreams: newEventStreams(r.Kept)}) +} diff --git a/modules/mesh-grants/internal/grants/askstreams_test.go b/modules/mesh-grants/internal/grants/askstreams_test.go new file mode 100644 index 00000000..cac2c39d --- /dev/null +++ b/modules/mesh-grants/internal/grants/askstreams_test.go @@ -0,0 +1,44 @@ +package grants + +import ( + "slices" + "testing" + + "github.com/nats-io/nats.go/jetstream" + + "git.novox.be/novox/mesh-sdk/go/seatdef" + + "mesh-grants/internal/buscompose" +) + +type askCreator struct{ made []string } + +func (c *askCreator) CreateDeclared(cfg jetstream.StreamConfig) error { + c.made = append(c.made, cfg.Name+" "+cfg.Subjects[0]) + return nil +} +func (c *askCreator) AddSubjects(string, []string) error { return nil } +func (c *askCreator) RaiseMaxBytes(string, int64) (int64, bool, error) { + return 0, false, nil +} + +// A seat whose queues came with G (mesh-builds) gets its work-queue ask stream from the seat list, as the controller made one for +// every seat before G; a seat that accepts nothing gets none, and a stream the bus holds is never made again (lead-47, 2026-11-15). +func TestEachSeatThatAcceptsWorkHasItsAskStream(t *testing.T) { + defs := map[string]seatdef.Definition{ + "mesh-builds": {Seat: "mesh-builds", Accepts: []seatdef.Message{{Name: "step"}}}, + "mesh-wants": {Seat: "mesh-wants", Accepts: []seatdef.Message{{Name: "step"}}}, + "git": {Seat: "git"}, + } + asks := buscompose.AskStreamsOf(defs) + if len(asks) != 2 || asks[0].Name != "SEAT_MESH_BUILDS" || asks[0].Retention != jetstream.WorkQueuePolicy || + !slices.Equal(asks[0].Subjects, []string{"mesh.seat.mesh-builds.accept.>"}) || asks[0].MaxAge == 0 { + t.Fatalf("ask streams = %+v", asks) + } + c := &askCreator{} + made, notMade := createAskStreams(c, &creations{}, asks, map[string]Limits{"SEAT_MESH_WANTS": {}}, false) + if !slices.Equal(made, []string{"SEAT_MESH_BUILDS"}) || len(notMade) != 0 || + !slices.Equal(c.made, []string{"SEAT_MESH_BUILDS mesh.seat.mesh-builds.accept.>"}) { + t.Errorf("made %v (not %v), created %v: want only the builds seat's, the wants seat's being held", made, notMade, c.made) + } +} diff --git a/modules/mesh-grants/internal/grants/bigvalues.go b/modules/mesh-grants/internal/grants/bigvalues.go new file mode 100644 index 00000000..119ef185 --- /dev/null +++ b/modules/mesh-grants/internal/grants/bigvalues.go @@ -0,0 +1,104 @@ +package grants + +import ( + "crypto/sha256" + "encoding/hex" + "encoding/json" + "fmt" +) + +// **The part's user list and pass result are kept as objects** (design 47 G A-373): each outgrows one value of a key-value bucket +// (live, 2026-11-13: the list 422584 bytes and the pass 479989, over the 262144 the bucket takes), so the state `user-list` keeps +// them in the part's object bucket and the keys `list` and `pass` name the object, with its digest and size. A write that cannot be +// made stays an error, as it was; a pointer that cannot be followed is an error naming the object, never an empty answer. + +// BigObjects is the object bucket the keys' values are kept in: the part's own (the process's connection). +type BigObjects interface { + PutObject(name string, data []byte) error + GetObject(name string) ([]byte, error) +} + +// bigKeys are the keys of StateUserList kept as objects. +var bigKeys = map[string]bool{KeyList: true, KeyPass: true} + +// BigObjectName is the object a key of StateUserList is kept in. +func BigObjectName(key string) string { return "state." + StateUserList + "." + key } + +// bigPointer is what the key holds in place of the value. +type bigPointer struct { + KeptIn string `json:"kept_in_object"` + SHA256 string `json:"sha256"` + Bytes int `json:"bytes"` + // Small is the value's small fields, what a reader that cannot open the object is shown (the tools'): the pass's `sealed` and its + // errors, the list's digest and revision. + Small json.RawMessage `json:"small,omitempty"` +} + +// smallFieldsOf is the fields of a JSON object value that are under 4 KiB each; nil when the value is no object. +func smallFieldsOf(value []byte) json.RawMessage { + var fields map[string]json.RawMessage + if json.Unmarshal(value, &fields) != nil { + return nil + } + for k, v := range fields { + if len(v) > 4096 { + delete(fields, k) + } + } + out, _ := json.Marshal(fields) + return out +} + +// BigValues is store with the keys `list` and `pass` of the state user-list kept in objects. With no objects (the tools') a value is +// kept in the key whole, and a key that names an object is an error saying where the value is. +func BigValues(store Store, objects BigObjects) Store { + return bigStore{Store: store, objects: objects} +} + +type bigStore struct { + Store + objects BigObjects +} + +func (s bigStore) Put(state, key string, value []byte) (uint64, error) { + if state != StateUserList || !bigKeys[key] || s.objects == nil { + return s.Store.Put(state, key, value) + } + name := BigObjectName(key) + if err := s.objects.PutObject(name, value); err != nil { + return 0, fmt.Errorf("the value of %s could not be put as the object %s: %w", key, name, err) + } + sum := sha256.Sum256(value) + ptr, _ := json.Marshal(bigPointer{KeptIn: name, SHA256: hex.EncodeToString(sum[:]), Bytes: len(value), Small: smallFieldsOf(value)}) + return s.Store.Put(state, key, ptr) +} + +func (s bigStore) Get(state, key string) ([]byte, uint64, bool, error) { + raw, rev, found, err := s.Store.Get(state, key) + if err != nil || !found || state != StateUserList || !bigKeys[key] { + return raw, rev, found, err + } + var p bigPointer + if json.Unmarshal(raw, &p) != nil || p.KeptIn == "" { + return raw, rev, found, nil // a value kept whole, as before + } + if s.objects == nil { + // A reader that cannot open the object (the tools') is shown the value's small fields and where the rest is, so what a pass said of + // the sealed list is readable without the object. + var fields map[string]json.RawMessage + if json.Unmarshal(p.Small, &fields) != nil || fields == nil { + fields = map[string]json.RawMessage{} + } + fields["partial"], _ = json.Marshal(fmt.Sprintf("the rest of the value of %s is in the object %s (%d bytes), which this reader cannot open", key, p.KeptIn, p.Bytes)) + out, _ := json.Marshal(fields) + return out, rev, true, nil + } + data, err := s.objects.GetObject(p.KeptIn) + if err != nil { + return nil, rev, true, fmt.Errorf("the object %s that %s names cannot be read: %w", p.KeptIn, key, err) + } + if sum := sha256.Sum256(data); hex.EncodeToString(sum[:]) != p.SHA256 { + return nil, rev, true, fmt.Errorf("the object %s is not the one %s names (digest differs): it was replaced while read", p.KeptIn, key) + } + return data, rev, true, nil +} diff --git a/modules/mesh-grants/internal/grants/bigvalues_test.go b/modules/mesh-grants/internal/grants/bigvalues_test.go new file mode 100644 index 00000000..2926cf06 --- /dev/null +++ b/modules/mesh-grants/internal/grants/bigvalues_test.go @@ -0,0 +1,66 @@ +package grants + +import ( + "bytes" + "errors" + "strings" + "testing" +) + +// limitStore refuses a value over the bucket's 262144 bytes, as the bus does. +type limitStore struct{ memStore } + +func (l limitStore) Put(state, key string, value []byte) (uint64, error) { + if len(value) > 262144 { + return 0, errors.New("the value is over the 262144 bytes the bucket takes") + } + return l.memStore.Put(state, key, value) +} + +type memObjects map[string][]byte + +func (m memObjects) PutObject(name string, data []byte) error { m[name] = data; return nil } +func (m memObjects) GetObject(name string) ([]byte, error) { + if d, ok := m[name]; ok { + return d, nil + } + return nil, errors.New("no such object") +} + +// Design 47 G A-373: the user list and the pass result, over 256 KB each, are written and read back through objects the keys name. +func TestAListOverTheBucketsValueIsKeptAsAnObject(t *testing.T) { + big := []byte(`{"sealed":"held: for the test","v":"` + strings.Repeat("x", 450000) + `"}`) + for _, key := range []string{KeyList, KeyPass} { + raw := limitStore{memStore{}} + if _, err := raw.Put(StateUserList, key, big); err == nil { + t.Fatal("the bucket takes a value over its limit") + } + objects := memObjects{} + s := BigValues(raw, objects) + if _, err := s.Put(StateUserList, key, big); err != nil { + t.Fatalf("%s: %v", key, err) + } + got, _, found, err := s.Get(StateUserList, key) + if err != nil || !found || !bytes.Equal(got, big) { + t.Fatalf("%s read back: %d bytes, found %v, %v", key, len(got), found, err) + } + // The tools' reader holds no objects: it is shown the small fields and where the rest is, never an empty answer. + part, _, found, err := BigValues(raw, nil).Get(StateUserList, key) + if err != nil || !found || !strings.Contains(string(part), BigObjectName(key)) || !strings.Contains(string(part), `"partial"`) || !strings.Contains(string(part), "held: for the test") { + t.Errorf("%s read with no objects: %s, %v", key, part, err) + } + // A write that cannot be made stays an error. + if _, err := BigValues(raw, failingObjects{}).Put(StateUserList, key, big); err == nil { + t.Errorf("%s: an object that could not be put is no error", key) + } + // Another key and a small value are kept as they were. + small := []byte(`{"a":1}`) + if _, err := s.Put(StateUserList, KeyAsked, small); err != nil || len(objects) != 1 { + t.Errorf("another key: %v, objects %v", err, objects) + } + } +} + +type failingObjects struct{ memObjects } + +func (failingObjects) PutObject(string, []byte) error { return errors.New("refused") } diff --git a/modules/mesh-grants/internal/grants/bindings.go b/modules/mesh-grants/internal/grants/bindings.go index e9256c4f..fd7fb757 100644 --- a/modules/mesh-grants/internal/grants/bindings.go +++ b/modules/mesh-grants/internal/grants/bindings.go @@ -262,6 +262,10 @@ func bindingStreams(b membership.BusBinding) []string { if b.ObjectStore != "" { out = append(out, "OBJ_"+b.ObjectStore) } + // A state's object store beside it (design 47 G §58). + if b.Objects != "" { + out = append(out, "OBJ_"+b.Objects) + } if b.History != "" { out = append(out, b.History, b.History+"_snapshot") } diff --git a/modules/mesh-grants/internal/grants/catalog.go b/modules/mesh-grants/internal/grants/catalog.go index a3527e09..270c7a3b 100644 --- a/modules/mesh-grants/internal/grants/catalog.go +++ b/modules/mesh-grants/internal/grants/catalog.go @@ -74,6 +74,10 @@ func (c *CatalogOf) Resolve(fingerprint string) (meshcatalog.CatalogEntry, meshc func (c *CatalogOf) Waiting() []string { followed := c.Branches.Followed() if len(followed) == 0 { + // A mesh whose registrations and gate's source are answered and name no branch is none-yet, as for every part (A-369). + if c.Branches.Ready() == nil { + return nil + } return []string{"no branch is followed yet (the registrations and the gate's source are not answered)"} } var out []string @@ -204,7 +208,7 @@ func catalogWaiting(r Reader) string { return "" } slices.Sort(w) - return fmt.Sprintf("the first views of the catalog half are not in (%v), so each account is composed from its want's entry by fingerprint and the list in force is kept", w) + return fmt.Sprintf("the first views of the catalog half are not in (%v), so each account is composed from the trunk's manifest of its module in union with its want's entry by fingerprint, and the list in force is kept in union", w) } // **The grants part reads the assignment half** (design 46 approval mark §6, design 47 G §195, lead answer A-203): the view of diff --git a/modules/mesh-grants/internal/grants/catalogwait_test.go b/modules/mesh-grants/internal/grants/catalogwait_test.go new file mode 100644 index 00000000..e95cdf6b --- /dev/null +++ b/modules/mesh-grants/internal/grants/catalogwait_test.go @@ -0,0 +1,51 @@ +package grants + +import ( + "context" + "encoding/json" + "testing" + "time" + + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" + seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + "git.novox.be/novox/mesh-sdk/go/views" +) + +type wiring struct{ followers []*views.Follower } + +func (w *wiring) Adopt(f *views.Follower, _, _ string, _ func(context.Context, []byte) error) error { + w.followers = append(w.followers, f) + return nil +} +func (w *wiring) Drop(string, string) error { return nil } + +// Design 47 G A-369: the grants part's wait for its catalog half asks the catalog client's Ready, so a mesh whose registrations +// and gate's source are answered and name no branch is none-yet for grants, and waits while either is not answered. +func TestAMeshThatNamesNoBranchIsNoWaitForGrants(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + call := func(key string, _ any) (json.RawMessage, error) { + if key == meshcatalogclient.RegistrationsVerb { + return json.Marshal(seat.RegistrationsAnswer{Registrations: []seat.Registration{}}) + } + return json.Marshal(map[string][]string{"branches": {}}) + } + for _, answered := range []bool{false, true} { + w := &wiring{} + b, err := meshcatalogclient.NewBranches(w, call) + if err != nil { + t.Fatal(err) + } + if answered { + for _, f := range w.followers { + if err := f.Start(ctx); err != nil { + t.Fatal(err) + } + } + } + got := (&CatalogOf{Branches: b, Context: ctx}).Waiting() + if (len(got) == 0) != answered { + t.Errorf("answered %v: waiting %v", answered, got) + } + } +} diff --git a/modules/mesh-grants/internal/grants/claimants_test.go b/modules/mesh-grants/internal/grants/claimants_test.go new file mode 100644 index 00000000..699da5e0 --- /dev/null +++ b/modules/mesh-grants/internal/grants/claimants_test.go @@ -0,0 +1,36 @@ +package grants + +import ( + "slices" + "testing" + + "git.novox.be/novox/mesh-sdk/go/catalogue" +) + +// A seat-form read resolves to the holder on record, else to the assigned module whose manifest claims the seat (A-398): +// on 2026-11-14 the builder's `seat:node-build-go.steps` stayed unresolved while no assignments held the build seat, so +// the bus refused it the steps and no build could start. +func TestSeatReadsResolveToTheClaimant(t *testing.T) { + in := Inputs{ + Assigned: map[string][]string{"shanks": {"mesh-delivery-builder", "mesh-build-go"}}, + Manifests: map[string]catalogue.Manifest{ + "mesh-delivery-builder": {Module: "mesh-delivery-builder"}, + "mesh-build-go": {Module: "mesh-build-go", Claims: []catalogue.Claim{{Name: "node-build-go"}}}, + }, + } + for _, c := range []struct { + name string + holders []catalogue.Held + want string + }{ + {"no holder on record: the claimant", nil, "mesh-build-go.steps"}, + {"a holder on record wins", []catalogue.Held{{Claim: "node-build-go", Node: "ace", Module: "other-build"}}, "other-build.steps"}, + } { + t.Run(c.name, func(t *testing.T) { + got := resolveSeatReads([]string{"seat:node-build-go.steps"}, withClaimants(c.holders, in)) + if !slices.Equal(got, []string{c.want}) { + t.Fatalf("reads = %v, want [%s]", got, c.want) + } + }) + } +} diff --git a/modules/mesh-grants/internal/grants/consumed_seat_events_test.go b/modules/mesh-grants/internal/grants/consumed_seat_events_test.go new file mode 100644 index 00000000..71d9c8b4 --- /dev/null +++ b/modules/mesh-grants/internal/grants/consumed_seat_events_test.go @@ -0,0 +1,77 @@ +package grants + +import ( + "slices" + "strings" + "testing" + + "git.novox.be/novox/mesh-sdk/go/catalogue" +) + +// A consume names a seat's event by its bare name, and the definition's local name carries the subject's parts as `*` +// (`catalog-revision.*`): it is the seat's event, on the seat's subject; one the seat does not say is refused, never +// turned into a module's event (design 47 G A-409). +func TestConsumedSeatEvents(t *testing.T) { + seats := map[string]catalogue.SeatDeclaration{ + "mesh-catalog": {Name: "mesh-catalog", Scope: "mesh", Emits: []string{"catalog-revision.*", "manifest-accepted", "owed.*.*", "milestone.*.asked"}}, + "mesh-wants": {Name: "mesh-wants", Scope: "mesh", Emits: []string{"moved"}}, + } + modules := map[string]catalogue.Manifest{"mesh-wants": {Module: "mesh-wants"}, "some-app": {Module: "some-app"}} + cases := []struct { + name string + consume string + wantWatch string + wantModule bool + wantRefusals int + }{ + {"bare name of an event with a part", "mesh-catalog.catalog-revision", "catalog-revision", false, 0}, + {"the local name", "mesh-catalog.catalog-revision.*", "catalog-revision.*", false, 0}, + {"an event without parts", "mesh-catalog.manifest-accepted", "manifest-accepted", false, 0}, + {"two parts", "mesh-catalog.owed", "owed", false, 0}, + {"a part between words", "mesh-catalog.milestone.asked", "milestone.asked", false, 0}, + {"a word of the name alone is not the event", "mesh-catalog.milestone", "", false, 1}, + {"an event the seat does not say", "mesh-catalog.no-such-event", "", false, 1}, + {"a word that only shares a prefix", "mesh-catalog.catalog", "", false, 1}, + {"a module of the seat's name says its own", "mesh-wants.something-else", "", true, 0}, + {"a module's event", "some-app.thing", "", true, 0}, + } + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + m := catalogue.Manifest{Module: "x", Consumes: []string{c.consume}} + fromModules, watches := consumedOf(m, seats, nil, modules) + if got := slices.Contains(fromModules, c.consume); got != c.wantModule { + t.Fatalf("module consume = %v (%v), want %v", got, fromModules, c.wantModule) + } + var watched string + if len(watches) > 0 { + watched = strings.Join(watches[0].Emits, ",") + } + if watched != c.wantWatch { + t.Fatalf("watch = %q, want %q", watched, c.wantWatch) + } + refused := refusedConsumes(m, seats, modules) + if len(refused) != c.wantRefusals { + t.Fatalf("refusals = %v, want %d", refused, c.wantRefusals) + } + if len(refused) > 0 && !strings.Contains(refused[0], c.consume) { + t.Fatalf("refusal %q does not name the consume", refused[0]) + } + }) + } +} + +// The refusal is in the pass's answer as a gap. +func TestRecordsSaysARefusedConsume(t *testing.T) { + m := catalogue.Manifest{Module: "reader", Consumes: []string{"mesh-catalog.no-such-event"}} + in := Inputs{Nodes: []string{"n1"}, Assigned: map[string][]string{"n1": {"reader"}}, Manifests: map[string]catalogue.Manifest{"reader": m}} + _, gaps := Records(in) + found := false + for _, g := range gaps { + if strings.Contains(g.Why, "no event no-such-event") { + found = true + } + } + if !found { + t.Fatalf("gaps %v do not say the refused consume", gaps) + } +} diff --git a/modules/mesh-grants/internal/grants/consumers.go b/modules/mesh-grants/internal/grants/consumers.go index c3ee1029..dc141292 100644 --- a/modules/mesh-grants/internal/grants/consumers.go +++ b/modules/mesh-grants/internal/grants/consumers.go @@ -136,6 +136,9 @@ func (p *Part) consumers(res *Result, recs buscompose.Records, match string) { for _, c := range byStream[stream] { key := stream + "." + c.Name h, ok := held[c.Name] + if ok && strings.HasSuffix(c.Name, "_named_worker") { + p.sayWorker(key + " is held already") + } if ok { if h.Pending > BehindBound { if p.behindSeen[key] { @@ -190,11 +193,24 @@ func (p *Part) consumers(res *Result, recs buscompose.Records, match string) { switch err := p.Consumers.CreateConsumer(stream, buscompose.ConsumerConfig(c)); { case err == nil: st.Created = append(st.Created, key) + if strings.HasSuffix(c.Name, "_named_worker") { + p.sayWorker(key + " is created") + } + if p.Logf != nil { + p.Logf("consumer %s created", key) + } p.say(res, EventAsserted, map[string]any{"consumer": c.Name, "stream": stream}) case errors.Is(err, ErrHeld): default: st.Missing = append(st.Missing, key) st.NotCreated = append(st.NotCreated, key+": "+err.Error()) + if p.Logf != nil && p.filterRefused[key] != "create: "+err.Error() { + p.Logf("consumer %s is not created: %v", key, err) + if p.filterRefused == nil { + p.filterRefused = map[string]string{} + } + p.filterRefused[key] = "create: " + err.Error() + } } } } @@ -330,3 +346,18 @@ func (p *Part) sayBehind(st *ConsumersState) { p.behindSaid, p.behindKnown = why, true } } + +// sayWorker logs one named seat worker's outcome (created, held already) once per change, so the journal names each worker the +// pass considers (A-413). +func (p *Part) sayWorker(line string) { + p.holdMu.Lock() + if p.workersSaid == nil { + p.workersSaid = map[string]bool{} + } + done := p.workersSaid[line] + p.workersSaid[line] = true + p.holdMu.Unlock() + if !done && p.Logf != nil { + p.Logf("seat worker %s", line) + } +} diff --git a/modules/mesh-grants/internal/grants/everyright_test.go b/modules/mesh-grants/internal/grants/everyright_test.go new file mode 100644 index 00000000..521fa1b4 --- /dev/null +++ b/modules/mesh-grants/internal/grants/everyright_test.go @@ -0,0 +1,43 @@ +package grants + +import ( + "slices" + "testing" + + "mesh-grants/internal/buscompose" +) + +// Design 47 G A-383, A-384: a runner's account kept from the list in force gains the rights of hearing new events and the streams' +// names, and loses nothing; every account may ask any seat (principle 6); a ledger's account gains none of them. +func TestAKeptRunnerGainsWhatEveryRunnerCarries(t *testing.T) { + own := map[string][]string{"novox.node-tools": buscompose.NewEventGrants([]string{"EVENTS"})} + kept := map[string]User{"novox.node-tools": {User: "novox.node-tools", Publish: []string{"a"}}, "ledger.novox.m": {User: "ledger.novox.m", Publish: []string{"b"}}} + users, kept := withEveryAccountsRights([]User{{User: "novox.node-tools", Publish: []string{"a"}}}, kept, own) + if !slices.Contains(kept["novox.node-tools"].Publish, buscompose.AnySeatSubject) { + t.Errorf("the kept runner may not ask a seat: %v", kept["novox.node-tools"].Publish) + } + for _, u := range []User{users[0], kept["novox.node-tools"]} { + for _, want := range []string{"a", buscompose.StreamNamesSubject, "$JS.API.CONSUMER.CREATE.EVENTS.*", "$JS.FC.EVENTS.>"} { + if !slices.Contains(u.Publish, want) { + t.Errorf("the runner lacks %s: %v", want, u.Publish) + } + } + } + if got := kept["ledger.novox.m"].Publish; !slices.Equal(got, []string{"b"}) { + t.Errorf("a ledger's account = %v", got) + } +} + +// Principle 6 (the operator, 2026-11-15): a module's account kept from the list in force may put an ask on any seat, named by any +// asker (a composed one has it from buscompose.PermissionsFor); an enrolling node's account gains none. +func TestAKeptModuleAccountMayAskAnySeat(t *testing.T) { + kept := map[string]User{"novox.mesh-delivery-pipeline": {User: "novox.mesh-delivery-pipeline", Publish: []string{"x"}}, + "enrol.ace": {User: "enrol.ace", Publish: []string{"y"}}} + _, kept = withEveryAccountsRights(nil, kept, nil) + if !slices.Contains(kept["novox.mesh-delivery-pipeline"].Publish, buscompose.AnySeatSubject) { + t.Errorf("a kept module account may not ask a seat: %v", kept["novox.mesh-delivery-pipeline"].Publish) + } + if got := kept["enrol.ace"].Publish; !slices.Equal(got, []string{"y"}) { + t.Errorf("an enrolling node's account = %v", got) + } +} diff --git a/modules/mesh-grants/internal/grants/grantskept_test.go b/modules/mesh-grants/internal/grants/grantskept_test.go new file mode 100644 index 00000000..92740e6f --- /dev/null +++ b/modules/mesh-grants/internal/grants/grantskept_test.go @@ -0,0 +1,41 @@ +package grants + +import ( + "testing" + + "mesh-grants/internal/buscompose" +) + +// Design 47 G A-364: the grants part's own account carries the right to create each kept event stream of the seat list, such as +// SEAT_git_branch-moved, composed from the same records as every other account. +func TestTheGrantsAccountMayCreateEachKeptEventStream(t *testing.T) { + const stream, subject = "SEAT_git_branch-moved", "mesh.seat.git.event.branch-moved" + for _, c := range []struct { + name string + kept []buscompose.KeptEvent + may bool + }{ + {"a kept event of the seat list", []buscompose.KeptEvent{{Seat: "git", Event: "branch-moved", Stream: stream, Filter: subject}}, true}, + {"no kept event", nil, false}, + } { + t.Run(c.name, func(t *testing.T) { + users, err := buscompose.Users(buscompose.Records{Nodes: []string{"ace"}, Kept: c.kept, + Assigned: map[string][]buscompose.Declared{"ace": {{Module: buscompose.GrantsModule}}}}) + if err != nil { + t.Fatal(err) + } + for _, u := range users { + if u.Kind != buscompose.KindModule || u.Module != buscompose.GrantsModule { + continue + } + perms, err := buscompose.PermissionsFor(u) + if err != nil { + t.Fatal(err) + } + if got := buscompose.MayPublish(perms, "$JS.API.STREAM.CREATE."+stream); got != c.may { + t.Errorf("the grants account may create %s: %v, want %v", stream, got, c.may) + } + } + }) + } +} diff --git a/modules/mesh-grants/internal/grants/held.go b/modules/mesh-grants/internal/grants/held.go index 6bf1cad2..832d2f73 100644 --- a/modules/mesh-grants/internal/grants/held.go +++ b/modules/mesh-grants/internal/grants/held.go @@ -153,3 +153,20 @@ func (p *Part) sayHeldModules(held map[string]string, kept map[string]User) { p.heldModulesSaid, p.heldModulesKnown = why, true } } + +// runnersOutOfTheList are, by user, why it is kept: a user of the list in force that is a tool runner (it says its node's runner is alive, +// buscompose.ToolsAliveSubject) and that the pass composed no account for. Pure. +func runnersOutOfTheList(inForce map[string]User, composed []User, already map[string]string) map[string]string { + out := map[string]string{} + for user, u := range inForce { + node, _, cut := strings.Cut(user, ".") + if !cut || !slices.Contains(u.Publish, buscompose.ToolsAliveSubject(node)) { + continue + } + if _, kept := already[user]; kept || slices.ContainsFunc(composed, func(c User) bool { return c.User == user }) { + continue + } + out[user] = fmt.Sprintf("the pass composes no account for the tool runner of %s (its manifest is not readable), so it keeps what it runs", node) + } + return out +} diff --git a/modules/mesh-grants/internal/grants/inputs.go b/modules/mesh-grants/internal/grants/inputs.go index 7e96a6a4..7bc118a9 100644 --- a/modules/mesh-grants/internal/grants/inputs.go +++ b/modules/mesh-grants/internal/grants/inputs.go @@ -7,6 +7,8 @@ package grants import ( + "github.com/nats-io/nats.go/jetstream" + "crypto/sha256" "encoding/json" "errors" @@ -127,6 +129,10 @@ type resolved struct { // Inputs is what the shadow composes from, read from the bus. type Inputs struct { + // CarriedNamedAsks says a membership held in the part's own state (composed, or carried over from the last published for + // a module the pass cannot compose) grants a named ask of a build seat's queue, `mesh.seat..accept..` + // (A-413); set once per pass by withCarriedNamedAsks. + CarriedNamedAsks bool // Nodes is every machine seen: in a node agent's have or the assignments. Nodes []string // Assigned is what the seat's assignments puts on each machine, sorted (issue 774: never the controller's assignments). @@ -188,6 +194,8 @@ type Inputs struct { // Kept is every seat event the seat list says is kept in a stream of its own (buscompose.KeptEventsOf): the part makes // each stream and each hearing module's durable on it. Empty while the list is unread. Kept []buscompose.KeptEvent + // AskStreams are the seats' ask streams (buscompose.AskStreamsOf), made where the bus lacks them. + AskStreams []jetstream.StreamConfig // Chunked is every verb the seat list says sends its answer's file in chunks (design 47 G §681): the part grants their subjects. Chunked []buscompose.ChunkVerb // EventSubjects are, by seat, the subjects of its events that carry parts, by the event's local name, as the definitions @@ -215,6 +223,8 @@ type Inputs struct { // CatalogUnread says why this pass composed before the first views of the catalog half were in (design 47 G §684); empty once they are. // As WantsUnread, such a pass retires nothing (ReadFailures) and only adds: the list in force is kept. CatalogUnread string + // StreamsAbsent says each stream the part reads whole that the bus lacks and the part creates, taken as empty this pass (A-371). + StreamsAbsent []string // AssignmentUnread says why this pass composed before the first view of the assignment half was in (design 46 approval // mark §6, design 47 G §195): no node's capability reading is known, so the list in force is kept; empty once it is. AssignmentUnread string @@ -382,6 +392,7 @@ func ReadInputs(r Reader, cache *Manifests) Inputs { // consumer only gains filters, so one made with such an event's subject on EVENTS would keep it). if d, ok := gate.(SeatDefinitions); ok { in.Kept = buscompose.KeptEventsOf(d.Definitions()) + in.AskStreams = buscompose.AskStreamsOf(d.Definitions()) in.Chunked = buscompose.ChunkVerbsOf(d.Definitions()) in.EventSubjects = eventSubjectsOf(d.Definitions()) in.AcceptCallers = acceptCallersOf(d.Definitions()) @@ -595,6 +606,7 @@ func ReadInputs(r Reader, cache *Manifests) Inputs { in.Gaps = append(in.Gaps, Gap{Input: ReadWants, Why: "not read: the modules are placed by the node-engines' haves this pass, so what runs is composed from each have's fingerprint"}) fromTrunk = runningByHaves(r, &in, cache, in.Running) } + var viaNewest, noNewest []string for key, raw := range wants { node, module, err := meshwantsclient.ParseWantKey(key) if err != nil || !slices.Contains(in.Assigned[node], module) { @@ -609,11 +621,34 @@ func ReadInputs(r Reader, cache *Manifests) Inputs { continue } // The manifest of the build the want names is the catalog graph's entry of its fingerprint (design 47 G §444, §614). - if m, _, err := cache.entryManifest(r, w.Fp); err == nil { + m, _, err := cache.entryManifest(r, w.Fp) + switch { + case err == nil: in.Running[node+"."+module] = m - } else { + continue + case w.Newest == "" || w.Newest == w.Fp: fromTrunk = append(fromTrunk, node+"."+module) + noNewest = append(noNewest, node+"."+module+" (its want names no newer build; "+err.Error()+")") + continue } + // A running build with no catalog entry (from before the catalog graph) is composed from the entry of the build its want + // says is being built, for its account's grants, membership and seat traffic alone (A-414, as A-407 does for the node). + nm, _, nerr := cache.entryManifest(r, w.Newest) + if nerr != nil { + fromTrunk = append(fromTrunk, node+"."+module) + noNewest = append(noNewest, node+"."+module+" (the entry of its want's newest build is not held: "+nerr.Error()+"; "+err.Error()+")") + continue + } + in.Running[node+"."+module] = nm + viaNewest = append(viaNewest, node+"."+module) + } + if len(noNewest) > 0 { + sort.Strings(noNewest) + in.Gaps = append(in.Gaps, Gap{Input: "wanted manifests", Why: "the running build has no catalog entry and its want's newest build gave none: " + strings.Join(noNewest, ", ")}) + } + if len(viaNewest) > 0 { + sort.Strings(viaNewest) + in.Gaps = append(in.Gaps, Gap{Input: "wanted manifests", Why: "no catalog entry holds the running build, so its account is composed from the entry of the build its want says is being built: " + strings.Join(viaNewest, ", ")}) } if len(fromTrunk) > 0 { sort.Strings(fromTrunk) @@ -836,7 +871,10 @@ func runningByHaves(r Reader, in *Inputs, cache *Manifests, into map[string]cata if err != nil { if state == meshcatalogclient.EntryAsked { in.HadFailed[node+"."+module] = "the catalog half's entry of " + h.Fp + " is asked" - in.Gaps = append(in.Gaps, Gap{Input: "catalog entry " + h.Fp, Why: "asked and not answered yet, so the manifest of the build " + node + "." + module + " runs is unknown: " + err.Error(), Failed: true}) + // While the catalog half is unread an entry cannot be answered yet: that is no failed read, and the account is composed + // from the trunk's manifest of its module (the indexer's `modules` view) in union with what its entry gives, so the list is + // not held to the list in force alone (design 47 G, A-363). + in.Gaps = append(in.Gaps, Gap{Input: "catalog entry " + h.Fp, Why: "asked and not answered yet, so the manifest of the build " + node + "." + module + " runs is unknown: " + err.Error(), Failed: in.CatalogUnread == ""}) } fromTrunk = append(fromTrunk, node+"."+module) continue diff --git a/modules/mesh-grants/internal/grants/kept.go b/modules/mesh-grants/internal/grants/kept.go index b87f86ec..05832155 100644 --- a/modules/mesh-grants/internal/grants/kept.go +++ b/modules/mesh-grants/internal/grants/kept.go @@ -1,6 +1,8 @@ package grants import ( + "github.com/nats-io/nats.go/jetstream" + "errors" "fmt" "slices" @@ -187,3 +189,36 @@ func withVerbCallers(callers map[string]map[string][]string, d *buscompose.Decla } } } + +// createAskStreams makes each seat's ask stream the bus lacks (buscompose.AskStreamsOf), as createKept makes a kept event's: only +// where the bus was read and holds no stream of that name, never changed where it holds one. +func createAskStreams(c Creator, done *creations, asks []jetstream.StreamConfig, held map[string]Limits, force bool) (made, notMade []string) { + for _, cfg := range asks { + if _, ok := held[cfg.Name]; ok { + continue + } + digest := strings.Join(cfg.Subjects, " ") + if !force && done.madeAt(cfg.Name) == digest { + notMade = append(notMade, cfg.Name+": made at this definition and gone since; grants_assert makes it again") + continue + } + switch err := c.CreateDeclared(cfg); { + case err == nil: + done.keep(cfg.Name, digest) + made = append(made, cfg.Name) + case errors.Is(err, ErrHeld): + default: + notMade = append(notMade, cfg.Name+": "+err.Error()+" (tried again at the next event)") + } + } + return made, notMade +} + +// askStreamNames are the names of the seats' ask streams, which the grants part's own account is granted to create. +func askStreamNames(asks []jetstream.StreamConfig) []string { + out := make([]string, 0, len(asks)) + for _, a := range asks { + out = append(out, a.Name) + } + return out +} diff --git a/modules/mesh-grants/internal/grants/loadedusers_size_test.go b/modules/mesh-grants/internal/grants/loadedusers_size_test.go new file mode 100644 index 00000000..2c09853d --- /dev/null +++ b/modules/mesh-grants/internal/grants/loadedusers_size_test.go @@ -0,0 +1,61 @@ +package grants + +import ( + "encoding/json" + "errors" + "fmt" + "strings" + "testing" +) + +// sizeBus answers nats_users as the bus module does, and refuses an answer over one bus message. +type sizeBus struct { + users []User + limit int +} + +func (b sizeBus) Call(key string, body any) (json.RawMessage, error) { + part, _ := body.(map[string]any)["user"].(string) + if part == "" { + var names []map[string]any + for _, u := range b.users { + names = append(names, map[string]any{"user": u.User, "publish_grants": len(u.Publish)}) + } + return json.Marshal(map[string]any{"users": names}) + } + var out []User + for _, u := range b.users { + if strings.Contains(u.User, part) { + out = append(out, u) + } + } + raw, _ := json.Marshal(map[string]any{"users": out}) + if len(raw) > b.limit { + return nil, errors.New("the answer is more than the bus carries in one message: ask for less") + } + return raw, nil +} + +// lead: principle 7, live hold 02:0x: the loaded list is read one user per answer, never the whole list in one. +func TestLoadedUsersReadsOneUserPerAnswer(t *testing.T) { + var users []User + for i := 0; i < 20; i++ { + var pub []string + for j := 0; j < 50; j++ { + pub = append(pub, fmt.Sprintf("subject.%d.%d.>", i, j)) + } + users = append(users, User{User: fmt.Sprintf("mod.u%02d", i), Publish: pub, Subscribe: []string{"x.>"}}) + } + users = append(users, User{User: "controller", Publish: []string{"a"}}) + got, err := LoadedUsers(sizeBus{users: users, limit: 5000}) + if err != nil { + t.Fatal(err) + } + if len(got) != len(users) { + t.Fatalf("read %d users, want %d", len(got), len(users)) + } + // a user whose own answer is too large stays a loud hold + if _, err := LoadedUsers(sizeBus{users: users, limit: 100}); err == nil { + t.Fatal("an unreadable user must hold loudly") + } +} diff --git a/modules/mesh-grants/internal/grants/namedpurge.go b/modules/mesh-grants/internal/grants/namedpurge.go index 56f76982..a4d98df9 100644 --- a/modules/mesh-grants/internal/grants/namedpurge.go +++ b/modules/mesh-grants/internal/grants/namedpurge.go @@ -4,9 +4,11 @@ import ( "encoding/json" "errors" "fmt" + "slices" "strings" "git.novox.be/novox/mesh-sdk/go/catalogue" + "git.novox.be/novox/mesh-sdk/go/membership" "mesh-grants/internal/buscompose" ) @@ -30,7 +32,7 @@ type NamedPurger interface { // NamedAsksUnused says the revision the part composes from holds entries and none invokes a queue of a build seat // (catalogue.QueueInvoke); false while the catalog half is not read, so a failed read purges nothing. func NamedAsksUnused(in Inputs) bool { - if in.CatalogUnread != "" || len(in.Manifests) == 0 { + if in.CatalogUnread != "" || len(in.Manifests) == 0 || in.CarriedNamedAsks { return false } for _, m := range in.Manifests { @@ -40,9 +42,35 @@ func NamedAsksUnused(in Inputs) bool { } } } + // The manifest each machine is wanted to run counts as an entry of the revision too: a build taken from its want's newest + // build (A-414) that invokes a queue keeps the named workers (A-413). + for _, m := range in.Running { + for _, i := range m.Invokes { + if _, _, ok := catalogue.QueueInvoke(i); ok { + return false + } + } + } return true } +// namedAsksWhy says what decided whether the named asks are unused, for the journal. +func namedAsksWhy(in Inputs, granted bool) string { + switch { + case in.CatalogUnread != "": + return "the catalog half is unread" + case len(in.Manifests) == 0: + return "no manifest is held" + case in.CarriedNamedAsks: + return "a carried membership is granted to publish a named ask" + case granted: + return "a composed account is granted to publish a named ask" + case NamedAsksUnused(in): + return "no entry of the revision and no wanted build invokes a build seat's queue" + } + return "an entry of the revision or a wanted build invokes a build seat's queue" +} + // withNoNamedAsks marks each pulled-by-kind seat a declaration holds as having no named worker while unused. func withNoNamedAsks(unused bool, d *buscompose.Declared) { for _, list := range []*[]buscompose.Seat{&d.Holds, &d.Uses, &d.Watches} { @@ -57,7 +85,7 @@ func withNoNamedAsks(unused bool, d *buscompose.Declared) { // purgeNamed purges the named asks and deletes the named workers of every build seat's queue the records compose, at the // first pass whose revision leaves them unused, and on a person's ask whatever the revision says. func (p *Part) purgeNamed(res *Result, in Inputs, recs buscompose.Records, byHand string) { - unused := NamedAsksUnused(in) + unused := NamedAsksUnused(in) && !buscompose.NamedAsksGranted(recs) due := unused && !p.namedPurged || byHand != "" p.namedPurged = unused if !due || p.NamedPurge == nil { @@ -119,3 +147,46 @@ func (p *Part) AskNamedPurge(caller, why string, record func(what, why string) e } return map[string]any{"asked": rev, "says": "the part's process purges the named asks and deletes the named workers at this ask; its journal names each"}, nil } + +// NamedAskPublish says a seat-traffic publish subject is a named ask of a queue, `mesh.seat..accept..`: five +// or more tokens with `accept` the fourth; main's `accept.` has four. +func NamedAskPublish(subject string) bool { + t := strings.Split(subject, ".") + return len(t) >= 6 && t[0] == "mesh" && t[1] == "seat" && t[3] == "accept" +} + +// withCarriedNamedAsks reads the memberships the part holds in its own state, which it publishes (composed in this pass or +// carried over for a module it cannot compose) and sets Inputs.CarriedNamedAsks where one grants a named ask (A-413). An +// unreadable state sets it, so a failed read purges nothing. +func (p *Part) withCarriedNamedAsks(in *Inputs) { + if p.Store == nil { + return + } + keys, err := p.Store.Keys(StateMemberships) + if err != nil { + in.CarriedNamedAsks = true + return + } + for _, k := range keys { + raw, _, found, err := p.Store.Get(StateMemberships, k) + if err != nil { + in.CarriedNamedAsks = true + return + } + if !found { + continue + } + bare, err := membership.BareGrantsMembership(raw) + if err != nil { + continue + } + var m membership.Membership + if json.Unmarshal(bare, &m) != nil || m.SeatTraffic == nil { + continue + } + if slices.ContainsFunc(m.SeatTraffic.Publish, NamedAskPublish) { + in.CarriedNamedAsks = true + return + } + } +} diff --git a/modules/mesh-grants/internal/grants/namedpurge_test.go b/modules/mesh-grants/internal/grants/namedpurge_test.go index 26a1aaf1..6db99f05 100644 --- a/modules/mesh-grants/internal/grants/namedpurge_test.go +++ b/modules/mesh-grants/internal/grants/namedpurge_test.go @@ -3,9 +3,11 @@ package grants import ( "errors" "slices" + "strings" "testing" "git.novox.be/novox/mesh-sdk/go/catalogue" + "git.novox.be/novox/mesh-sdk/go/membership" "mesh-grants/internal/buscompose" ) @@ -32,7 +34,15 @@ func (m memStore) Put(state, key string, value []byte) (uint64, error) { m[state+"/"+key] = value return uint64(len(m)), nil } -func (m memStore) Keys(string) ([]string, error) { return nil, nil } +func (m memStore) Keys(state string) ([]string, error) { + var out []string + for k := range m { + if rest, ok := strings.CutPrefix(k, state+"/"); ok { + out = append(out, rest) + } + } + return out, nil +} func (m memStore) Delete(state, key string) error { delete(m, state+"/"+key); return nil } // Design 47 G §544, A-231: at the first revision in which no entry invokes a queue of a build seat the part purges each @@ -43,6 +53,12 @@ func TestTheNamedAsksArePurgedAtTheFirstRevisionThatLeavesThem(t *testing.T) { Holds: []buscompose.Seat{{Name: "node-build-go", Scope: "node", Accepts: []string{"check"}, PulledByKind: true}}}}}} unused := Inputs{Manifests: map[string]catalogue.Manifest{"runner": {Module: "runner", Invokes: []string{"seat:node-build-go.run"}}}} used := Inputs{Manifests: map[string]catalogue.Manifest{"runner": {Module: "runner", Invokes: []string{"seat:node-build-go.accept.check"}}}} + // A-414: a build taken from its want's newest build that invokes a queue keeps the named workers too. + runs := unused + runs.Running = map[string]catalogue.Manifest{"shanks.builder": {Module: "builder", Invokes: []string{"seat:node-build-go.accept.check"}}} + if NamedAsksUnused(runs) { + t.Error("named asks unused though a wanted build invokes a queue") + } unread := unused unread.CatalogUnread = "the catalog half of the branch main" bus := &purged{} @@ -76,6 +92,42 @@ func TestTheNamedAsksArePurgedAtTheFirstRevisionThatLeavesThem(t *testing.T) { t.Errorf("a named worker composed %v, want %v (%v)", has, c.named, c.in.Manifests["runner"].Invokes) } } + // A-413: an account granted a named ask (it uses the seat's queue and holds a seat its AcceptCallers name) keeps the named + // workers though no entry invokes the queue; with neither, they go out and the purge runs. + asker := buscompose.Declared{Module: "asker", + Holds: []buscompose.Seat{{Name: "node-delivery", Scope: "node"}}, + Uses: []buscompose.Seat{{Name: "node-build-go", Scope: "node", Accepts: []string{"check"}, PulledByKind: true, AcceptCallers: map[string][]string{"check": {"node-delivery"}}}}} + granted := buscompose.Records{Nodes: []string{"one"}, Assigned: map[string][]buscompose.Declared{"one": {recs.Assigned["one"][0], asker}}} + for _, c := range []struct { + r buscompose.Records + granted bool + }{{granted, true}, {recs, false}} { + if got := buscompose.NamedAsksGranted(c.r); got != c.granted { + t.Errorf("NamedAsksGranted = %v, want %v", got, c.granted) + } + before := len(bus.acts) + var res Result + pp := &Part{NamedPurge: bus, Store: memStore{}} + pp.purgeNamed(&res, unused, c.r, "") + if purgedNow := len(bus.acts) > before; purgedNow == c.granted { + t.Errorf("granted %v: purged %v", c.granted, purgedNow) + } + } + // A-413: a membership held in the part's state (carried over for a module it cannot compose) that publishes a named ask keeps + // the named workers; main's own `accept.` does not. + for _, c := range []struct { + publish string + kept bool + }{{"mesh.seat.node-build-go.accept.delivery.mesh-builds", true}, {"mesh.seat.node-build-go.accept.delivery", false}} { + st := memStore{} + st.Put(StateMemberships, "shanks.mesh-delivery-builder", membership.EncodeGrantsMembership(membership.Membership{Node: "shanks", Module: "mesh-delivery-builder", + SeatTraffic: &membership.SeatTraffic{Publish: []string{c.publish}}})) + cin := unused + (&Part{Store: st}).withCarriedNamedAsks(&cin) + if NamedAsksUnused(cin) == c.kept { + t.Errorf("carried publish %s: unused = %v", c.publish, NamedAsksUnused(cin)) + } + } // The hand tool: nothing is asked when the hand act is not recorded; once it is, the process purges at its ask. if _, err := p.AskNamedPurge("jochen@shanks", "the part stopped first", func(string, string) error { return errors.New("down") }); err == nil { t.Error("asked though the hand act was not recorded") diff --git a/modules/mesh-grants/internal/grants/part.go b/modules/mesh-grants/internal/grants/part.go index 113a444f..1b94c900 100644 --- a/modules/mesh-grants/internal/grants/part.go +++ b/modules/mesh-grants/internal/grants/part.go @@ -31,6 +31,9 @@ const ( // StateGrants is the part's grants by module and fingerprint, the key layout of the controller's (grants.go). StateGrants = grantsstate.PartGrantsState KeyList = "list" + // KeyWithheld is the marked subjects withheld by node, kept small beside the list (which is an object the tools cannot open) for + // the seat verb withheld (design 47 G A-373). + KeyWithheld = "withheld" // KeyPass is the last pass's result, and KeyAsked a tool's ask to compose again now, both in StateUserList. KeyPass = "pass" KeyAsked = "asked" @@ -149,7 +152,9 @@ type Result struct { // of the list in force, or stays out where it holds none (refused.go); the condition mesh-grants.principal-refused says it. PrincipalsRefused []string `json:"principals_refused,omitempty"` // CatalogWaiting is why this pass composed before the first views of the catalog half were in (design 47 G §684); empty once they are. - CatalogWaiting string `json:"catalog_waiting,omitempty"` + CatalogWaiting string `json:"catalog_waiting,omitempty"` + // StreamsAbsent names each stream read whole that the bus lacked, taken as empty and created after this pass (design 47 G, A-371). + StreamsAbsent []string `json:"streams_absent,omitempty"` Errors []string `json:"errors,omitempty"` PublishedOrAsserted string `json:"published_or_asserted"` } @@ -202,9 +207,13 @@ type Part struct { // heldSaid is the reason of the held-list condition last said (empty: none raised); heldKnown is whether one was said // since the start, so the first pass after a start always says its state (a condition raised before a restart is cleared // by it). holdMu guards both. - holdMu sync.Mutex - heldSaid string - heldKnown bool + holdMu sync.Mutex + heldSaid string + // leftOutSaid is the left-out and wanted-manifest lines last logged, so each change is said once (sayLeftOut). + leftOutSaid string + namedSaid string + workersSaid map[string]bool + heldKnown bool // differSaid is the account consumers' differences last said as a condition, once differKnown (consumers.go). differSaid string differKnown bool @@ -327,12 +336,14 @@ func (p *Part) Compose() Result { in := p.inputs() p.keepBrokers(in) res.CatalogWaiting = in.CatalogUnread + res.StreamsAbsent = in.StreamsAbsent if err := p.withBound(&in); err != nil { res.Errors = append(res.Errors, err.Error()) } if err := p.withKeptNames(&in); err != nil { res.Errors = append(res.Errors, err.Error()) } + p.withCarriedNamedAsks(&in) for _, g := range in.Refused { res.Refused = append(res.Refused, g.Input+": "+g.Why) } @@ -341,6 +352,7 @@ func (p *Part) Compose() Result { recs, _ := Records(in) listRecs, left := ListRecords(in) holdings := HoldingsOf(in) + p.sayLeftOut(in.Gaps, left) res.RootNotFree = WithRootFree(&listRecs, p.Call) recs.RootFree = listRecs.RootFree st := UserListState{V: 1, Mode: InForce, LeftOut: left, Loaded: in.Loaded, BusNode: in.BusNode, @@ -363,11 +375,22 @@ func (p *Part) Compose() Result { candidates = append(candidates, user) } heldUsers := heldModuleUsers(in, candidates) - for user, why := range runnerUsersKept(listRecs, inForce) { + runnersKept := runnerUsersKept(listRecs, inForce) + // And a runner of the list in force that the pass composes no principal for, whatever the reason (its manifest is unreadable and another + // module placed on its node says it is the runner): kept as it runs, and written as a carrying runner (design 47 G A-386). + for user, why := range runnersOutOfTheList(inForce, users, runnersKept) { + runnersKept[user] = why + } + for user, why := range runnersKept { heldUsers[user] = why } allRefused := mergedRefusals(refused, heldUsers) kept, _ := p.keptOf(allRefused) + // An account kept beyond the pass is the union of the list in force and what the pass composes for it, never the list in force + // alone (design 47 G A-385); a runner kept for what it runs, whose manifest does not say it is one, is never composed as a plain module + // (ADR 0601 §4). + kept = unionComposed(kept, users, runnersKept) + kept = unionKeptRunners(kept, listRecs, runnersKept, declaredByBindings(in, listRecs)) for _, user := range sortedKeys(refused) { res.PrincipalsRefused = append(res.PrincipalsRefused, user+": "+refused[user]) } @@ -393,6 +416,9 @@ func (p *Part) Compose() Result { res.KeptLoaded = sortedKeys(union) } } + // A right every account carries is written to every account of the list, one kept or held from the list in force included + // (design 47 G A-383); the pass only adds. + users, kept = withEveryAccountsRights(users, kept, buscompose.RunnerNewEventGrants(listRecs)) users = WithHashes(users, in.Hashes) st.Digest, st.Users = Digest(users), len(users) st.Compare = Compare(users, loaded, Placed(in)).Excusing(ExcusedBy(MultiHeld(listRecs))) @@ -418,6 +444,9 @@ func (p *Part) Compose() Result { } } } + if data, err := json.Marshal(st.Withheld); err == nil { + p.changed(&res, StateUserList, KeyWithheld, data) + } // The accounts the vault mints from, said in the state only it reads (ADR 0561 §2). if p.Store != nil { p.writeAccounts(&res, in, listRecs) @@ -441,7 +470,11 @@ func (p *Part) Compose() Result { var bus, lost []string if st.Compare.Unread == "" { bus = names(loaded) - lost = holdings.LastHolders(holdings.ByUsers(loaded), holdings.ByUsers(users)) + // With every account subscribing to every subject (buscompose.EveryAccountMayDoEverything) no seat can lose its holder + // by the list: the guard reads seat subjects by their text, and `>` names none of them. + if !buscompose.EveryAccountMayDoEverything { + lost = holdings.LastHolders(holdings.ByUsers(loaded), holdings.ByUsers(users)) + } } p.writeSealed(&res, list, n, leftOut, dropped, in, bus, lost, users, loaded) } @@ -540,14 +573,26 @@ func (p *Part) Compose() Result { for _, why := range notMade { res.NotAsserted = append(res.NotAsserted, "kept event "+why) } + made, notMade = createAskStreams(p.Create, &p.made, in.AskStreams, held, forced != "") + if len(made) > 0 { + res.Asserted = append(res.Asserted, "the seats' ask streams: created "+strings.Join(made, ", ")) + p.say(&res, EventAsserted, map[string]any{"module": Module, "created": made}) + if p.Logf != nil { + p.Logf("the seats' ask streams the bus lacked are created: %s", strings.Join(made, ", ")) + } + } + for _, why := range notMade { + res.NotAsserted = append(res.NotAsserted, "ask stream "+why) + } } + createRefused := false for _, module := range sortedKeys(in.Manifests) { if !assigned(in, module) { continue } a := Assert(module, in.Digests[module], in.Manifests[module], in.Nodes, held, heldErr) // Created only where the bus was read and lacks it, never changed where it holds it (issue 1790). - if p.Create != nil && heldErr == nil { + if p.Create != nil && heldErr == nil && !createRefused { if made, raises := createMissing(p.Create, &p.made, &a, in.Manifests[module], in.Nodes, forced == module); len(made) > 0 { res.Asserted = append(res.Asserted, fmt.Sprintf("%s at %s: created %s", module, a.Manifest, strings.Join(made, ", "))) if p.Logf != nil { @@ -557,6 +602,14 @@ func (p *Part) Compose() Result { } for _, why := range notCreated(a) { res.NotAsserted = append(res.NotAsserted, module+" "+why) + // A create the bus refuses or leaves unanswered is not tried for the rest of this pass: each waits out its + // bound, and the grant that admits it comes with the list this pass wrote (lead-47, 2026-11-15). + if strings.Contains(why, "deadline exceeded") || strings.Contains(why, "ermission") { + createRefused = true + } + } + if createRefused && p.Logf != nil { + p.Logf("a create was refused at %s: no more buckets are created this pass", module) } } res.Assertions++ @@ -565,6 +618,7 @@ func (p *Part) Compose() Result { res.AssertionsWritten++ } } + p.sayNamedAsks(in, recs) p.consumers(&res, recs, ask.Consumer) byHand := "" if ask.NamedPurge { @@ -696,15 +750,20 @@ func (p *Part) WithheldOn(node string) (meshgrants.Withheld, error) { return meshgrants.Withheld{}, errors.New("withheld names a node") } out := meshgrants.Withheld{Node: node, Modules: []meshgrants.WithheldModulesItem{}} - raw, _, found, err := p.Store.Get(StateUserList, KeyList) - if err != nil { - return out, fmt.Errorf("its own user list cannot be read: %w", err) - } - if !found { - return out, errors.New("nothing composed yet: grants_compose_now composes it") - } var st UserListState - if err := json.Unmarshal(raw, &st); err != nil { + raw, _, found, err := p.Store.Get(StateUserList, KeyWithheld) + if err == nil && found { + err = json.Unmarshal(raw, &st.Withheld) + } else if err == nil { + // Before the process kept the small key: the list's own, which only a reader that can open it reads. + if raw, _, found, err = p.Store.Get(StateUserList, KeyList); err == nil { + if !found { + return out, errors.New("nothing composed yet: grants_compose_now composes it") + } + err = json.Unmarshal(raw, &st) + } + } + if err != nil { return out, fmt.Errorf("its own user list cannot be read: %w", err) } for _, w := range st.Withheld[node] { @@ -716,3 +775,54 @@ func (p *Part) WithheldOn(node string) (meshgrants.Withheld, error) { } return out, nil } + +// sayLeftOut logs, once per change, what the pass did for a module whose running build has no entry (A-413, A-414): how its want's +// newest build was read, and each module left out for want of a manifest, whose carried membership's seat workers are then not +// created, since the account consumers are made from the accounts composed alone (consumers.go). +func (p *Part) sayLeftOut(gaps, left []Gap) { + var lines []string + for _, g := range gaps { + if g.Input == "wanted manifests" { + lines = append(lines, g.Why) + } + } + for _, g := range left { + lines = append(lines, g.Input+" "+g.Why+": its carried membership stays as published and the consumers it names (its seat workers) are not created by this pass") + } + said := strings.Join(lines, "\n") + if said == p.leftOutSaid { + return + } + p.leftOutSaid = said + if p.Logf != nil { + for _, l := range lines { + p.Logf("%s", l) + } + } +} + +// sayNamedAsks logs, once per change, whether the named asks of the build seats' queues are in use and why (A-413), and so whether +// the pass composes each seat's named worker. +func (p *Part) sayNamedAsks(in Inputs, recs buscompose.Records) { + granted := buscompose.NamedAsksGranted(recs) + unused := NamedAsksUnused(in) && !granted + var workers []string + for _, ds := range recs.Assigned { + for _, d := range ds { + for _, w := range buscompose.SeatTrafficOf(d.Module, d.Holds, d.Uses, d.Watches).Workers { + if strings.HasSuffix(w.Consumer, "_named_worker") { + workers = append(workers, w.Consumer+" of "+d.Module) + } + } + } + } + slices.Sort(workers) + said := fmt.Sprintf("named asks %s: %s; named workers composed: %d", map[bool]string{true: "unused", false: "in use"}[unused], namedAsksWhy(in, granted), len(workers)) + if said == p.namedSaid { + return + } + p.namedSaid = said + if p.Logf != nil { + p.Logf("%s", said) + } +} diff --git a/modules/mesh-grants/internal/grants/processbus_test.go b/modules/mesh-grants/internal/grants/processbus_test.go index 3f7d12c8..e1fc76fa 100644 --- a/modules/mesh-grants/internal/grants/processbus_test.go +++ b/modules/mesh-grants/internal/grants/processbus_test.go @@ -88,7 +88,7 @@ func TestAProcessBusHearsWhatItsModuleConsumes(t *testing.T) { } var made []string for _, c := range buscompose.AccountConsumers(users) { - if c.Module == "zfs" && strings.HasPrefix(c.Consumer.Name, "ace_zfs_") { // the processes' own, not the module's + if c.Module == "zfs" && strings.HasPrefix(c.Consumer.Name, "ace_zfs_") && !strings.HasSuffix(c.Consumer.Name, buscompose.ToolsSuffix) { // the processes' own, not the module's nor its runner's made = append(made, c.Consumer.Stream+"/"+c.Consumer.Name+"/"+strings.Join(c.Consumer.Filters, ",")) } } diff --git a/modules/mesh-grants/internal/grants/records.go b/modules/mesh-grants/internal/grants/records.go index 8c55fd16..44691e97 100644 --- a/modules/mesh-grants/internal/grants/records.go +++ b/modules/mesh-grants/internal/grants/records.go @@ -46,7 +46,7 @@ func records(in Inputs, union bool) (buscompose.Records, []Gap) { out := buscompose.Records{Assigned: map[string][]buscompose.Declared{}, People: map[string][]string{}, Interchangeable: map[string]bool{}, Enrolling: slices.Clone(in.Enrolling), // And each node's logins (ADR 0583 §1): both while it rotates. - NodeLogins: in.NodeLogins, Kept: in.Kept, Chunked: in.Chunked, EngineEvents: in.EventSubjects[buscompose.EngineSeat], + NodeLogins: in.NodeLogins, Kept: in.Kept, AskStreams: askStreamNames(in.AskStreams), Chunked: in.Chunked, EngineEvents: in.EventSubjects[buscompose.EngineSeat], // What the bus module's process may define: every manifest's bus state, and what it said it created (DLV-G2). BusState: map[string][]catalogue.BusStateEntry{}, Bound: in.Bound, // Each node's capability reading and what each node-engine said running (design 46 approval mark §6). @@ -68,6 +68,9 @@ func records(in Inputs, union bool) (buscompose.Records, []Gap) { // node-engine's too, read with the manifest each node runs, else the trunk's. Composed, never recorded. holders, passed := holdersAfterPass(in) gaps = append(gaps, passed...) + // A seat-form read, view or view tool resolves to the holder on record, else to the assigned module whose manifest claims + // the seat (lead answer A-398); holds keep heldWherePlaced's own rule. + readHolders := withClaimants(holders, in) values := func(provider, setting string) []any { var vs []any for _, node := range in.Nodes { @@ -83,7 +86,12 @@ func records(in Inputs, union bool) (buscompose.Records, []Gap) { if m, ok := in.Running[node+"."+module]; ok { return m, true } - m, ok := in.Manifests[module] + if m, ok := in.Manifests[module]; ok { + return m, true + } + // The manifest the module's running build was judged on, while its trunk manifest is held: the runner it is, the modules it + // carries and their grants are composed from it, never from the list in force alone (design 47 G A-385). + m, ok := in.Held[module] return m, ok } var here []catalogue.Manifest @@ -99,9 +107,15 @@ func records(in Inputs, union bool) (buscompose.Records, []Gap) { continue } declare := func(m catalogue.Manifest) buscompose.Declared { - m.Consumes = resolveSeatViews(m.Consumes, holders) - m.Reads = resolveSeatReads(m.Reads, holders) - d := declaredFor(m, seats, declarers) + m.Invokes = slices.Concat(m.Invokes, seatViewTools(m.Consumes, readHolders)) + m.Consumes = resolveSeatViews(m.Consumes, readHolders) + m.Reads = resolveSeatReads(m.Reads, readHolders) + for _, why := range refusedConsumes(m, seats, declared) { + if g := (Gap{Input: m.Module + " on " + node, Why: why}); !slices.Contains(gaps, g) { + gaps = append(gaps, g) + } + } + d := declaredFor(m, seats, declarers, declared) if len(in.Placed) > 0 { d.Holds = heldWherePlaced(d.Holds, holders, node, m.Module) } @@ -122,7 +136,6 @@ func records(in Inputs, union bool) (buscompose.Records, []Gap) { withEventSubjects(in.EventSubjects, &d) withAcceptCallers(in.AcceptCallers, &d) withVerbCallers(in.VerbCallers, &d) - withNoNamedAsks(NamedAsksUnused(in), &d) return d } d := declare(m) @@ -144,13 +157,21 @@ func records(in Inputs, union bool) (buscompose.Records, []Gap) { } } } + // Named asks are unused only where no entry invokes a queue of a build seat and no composed account is granted to publish + // one (A-413): read from the declarations composed above, so it follows the pass's own grants. + unused := NamedAsksUnused(in) && !buscompose.NamedAsksGranted(out) + for _, ds := range out.Assigned { + for i := range ds { + withNoNamedAsks(unused, &ds[i]) + } + } // The node-engine's own manifest, placed on every node (ADR 0563): its state, logs and streams alone, created by this // part; it adds no principal, since each node's engine speaks as the node's account. if m, ok := declared[buscompose.EngineModule]; ok { // What it consumes and invokes are its node account's: a seat's event also on the seat's own subject, as a module's // consumes are split (consumedOf), every consume still on its emitter's as before, and each verb it invokes in the // node's own name (issue 1966: the seat list's verb and events). - _, watches := consumedOf(m, seats, declarers) + _, watches := consumedOf(m, seats, declarers, declared) out.Engine = &buscompose.Declared{Module: m.Module, Consumes: m.Consumes, Watches: watches, Invokes: m.Invokes, State: bucketsFor(m, in.Nodes), Logs: logsOf(m), Streams: streamsOf(m)} withEventSubjects(in.EventSubjects, out.Engine) @@ -162,11 +183,11 @@ func records(in Inputs, union bool) (buscompose.Records, []Gap) { // declaredFor is mesh-controller's declaredFor (internal/inventory/busrecords.go), copied: one module's manifest as the // composer needs it. -func declaredFor(m catalogue.Manifest, seats map[string]catalogue.SeatDeclaration, declarers map[string]string) buscompose.Declared { - fromModules, watches := consumedOf(m, seats, declarers) +func declaredFor(m catalogue.Manifest, seats map[string]catalogue.SeatDeclaration, declarers map[string]string, modules map[string]catalogue.Manifest) buscompose.Declared { + fromModules, watches := consumedOf(m, seats, declarers, modules) d := buscompose.Declared{ Module: m.Module, ToolRunner: catalogue.IsToolRunner(m), Emits: m.EmitsAll(), Consumes: fromModules, Watches: watches, Serves: m.Tools, - Invokes: m.Invokes, State: bucketsOf(m), Reads: m.Reads, Logs: logsOf(m), + Invokes: withRunnerReads(m.Invokes), State: bucketsOf(m), Reads: m.Reads, Logs: logsOf(m), Streams: streamsOf(m), Queues: queueOwnersOf(m), Processes: processesOf(m), ServesOwn: ownServesOf(m), Checks: catalogue.HealthChecks(m), RunsAs: m.RunsAs, Issued: issuedTools(m), // The keys its served values fill, which every node may read where it runs (issue 1126). @@ -245,6 +266,25 @@ func resolveSeatViews(consumes []string, holders []catalogue.Held) []string { return out } +// seatViewTools is, for each `seat:.views.` of a module's consumes whose seat has a holder on record, the +// holder's first-view tool `.`: a reader takes its first view by asking that tool and then follows the +// events, so the view grants both (design 47 G §616); the events alone left the reader's first view refused by the bus. +// Pure. +func seatViewTools(consumes []string, holders []catalogue.Held) []string { + var out []string + for _, c := range consumes { + rest, isSeat := strings.CutPrefix(c, seatViewConsume) + seatName, view, named := strings.Cut(rest, ".views.") + if !isSeat || !named || view == "" { + continue + } + if h := slices.IndexFunc(holders, func(h catalogue.Held) bool { return sameSeat(h.Claim, seatName) }); h >= 0 { + out = append(out, holders[h].Module+"."+view) + } + } + return out +} + // resolveSeatReads resolves each `seat:.` of a module's reads to `.`, the module holding the seat // on record, as resolveSeatViews does a view: a new holder is read with no change of the manifest (design 47 G A-116). An entry // whose seat has no holder on record stays as written, and grants nothing. Pure. @@ -277,8 +317,9 @@ func resolveSeatReads(reads []string, holders []catalogue.Held) []string { // consumedOf splits what a manifest consumes as the composer grants it: a seat's event on the seat's own subject (its // watches), every other by its emitter's (novox/hq ADR 0118). A placed module and the node-engine's own manifest are split -// alike. -func consumedOf(m catalogue.Manifest, seats map[string]catalogue.SeatDeclaration, declarers map[string]string) ([]string, []buscompose.Seat) { +// alike. A consume naming a seat that says no such event (and no module of the seat's name, which says its own, ADR 0239) +// is neither: it is refused (refusedConsumes), never turned into a module's event (design 47 G A-409). +func consumedOf(m catalogue.Manifest, seats map[string]catalogue.SeatDeclaration, declarers map[string]string, modules map[string]catalogue.Manifest) ([]string, []buscompose.Seat) { var fromModules []string var watches []buscompose.Seat for _, c := range m.Consumes { @@ -286,18 +327,23 @@ func consumedOf(m catalogue.Manifest, seats map[string]catalogue.SeatDeclaration if named { if s, isASeat := seats[emitter]; isASeat && s.Kinded { ev := strings.TrimSuffix(event, ".*") - if catalogue.SeatSays(s.Emits, ev) { + if seatSaysEvent(s.Emits, ev) { watches = append(watches, buscompose.Seat{Name: s.Name, Scope: s.Scope, Emits: []string{ev}, Kinded: true, Proofs: s.Proofs, DeclaredBy: declarers[s.Name]}) continue } } - if s, isASeat := seats[emitter]; isASeat && catalogue.SeatSays(s.Emits, event) { - // Its scope, and whether the node-engine holds it, place an event that names its holder's machine (ADR 0618 §4). - compiled, _ := catalogue.SeatNamed(s.Name) - watches = append(watches, buscompose.Seat{Name: s.Name, Scope: s.Scope, Emits: []string{event}, - HeldByTheEngine: compiled.HeldByTheEngine}) - continue + if s, isASeat := seats[emitter]; isASeat { + if seatSaysEvent(s.Emits, event) { + // Its scope, and whether the node-engine holds it, place an event that names its holder's machine (ADR 0618 §4). + compiled, _ := catalogue.SeatNamed(s.Name) + watches = append(watches, buscompose.Seat{Name: s.Name, Scope: s.Scope, Emits: []string{event}, + HeldByTheEngine: compiled.HeldByTheEngine}) + continue + } + if _, isModule := modules[emitter]; !isModule { + continue + } } } fromModules = append(fromModules, c) @@ -305,6 +351,57 @@ func consumedOf(m catalogue.Manifest, seats map[string]catalogue.SeatDeclaration return fromModules, watches } +// seatSaysEvent is whether a seat's events (as a definition names them locally: `catalog-revision.*` for the subject +// `catalog-revision.`) say the event a consume names: the event of that name whatever parts its subject has, or +// one a declared pattern matches. +func seatSaysEvent(emits []string, event string) bool { + if catalogue.SeatSays(emits, event) { + return true + } + for _, e := range emits { + if nameOf(e) == event { + return true + } + } + return false +} + +// nameOf is an event's name from its local form: the tokens that are not a part (`*`), so `milestone.*.asked` is +// `milestone.asked` and `catalog-revision.*` is `catalog-revision`. +func nameOf(local string) string { + var words []string + for _, t := range strings.Split(local, ".") { + if t != "*" { + words = append(words, t) + } + } + return strings.Join(words, ".") +} + +// refusedConsumes are the consumes of a manifest naming a seat that says no such event, with why; a module of the seat's +// name says its own events (ADR 0239) and is not refused. The grants part says each aloud as a gap of its answer. +func refusedConsumes(m catalogue.Manifest, seats map[string]catalogue.SeatDeclaration, modules map[string]catalogue.Manifest) []string { + var out []string + for _, c := range m.Consumes { + emitter, event, named := strings.Cut(c, ".") + if !named { + continue + } + s, isASeat := seats[emitter] + if !isASeat { + continue + } + if _, isModule := modules[emitter]; isModule { + continue + } + if seatSaysEvent(s.Emits, strings.TrimSuffix(event, ".*")) { + continue + } + out = append(out, "consumes "+c+": the seat "+emitter+" says no event "+event+", so no filter is granted for it") + } + return out +} + // loadsABundle says the node's tool runtime loads a bundle of the module. The controller reads it from the resolved // manifest's Bundles, which a build derives and the indexer's manifest does not carry (the builder's build record names // the repository's manifest digest), so the same answer is derived here from `build.artifacts` by mesh-sdk's rule @@ -368,15 +465,36 @@ func bucketsFor(m catalogue.Manifest, nodes []string) []buscompose.Bucket { return append(out, buscompose.EngineComposedBuckets(nodes)...) } -// objectsOf is a manifest's own object buckets (ADR 0592 §5). +// objectsOf is a manifest's own object buckets (ADR 0592 §5), and the object store beside each state it keeps in its `state`, +// `-objects`, its owner's alone (design 47 G §58, §607, A-237): a state asked in `requires` gets its store from the bus +// module (its binding's objects), a state of the field `state` from the grants part, as its other buckets. Its cap is the state's +// size, StateObjectsMiB when it names none. A state only read, or one whose store's name is one of the module's own object +// buckets, gets none. func objectsOf(m catalogue.Manifest) []buscompose.ObjectBucket { var out []buscompose.ObjectBucket + own := map[string]bool{} for _, o := range m.Objects { + own[o.Name] = true out = append(out, buscompose.ObjectBucket{Module: m.Module, Name: o.Name, MaxMiB: o.MaxMiB, Restricted: o.Grant != nil}) } + for _, s := range m.State { + name := catalogue.StateObjectsName(s.Name) + if s.ReadOnly || own[name] { + continue + } + size := s.MaxMiB + if size <= 0 { + size = StateObjectsMiB + } + out = append(out, buscompose.ObjectBucket{Module: m.Module, Name: name, MaxMiB: min(max(size, catalogue.ObjectsLeastMiB), catalogue.ObjectsMostMiB)}) + } return out } +// StateObjectsMiB is the cap of a state's object store when the state names no size: the bus module's for a state asked in +// `requires` (StateObjectsCapMiB there). +const StateObjectsMiB = 16 + // readsOfObjects takes out of a module's reads each that names another module's object bucket (ADR 0592 §9): read, by // its bus name, where the owner's trusted config value of the bucket's grant names the module on this node, and refused // otherwise, a bucket with no grant included (its owner alone reads it). Every other read stays as it was: a state's. @@ -684,6 +802,31 @@ func holdersAfterPass(in Inputs) ([]catalogue.Held, []Gap) { return held, gaps } +// withClaimants is holders and, for each seat no holder names, the first module assigned to a node (nodes and modules in +// order) whose manifest (the trunk's, else the running build of a held module) claims it (lead answer A-398; the operator, +// 2026-11-14: who holds a seat follows from the module graph and the assignments). Pure. +func withClaimants(holders []catalogue.Held, in Inputs) []catalogue.Held { + out := slices.Clone(holders) + for _, node := range slices.Sorted(maps.Keys(in.Assigned)) { + for _, module := range slices.Sorted(slices.Values(in.Assigned[node])) { + m, ok := in.Manifests[module] + if !ok { + m, ok = in.Held[module] + } + if !ok { + continue + } + for _, c := range m.Claims { + if slices.ContainsFunc(out, func(h catalogue.Held) bool { return sameSeat(h.Claim, c.Name) }) { + continue + } + out = append(out, catalogue.Held{Claim: c.Name, Scope: c.Scope, Node: node, Module: module}) + } + } + } + return out +} + // ranEntries is the reader of entries SeatsToPassOn takes (design 47 G §459): the manifest of a fingerprint a node-engine // said it runs, and a module's manifest where none was heard: the trunk's, else the running build of a held module. type ranEntries struct{ in Inputs } @@ -802,3 +945,18 @@ func findingEventsOf(m catalogue.Manifest) []string { } return nil } + +// RunnerReads are the seat verbs the tool runner itself asks for every module it serves, on that module's account: its seat +// list and the catalog half's first views. Every module is composed as invoking them (lead answer A-396, beside A-395). +var RunnerReads = []string{"seat:mesh-catalog.seat-definitions", "seat:mesh-catalog.revision", "seat:mesh-catalog.registrations", "seat:mesh-delivery.source"} + +// withRunnerReads is invokes with each of RunnerReads it lacks. +func withRunnerReads(invokes []string) []string { + out := slices.Clone(invokes) + for _, r := range RunnerReads { + if !slices.Contains(out, r) && !slices.Contains(out, "*") { + out = append(out, r) + } + } + return out +} diff --git a/modules/mesh-grants/internal/grants/refused.go b/modules/mesh-grants/internal/grants/refused.go index 7ea2c0a9..7fa6eb52 100644 --- a/modules/mesh-grants/internal/grants/refused.go +++ b/modules/mesh-grants/internal/grants/refused.go @@ -137,3 +137,123 @@ func (p *Part) sayPrincipalsRefused(refused map[string]string, kept map[string]U p.refusedSaid, p.refusedKnown = why, true } } + +// withEveryAccountsRights gives each account a right every account of its kind carries (buscompose.StreamNamesSubject, design 47 G +// A-382; buscompose.AnySeatSubject, principle 6, to a kept one) that it lacks, in users and in kept: a user kept from the list in force or held is copied whole, so it would never gain it. An +// account of a ledger, an enrolling node, a person or a provisioner publishes on a few subjects alone and gets none. It only adds. +func withEveryAccountsRights(users []User, kept map[string]User, own map[string][]string) ([]User, map[string]User) { + add := func(u User, isKept bool) User { + u.Publish = withMissing(u.Publish, own[u.User]) + for _, alone := range []string{"ledger.", "enrol.", "person.", "provisioner."} { + if strings.HasPrefix(u.User, alone) { + return u + } + } + u.Publish = withMissing(u.Publish, []string{buscompose.StreamNamesSubject}) + if isKept { + // A composed account has it from buscompose.PermissionsFor where its kind asks; a kept one is copied whole. + u.Publish = withMissing(u.Publish, []string{buscompose.AnySeatSubject}) + } + return u + } + out := make([]User, len(users)) + for i, u := range users { + out[i] = add(u, false) + } + var withKept map[string]User + if kept != nil { + withKept = make(map[string]User, len(kept)) + for k, u := range kept { + withKept[k] = add(u, true) + } + } + return out, withKept +} + +// withMissing is list with each of rights it lacks, never taking one away. +func withMissing(list, rights []string) []string { + out := list + for _, r := range rights { + if !slices.Contains(out, r) { + out = append(slices.Clone(out), r) + } + } + return out +} + +// unionComposed is kept with each kept user that the pass also composed (composed, and not one in apart) holding the union of +// the grants of the list in force and of the composed account; the composed copy stays out of users, as a kept one's place is its own +// (withKept). It only adds. +func unionComposed(kept map[string]User, composed []User, apart map[string]string) map[string]User { + if len(kept) == 0 { + return kept + } + out := make(map[string]User, len(kept)) + for name, u := range kept { + out[name] = u + } + for _, c := range composed { + u, ok := out[c.User] + if !ok { + continue + } + if _, no := apart[c.User]; no { + continue + } + u.Publish = set(append(slices.Clone(u.Publish), c.Publish...)) + u.Subscribe = set(append(slices.Clone(u.Subscribe), c.Subscribe...)) + u.AllowResponses = u.AllowResponses || c.AllowResponses + if u.PublishDeny != nil || c.PublishDeny != nil { + u.PublishDeny = set(append(slices.Clone(u.PublishDeny), c.PublishDeny...)) + } + if u.SubscribeDeny != nil || c.SubscribeDeny != nil { + u.SubscribeDeny = set(append(slices.Clone(u.SubscribeDeny), c.SubscribeDeny...)) + } + out[c.User] = u + } + return out +} + +// unionKeptRunners is kept with each tool runner kept as it runs (runnersKept) holding the union of the list in force and the grants of a +// carrying runner on its node, composed from the modules the pass places there with their bindings and events (design 47 G A-386); a +// runner that cannot be composed so stays as the list in force holds it. It only adds. +func unionKeptRunners(kept map[string]User, r buscompose.Records, runnersKept map[string]string, byBindings map[string][]buscompose.Declared) map[string]User { + if len(kept) == 0 || len(runnersKept) == 0 { + return kept + } + out := make(map[string]User, len(kept)) + for name, u := range kept { + out[name] = u + } + for name := range runnersKept { + u, ok := out[name] + node, runner, cut := strings.Cut(name, ".") + if !ok || !cut { + continue + } + perms, err := buscompose.KeptRunnerGrants(r, node, runner, byBindings[node]) + if err != nil { + continue + } + u.Publish = set(append(slices.Clone(u.Publish), perms.Publish...)) + u.Subscribe = set(append(slices.Clone(u.Subscribe), perms.Subscribe...)) + u.AllowResponses = u.AllowResponses || perms.AllowResponses + out[name] = u + } + return out +} + +// declaredByBindings are, by node, the modules placed there that the records leave out for want of a manifest and that have bindings kept: each +// declared by its bindings alone, with no account of its own, so a tool runner carries it and reads what it is bound to (design 47 G A-386). +func declaredByBindings(in Inputs, r buscompose.Records) map[string][]buscompose.Declared { + out := map[string][]buscompose.Declared{} + for node, modules := range in.Assigned { + for _, module := range modules { + if len(in.Bindings[module]) == 0 || slices.ContainsFunc(r.Assigned[node], func(d buscompose.Declared) bool { return d.Module == module }) { + continue + } + out[node] = append(out[node], buscompose.Declared{Module: module, NoAccount: true, Bindings: in.Bindings[module]}) + } + } + return out +} diff --git a/modules/mesh-grants/internal/grants/runner_reads_test.go b/modules/mesh-grants/internal/grants/runner_reads_test.go new file mode 100644 index 00000000..4ce25001 --- /dev/null +++ b/modules/mesh-grants/internal/grants/runner_reads_test.go @@ -0,0 +1,25 @@ +package grants + +import ( + "slices" + "testing" + + "git.novox.be/novox/mesh-sdk/go/catalogue" +) + +// A-396: every module is composed as invoking the runner's own reads, so its account may ask them. +func TestEveryModuleInvokesTheRunnersReads(t *testing.T) { + for _, c := range []struct { + name string + invokes []string + want int + }{{"none declared", nil, len(RunnerReads)}, {"one declared", []string{"seat:mesh-catalog.revision"}, len(RunnerReads)}, {"every verb", []string{"*"}, 1}} { + d := declaredFor(catalogue.Manifest{Module: "mesh-build-go", Invokes: c.invokes}, nil, nil, nil) + if len(d.Invokes) != c.want { + t.Errorf("%s: invokes %v, want %d", c.name, d.Invokes, c.want) + } + if c.want > 1 && !slices.Contains(d.Invokes, "seat:mesh-catalog.seat-definitions") { + t.Errorf("%s: invokes %v lack the seat list's verb", c.name, d.Invokes) + } + } +} diff --git a/modules/mesh-grants/internal/grants/running.go b/modules/mesh-grants/internal/grants/running.go index 5d21e384..81652c48 100644 --- a/modules/mesh-grants/internal/grants/running.go +++ b/modules/mesh-grants/internal/grants/running.go @@ -4,12 +4,15 @@ import ( "bytes" "encoding/json" "fmt" + "slices" "sort" "strings" "time" "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" "git.novox.be/novox/mesh-sdk/go/catalogue" + + "mesh-grants/internal/buscompose" ) // **What each node runs, as its node-engine says it** (novox/hq design 47, ADR 0660 §2): the seat node-engine's event @@ -67,6 +70,9 @@ type StreamRead struct { // State is `waiting` until the read ends, then `read`. State string `json:"state"` Since time.Time `json:"since"` + // Absent says why a waiting read is taken as empty: the stream is one the part creates and the bus does not hold yet, so its first + // view is empty and the stream is created after the pass (design 47 G, A-371); empty when the read waits for its answer. + Absent string `json:"absent,omitempty"` } // ReadingRunning begins the whole read of the node-engine's stream running at the part's start; the part acts on none of @@ -98,10 +104,44 @@ func (p *Part) StreamReads() []StreamRead { return []StreamRead{r} } +// noteAbsent keeps in the stream's status whether its waiting read is taken as empty for the stream's absence. +func (p *Part) noteAbsent(absent bool) { + p.mu.Lock() + defer p.mu.Unlock() + if p.runningRead == nil { + return + } + p.runningRead.Absent = "" + if absent { + p.runningRead.Absent = "the stream is absent on the bus: its first view is taken as empty, and the part creates it after this pass" + } +} + +// createsAndLacks says a stream the part reads whole at its start is one of the kept event streams it creates itself and the bus +// does not hold yet: its first view is empty, no wait (design 47 G, A-371). The pass composes, writes the part's own create right, +// and the part creates the stream and hears it from its start. A bus whose streams cannot be read leaves the read a wait. +func (p *Part) createsAndLacks(in Inputs, stream string) bool { + if !slices.ContainsFunc(in.Kept, func(k buscompose.KeptEvent) bool { return k.Stream == stream }) || p.Call == nil { + return false + } + held, err := HeldStreams(p.Call) + if err != nil { + return false + } + _, has := held[stream] + return !has +} + // readRan reads each key of StateRunning and the manifest its digest names (the indexer's, by digest), into in.Ran. A key // whose manifest cannot be read is a gap, and that node's module is read as it was before (the trunk's). func (p *Part) readRan(in *Inputs) { - if reads := p.StreamReads(); len(reads) > 0 && reads[0].State == "waiting" { + reads := p.StreamReads() + absent := len(reads) > 0 && reads[0].State == "waiting" && p.createsAndLacks(*in, reads[0].Stream) + p.noteAbsent(absent) + if absent { + in.StreamsAbsent = append(in.StreamsAbsent, reads[0].Stream+": absent on the bus, taken as empty; the part creates it after this pass") + } + if len(reads) > 0 && reads[0].State == "waiting" && !absent { // The whole read of `running` has not ended: the part acts on none of it, and keeps the list it has (design 47 G §556). in.Gaps = append(in.Gaps, Gap{Input: StateRunning, Failed: true, Why: "the stream " + reads[0].Stream + " is waiting: its whole read at the part's start has not ended"}) diff --git a/modules/mesh-grants/internal/grants/sealed.go b/modules/mesh-grants/internal/grants/sealed.go index cd5b27ff..aec8e29e 100644 --- a/modules/mesh-grants/internal/grants/sealed.go +++ b/modules/mesh-grants/internal/grants/sealed.go @@ -126,6 +126,9 @@ func (p *Part) writeSealed(res *Result, list []byte, users int, leftOut, dropped next.Digest, next.Object, next.SealedTo, next.Node = digest, grantsstate.UserListObjectName(digest), grantsstate.SealingKeyID(key), in.BusNode } p.sayHeld(held) + if p.Logf != nil { + p.Logf("the user list: composed %s, in force %s, sealed to key %q, bus node %q, held %q, why %q", short(digest), short(cur.Digest), short(key), in.BusNode, held, why) + } if next.Digest == digest { next.Users, next.LeftOut = users, leftOut } diff --git a/modules/mesh-grants/internal/grants/seats_main_test.go b/modules/mesh-grants/internal/grants/seats_main_test.go index 7c6e1b6c..12f74fa0 100644 --- a/modules/mesh-grants/internal/grants/seats_main_test.go +++ b/modules/mesh-grants/internal/grants/seats_main_test.go @@ -1,6 +1,7 @@ package grants import ( + "mesh-grants/internal/buscompose" "os" "testing" @@ -11,5 +12,7 @@ import ( // TestMain gives catalogue the seat list a host reads (ADR 0636 §1): none is compiled into mesh-sdk. func TestMain(m *testing.M) { catalogue.UseSeats(catalogue.SeatsFromDefinitions(seatlisttest.Definitions())) + // These tests read each account's own subjects, which the part composes beneath the wide grant. + buscompose.EveryAccountMayDoEverything = false os.Exit(m.Run()) } diff --git a/modules/mesh-grants/internal/grants/sentobjects_test.go b/modules/mesh-grants/internal/grants/sentobjects_test.go index 0db59117..59e97976 100644 --- a/modules/mesh-grants/internal/grants/sentobjects_test.go +++ b/modules/mesh-grants/internal/grants/sentobjects_test.go @@ -13,6 +13,14 @@ import ( // The sent stores a module reads follow the catalog graph (design 47 G §59, §124): the consumers of a module's events and the // callers a seat's verb admits, and no other module. func TestSentStoresRead(t *testing.T) { + // The store beside each state of the field state is the module's own object bucket (design 47 G §58, A-237); a state only + // read has none, a state's size is its store's. + objs := objectsOf(catalogue.Manifest{Module: "mesh-delivery-indexer", State: []catalogue.StateDeclaration{{Name: "inputs", History: 1}, + {Name: "versions", MaxMiB: 64}, {Name: "seen", ReadOnly: true}}}) + if len(objs) != 2 || objs[0].Bucket() != "mesh-delivery-indexer_inputs-objects" || objs[0].MaxMiB != StateObjectsMiB || + objs[1].Bucket() != "mesh-delivery-indexer_versions-objects" || objs[1].MaxMiB != 64 { + t.Errorf("the state's object stores = %+v", objs) + } holder := catalogue.Manifest{Module: "shop", Claims: []catalogue.Claim{{Name: "orders-seat"}}} all := map[string]catalogue.Manifest{"shop": holder, "bank": {Module: "bank"}, "plain": {Module: "plain"}} callers := map[string]map[string][]string{"orders-seat": { @@ -56,7 +64,7 @@ func TestTheMarkedVerbsADeclarationNames(t *testing.T) { t.Errorf("marked = %v", got) } m := catalogue.Manifest{Module: "shop", Invokes: []string{"seat:node-login-shell.execute"}} - if got := declaredFor(m, seats, nil).MarkedVerbs; !slices.Equal(got, []string{"seat:node-login-shell.execute"}) { + if got := declaredFor(m, seats, nil, nil).MarkedVerbs; !slices.Equal(got, []string{"seat:node-login-shell.execute"}) { t.Errorf("the declaration carries %v, want the marked verb it invokes", got) } } diff --git a/modules/mesh-grants/internal/grants/tools.go b/modules/mesh-grants/internal/grants/tools.go index 3ce1114c..77681b63 100644 --- a/modules/mesh-grants/internal/grants/tools.go +++ b/modules/mesh-grants/internal/grants/tools.go @@ -136,6 +136,18 @@ func (p *Part) MembershipOf(node, module string) (any, error) { } } out["composed"] = why + // Why no manifest was found: every gap of the pass that names the module, its manifest or its node's build of it + // (the trunk's verdict, the catalog entry of the running build, the want's), so a module left out says why. + var said []Gap + for _, g := range in.Gaps { + if strings.Contains(g.Input, module) || strings.Contains(g.Why, node+"."+module) { + said = append(said, g) + } + } + _, running := in.Running[node+"."+module] + _, trunk := in.Manifests[module] + _, held := in.Held[module] + out["manifest"] = map[string]any{"running": running, "trunk": trunk, "held": held, "gaps": said} } // The state holds the bare membership last published (mesh-sdk's codec, issue 774); what became of it at the last // pass is the pass's, kept in user-list at KeyPass. @@ -223,6 +235,13 @@ func (p *Part) Pass() Result { if _, err := p.Store.Put(StateUserList, KeyPass, data); err != nil { res.Errors = append(res.Errors, fmt.Sprintf("its own %s %s cannot be written: %v", StateUserList, KeyPass, err)) } + // Every error of the pass in the journal too: the key pass is read only by tools that may not open its object. + if p.Logf != nil { + for _, e := range res.Errors { + p.Logf("the pass: %s", e) + } + p.Logf("the pass ended: %d errors, sealed %+v", len(res.Errors), res.Sealed) + } return res } diff --git a/modules/mesh-grants/internal/grants/userlist.go b/modules/mesh-grants/internal/grants/userlist.go index 85bf01c7..7bed9387 100644 --- a/modules/mesh-grants/internal/grants/userlist.go +++ b/modules/mesh-grants/internal/grants/userlist.go @@ -151,7 +151,7 @@ func Digest(users []User) string { } // LoadedUsers is the list the bus loaded, as its module's nats_users reads it from the file: every user by name, then -// each one's grants in full. +// each one's grants in full, one user per answer so no answer exceeds one bus message. func LoadedUsers(c Caller) ([]User, error) { raw, err := c.Call(CallUsers, map[string]any{}) if err != nil { @@ -183,12 +183,9 @@ func LoadedUsers(c Caller) ([]User, error) { } return nil } - // Every name with a dot in one call; each name without one (the controller) alone. - if err := ask("."); err != nil { - return nil, err - } out := make([]User, 0, len(names.Users)) for _, n := range names.Users { + // One user per answer: the whole list is more than one bus message (the live hold, 2026-11-14). if _, ok := full[n.User]; !ok { if err := ask(n.User); err != nil { return nil, err diff --git a/modules/mesh-grants/seats_main_test.go b/modules/mesh-grants/seats_main_test.go index 95e44d8c..2f4001c0 100644 --- a/modules/mesh-grants/seats_main_test.go +++ b/modules/mesh-grants/seats_main_test.go @@ -1,6 +1,7 @@ package manifest import ( + "mesh-grants/internal/buscompose" "os" "testing" @@ -11,5 +12,7 @@ import ( // TestMain gives catalogue the seat list a host reads (ADR 0636 §1): none is compiled into mesh-sdk. func TestMain(m *testing.M) { catalogue.UseSeats(catalogue.SeatsFromDefinitions(seatlisttest.Definitions())) + // These tests read each account's own subjects, which the part composes beneath the wide grant. + buscompose.EveryAccountMayDoEverything = false os.Exit(m.Run()) } diff --git a/sdk/buildstep/request.go b/sdk/buildstep/request.go index 9cc961ff..5ea272b0 100644 --- a/sdk/buildstep/request.go +++ b/sdk/buildstep/request.go @@ -19,8 +19,9 @@ var ( // // **The paths come from the builder, not from a manifest** (ADR 0495 clause 1; the lead's decision L8 of R4e): the // builder fills Dir and Paths from the indexer's Module value (Path, and KeptInputs2.Paths' keys), and the build module -// gives the build and test steps a workspace holding those paths, the manifest and its lock files. A request without -// them builds from the module's directory, as before. +// gives the build and test steps a workspace holding those paths, the manifest and its lock files. A request with a directory and no +// paths builds from the module's directory, which a Go build resolves with the Go modules it replaces alone (A-447); +// one without either builds the whole tree. type FetchRequest struct { Repository string `json:"repository"` Commit string `json:"commit"` @@ -138,11 +139,9 @@ func (r FetchRequest) Check() error { if r.Base != "" && !requestCommitOK.MatchString(r.Base) { return fmt.Errorf("%q is not a trunk commit (40 hex digits)", r.Base) } - switch { - case len(r.Paths) > 0 && r.Dir == "": + // A module directory alone is a request for that module's Go modules alone (design 47 G, A-447); paths need it. + if len(r.Paths) > 0 && r.Dir == "" { return fmt.Errorf("the request names paths and names no module directory (dir) they are relative to") - case len(r.Paths) == 0 && r.Dir != "": - return fmt.Errorf("the request names a module directory and no path") } if r.Dir != "" && (outside(r.Dir) || strings.HasPrefix(r.Dir, "/")) { return fmt.Errorf("the module directory %q leaves the repository", r.Dir) diff --git a/sdk/buildstep/request_test.go b/sdk/buildstep/request_test.go index 7732329f..fbd79d55 100644 --- a/sdk/buildstep/request_test.go +++ b/sdk/buildstep/request_test.go @@ -33,6 +33,10 @@ func TestAFetchRequestCarriesTheNamedPathsThroughTheToolCall(t *testing.T) { } ok := map[string]any{"repository": "novox/x", "commit": strings.Repeat("b", 40)} + // A module directory with no paths is a request (design 47 G, A-447). + if dirOnly, err := ParseFetchRequest(map[string]any{"repository": "novox/x", "commit": strings.Repeat("b", 40), "dir": "modules/a"}); err != nil || dirOnly.Dir != "modules/a" || dirOnly.Paths != nil { + t.Fatalf("a directory with no paths: %+v, %v", dirOnly, err) + } for _, c := range []struct { set map[string]any says string @@ -45,7 +49,6 @@ func TestAFetchRequestCarriesTheNamedPathsThroughTheToolCall(t *testing.T) { {map[string]any{"dir": "modules/a", "paths": []any{"../b"}}, "leaves the module's directory"}, {map[string]any{"dir": "../a", "paths": []any{"src"}}, "leaves the repository"}, {map[string]any{"dir": "modules/a", "paths": []any{3}}, "paths is a list of strings"}, - {map[string]any{"dir": "modules/a"}, "names a module directory and no path"}, {map[string]any{"packages": map[string]any{"git.novox.be/novox/mesh-sdk/go": "main"}}, "neither a full commit nor a Go semantic version"}, {map[string]any{"packages": map[string]any{"a b": strings.Repeat("d", 40)}}, "no module path"}, {map[string]any{"packages": []any{"x"}}, "packages is an object"},