From 7ffec1b56b266128578b6e80bdcb6f35be0002bb Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 00:53:49 +0100 Subject: [PATCH 01/16] I1: a module's fingerprint takes a package by what is published, never by a commit of its repository MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A package of another repository none publishes leaves the module without a fingerprint (NoPackageVersion) instead of taking the gate's source head; one of the module's own repository none publishes enters by its directory's tree, which the tree input carries, so the same source gives the same fingerprint. Builds: design 47 H2 §802, H-A-349 DQ-8, H-A-350 DMC-5 --- .../internal/fingerprint/fingerprint.go | 7 ++-- .../internal/fingerprint/fingerprint_test.go | 13 +++++- .../internal/index/form.go | 37 ++++++----------- .../internal/index/imports_test.go | 41 +++++++++++-------- .../internal/index/source.go | 7 ---- .../internal/index/toolchains.go | 8 ++-- 6 files changed, 54 insertions(+), 59 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint.go b/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint.go index 64bf2d128..6c3cd5637 100644 --- a/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint.go +++ b/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint.go @@ -229,8 +229,10 @@ func ReplacedSiblings(goMod []byte, repository string) []string { // VersionLine is the version line's value of each package (Inputs.Packages) of a module of repository: a mesh Go // module of another repository by its version (versions), and one of repository itself, replaced by its directory // (ReplacedSiblings), by the content its directory publishes, `content:` and the hex sha256 of its requirements' digest -// and each package's digest (empty while it is not published, which gives no fingerprint until it is, as a version -// none publishes does). +// and each package's digest. A package of another repository with no version is empty, which gives no fingerprint until +// it is published (NoPackageVersion); one of repository that is not published yet has no line: it enters by its +// directory's tree, which the module's tree input carries (its own directory, or a derived directory of H-A-202), never by +// a commit (design 47 H2 §802, H-A-349 DQ-8). func VersionLine(repository string, packages []string, versions sdkstep.PackageVersions, published map[string]meshcatalog.PackagesByModuleValue) map[string]string { if len(packages) == 0 { return nil @@ -244,7 +246,6 @@ func VersionLine(repository string, packages []string, versions sdkstep.PackageV } pub, held := published[p] if !held { - out[p] = "" continue } lines := []string{"requires " + pub.Requires} diff --git a/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint_test.go b/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint_test.go index 6a1d68bbc..257e6781f 100644 --- a/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint_test.go +++ b/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint_test.go @@ -62,8 +62,17 @@ func versionLineTakesASiblingDirectoryByItsContent(t *testing.T) { if a, b := line("d1"), line("d2"); a == b { t.Error("a change of the sibling directory alone left the importer's fingerprint where it was") } - if got := VersionLine(repo, []string{buildrun}, nil, nil)[buildrun]; got != "" { - t.Errorf("an unpublished sibling is taken as %q, want none (no fingerprint until it is published)", got) + // An unpublished sibling has no line: it enters by its directory's tree, which the tree input carries (design 47 H2 + // §802, H-A-349 DQ-8); one of another repository with no version still gives no fingerprint. + if got, ok := VersionLine(repo, []string{buildrun}, nil, nil)[buildrun]; ok { + t.Errorf("an unpublished sibling is taken as %q, want no line (it enters by its directory's tree)", got) + } + in := base() + if in.Packages = VersionLine(repo, []string{sdk}, nil, nil); in.Packages[sdk] != "" { + t.Fatalf("a package of another repository with no version is taken as %q", in.Packages[sdk]) + } + if fp, none := Of(in); fp != "" || !strings.HasPrefix(none, NoPackageVersion) { + t.Errorf("a package of another repository with no version gives %q (%q), want none naming it", fp, none) } } diff --git a/modules/mesh-delivery-indexer/internal/index/form.go b/modules/mesh-delivery-indexer/internal/index/form.go index 133f42e1b..8e9c0687f 100644 --- a/modules/mesh-delivery-indexer/internal/index/form.go +++ b/modules/mesh-delivery-indexer/internal/index/form.go @@ -7,7 +7,6 @@ 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" ) @@ -39,14 +38,15 @@ type form struct { // another repository its go.mod requires, at any version (design 47 H-A-157), 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). +// A package of another repository none of them publishes leaves the module without a fingerprint until one does +// (fingerprint.NoPackageVersion), and one of its own repository none publishes enters by its directory's tree alone, +// never by a commit: the same source, the same fingerprint (design 47 H2 §802, H-A-349 DQ-8). // - **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, heads map[string]string, 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, logf func(string, ...any)) form { in := inputsFrom(module, *kept, toolchains) if len(kept.Imports) > 0 { r := fingerprint.Resolve(repository, kept.Imports, published) @@ -58,11 +58,11 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp return form{none: none} case kept.ImportForm == fp && prev.Fp2 != "": // The build that reported the imports stands, and so do its versions. - return form{fp: prev.Fp2, versions: refined(sdkstep.PackageVersions(prev.Packages), r.Versions, module, repository, kept, held, pins, heads), + return form{fp: prev.Fp2, versions: refined(sdkstep.PackageVersions(prev.Packages), r.Versions, module, repository, kept, held, pins), stands: true, raw: fp, built: prev.Packages} } kept.ImportForm = fp - return form{fp: fp, versions: refined(r.Versions, nil, module, repository, kept, held, pins, heads)} + return form{fp: fp, versions: refined(r.Versions, nil, module, repository, kept, held, pins)} } if logf != nil { logf("%s: no published package holds %s, so its fingerprint takes the version line", module, strings.Join(r.Missing, ", ")) @@ -71,7 +71,7 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp // The fingerprint written here is the version line's, not the import form's: no import form is held for the inputs it was // computed from, so a later pass whose import form computes the same does not take this one for the build's (issue 1966). kept.ImportForm = "" - versions := lineVersions(module, repository, kept, held, pins, heads, logf) + versions := lineVersions(module, repository, kept, held, pins, logf) in.Packages = fingerprint.VersionLine(repository, kept.Packages, versions, published) fp, none := fingerprint.Of(in) if fp == "" { @@ -83,22 +83,22 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp // refined are an import form's versions: the first of sets that names a package, else, while the module's go.mod // requires a mesh package of another repository (kept.Packages), the version line's, so a build's reported imports // refine the go.mod's set and never empty it (design 47 H-A-157); nil when nothing names one. -func refined(versions, then sdkstep.PackageVersions, module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, held map[string]meshcatalog.ModulesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string) sdkstep.PackageVersions { +func refined(versions, then sdkstep.PackageVersions, module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, held map[string]meshcatalog.ModulesByModuleValue, pins sdkstep.PackageVersions) sdkstep.PackageVersions { switch { case len(versions) > 0: return versions case len(then) > 0: return then case len(fingerprint.OtherPackages(kept.Packages, repository)) > 0: - return lineVersions(module, repository, kept, held, pins, heads, nil) + return lineVersions(module, repository, kept, held, pins, nil) } return versions } // lineVersions are the version line's versions of the mesh Go modules of other repositories the module's go.mod requires -// (kept.Packages): each as the indexer has always read it, an accepted series' pin over it, else the commit the gate's -// source names for its repository. -func lineVersions(module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, held map[string]meshcatalog.ModulesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string, logf func(string, ...any)) sdkstep.PackageVersions { +// (kept.Packages): each as the indexer has always read it, an accepted series' pin over it; one neither gives has no +// version, so the module has no fingerprint until it is published (design 47 H2 §802). +func lineVersions(module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, held map[string]meshcatalog.ModulesByModuleValue, pins sdkstep.PackageVersions, logf func(string, ...any)) sdkstep.PackageVersions { others := fingerprint.OtherPackages(kept.Packages, repository) versions, unpublished := fingerprint.HeldVersionsOf(others, held) for p, v := range pins { // an accepted series' newest published version (acceptedSeries, DLV-I6) @@ -110,19 +110,6 @@ func lineVersions(module, repository string, kept *meshcatalog.ModulesByModuleVa 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_test.go b/modules/mesh-delivery-indexer/internal/index/imports_test.go index 65876c137..762b8bbd9 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports_test.go +++ b/modules/mesh-delivery-indexer/internal/index/imports_test.go @@ -11,6 +11,8 @@ 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" "git.novox.be/novox/mesh-sdk/go/process" + + "mesh-delivery-indexer/internal/fingerprint" ) const meshSDK = "git.novox.be/novox/mesh-sdk/go" @@ -402,41 +404,44 @@ 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) + t.Run("formOf takes a package by what is published, never by a commit of its repository", func(t *testing.T) { // design 47 H2 §802, H-A-349 DQ-8 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"}} // A build's imports of its own repository alone (design 47 H-A-157): they refine the go.mod's set and never empty it. own := "git.novox.be/novox/mesh-catalog/modules/avahi/lib" - published := map[string]meshcatalog.PackagesByModuleValue{own: {Module: own, Repository: "novox/mesh-catalog", Commit: head, Requires: "r1", + published := map[string]meshcatalog.PackagesByModuleValue{own: {Module: own, Repository: "novox/mesh-catalog", Commit: strings.Repeat("c", 40), Requires: "r1", Packages: []meshcatalog.PackagesByModuleValuePackagesItem{{Package: own, Digest: "d1"}}}} for _, c := range []struct { name string - heads map[string]string held map[string]meshcatalog.ModulesByModuleValue imports []string want string }{ - {"the source names its repository", map[string]string{"novox/mesh-contracts": head}, held, nil, head}, - {"the source names another repository only", map[string]string{"novox/mesh-sdk": head}, held, nil, ""}, - {"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"}}, nil, strings.Repeat("e", 40)}, - {"a build's imports naming none of another repository keep the go.mod's", map[string]string{"novox/mesh-contracts": head}, held, []string{own}, head}, + {"a package of another repository none publishes", held, nil, ""}, + {"a module the indexer holds publishes it", map[string]meshcatalog.ModulesByModuleValue{"c": {Repository: "novox/mesh-contracts", Commit: strings.Repeat("e", 40), Path: "go/seats/findings"}}, nil, strings.Repeat("e", 40)}, + {"a build's imports naming none of another repository, which none publishes", held, []string{own}, ""}, } { kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t", Packages: []string{contracts}, Imports: c.imports} - f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, c.held, published, nil, c.heads, nil) + f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, c.held, published, nil, nil) if got := f.versions[contracts]; got != c.want { t.Errorf("%s: version of %s = %q, want %q", c.name, contracts, got, c.want) } - if c.imports == nil { - continue - } - // The build that reported them stands, its held versions empty (a version line read from go.sum). - f = formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{Fp2: "src2:" + strings.Repeat("b", 64)}, c.held, published, nil, c.heads, nil) - if got := f.versions[contracts]; got != c.want || f.fp != "src2:"+strings.Repeat("b", 64) { - t.Errorf("%s, the build standing: version of %s = %q (fp %q), want %q", c.name, contracts, got, f.fp, c.want) + if c.want == "" && c.imports == nil && (f.fp != "" || !strings.HasPrefix(f.none, fingerprint.NoPackageVersion)) { + t.Errorf("%s: fingerprint %q (none %q), want none naming %s", c.name, f.fp, f.none, fingerprint.NoPackageVersion) } } + // A package of the module's own repository no module has published enters by its directory's tree (the tree input), + // so the module has a fingerprint, and the same tree gives the same one whatever commit names it. + sibling := "git.novox.be/novox/mesh-catalog/modules/sibling" + kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t\nderived modules/sibling o1", Packages: []string{sibling}} + f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil) + if f.fp == "" { + t.Fatalf("an unpublished package of the same repository: none %q, want a fingerprint by its directory's tree", f.none) + } + kept.Tree = "t\nderived modules/sibling o2" + if g := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, nil, nil, nil, nil); g.fp == "" || g.fp == f.fp { + t.Errorf("the sibling's directory changed: fingerprint %q, was %q; want a new one", g.fp, f.fp) + } }) t.Run("formOf clears the import form when it writes the version line", func(t *testing.T) { for _, c := range []struct { @@ -444,7 +449,7 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t * 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, nil) + f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, 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) } diff --git a/modules/mesh-delivery-indexer/internal/index/source.go b/modules/mesh-delivery-indexer/internal/index/source.go index a0d2ba74f..55fbf1937 100644 --- a/modules/mesh-delivery-indexer/internal/index/source.go +++ b/modules/mesh-delivery-indexer/internal/index/source.go @@ -24,13 +24,6 @@ type sourceNow struct { heads map[string]string } -// 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) -} - // wholeAt reads repository's trees at the commit head through the seat git (design 47 H §743): every module directory's manifest, // templates' needs, lock files and packages, and the catalogue's predefined list where the repository is the catalogue's (§769). func (ix *Indexer) wholeAt(ctx context.Context, repository, head string) (whole, error) { diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index dfba512a6..0a4553916 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -303,11 +303,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, ix.sourceHeads(), series); ok { + if fp, pkgs, ok := stillComputed(module, kept, k, toolchains, held, pub, pins, series); 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.sourceHeads(), ix.logf) + f := formOf(module, k.cur.Repository, &kept, toolchains, k.held, held, pub, pins, ix.logf) r.fp, r.none = f.fp, f.none if r.fp != "" { // a pin is a released version, never a commit (H-A-161), and the version line's fingerprint takes it (H-A-167) @@ -510,7 +510,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, heads map[string]string, series map[string]SeriesPackage) (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, series map[string]SeriesPackage) (string, sdkstep.PackageVersions, bool) { if k.held.Fp2 == "" { return "", nil, false } @@ -526,7 +526,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, heads, nil) + f := formOf(module, k.held.Repository, &kept, toolchains, k.held, held, published, pins, nil) if f.none != "" || f.fp == "" { return "", nil, false } From 8bd66112f07534064f5c0ffff2b097627f352ff8 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 01:02:11 +0100 Subject: [PATCH 02/16] I2: a take-in says what it waits on MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A source-moved take-in waiting over a minute on the seat git writes one journal line and its waiting-on (part, verb, since) in the state takeins under running., removed at the take-in's end; past five minutes it raises take-in-waiting (scope merge), cleared when the wait ends. indexer_pending answers the running take-ins beside the held ones. The wait is measured by a context's bound, no timer (ADR 0437 §8). Builds: design 47 H2 §803, H-A-409 --- .../cmd/mesh-delivery-indexer-tools/main.go | 2 +- .../cmd/mesh-delivery-indexer/main.go | 6 +- .../cmd/mesh-delivery-indexer/takein.go | 5 +- .../takein_integration_test.go | 2 +- .../cmd/mesh-delivery-indexer/takein_test.go | 2 +- .../internal/index/candidates.go | 9 +- .../internal/index/dryrun.go | 4 +- .../internal/index/findings.go | 2 +- .../internal/index/held.go | 15 +- .../internal/index/held_test.go | 4 +- .../internal/index/modules.go | 10 +- .../internal/index/moves.go | 4 +- .../internal/index/order.go | 2 +- .../internal/index/package_trees.go | 6 +- .../internal/index/packages.go | 4 +- .../internal/index/source.go | 6 +- .../internal/index/takein_source.go | 3 +- .../internal/index/takein_source_test.go | 111 ++++++++++ .../internal/index/takein_waiting.go | 194 ++++++++++++++++++ .../internal/index/taken.go | 2 +- 20 files changed, 359 insertions(+), 34 deletions(-) create mode 100644 modules/mesh-delivery-indexer/internal/index/takein_waiting.go 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 a2eba94a8..09fd60658 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 @@ -208,7 +208,7 @@ func main() { _, err := acts.Record(meshhandactsclient.Request{What: what, Why: why, Cause: index.PinDropTool, Verb: "pin-drop"}) return err })...) - tools = append(tools, index.HeldTools(keptRead{stdio.State(index.HeldState)}, asks, time.Now, func(what, why string) error { + tools = append(tools, index.HeldTools(keptRead{stdio.State(index.HeldState)}, keptRead{stdio.State(index.TakeInsState)}, asks, time.Now, func(what, why string) error { _, err := acts.Record(meshhandactsclient.Request{What: what, Why: why, Cause: index.TakeInSkipTool, Verb: "take-in-skip"}) return err })...) 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 c87463d79..aca38fc31 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -331,7 +331,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro return fmt.Errorf("answering the verb input: %w", err) } defer stopInput() - ix := &index.Indexer{Module: cred.Module, NamedSets: named, Findings: writer, OldSections: awaitedStore{b: oldSections}, Requirements: awaitedStore{b: requirements}, Store: kvStore{candidates}, Modules: modules, Manifests: kvStore{manifests}, Taken: awaitedStore{b: taken}, Builds: known, + // The state takeins: hand acts ask there (watched below), and a running take-in keeps what it waits on (H2 §803, H-A-409). + takeIns := process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.TakeInsState), "no hand act of the indexer is answered", logger.Printf) + ix := &index.Indexer{Module: cred.Module, TakeIns: awaitedStore{b: takeIns}, NamedSets: named, Findings: writer, OldSections: awaitedStore{b: oldSections}, Requirements: awaitedStore{b: requirements}, Store: kvStore{candidates}, Modules: modules, Manifests: kvStore{manifests}, Taken: awaitedStore{b: taken}, Builds: known, Predefined: awaitedStore{b: predefined}, Logf: logger.Printf, Named: namedVia(calls.Call), Trunk: trunkVia(calls.Call), BranchHead: branchHeadVia(calls.Call), Contains: containsVia(calls.Call), Read: readVia(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), @@ -502,7 +504,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro done() // A person's hand act writes the takeins state (issue 1945): watched, as every other input. // A state not on the bus yet at this start is watched once it appears (issue 1790). - process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.TakeInsState), "no hand act of the indexer is answered", logger.Printf).Ready(func(kv jetstream.KeyValue) { + takeIns.Ready(func(kv jetstream.KeyValue) { eachTakeIn := func(e jetstream.KeyValueEntry) { takenIn(ctx, actor{ix, sources}, kv, e, logger.Printf) } if tw, err := settle(ctx, kv, eachTakeIn); err != nil { process.NotWatched(logger.Printf, index.Bucket(cred.Module, index.TakeInsState), err, "no hand act of the indexer is answered until the indexer starts again") 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 31c7f4a84..11a52cd33 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "errors" + "strings" "time" "github.com/nats-io/nats.go/jetstream" @@ -32,8 +33,8 @@ type takerIn interface { // written back, by compare-and-set at its revision, with what the indexer stored or why not. A value // answered already (this indexer's own write) or deleted is left. func takenIn(ctx context.Context, ix takerIn, kv jetstream.KeyValue, e jetstream.KeyValueEntry, logf func(string, ...any)) { - if e.Operation() != jetstream.KeyValuePut { - return + if e.Operation() != jetstream.KeyValuePut || strings.HasPrefix(e.Key(), index.RunningPrefix) { + return // a running take-in's waiting-on is the indexer's own record, no ask (H-A-409) } a, err := index.DecodeTakeIn(e.Value()) if err != nil { diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go index 3055a5ac7..474cfc4f8 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go @@ -592,7 +592,7 @@ func TestIndexerWhole(t *testing.T) { t.Errorf("main 14 at main 13's head said %+v, want no mover", next) } var log []string - tools := index.HeldTools(kvStore{held}, askVia(t, ctx, takeinsKV), time.Now, func(what, why string) error { + tools := index.HeldTools(kvStore{held}, kvStore{takeinsKV}, askVia(t, ctx, takeinsKV), time.Now, func(what, why string) error { log = append(log, what+": "+why) return nil }) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_test.go index 713eb631d..495844ebf 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_test.go @@ -92,7 +92,7 @@ func TestEveryHandToolsAskIsReadAndActedOn(t *testing.T) { } record := func(string, string) error { return nil } tools := map[string]func(map[string]any) (any, error){} - for _, tl := range slices.Concat(index.HeldTools(nil, ask, time.Now, record), index.PinsTools(nil, nil, ask, time.Now, record), + for _, tl := range slices.Concat(index.HeldTools(nil, nil, ask, time.Now, record), index.PinsTools(nil, nil, ask, time.Now, record), index.RunsTools(nil, nil, ask, time.Now, record), index.NamedTools(ask, time.Now, record), index.FingerprintsTools(ask, time.Now, record, time.Minute), index.CatalogRevisionTools(nil, ask, time.Now, record), index.RegistrationTools(nil, nil, ask, time.Now, func(string, string, string, string) error { return nil })) { diff --git a/modules/mesh-delivery-indexer/internal/index/candidates.go b/modules/mesh-delivery-indexer/internal/index/candidates.go index b880cdb9c..90dbbde3c 100644 --- a/modules/mesh-delivery-indexer/internal/index/candidates.go +++ b/modules/mesh-delivery-indexer/internal/index/candidates.go @@ -126,8 +126,13 @@ type Indexer struct { // content; nil reads none. GoMod func(ctx context.Context, repository, sha, dir string) ([]byte, error) // Now is the clock of a taken value; nil is time.Now. - Now func() time.Time - Builds *Builds + Now func() time.Time + // Bound bounds a running take-in's wait (takein_waiting.go), a context's bound and no timer (ADR 0437 §8); nil is + // context.WithTimeout. + Bound func(context.Context, time.Duration) (context.Context, context.CancelFunc) + // TakeIns is the state takeins, where a running take-in keeps what it waits on (design 47 H2 §803, H-A-409); nil keeps none. + TakeIns Store + Builds *Builds // Named asks the forge for the git object of each named path of the module directories given, at a commit // (the seat git's trees with paths; novox/hq ADR 0499 clauses 2 and 3): the indexer is the one reader of a // manifest's paths (ADR 0495 clause 1, the lead's decision L8 of R4e). Nil asks nothing, and a module naming paths diff --git a/modules/mesh-delivery-indexer/internal/index/dryrun.go b/modules/mesh-delivery-indexer/internal/index/dryrun.go index bdf7a4bdb..2fe12d418 100644 --- a/modules/mesh-delivery-indexer/internal/index/dryrun.go +++ b/modules/mesh-delivery-indexer/internal/index/dryrun.go @@ -29,7 +29,9 @@ 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, BranchHead: ix.BranchHead, Read: ix.Read, Contains: ix.Contains, + GoMod: ix.GoMod, Now: ix.Now, Bound: ix.Bound, + // A dry run keeps no waiting-on: the take-in it computes for says its waits through the live indexer (H-A-409). + TakeIns: nil, Builds: ix.Builds, Named: ix.Named, Trunk: ix.Trunk, BranchHead: ix.BranchHead, Read: ix.Read, Contains: ix.Contains, SayTakeIn: nil, // 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 // requirements, findings, seat definitions, holds and their bounds are not overlaid, nothing is said, and no hold is diff --git a/modules/mesh-delivery-indexer/internal/index/findings.go b/modules/mesh-delivery-indexer/internal/index/findings.go index 542c707b2..f21c16227 100644 --- a/modules/mesh-delivery-indexer/internal/index/findings.go +++ b/modules/mesh-delivery-indexer/internal/index/findings.go @@ -22,7 +22,7 @@ const CallUnansweredKind = "indexer-call-unanswered" // H-A-242, H-A-247): its own, the process reader's event-unhandled and the family-not-heard of the heard writer it is handed // (H-A-247 (1)); a views reader's and the emitter's (views.ViewKinds) are always the writer's besides. The tool runner's // writer over the same state `findings` owns its own. TestFindingKindsHoldEveryKindTheCodeRaises holds the code to this list. -var FindingKinds = []string{PinMissingKind, OutOfStepKind, PackagesNotPublishedKind, HistoryFillingKind, SeedWaitsKind, +var FindingKinds = []string{TakeInWaitingKind, PinMissingKind, OutOfStepKind, PackagesNotPublishedKind, HistoryFillingKind, SeedWaitsKind, SeedLeftOutKind, SeatDefinitionUnparsedKind, SeatDefinedTwiceKind, SeatOutsideItsDomainKind, CallUnansweredKind, views.EventUnhandledKind, heard.Kind} diff --git a/modules/mesh-delivery-indexer/internal/index/held.go b/modules/mesh-delivery-indexer/internal/index/held.go index 5e8774ad8..ca1e685da 100644 --- a/modules/mesh-delivery-indexer/internal/index/held.go +++ b/modules/mesh-delivery-indexer/internal/index/held.go @@ -49,6 +49,8 @@ func (h HeldTakeIn) Event() meshdelivery.SourceMovedEvent { // PendingAnswer is indexer_pending's answer (H-A-102): every branch's held take-ins, in the state held's form (since in RFC 3339). type PendingAnswer struct { Held []HeldTakeIn `json:"held"` + // Running are the take-ins that run, each with what it waits on (design 47 H2 §803, H-A-409). + Running []RunningTakeIn `json:"running,omitempty"` } // ErrHeldUnwritten says a source-moved that could not be taken in is not written into the state held either: its message @@ -224,20 +226,25 @@ func ReadHeld(ctx context.Context, st Store) ([]HeldTakeIn, error) { return out, nil } -// HeldTools are the held take-in's tools (§744): indexer_pending reads the state held; indexer_take_in_pending takes a branch's +// HeldTools are the held take-in's tools (§744): indexer_pending reads the state held and the running take-ins' waiting-on in +// the state takeins (H2 §803, H-A-409); indexer_take_in_pending takes a branch's // held source-moved again now and indexer_take_in_skip acknowledges it unwritten, each an ask in the state takeins the indexer // acts on (H-A-97), the skip a hand act recorded through mesh-hand-acts before it is asked. -func HeldTools(held Store, ask func(key string, value []byte) (TakeInAsk, error), now func() time.Time, record func(what, why string) error) []stdio.Tool { +func HeldTools(held, takeIns Store, ask func(key string, value []byte) (TakeInAsk, error), now func() time.Time, record func(what, why string) error) []stdio.Tool { str := func(args map[string]any, k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) } return []stdio.Tool{ {Name: PendingTool, Description: "Each watched branch's held take-in (design 47 H §744): the source revision of the gate's source-moved the indexer " + "could not take in (the catalog store full, a read of the forge unanswered), why and since when, in order, each kept here once " + - "acknowledged and taken in again on the indexer's room and at its start. indexer_take_in_pending takes it again now, indexer_take_in_skip ends it unwritten.", + "acknowledged and taken in again on the indexer's room and at its start; and each running take-in that waits over a minute on another part, its waiting-on (part, verb, since). indexer_take_in_pending takes it again now, indexer_take_in_skip ends it unwritten.", Input: map[string]any{"type": "object", "properties": map[string]any{}}, Run: func(map[string]any) (any, error) { h, err := ReadHeld(context.Background(), held) - return PendingAnswer{Held: h}, err + if err != nil { + return PendingAnswer{Held: h}, err + } + r, err := ReadRunning(context.Background(), takeIns) + return PendingAnswer{Held: h, Running: r}, err }}, {Name: TakeInPendingTool, Description: "Take a watched branch's held source-moved in again now (design 47 H §744), as the indexer's room would: " + diff --git a/modules/mesh-delivery-indexer/internal/index/held_test.go b/modules/mesh-delivery-indexer/internal/index/held_test.go index 976e29eb0..fd9c77ca0 100644 --- a/modules/mesh-delivery-indexer/internal/index/held_test.go +++ b/modules/mesh-delivery-indexer/internal/index/held_test.go @@ -26,7 +26,7 @@ func TestTheHeldAndPinToolsAskWhatTheIndexerReads(t *testing.T) { } record := func(what, _ string) error { recorded = append(recorded, what); return nil } tools := map[string]stdio.Tool{} - for _, tl := range append(HeldTools(newMem(), ask, time.Now, record), PinsTools(newMem(), newMemObjects(0), ask, time.Now, record)...) { + for _, tl := range append(HeldTools(newMem(), nil, ask, time.Now, record), PinsTools(newMem(), newMemObjects(0), ask, time.Now, record)...) { tools[tl.Name] = tl } for _, c := range []struct { @@ -56,7 +56,7 @@ func TestTheHeldAndPinToolsAskWhatTheIndexerReads(t *testing.T) { held := newMem() ix := &Indexer{Held: held} ix.hold(t.Context(), meshdelivery.SourceMovedEvent{Branch: "main", Source: 4, Call: "0123456789abcdef"}, "the catalog store is full") - got, err := HeldTools(held, ask, time.Now, record)[0].Run(map[string]any{}) + got, err := HeldTools(held, nil, ask, time.Now, record)[0].Run(map[string]any{}) data, _ := json.Marshal(got) var answer struct { Held []struct { diff --git a/modules/mesh-delivery-indexer/internal/index/modules.go b/modules/mesh-delivery-indexer/internal/index/modules.go index 9a59b83d6..60321160f 100644 --- a/modules/mesh-delivery-indexer/internal/index/modules.go +++ b/modules/mesh-delivery-indexer/internal/index/modules.go @@ -227,7 +227,7 @@ func (ix *Indexer) namedObjects(ctx context.Context, f whole) (map[string]map[st if len(need) == 0 || ix.Named == nil { return objects, nil } - got, err := ix.Named(ctx, f.Repository, f.Merge, need) + got, err := waited(ctx, "git", "trees", func() (map[string]map[string]string, error) { return ix.Named(ctx, f.Repository, f.Merge, need) }) if err != nil { words := map[string]string{} for dir := range need { @@ -320,7 +320,7 @@ func (ix *Indexer) reconcile(ctx context.Context) error { if len(mine) == 0 { continue } - dirs, err := ix.Trunk(ctx, repository, heads[repository]) + dirs, err := waited(ctx, "git", "trees", func() ([]string, error) { return ix.Trunk(ctx, repository, heads[repository]) }) if err != nil { ix.logf("%s at %s: the modules of the trunk cannot be read, so none is dropped: %v", repository, heads[repository], err) continue @@ -346,7 +346,7 @@ func (ix *Indexer) reconcile(ctx context.Context) error { if m.Commit == "" || ix.Contains == nil { return true } - in, err := ix.Contains(ctx, repository, m.Commit, head) + in, err := waited(ctx, "git", "contains", func() (bool, error) { return ix.Contains(ctx, repository, m.Commit, head) }) if err != nil { ix.logf("%s: whether %s is in %s cannot be read, so the module at %s is kept: %v", repository, m.Commit, head, m.Path, err) return true @@ -421,7 +421,7 @@ func (ix *Indexer) goModOf(ctx context.Context, f whole, dir string) ([]byte, bo if ix.GoMod == nil { return nil, false } - raw, err := ix.GoMod(ctx, f.Repository, f.Merge, dir) + raw, err := waited(ctx, "git", "file", func() ([]byte, error) { return ix.GoMod(ctx, f.Repository, f.Merge, dir) }) if err != nil { ix.logf("%s at %s: the go.mod of %q cannot be read, so its module keeps the packages it held: %v", f.Repository, f.Merge, dir, err) return nil, false @@ -444,7 +444,7 @@ func (ix *Indexer) requirementsOf(ctx context.Context, f whole, dir string, cur } } } - raw, err := ix.GoSum(ctx, f.Repository, f.Merge, dir) + raw, err := waited(ctx, "git", "file", func() ([]byte, error) { return ix.GoSum(ctx, f.Repository, f.Merge, dir) }) if err != nil { ix.logf("%s at %s: the go.sum of %q cannot be read, so what it requires is not kept: %v", f.Repository, f.Merge, dir, err) return diff --git a/modules/mesh-delivery-indexer/internal/index/moves.go b/modules/mesh-delivery-indexer/internal/index/moves.go index 03c7de2b6..17088ef94 100644 --- a/modules/mesh-delivery-indexer/internal/index/moves.go +++ b/modules/mesh-delivery-indexer/internal/index/moves.go @@ -26,7 +26,7 @@ func (ix *Indexer) heldByAnotherTrunk(ctx context.Context, module, repository st if head == "" || trunk.SameRepository(other, repository) { continue } - dirs, err := ix.Trunk(ctx, other, head) + dirs, err := waited(ctx, "git", "trees", func() ([]string, error) { return ix.Trunk(ctx, other, head) }) if err != nil { ix.logf("%s at %s: the modules of the trunk cannot be read, so %s is not looked for there: %v", other, head, module, err) continue @@ -36,7 +36,7 @@ func (ix *Indexer) heldByAnotherTrunk(ctx context.Context, module, repository st if nameOfDirectory(dir) != module { continue } - read, err := ix.Read(ctx, other, head, dir) + read, err := waited(ctx, "git", "trees", func() (RepoRead, error) { return ix.Read(ctx, other, head, dir) }) if err != nil { ix.logf("%s at %s: %q cannot be read, so %s is not handed over from it: %v", other, head, dir, module, err) continue diff --git a/modules/mesh-delivery-indexer/internal/index/order.go b/modules/mesh-delivery-indexer/internal/index/order.go index 395cebd96..90a99491f 100644 --- a/modules/mesh-delivery-indexer/internal/index/order.go +++ b/modules/mesh-delivery-indexer/internal/index/order.go @@ -67,7 +67,7 @@ func (ix *Indexer) older(ctx context.Context, repository, commit, later string) if ix.Contains == nil || commit == "" || later == "" || commit == later { return false, nil } - in, err := ix.Contains(ctx, repository, commit, later) + in, err := waited(ctx, "git", "contains", func() (bool, error) { return ix.Contains(ctx, repository, commit, later) }) if notFound(err) { ix.logf("%s: the forge does not have %.12s or %.12s (a rewritten history?), so %.12s is not known to be older and is written: %v", repository, commit, later, commit, err) return false, nil diff --git a/modules/mesh-delivery-indexer/internal/index/package_trees.go b/modules/mesh-delivery-indexer/internal/index/package_trees.go index 128150fff..9cb36c2e6 100644 --- a/modules/mesh-delivery-indexer/internal/index/package_trees.go +++ b/modules/mesh-delivery-indexer/internal/index/package_trees.go @@ -36,7 +36,7 @@ func (t *goModTree) goMod(dir string) []byte { var raw []byte if t.ix.GoMod != nil { var err error - if raw, err = t.ix.GoMod(t.ctx, t.f.Repository, t.f.Merge, dir); err != nil { + if raw, err = waited(t.ctx, "git", "file", func() ([]byte, error) { return t.ix.GoMod(t.ctx, t.f.Repository, t.f.Merge, dir) }); err != nil { t.ix.logf("%s at %s: the go.mod of %q cannot be read, so no module of the tree is found there: %v", t.f.Repository, t.f.Merge, dir, err) raw = nil } @@ -167,7 +167,9 @@ func (ix *Indexer) derivedTree(ctx context.Context, f whole, t *goModTree, m cat if ix.Named == nil { return "", "the forge cannot be asked the git objects of the derived directories " + strings.Join(dirs, ", ") } - got, err := ix.Named(ctx, f.Repository, f.Merge, map[string][]string{"": dirs}) + got, err := waited(ctx, "git", "trees", func() (map[string]map[string]string, error) { + return ix.Named(ctx, f.Repository, f.Merge, map[string][]string{"": dirs}) + }) if err != nil { return "", fmt.Sprintf("the git objects of the derived directories %s: %v", strings.Join(dirs, ", "), err) } diff --git a/modules/mesh-delivery-indexer/internal/index/packages.go b/modules/mesh-delivery-indexer/internal/index/packages.go index d898e2c9a..a730f4d14 100644 --- a/modules/mesh-delivery-indexer/internal/index/packages.go +++ b/modules/mesh-delivery-indexer/internal/index/packages.go @@ -174,7 +174,7 @@ func (ix *Indexer) packagesIn(ctx context.Context, repository, commit string, mo if len(ask) == 0 { return nil } - got, err := ix.Files(ctx, repository, commit, ask) + got, err := waited(ctx, "git", "trees", func() (map[string]map[string]string, error) { return ix.Files(ctx, repository, commit, ask) }) if err != nil { return fmt.Errorf("the forge's listing of %s at %s (%s): %w", repository, commit, strings.Join(ask, ", "), err) } @@ -231,7 +231,7 @@ func (ix *Indexer) packagesIn(ctx context.Context, repository, commit string, mo if ix.Trunk == nil { return nil, nil, whole } - if _, err := ix.Trunk(ctx, repository, commit); err != nil { + if _, err := waited(ctx, "git", "trees", func() ([]string, error) { return ix.Trunk(ctx, repository, commit) }); err != nil { return nil, nil, fmt.Errorf("%w (and the commit's trees: %v)", whole, err) } ix.logf("%s at %s: the commit holds a tree, so every directory asked (%s) is gone", repository, commit, strings.Join(dirs, ", ")) diff --git a/modules/mesh-delivery-indexer/internal/index/source.go b/modules/mesh-delivery-indexer/internal/index/source.go index 55fbf1937..ea7531504 100644 --- a/modules/mesh-delivery-indexer/internal/index/source.go +++ b/modules/mesh-delivery-indexer/internal/index/source.go @@ -32,9 +32,9 @@ func (ix *Indexer) wholeAt(ctx context.Context, repository, head string) (whole, if ix.ReadFile == nil { return nil, errors.New("the indexer reads no file of the forge") } - return ix.ReadFile(ctx, repository, head, p) + return waited(ctx, "git", "file", func() ([]byte, error) { return ix.ReadFile(ctx, repository, head, p) }) } - first, err := ix.Read(ctx, repository, head, "") + first, err := waited(ctx, "git", "trees", func() (RepoRead, error) { return 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) } @@ -42,7 +42,7 @@ func (ix *Indexer) wholeAt(ctx context.Context, repository, head string) (whole, for _, dir := range slices.Sorted(maps.Keys(first.Trees)) { read := first if dir != "" { - if read, err = ix.Read(ctx, repository, head, dir); err != nil { + if read, err = waited(ctx, "git", "trees", func() (RepoRead, error) { return 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) } } diff --git a/modules/mesh-delivery-indexer/internal/index/takein_source.go b/modules/mesh-delivery-indexer/internal/index/takein_source.go index 667eb11a2..ecb392210 100644 --- a/modules/mesh-delivery-indexer/internal/index/takein_source.go +++ b/modules/mesh-delivery-indexer/internal/index/takein_source.go @@ -38,7 +38,8 @@ func TakenID(branch string, source int64) string { // ErrObjectsFull waits for the indexer's own room, any other is the failed read or write it says; ErrOldForm is never taken in // and said as no take-in. func (ix *Indexer) TakeInSource(ctx context.Context, e meshdelivery.SourceMovedEvent) (meshcatalog.TakeInTaken, error) { - taken, err := ix.takeInSource(ctx, e) + taken, err := ix.takeInSource(ix.withTakeIn(ctx, e.Branch, e.Source), e) + ix.endTakeIn(ctx, e.Source) switch { case err == nil: ix.unhold(ctx, e.Branch, e.Source) diff --git a/modules/mesh-delivery-indexer/internal/index/takein_source_test.go b/modules/mesh-delivery-indexer/internal/index/takein_source_test.go index 2e439e85d..f0da42a54 100644 --- a/modules/mesh-delivery-indexer/internal/index/takein_source_test.go +++ b/modules/mesh-delivery-indexer/internal/index/takein_source_test.go @@ -6,7 +6,14 @@ import ( "errors" "fmt" "reflect" + "slices" + "strings" + "sync" "testing" + "time" + + mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient" + mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" "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" @@ -98,6 +105,110 @@ func TestASourceRevisionIsTakenInAsOneRevision(t *testing.T) { if _, err := ix.TakeInSource(ctx, old); !errors.Is(err, ErrOldForm) { t.Errorf("a source-moved with no call answered %v, want ErrOldForm", err) } + // Design 47 H2 §803, H-A-409: a take-in says what it waits on, in the journal, in takeins and past five minutes as a finding. + t.Run("a take-in says what it waits on", func(t *testing.T) { + running := newMem() + ix.TakeIns = running + ix.Findings = newFindings() + // The take-in's end removes its waiting-on. + if err := running.Create(ctx, RunningKey(10), []byte(`{"source":10}`)); err != nil { + t.Fatal(err) + } + next := moved + next.Source, next.Call = 10, "00112233445566ff" + if _, err := ix.TakeInSource(ctx, next); err != nil { + t.Fatal(err) + } + if _, _, found, _ := running.Get(ctx, RunningKey(10)); found { + t.Error("the take-in's end left its waiting-on in takeins") + } + start := time.Date(2026, 11, 22, 1, 0, 0, 0, time.UTC) + now := start + timers := make(chan context.CancelFunc) + var mu sync.Mutex + var lines []string + wrote := make(chan struct{}, 1) + findings := newFindings() + w := &Indexer{Module: testSelf, TakeIns: running, Findings: findings, Now: func() time.Time { mu.Lock(); defer mu.Unlock(); return now }, + Bound: func(parent context.Context, _ time.Duration) (context.Context, context.CancelFunc) { + b, cancel := context.WithCancel(parent) + timers <- cancel + return b, cancel + }, + Logf: func(format string, args ...any) { + mu.Lock() + defer mu.Unlock() + lines = append(lines, fmt.Sprintf(format, args...)) + }} + w.Findings = findingsSignal{findings, wrote} + listing := func(answerAfter time.Duration) { + t.Helper() + mu.Lock() + now, lines = start, nil + mu.Unlock() + release, res := make(chan struct{}), make(chan error) + go func() { + _, err := waited(w.withTakeIn(ctx, "main", 9), "git", "trees", func() (int, error) { <-release; return 1, nil }) + res <- err + }() + first := <-timers + if answerAfter < WaitingLineAfter { + close(release) + <-res + return + } + mu.Lock() + now = start.Add(70 * time.Second) + mu.Unlock() + first() + second := <-timers // asked once the line is said and the waiting-on written + if answerAfter >= WaitingFindingAfter { + second() + <-wrote + if h := findings.Held(); len(h) != 1 || h[0].Kind != TakeInWaitingKind || h[0].Scope != mcc.ScopeMerge || h[0].ID != "9" { + t.Errorf("after %s: findings %+v, want take-in-waiting of merge 9", answerAfter, h) + } + } + close(release) + if err := <-res; err != nil { + t.Fatal(err) + } + } + for _, c := range []struct { + after time.Duration + lines int + finding bool + }{{30 * time.Second, 0, false}, {70 * time.Second, 1, false}, {6 * time.Minute, 1, false}} { + listing(c.after) + mu.Lock() + got := slices.Clone(lines) + mu.Unlock() + if len(got) != c.lines || (c.lines == 1 && !strings.Contains(got[0], "waits on git trees since 2026-11-22T01:00:00Z")) { + t.Errorf("answered after %s: lines %q, want %d naming git trees and since when", c.after, got, c.lines) + } + r, err := ReadRunning(ctx, running) + want := c.lines == 1 + if err != nil || want != (len(r) == 1) || (want && (r[0].Source != 9 || r[0].Branch != "main" || r[0].WaitingOn != WaitingOn{Part: "git", Verb: "trees", Since: start})) { + t.Errorf("answered after %s: running %+v (%v), want waiting-on git trees since %s: %v", c.after, r, err, start, want) + } + if len(findings.Held()) != 0 { + t.Errorf("answered after %s: take-in-waiting still raised: %+v", c.after, findings.Held()) + } + w.endTakeIn(ctx, 9) + } + }) +} + +// findingsSignal is a finding writer that says each write it passes on. +type findingsSignal struct { + *memFindings + wrote chan struct{} +} + +func (f findingsSignal) Write(ctx context.Context, x mcseat.Finding) error { + err := f.memFindings.Write(ctx, x) + f.wrote <- struct{}{} + return err } // Design 47 H §768, §743, H-A-19: a branch's first source revision (start true) is taken in with no mover, says take-in.taken diff --git a/modules/mesh-delivery-indexer/internal/index/takein_waiting.go b/modules/mesh-delivery-indexer/internal/index/takein_waiting.go new file mode 100644 index 000000000..e732b658f --- /dev/null +++ b/modules/mesh-delivery-indexer/internal/index/takein_waiting.go @@ -0,0 +1,194 @@ +package index + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "strconv" + "time" + + mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient" +) + +// A take-in says what it waits on (design 47 H2 §803, H-A-409): a source-moved take-in that waits longer than +// WaitingLineAfter on another part (the seat git's listing or a file, a package's versions, a registry) writes one journal +// line naming the part, the verb and since when, and keeps its waiting-on in the state takeins under the key +// RunningPrefix and the source revision, rewritten at each new wait and removed at the take-in's end; past +// WaitingFindingAfter it raises the finding take-in-waiting (scope merge, id the source revision), cleared when the wait +// ends. indexer_pending answers it beside the held take-ins. +const ( + TakeInWaitingKind = "take-in-waiting" + RunningPrefix = "running." + WaitingLineAfter = time.Minute + WaitingFindingAfter = 5 * time.Minute +) + +// WaitingOn is what a running take-in waits on: the part, its verb and since when. +type WaitingOn struct { + Part string `json:"part"` + Verb string `json:"verb"` + Since time.Time `json:"since"` +} + +// RunningTakeIn is the value of a running take-in in the state takeins (H-A-409). +type RunningTakeIn struct { + Branch string `json:"branch"` + Source int64 `json:"source"` + WaitingOn WaitingOn `json:"waiting-on"` +} + +// RunningKey is the takeins key of the running take-in of a source revision. +func RunningKey(source int64) string { return RunningPrefix + strconv.FormatInt(source, 10) } + +type takeInRunKey struct{} + +// takeInRun is the running take-in a context carries, and the live indexer that says its waits (a branch's take-in +// computes on a dry copy, which writes nothing). +type takeInRun struct { + ix *Indexer + branch string + source int64 +} + +// withTakeIn is ctx carrying the running take-in of the source revision of branch. +func (ix *Indexer) withTakeIn(ctx context.Context, branch string, source int64) context.Context { + return context.WithValue(ctx, takeInRunKey{}, &takeInRun{ix: ix, branch: branch, source: source}) +} + +// endTakeIn removes the running take-in's value from the state takeins, when one was written. +func (ix *Indexer) endTakeIn(ctx context.Context, source int64) { + if ix.TakeIns == nil { + return + } + key := RunningKey(source) + _, rev, found, err := ix.TakeIns.Get(ctx, key) + if err == nil && found { + err = ix.TakeIns.Delete(ctx, key, rev) + } + if err != nil && !errors.Is(err, ErrConflict) { + ix.logf("take-in: source revision %d: its waiting-on is not removed from %s: %v", source, TakeInsState, err) + } +} + +// bound is ctx bounded by d, a context's bound and no timer (ADR 0437 §8, as fingerprints.go bounds its wait); Bound +// when set. +func (ix *Indexer) bound(ctx context.Context, d time.Duration) (context.Context, context.CancelFunc) { + if ix.Bound != nil { + return ix.Bound(ctx, d) + } + return context.WithTimeout(ctx, d) +} + +// passed is whether the wait outlasted the bound b: false once it ended (done) or the take-in's own context ended. +func passed(ctx, b context.Context, done <-chan struct{}) bool { + select { + case <-done: + return false + case <-b.Done(): + } + select { + case <-done: + return false + default: + } + return ctx.Err() == nil +} + +// waited is f, a call on part's verb: within a running take-in (ctx), a wait past WaitingLineAfter is said and kept, one +// past WaitingFindingAfter raises take-in-waiting until it ends. Outside a take-in it is f alone. +func waited[T any](ctx context.Context, part, verb string, f func() (T, error)) (T, error) { + run, ok := ctx.Value(takeInRunKey{}).(*takeInRun) + if !ok { + return f() + } + done, finished := make(chan struct{}), make(chan struct{}) + go func() { + defer close(finished) + run.ix.watchWait(ctx, run, part, verb, done) + }() + v, err := f() + close(done) + <-finished + return v, err +} + +func (ix *Indexer) watchWait(ctx context.Context, run *takeInRun, part, verb string, done <-chan struct{}) { + since := ix.now().UTC() + line, cancel := ix.bound(ctx, WaitingLineAfter) + defer cancel() + if !passed(ctx, line, done) { + return + } + ix.logf("take-in: source revision %d of %s waits on %s %s since %s", run.source, run.branch, part, verb, since.Format(time.RFC3339)) + ix.writeWaiting(ctx, RunningTakeIn{Branch: run.branch, Source: run.source, WaitingOn: WaitingOn{Part: part, Verb: verb, Since: since}}) + id := strconv.FormatInt(run.source, 10) + finding, cancelFinding := ix.bound(ctx, WaitingFindingAfter-WaitingLineAfter) + defer cancelFinding() + if !passed(ctx, finding, done) { + return + } + if ix.Findings != nil { + f := ix.observed(mcc.ScopeMerge, id, TakeInWaitingKind, + fmt.Sprintf("the take-in of source revision %d of %s waits on %s %s", run.source, run.branch, part, verb), + "A take-in waits on another part", + fmt.Sprintf("The take-in of source revision %d of %s has waited on %s's %s since %s, so the revision is not taken in.", run.source, run.branch, part, verb, since.Format(time.RFC3339)), + "indexer."+TakeInWaitingKind) + if err := ix.Findings.Write(ctx, f); err != nil { + ix.logf("take-in: the finding %s is not written: %v", TakeInWaitingKind, err) + } + } + <-done + if ix.Findings != nil { + if err := ix.clearFinding(context.WithoutCancel(ctx), mcc.ScopeMerge, id, TakeInWaitingKind, part+" "+verb+" answered"); err != nil { + ix.logf("take-in: the finding %s is not cleared: %v", TakeInWaitingKind, err) + } + } +} + +// writeWaiting writes the running take-in's value in the state takeins, over the one it holds. +func (ix *Indexer) writeWaiting(ctx context.Context, v RunningTakeIn) { + if ix.TakeIns == nil { + return + } + raw, _ := json.Marshal(v) + key := RunningKey(v.Source) + _, rev, found, err := ix.TakeIns.Get(ctx, key) + switch { + case err != nil: + case found: + err = ix.TakeIns.Update(ctx, key, raw, rev) + default: + err = ix.TakeIns.Create(ctx, key, raw) + } + if err != nil { + ix.logf("take-in: source revision %d: its waiting-on is not written in %s: %v", v.Source, TakeInsState, err) + } +} + +// ReadRunning is every running take-in's value of the state takeins (indexer_pending's running part); none for no state. +func ReadRunning(ctx context.Context, st Store) ([]RunningTakeIn, error) { + if st == nil { + return nil, nil + } + keys, err := st.Keys(ctx) + if err != nil { + return nil, err + } + var out []RunningTakeIn + for _, k := range keys { + if len(k) <= len(RunningPrefix) || k[:len(RunningPrefix)] != RunningPrefix { + continue + } + raw, _, found, err := st.Get(ctx, k) + if err != nil { + return nil, err + } + var r RunningTakeIn + if !found || json.Unmarshal(raw, &r) != nil { + continue + } + out = append(out, r) + } + return out, nil +} diff --git a/modules/mesh-delivery-indexer/internal/index/taken.go b/modules/mesh-delivery-indexer/internal/index/taken.go index 3d5df687b..4727a25c3 100644 --- a/modules/mesh-delivery-indexer/internal/index/taken.go +++ b/modules/mesh-delivery-indexer/internal/index/taken.go @@ -43,7 +43,7 @@ func (ix *Indexer) writeTakenKnown(ctx context.Context, f whole, notOlder string return nil, false, nil } if ix.Contains != nil && cur.Merge != notOlder { - later, err := ix.Contains(ctx, f.Repository, f.Merge, cur.Merge) + later, err := waited(ctx, "git", "contains", func() (bool, error) { return ix.Contains(ctx, f.Repository, f.Merge, cur.Merge) }) if err != nil { ix.logf("%s: whether %s is in %s cannot be read, so taken.%s stays at %s: %v", f.Repository, f.Merge, cur.Merge, key, cur.Merge, err) return nil, false, nil From d719a69b7de6696db4ff86f3c78f31755edd5b91 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 01:08:34 +0100 Subject: [PATCH 03/16] I3: a dry run keeps its packages in its own scratch state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A branch's take-in, a run's candidate and a branch's re-pin compute as dry runs whose packages went to the trunk's packages state. They now write them to the state dry-runs under ..packages., read through to the live state, deleted when the dry run answers and every key at the indexer's start; the manifests stay create-once by digest as every take-in's. indexer_dry_runs reads the state; the manifest asks for it, 16 MiB, one hour's TTL. Builds: design 47 H2 §804, §820; H-A-413 and its addendum --- .../cmd/mesh-delivery-indexer-tools/main.go | 1 + .../mesh-delivery-indexer/integration_test.go | 4 + .../cmd/mesh-delivery-indexer/main.go | 10 +- .../packages_integration_test.go | 65 ++++- .../internal/index/candidates.go | 5 +- .../internal/index/dryrun.go | 267 +++++++++++++++++- .../internal/index/packages_gone_test.go | 41 ++- .../internal/index/runcandidates.go | 7 +- .../internal/index/takein_source.go | 3 +- .../internal/index/toolchains.go | 55 ++-- .../mesh-delivery-indexer/manifest_test.go | 9 +- modules/mesh-delivery-indexer/module.json | 6 +- 12 files changed, 419 insertions(+), 54 deletions(-) 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 09fd60658..d1bf3dcac 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 @@ -212,6 +212,7 @@ func main() { _, err := acts.Record(meshhandactsclient.Request{What: what, Why: why, Cause: index.TakeInSkipTool, Verb: "take-in-skip"}) return err })...) + tools = append(tools, index.DryRunsTools(keptRead{stdio.State(index.DryRunsState)})...) tools = append(tools, index.RunsTools(keptRead{stdio.State(index.RunsState)}, keptRead{stdio.State(index.CandidatesState)}, asks, time.Now, func(what, why string) error { _, err := acts.Record(meshhandactsclient.Request{What: what, Why: why, Cause: index.RunDropTool, Verb: "run-drop"}) return err 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 737b27c38..c9bd95909 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 @@ -363,6 +363,10 @@ func startIndexerRun(t *testing.T, put func(context.Context, buildLog), before . if _, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, index.ManifestsState), History: index.ManifestsHistory}); err != nil { t.Fatal(err) } + // The dry runs' scratch, made by the grants part from the manifest's state entry dry-runs (design 47 H2 §804, §820). + if _, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, index.DryRunsState), History: 1, TTL: time.Hour, MaxBytes: 16 << 20}); err != nil { + t.Fatal(err) + } // The builder's module log, as the runtime raises it (ADR 0297), filled by put before the indexer starts. if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: buscompose.LogStreamName(builds.BuilderModule, builds.BuilderLog), Subjects: []string{buscompose.LogSubject(builds.BuilderModule, builds.BuilderLog) + ".>"}, AllowDirect: true}); err != nil { 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 aca38fc31..043bad17d 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -333,7 +333,15 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro defer stopInput() // The state takeins: hand acts ask there (watched below), and a running take-in keeps what it waits on (H2 §803, H-A-409). takeIns := process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.TakeInsState), "no hand act of the indexer is answered", logger.Printf) - ix := &index.Indexer{Module: cred.Module, TakeIns: awaitedStore{b: takeIns}, NamedSets: named, Findings: writer, OldSections: awaitedStore{b: oldSections}, Requirements: awaitedStore{b: requirements}, Store: kvStore{candidates}, Modules: modules, Manifests: kvStore{manifests}, Taken: awaitedStore{b: taken}, Builds: known, + // The state dry-runs, a dry run's scratch of the packages it writes (H2 §804): every key it holds goes at this start, before + // any dry run, so no dry run outlives a start. + dryRuns := process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.DryRunsState), "no dry run is computed: a branch's take-in, a run's candidate and a branch's re-pin wait for it", logger.Printf) + dryRuns.Ready(func(kv jetstream.KeyValue) { + if err := index.ClearDryRuns(ctx, kvStore{kv}); err != nil { + logger.Printf("the state %s is not cleared at this start: %v", index.DryRunsState, err) + } + }) + ix := &index.Indexer{Module: cred.Module, TakeIns: awaitedStore{b: takeIns}, DryRuns: awaitedStore{b: dryRuns}, NamedSets: named, Findings: writer, OldSections: awaitedStore{b: oldSections}, Requirements: awaitedStore{b: requirements}, Store: kvStore{candidates}, Modules: modules, Manifests: kvStore{manifests}, Taken: awaitedStore{b: taken}, Builds: known, Predefined: awaitedStore{b: predefined}, Logf: logger.Printf, Named: namedVia(calls.Call), Trunk: trunkVia(calls.Call), BranchHead: branchHeadVia(calls.Call), Contains: containsVia(calls.Call), Read: readVia(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), diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/packages_integration_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/packages_integration_test.go index e2f463232..9976e707b 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/packages_integration_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/packages_integration_test.go @@ -5,7 +5,9 @@ package main import ( "context" "encoding/json" + "errors" "os" + "reflect" "slices" "strconv" "strings" @@ -62,14 +64,17 @@ func untilModule(t *testing.T, ctx context.Context, js jetstream.JetStream, name // go.sum line names it, ADR 0573 §2; design 47 H-A-157), and plain, which requires // nothing of it, are taken in with mesh-sdk as main's first source revision. A source revision moving mesh-sdk to a commit // changing its buildstep package is taken in as one revision whose movers are mesh-sdk and importer, of another repository, -// and not plain; the packages key of mesh-sdk/go names that commit with a digest per package. +// and not plain; the packages key of mesh-sdk/go names that commit with a digest per package. Design 47 H2 §804: a key a dry +// run left in the state dry-runs is gone at the start, and the take-in of a branch moving mesh-sdk again, a dry run, leaves +// the trunk's packages state byte for byte as before and no key in dry-runs once it answered. func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { const ( sdkGo = "git.novox.be/novox/mesh-sdk/go" - m1, m2 = "1111111111111111111111111111111111111111", "2222222222222222222222222222222222222222" + m1, m2, m3 = "1111111111111111111111111111111111111111", "2222222222222222222222222222222222222222", "4444444444444444444444444444444444444444" catalogMerge = "3333333333333333333333333333333333333333" goModContent = "module importer\n\nrequire git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000\n" sdkRoot1, sdk2 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + sdk3 = "cccccccccccccccccccccccccccccccccccccccc" ) avahi, err := os.ReadFile("../../internal/index/testdata/catalogue-a67f0196-avahi.module.json") if err != nil { @@ -92,7 +97,7 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { "package.json": "3333333333333333333333333333333333333333", "package-lock.json": "4444444444444444444444444444444444444444", "tsconfig.json": "5555555555555555555555555555555555555555"}}} } - var packages jetstream.KeyValue + var packages, dryRuns jetstream.KeyValue var heard *takeIns js, ctx, _, _ := startIndexer(t, func(context.Context, buildLog) {}, func(ctx context.Context, js jetstream.JetStream) { var err error @@ -118,6 +123,14 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { forge := serveCommits(t, js.Conn()) forge.put(m1, sdkAt(sdkRoot1, "f5", "6666666666666666666666666666666666666666")) forge.put(m2, sdkAt(sdk2, "f6", "7777777777777777777777777777777777777777")) + forge.put(m3, sdkAt(sdk3, "f7", "8888888888888888888888888888888888888888")) + // A dry run's key left by an indexer that stopped mid-run (§804). + if dryRuns, err = js.KeyValue(ctx, index.Bucket(testIndexer, index.DryRunsState)); err != nil { + t.Fatal(err) + } + if _, err := dryRuns.Put(ctx, index.DryRunPrefix("beta", "0123")+index.PackagesState+".left", []byte(`{"value":"e30="}`)); err != nil { + t.Fatal(err) + } forge.put(catalogMerge, repoAt{trees: map[string]string{"modules/importer": "t1", "modules/plain": "t2"}, files: map[string]string{"modules/importer/module.json": named("importer"), "modules/plain/module.json": named("plain"), "modules/importer/go.mod": goModContent, "modules/importer/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n", @@ -125,7 +138,7 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { regs := registerAvahi(t, ctx, js, "main") for _, r := range []meshcatalog.Registration{{V: 1, Module: "importer", Origin: "novox/mesh-catalog", Path: "modules/importer", Branches: []string{"main"}}, {V: 1, Module: "plain", Origin: "novox/mesh-catalog", Path: "modules/plain", Branches: []string{"main"}}, - {V: 1, Module: "mesh-sdk", Origin: "novox/mesh-sdk", Path: ".", Branches: []string{"main"}}} { + {V: 1, Module: "mesh-sdk", Origin: "novox/mesh-sdk", Path: ".", Branches: []string{"main", "beta"}}} { raw, _ := json.Marshal(r) if _, err := regs.Put(ctx, index.RegistrationKey(r.Module), raw); err != nil { t.Fatal(err) @@ -134,16 +147,40 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { seedBuildModules(t, ctx, js, nil) heard = hearTakeIns(t, js.Conn()) }) - say := func(source int64, start bool, heads ...meshdelivery.SourceMovedEventHeadsItem) { + sayOn := func(branch string, source int64, start bool, heads ...meshdelivery.SourceMovedEventHeadsItem) { t.Helper() - raw, _ := json.Marshal(meshdelivery.SourceMovedEvent{V: 1, Branch: "main", Source: source, Call: "0123456789abcdef", Start: start, Heads: heads}) - if _, err := js.Publish(ctx, meshdelivery.SubjectSourceMoved("main", strconv.FormatInt(source, 10)), raw); err != nil { + raw, _ := json.Marshal(meshdelivery.SourceMovedEvent{V: 1, Branch: branch, Source: source, Call: "0123456789abcdef", Start: start, Heads: heads}) + if _, err := js.Publish(ctx, meshdelivery.SubjectSourceMoved(branch, strconv.FormatInt(source, 10)), raw); err != nil { t.Fatal(err) } } + say := func(source int64, start bool, heads ...meshdelivery.SourceMovedEventHeadsItem) { + t.Helper() + sayOn("main", source, start, heads...) + } + // every is each key of kv with its value. + every := func(kv jetstream.KeyValue) map[string]string { + t.Helper() + out := map[string]string{} + ks, err := kv.Keys(ctx) + if err != nil && !errors.Is(err, jetstream.ErrNoKeysFound) { + t.Fatal(err) + } + for _, k := range ks { + e, err := kv.Get(ctx, k) + if err != nil { + t.Fatal(err) + } + out[k] = string(e.Value()) + } + return out + } say(10, true, meshdelivery.SourceMovedEventHeadsItem{Repository: "novox/mesh-sdk", Commit: m1}, meshdelivery.SourceMovedEventHeadsItem{Repository: "novox/mesh-catalog", Commit: catalogMerge}) heard.next(t, "main", 10) heard.acked(t, "main") + if left := every(dryRuns); len(left) != 0 { + t.Errorf("dry-runs holds %v after the start, want every key gone (§804)", left) + } // mesh-sdk has released no version: importer keeps the package for its kind-1 edge, with no pin (H-A-161). untilModule(t, ctx, js, "importer", func(m meshcatalog.ModulesByModuleValue) bool { pin, kept := m.Packages[sdkGo] @@ -169,4 +206,18 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { pub, err := index.DecodePublishedPackages(v) return v != nil && err == nil && pub.Commit == m2 && len(pub.Packages) == 3 }) + + // A branch's take-in moving mesh-sdk to m3 is a dry run: its packages stay in dry-runs while it runs, the trunk's are + // untouched, and its keys go once it answered (§804). + heard.acked(t, "main") + before := every(packages) + sayOn("beta", 1, true, meshdelivery.SourceMovedEventHeadsItem{Repository: "novox/mesh-catalog", Commit: catalogMerge}, meshdelivery.SourceMovedEventHeadsItem{Repository: "novox/mesh-sdk", Commit: m3}) + heard.next(t, "beta", 1) + heard.acked(t, "beta") + if after := every(packages); !reflect.DeepEqual(after, before) { + t.Errorf("the branch's take-in changed the trunk's packages state:\n%v\nwant\n%v", after, before) + } + if left := every(dryRuns); len(left) != 0 { + t.Errorf("dry-runs holds %v once the branch's take-in answered, want none", left) + } } diff --git a/modules/mesh-delivery-indexer/internal/index/candidates.go b/modules/mesh-delivery-indexer/internal/index/candidates.go index 90dbbde3c..4f4df5137 100644 --- a/modules/mesh-delivery-indexer/internal/index/candidates.go +++ b/modules/mesh-delivery-indexer/internal/index/candidates.go @@ -132,6 +132,9 @@ type Indexer struct { Bound func(context.Context, time.Duration) (context.Context, context.CancelFunc) // TakeIns is the state takeins, where a running take-in keeps what it waits on (design 47 H2 §803, H-A-409); nil keeps none. TakeIns Store + // DryRuns is the state dry-runs, a dry run's scratch of the packages it writes (dryrun.go; design 47 H2 §804); nil keeps + // a dry run's packages in memory. + DryRuns Store Builds *Builds // Named asks the forge for the git object of each named path of the module directories given, at a commit // (the seat git's trees with paths; novox/hq ADR 0499 clauses 2 and 3): the indexer is the one reader of a @@ -161,7 +164,7 @@ type Indexer struct { filling atomic.Bool // a FillTaken runs in the background (KickFill) fillAgain atomic.Bool // a kick arrived while it ran underSeats bool // a dry run inside judge.WithSeats: its judge passes do not hold the seat list (verdicts.go) - isDry bool // a dry run (dryrun.go): it shares the live packages state, so it drops no kept package key (packages.go) + isDry bool // a dry run (dryrun.go): its packages are a working copy over the live state, and it drops no kept package key (packages.go) judgeMu sync.Mutex // one judge pass at a time (verdicts.go) keepMu sync.Mutex // one catalog graph revision kept at a time (keepEntries) // Pins is the state pins (pins.go); nil keeps none. PinsPending says how many messages the indexer's durable consumer of the diff --git a/modules/mesh-delivery-indexer/internal/index/dryrun.go b/modules/mesh-delivery-indexer/internal/index/dryrun.go index 2fe12d418..51b3cb61d 100644 --- a/modules/mesh-delivery-indexer/internal/index/dryrun.go +++ b/modules/mesh-delivery-indexer/internal/index/dryrun.go @@ -1,12 +1,20 @@ package index import ( + "context" + "encoding/json" + "errors" "fmt" "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-contracts/go/seats/nodebuildgo" + stdio "git.novox.be/novox/mesh-sdk/go" + "git.novox.be/novox/mesh-sdk/go/keys" + "git.novox.be/novox/mesh-sdk/go/views" ) type dryRun struct { @@ -14,12 +22,20 @@ type dryRun struct { modules, graph *overlayStore candidates, taken, predefined *overlayStore oldSections *overlayStore + // scratch is the state dry-runs this dry run's packages are written to, under prefix (§804); nil when the indexer keeps + // none, and the packages then stay in memory. + scratch Store + prefix string + logf func(string, ...any) } -// dry is an indexer over overlays of this one's states (overlay.go), for a run on request's candidate (runcandidates.go): what -// it computes stays in memory and nothing reaches the bus but the manifests and the packages, which clause 1 writes all the -// same. It says no event, kicks nothing in the background, and knows what this one knows of the source and the toolchains. Every field of Indexer is named here (TestDryNamesEveryField holds it so). -func (ix *Indexer) dry() *dryRun { +// dry is an indexer over overlays of this one's states (overlay.go), for a run on request's candidate (runcandidates.go), a +// branch's take-in or re-pin: what it computes stays in memory but the packages it writes, kept in the state dry-runs under +// the branch and call given (scratchStore; design 47 H2 §804, H-A-413), so the trunk's packages state is left untouched; its +// manifests are written create-once by digest as every take-in's (H-A-413's addendum). The caller ends it (end) once it +// answered. It says no event, kicks nothing in the background, and knows what this one knows of the source and the +// toolchains. Every field of Indexer is named here. +func (ix *Indexer) dry(branch, call string) *dryRun { over := func(st Store) (Store, *overlayStore) { if st == nil { return nil, nil @@ -27,8 +43,14 @@ func (ix *Indexer) dry() *dryRun { o := newOverlay(st) return o, o } - d := &dryRun{} - x := &Indexer{Module: ix.Module, Manifests: ix.Manifests, Packages: ix.Packages, JudgeID: ix.JudgeID, Files: ix.Files, GoSum: ix.GoSum, + d := &dryRun{scratch: ix.DryRuns, prefix: DryRunPrefix(branch, call), logf: ix.logf} + packages := ix.Packages + if packages != nil && d.scratch != nil { + packages = &scratchStore{under: ix.Packages, scratch: d.scratch, prefix: d.prefix + PackagesState + "."} + } else if packages != nil { + packages = newOverlay(ix.Packages) + } + x := &Indexer{Module: ix.Module, Manifests: ix.Manifests, Packages: packages, DryRuns: nil, JudgeID: ix.JudgeID, Files: ix.Files, GoSum: ix.GoSum, GoMod: ix.GoMod, Now: ix.Now, Bound: ix.Bound, // A dry run keeps no waiting-on: the take-in it computes for says its waits through the live indexer (H-A-409). TakeIns: nil, Builds: ix.Builds, Named: ix.Named, Trunk: ix.Trunk, BranchHead: ix.BranchHead, Read: ix.Read, Contains: ix.Contains, @@ -85,3 +107,236 @@ func (ix *Indexer) refuseDisagreement(c meshcatalog.CandidatesByGroupValue) erro } return nil } + +// DryRunsState is the indexer's state dry-runs (design 47 H2 §804, §820; H-A-413): a dry run's scratch, the overlay of the +// packages state a dry run writes, keyed ... (DryRunPrefix, the kind the overlaid state's name and +// the name its key), so a dry run leaves the trunk's packages state untouched. The indexer deletes a dry run's keys when it +// answers, and every key at its start; each lives an hour at most (the state's TTL). indexer_dry_runs reads it. +const ( + DryRunsState = "dry-runs" + DryRunsTool = "indexer_dry_runs" +) + +// DryRunPrefix is the prefix of a dry run's keys in the state dry-runs: its branch, escaped as a key's name is, and its call. +func DryRunPrefix(branch, call string) string { + return keys.EscapeName(branch) + "." + keys.EscapeName(call) + "." +} + +// scratchRevision lifts a revision of the state dry-runs above every revision of the state it overlays, as overlayStore does. +const scratchRevision = 1 << 62 + +// scratched is a value of the state dry-runs: the value a dry run wrote over its key, or that it deleted it. +type scratched struct { + Value []byte `json:"value,omitempty"` + Deleted bool `json:"deleted,omitempty"` +} + +// scratchStore is a store whose writes go to the state dry-runs under its prefix, over the store it reads through: a key +// it wrote reads as written, a key it deleted as absent, every other as the store under it holds it. Its compare-and-set +// holds against what it reads, a key it wrote carrying the dry-runs revision lifted by scratchRevision. +type scratchStore struct { + under, scratch Store + prefix string +} + +func (s *scratchStore) held(ctx context.Context, key string) (scratched, uint64, bool, error) { + raw, rev, found, err := s.scratch.Get(ctx, s.prefix+key) + if err != nil || !found { + return scratched{}, 0, false, err + } + var v scratched + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, false, fmt.Errorf("%s.%s%s: %w", DryRunsState, s.prefix, key, err) + } + return v, rev, true, nil +} + +func (s *scratchStore) Get(ctx context.Context, key string) ([]byte, uint64, bool, error) { + v, rev, found, err := s.held(ctx, key) + if err != nil { + return nil, 0, false, err + } + if found { + if v.Deleted { + return nil, rev + scratchRevision, false, nil + } + return v.Value, rev + scratchRevision, true, nil + } + if s.under == nil { + return nil, 0, false, nil + } + return s.under.Get(ctx, key) +} + +// put checks the revision read against what the key reads as now and writes it into the state dry-runs. +func (s *scratchStore) put(ctx context.Context, key string, value []byte, revision uint64, create, del bool) error { + _, own, mine, err := s.held(ctx, key) + if err != nil { + return err + } + _, rev, found, err := s.Get(ctx, key) + if err != nil { + return err + } + if create && found || !create && (!found || rev != revision) { + return ErrConflict + } + data, err := json.Marshal(scratched{Value: value, Deleted: del}) + if err != nil { + return err + } + if mine { + return s.scratch.Update(ctx, s.prefix+key, data, own) + } + return s.scratch.Create(ctx, s.prefix+key, data) +} + +func (s *scratchStore) Create(ctx context.Context, key string, value []byte) error { + return s.put(ctx, key, value, 0, true, false) +} + +func (s *scratchStore) Update(ctx context.Context, key string, value []byte, revision uint64) error { + return s.put(ctx, key, value, revision, false, false) +} + +func (s *scratchStore) Delete(ctx context.Context, key string, revision uint64) error { + return s.put(ctx, key, nil, revision, false, true) +} + +func (s *scratchStore) Keys(ctx context.Context) ([]string, error) { + var out []string + if s.under != nil { + var err error + if out, err = s.under.Keys(ctx); err != nil { + return nil, err + } + } + all, err := s.scratch.Keys(ctx) + if err != nil { + return nil, err + } + mine := map[string]bool{} + for _, k := range all { + if !strings.HasPrefix(k, s.prefix) { + continue + } + key := strings.TrimPrefix(k, s.prefix) + v, _, found, err := s.held(ctx, key) + if err != nil { + return nil, err + } + if found { + mine[key] = !v.Deleted + } + } + out = slices.DeleteFunc(out, func(k string) bool { _, ok := mine[k]; return ok }) + for k, live := range mine { + if live { + out = append(out, k) + } + } + slices.Sort(out) + return out, nil +} + +// end deletes the dry run's keys from the state dry-runs, once it answered (§804); a key it cannot delete is said, and goes +// with the state's TTL or at the indexer's next start. +func (d *dryRun) end(ctx context.Context) { + if d == nil || d.scratch == nil { + return + } + if err := dropPrefixed(ctx, d.scratch, d.prefix); err != nil { + d.logf("the dry run's keys %s* are not all deleted from %s: %v", d.prefix, DryRunsState, err) + } +} + +// ClearDryRuns deletes every key of the state dry-runs, at the indexer's start (§804): no dry run outlives a start. +func ClearDryRuns(ctx context.Context, st Store) error { return dropPrefixed(ctx, st, "") } + +func dropPrefixed(ctx context.Context, st Store, prefix string) error { + all, err := st.Keys(ctx) + if err != nil { + return err + } + var errs []error + for _, k := range all { + if !strings.HasPrefix(k, prefix) { + continue + } + _, rev, found, err := st.Get(ctx, k) + if err == nil && found { + err = st.Delete(ctx, k, rev) + } + if err != nil && !errors.Is(err, ErrConflict) { + errs = append(errs, fmt.Errorf("%s: %w", k, err)) + } + } + return errors.Join(errs...) +} + +// DryRunKey is one key of the state dry-runs as indexer_dry_runs answers it: the key, the value the dry run wrote (none when +// it deleted the key) and whether it deleted it. +type DryRunKey struct { + Key string `json:"key"` + Value json.RawMessage `json:"value,omitempty"` + Deleted bool `json:"deleted,omitempty"` +} + +// DryRunsAnswer is indexer_dry_runs' answer: the keys in key order up to views.PageBytes, capped when more are held, and +// how many the state holds in all. +type DryRunsAnswer struct { + Keys []DryRunKey `json:"keys"` + Capped bool `json:"capped,omitempty"` + Total int `json:"total"` +} + +// ReadDryRuns is what the state dry-runs holds now, at most views.PageBytes of values (§804, §811). +func ReadDryRuns(ctx context.Context, st Store) (DryRunsAnswer, error) { + out := DryRunsAnswer{Keys: []DryRunKey{}} + if st == nil { + return out, nil + } + all, err := st.Keys(ctx) + if err != nil { + return out, err + } + slices.Sort(all) + out.Total = len(all) + size := 0 + for _, k := range all { + raw, _, found, err := st.Get(ctx, k) + if err != nil { + return out, err + } + if !found { + continue + } + var v scratched + if err := json.Unmarshal(raw, &v); err != nil { + return out, fmt.Errorf("%s.%s: %w", DryRunsState, k, err) + } + if size += len(k) + len(v.Value); size > views.PageBytes && len(out.Keys) > 0 { + out.Capped = true + break + } + e := DryRunKey{Key: k, Deleted: v.Deleted} + if !v.Deleted { + e.Value = v.Value + } + out.Keys = append(out.Keys, e) + } + return out, nil +} + +// DryRunsTools are the dry runs' tools: indexer_dry_runs reads the state dry-runs (§804). +func DryRunsTools(st Store) []stdio.Tool { + return []stdio.Tool{{Name: DryRunsTool, + Description: "The dry runs' scratch state dry-runs (design 47 H2 §804): the packages a branch's take-in, a run's candidate " + + "or a branch's re-pin computes, kept as ..packages. while it runs, so the trunk's packages state " + + "is left untouched; a dry run's keys go when it answers and every key at the indexer's start. Each key with the " + + "value it wrote or deleted, up to 768 KB (capped) and the total held.", + Input: map[string]any{"type": "object", "properties": map[string]any{}}, + Run: func(map[string]any) (any, error) { + return ReadDryRuns(context.Background(), st) + }}} +} diff --git a/modules/mesh-delivery-indexer/internal/index/packages_gone_test.go b/modules/mesh-delivery-indexer/internal/index/packages_gone_test.go index 56ac91e81..4c3b23c0d 100644 --- a/modules/mesh-delivery-indexer/internal/index/packages_gone_test.go +++ b/modules/mesh-delivery-indexer/internal/index/packages_gone_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "reflect" "strings" "testing" "time" @@ -115,18 +116,26 @@ func TestARepositorysPackagesAreThoseInTheMergesTree(t *testing.T) { }) for _, row := range []struct { - name string - dry bool - branch string + name string + dry, scratch bool + branch string }{ - {"a branch's take-in keeps the key: only the trunk's merge says a directory is gone", false, "feat/x"}, - {"a dry run keeps the key: it shares the live packages state", true, TrunkBranch}, + {"a branch's take-in keeps the key: only the trunk's merge says a directory is gone", false, false, "feat/x"}, + {"a dry run keeps the key: its packages are a working copy over the live state", true, false, TrunkBranch}, + // Design 47 H2 §804: over the state dry-runs, a dry run's packages are kept there alone, under its branch and call, + // read by indexer_dry_runs and gone at its end; the live packages state is left as it was. + {"a dry run over the state dry-runs writes its packages there alone and drops them at its end", true, true, TrunkBranch}, } { t.Run(row.name, func(t *testing.T) { s := newSetup(t, live, gone) - ix := s.ix + if row.scratch { + s.ix.DryRuns = newMem() + } + before := s.ix.publishedAll(ctx) + ix, d := s.ix, (*dryRun)(nil) if row.dry { - ix = s.ix.dry().ix + d = s.ix.dry("beta", "t") + ix = d.ix } if err := ix.publish(ctx, catalogueRepo, merge, reaching(live), false, row.branch); err != nil { t.Fatal(err) @@ -134,6 +143,24 @@ func TestARepositorysPackagesAreThoseInTheMergesTree(t *testing.T) { if _, kept := s.ix.publishedAll(ctx)[gone]; !kept { t.Errorf("the kept key of %s was dropped", gone) } + if !row.scratch { + return + } + if got := s.ix.publishedAll(ctx); !reflect.DeepEqual(got, before) { + t.Errorf("the live packages state is %+v after the dry run, want %+v as before", got, before) + } + if mine := ix.publishedAll(ctx); mine[live].Commit != merge { + t.Errorf("the dry run reads %s at %q, want its own write at %s", live, mine[live].Commit, merge) + } + read, err := DryRunsTools(s.ix.DryRuns)[0].Run(map[string]any{}) + a, _ := read.(DryRunsAnswer) + if err != nil || a.Total == 0 || len(a.Keys) != a.Total || !strings.HasPrefix(a.Keys[0].Key, DryRunPrefix("beta", "t")+PackagesState+".") { + t.Errorf("indexer_dry_runs = %+v (%v), want the dry run's packages under beta.t.packages.", read, err) + } + d.end(ctx) + if a, err := ReadDryRuns(ctx, s.ix.DryRuns); err != nil || a.Total != 0 { + t.Errorf("dry-runs holds %+v (%v) after the dry run's end, want none", a, err) + } }) } diff --git a/modules/mesh-delivery-indexer/internal/index/runcandidates.go b/modules/mesh-delivery-indexer/internal/index/runcandidates.go index bfcfead88..9353b42b1 100644 --- a/modules/mesh-delivery-indexer/internal/index/runcandidates.go +++ b/modules/mesh-delivery-indexer/internal/index/runcandidates.go @@ -211,6 +211,11 @@ func (ix *Indexer) writeRunCandidate(ctx context.Context, group string, members pulls := make([]meshcatalog.CandidatesByGroupValuePullsItem, len(placed)) // One take-in per base branch: the members on one base are taken in together, so one member sees another's. bases := map[string]*dryRun{} + defer func() { + for _, d := range bases { + d.end(ctx) // the run's scratch goes once it answered (design 47 H2 §804) + } + }() for i, m := range placed { d, ok := bases[m.base] if !ok { @@ -218,7 +223,7 @@ func (ix *Indexer) writeRunCandidate(ctx context.Context, group string, members if err != nil { return fmt.Errorf("the run %s: the revision view of %s: %w", group, m.base, err) } - d = ix.dry() + d = ix.dry(m.base, group) d.ix.Modules, d.ix.Graph, d.ix.Taken = view, nodes, newOverlay(nil) d.ix.Logf = func(format string, args ...any) { ix.logf("the run "+group+", computed and not written: "+format, args...) diff --git a/modules/mesh-delivery-indexer/internal/index/takein_source.go b/modules/mesh-delivery-indexer/internal/index/takein_source.go index ecb392210..4d108e3a5 100644 --- a/modules/mesh-delivery-indexer/internal/index/takein_source.go +++ b/modules/mesh-delivery-indexer/internal/index/takein_source.go @@ -79,7 +79,8 @@ func (ix *Indexer) takeInSource(ctx context.Context, e meshdelivery.SourceMovedE if err != nil { return taken, err } - d := ix.dry() + d := ix.dry(e.Branch, e.Call) + defer d.end(ctx) d.ix.Modules, d.ix.Graph, d.ix.Taken = view, nodes, newOverlay(nil) d.ix.Logf = func(format string, args ...any) { ix.logf("take-in of "+e.Branch+": "+format, args...) } x = d.ix diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index 0a4553916..8300429f3 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -636,38 +636,43 @@ func (ix *Indexer) Repin(ctx context.Context, module, version string) (int, erro } named := 0 for _, branch := range branches { - x := ix - if !isTrunkBranch(branch) { - view, nodes, _, err := BranchView(ctx, ix.Revisions, branch) - if err != nil { - return named, err - } - d := ix.dry() - d.ix.Modules, d.ix.Graph, d.ix.Taken = view, nodes, newOverlay(nil) - d.ix.Logf = func(format string, args ...any) { ix.logf("re-pin of "+branch+": "+format, args...) } - x = d.ix - } - only, err := x.repinned(ctx, module) + n, err := ix.repinBranch(ctx, branch, module, version) + named += n if err != nil { return named, err } - if len(only) == 0 { - continue - } - named += len(only) - x.recompute.Lock() - err = x.recomputeLocked(ctx, nil, nil, "", only) - x.recompute.Unlock() - if err != nil { - return named, err - } - if err := ix.keepRepinned(ctx, x, branch, releaseCall(module, version), only); err != nil { - return named, err - } } return named, nil } +// repinBranch re-pins branch's importers of module at version: the trunk in place, another branch as a dry run over its +// revision view, whose scratch goes once it is kept (design 47 H2 §804). It answers how many modules it named. +func (ix *Indexer) repinBranch(ctx context.Context, branch, module, version string) (int, error) { + x, call := ix, releaseCall(module, version) + if !isTrunkBranch(branch) { + view, nodes, _, err := BranchView(ctx, ix.Revisions, branch) + if err != nil { + return 0, err + } + d := ix.dry(branch, call.Call) + defer d.end(ctx) + d.ix.Modules, d.ix.Graph, d.ix.Taken = view, nodes, newOverlay(nil) + d.ix.Logf = func(format string, args ...any) { ix.logf("re-pin of "+branch+": "+format, args...) } + x = d.ix + } + only, err := x.repinned(ctx, module) + if err != nil || len(only) == 0 { + return 0, err + } + x.recompute.Lock() + err = x.recomputeLocked(ctx, nil, nil, "", only) + x.recompute.Unlock() + if err != nil { + return len(only), err + } + return len(only), ix.keepRepinned(ctx, x, branch, call, only) +} + // repinned are the modules the indexer's modules state holds whose packages name a package of module: by their pins, and // by their kept requirements, which name a package they hold no pin of yet (design 47 H-A-204, H-A-165, H-A-167). func (ix *Indexer) repinned(ctx context.Context, module string) (map[string]bool, error) { diff --git a/modules/mesh-delivery-indexer/manifest_test.go b/modules/mesh-delivery-indexer/manifest_test.go index 81ef37ba3..99f0974c0 100644 --- a/modules/mesh-delivery-indexer/manifest_test.go +++ b/modules/mesh-delivery-indexer/manifest_test.go @@ -31,6 +31,7 @@ type state struct { History int `json:"history,omitempty"` KeyTTL bool `json:"key-ttl,omitempty"` MaxMiB int `json:"max-mib,omitempty"` + TTL int `json:"ttl-seconds,omitempty"` } type artifact struct { @@ -138,7 +139,8 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build {Name: index.RequirementsState, History: 5}, {Name: index.SeatDefinitionsState, History: 5}, {Name: index.EntryIndexState, History: 1, MaxMiB: 8}, {Name: index.NamedState, History: 1, MaxMiB: 4}, // design 47 G §695 {Name: index.RegistrationsState, History: 1}, {Name: index.ProposalsState, History: 1, MaxMiB: 4}, - {Name: index.VersionsState, History: 1, MaxMiB: 64}, {Name: index.BuildEdgesState, History: 1}, {Name: index.InputsState, History: 1}, {Name: index.PinsState, History: 1, MaxMiB: index.PinsCapMiB}, {Name: index.HeldState, History: 1}}; !reflect.DeepEqual(m.State, want) { // DLV-I7, DLV-I17 + {Name: index.VersionsState, History: 1, MaxMiB: 64}, {Name: index.BuildEdgesState, History: 1}, {Name: index.InputsState, History: 1}, {Name: index.PinsState, History: 1, MaxMiB: index.PinsCapMiB}, {Name: index.HeldState, History: 1}, + {Name: index.DryRunsState, History: 1, TTL: 3600, MaxMiB: 16}}; !reflect.DeepEqual(m.State, want) { // DLV-I7, DLV-I17; design 47 H2 §804, §820 t.Errorf("state = %+v, want %+v", m.State, want) } // Milestone 47/G W4.2 (design 47, Two graphs; ADR 0619 §2): the catalog graph revisions are objects in the old section, @@ -206,8 +208,9 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build // milestone 47/G W4.12 (design 47, the indexer's tools): the catalog graph revisions read and steered. index.CatalogRevisionTool, index.CatalogRevisionsTool, index.CandidateGraphsTool, index.RecomputeTool, index.DropCandidateGraphTool, index.EntryIndexTool, index.EntryPinsTool, index.NamedDropTool, // design 47 G §675, H-A-204 - index.ProposalsTool, index.ProposalDropTool, index.SeedAgainTool, index.InputsTool, index.PinsTool, index.PinDropTool, index.PendingTool, index.TakeInPendingTool, index.TakeInAgainTool, index.TakeInSkipTool, index.RunsTool, index.RunDropTool) // design 47 G §667, §8, §579, §64 (A-194) - if !reflect.DeepEqual(m.Tools, want) || len(want) != 44 || !slices.Contains(m.Tools, "modules") { + index.ProposalsTool, index.ProposalDropTool, index.SeedAgainTool, index.InputsTool, index.PinsTool, index.PinDropTool, index.PendingTool, index.TakeInPendingTool, index.TakeInAgainTool, index.TakeInSkipTool, index.RunsTool, index.RunDropTool, // design 47 G §667, §8, §579, §64 (A-194) + index.DryRunsTool) // design 47 H2 §804 + if !reflect.DeepEqual(m.Tools, want) || len(want) != 45 || !slices.Contains(m.Tools, "modules") { t.Errorf("tools = %v, want %v", m.Tools, want) } // Design 47 G §2, §9: every version of every registration is kept with no age limit, 64 MiB, on the old streams section. diff --git a/modules/mesh-delivery-indexer/module.json b/modules/mesh-delivery-indexer/module.json index bc75c22c2..8926fa796 100644 --- a/modules/mesh-delivery-indexer/module.json +++ b/modules/mesh-delivery-indexer/module.json @@ -70,7 +70,8 @@ "indexer_take_in_again", "indexer_take_in_skip", "indexer_runs", - "indexer_run_drop" + "indexer_run_drop", + "indexer_dry_runs" ], "consumes": [ "go-package-registry.published", @@ -119,7 +120,8 @@ { "name": "build-edges", "history": 1 }, { "name": "inputs", "history": 1 }, { "name": "pins", "history": 1, "max-mib": 4 }, - { "name": "held", "history": 1 } + { "name": "held", "history": 1 }, + { "name": "dry-runs", "history": 1, "ttl-seconds": 3600, "max-mib": 16 } ], "streams": [ { "name": "registration-history", "events": ["registration.*"], "retention": "history", "max-mib": 64 }, From cc5f803f8797e391c109d1961091ae6aa7b6d8d4 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 01:12:04 +0100 Subject: [PATCH 04/16] I5: the registrations are read in one call, filtered and paged MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The verb registrations and the new tool indexer_registrations filter by module and repository while they read, at most 768 KB a page, capped with the cursor next: the tools bundle reads the state from the bus's cursor (mesh/state.page), a store that pages none by its keys in order; total is said when one page holds the whole read. Builds: design 47 H2 §806, §811, §779 --- .../cmd/mesh-delivery-indexer-tools/main.go | 5 ++ .../internal/index/registrations.go | 75 ++++++++++++++--- .../internal/index/registrations_tools.go | 50 ++++++----- .../index/registrations_tools_test.go | 84 +++++++++++++++++++ .../mesh-delivery-indexer/manifest_test.go | 4 +- modules/mesh-delivery-indexer/module.json | 3 +- 6 files changed, 187 insertions(+), 34 deletions(-) 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 d1bf3dcac..6f7f219d9 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 @@ -156,6 +156,11 @@ func (k keptRead) Get(_ context.Context, key string) ([]byte, uint64, bool, erro func (k keptRead) Keys(context.Context) ([]string, error) { return k.s.Keys() } +// Page reads the state a page at a time from the bus's cursor (design 47 H2 §779): the registrations are read so (§806). +func (k keptRead) Page(cursor string, maxBytes int, budget time.Duration) (stdio.StatePage, error) { + return k.s.Page(cursor, maxBytes, budget) +} + func (keptRead) Create(context.Context, string, []byte) error { return errReadOnly } func (keptRead) Update(context.Context, string, []byte, uint64) error { return errReadOnly } diff --git a/modules/mesh-delivery-indexer/internal/index/registrations.go b/modules/mesh-delivery-indexer/internal/index/registrations.go index 519515998..9b0205979 100644 --- a/modules/mesh-delivery-indexer/internal/index/registrations.go +++ b/modules/mesh-delivery-indexer/internal/index/registrations.go @@ -16,7 +16,10 @@ import ( oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel" gitseat "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/meshcatalog" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" + stdio "git.novox.be/novox/mesh-sdk/go" "git.novox.be/novox/mesh-sdk/go/keys" + "git.novox.be/novox/mesh-sdk/go/views" ) // A module's registration, and the trusted change of one (design 47 G §2 to §4, §10, §342, §343, §667): the indexer keeps each @@ -169,15 +172,34 @@ func (r *Registry) Registration(ctx context.Context, module string) (meshcatalog return reg, true, nil } -// Registrations is the verb registrations (§4): every registration, or one module's, with its history. +// RegistrationsTool is the indexer's tool of the registrations (design 47 H2 §806): the verb registrations' answer, by hand. +const RegistrationsTool = "indexer_registrations" + +// StatePager reads a state a page at a time, in the order the bus wrote it, after an opaque cursor (mesh-sdk +// KeptState.Page, design 47 H2 §779). +type StatePager interface { + Page(cursor string, maxBytes int, budget time.Duration) (stdio.StatePage, error) +} + +// keyCursor is the cursor of a store read by its keys (a store that pages none): after this key, in key order. +const keyCursor = "key:" + +// RegistrationsAnswer is the verb registrations and the tool indexer_registrations (§4; design 47 H2 §806, §811): every +// registration, or one module's with its history, filtered by module and repository while it reads, at most views.PageBytes +// a page, capped with the cursor next when more is held; a store that pages (StatePager) is read from the bus's cursor, +// any other by its keys in order. total is how many the filters hold, said when one page holds the whole read. func (r *Registry) RegistrationsAnswer(ctx context.Context, in meshcatalog.RegistrationsInput) (meshcatalog.RegistrationsAnswer, error) { out := meshcatalog.RegistrationsAnswer{Registrations: []meshcatalog.Registration{}} + repository := trunk.RepositoryName(strings.TrimSpace(in.Repository)) + keep := func(reg meshcatalog.Registration) bool { + return (in.Module == "" || reg.Module == in.Module) && (repository == "" || trunk.SameRepository(reg.Origin, repository)) + } if in.Module != "" { reg, found, err := r.Registration(ctx, in.Module) if err != nil { return out, err } - if found { + if found && keep(reg) { out.Registrations = append(out.Registrations, reg) } if in.History && r.HistoryOf != nil { @@ -185,22 +207,53 @@ func (r *Registry) RegistrationsAnswer(ctx context.Context, in meshcatalog.Regis return out, fmt.Errorf("the history of %s cannot be read: %w", in.Module, err) } } + out.Total = int64(len(out.Registrations)) return out, nil } - all, err := r.Registrations.Keys(ctx) - if err != nil { - return out, err + match := func(value []byte) (meshcatalog.Registration, bool) { + var reg meshcatalog.Registration + return reg, json.Unmarshal(value, ®) == nil && keep(reg) } - slices.Sort(all) - for _, k := range all { - v, _, found, err := r.Registrations.Get(ctx, k) + if p, ok := r.Registrations.(StatePager); ok { + page, err := p.Page(in.Next, views.PageBytes, views.PageBudget) if err != nil { return out, err } - var reg meshcatalog.Registration - if found && json.Unmarshal(v, ®) == nil { - out.Registrations = append(out.Registrations, reg) + // A page holds at most views.PageBytes, so what the filters keep of it always fits one answer. + for _, e := range page.Entries { + if reg, ok := match(e.Value); ok { + out.Registrations = append(out.Registrations, reg) + } } + out.Next, out.Capped = page.Next, page.Next != "" + } else { + all, err := r.Registrations.Keys(ctx) + if err != nil { + return out, err + } + slices.Sort(all) + after, size := strings.TrimPrefix(in.Next, keyCursor), 0 + for _, k := range all { + if in.Next != "" && k <= after { + continue + } + v, _, found, err := r.Registrations.Get(ctx, k) + if err != nil { + return out, err + } + reg, ok := match(v) + if !found || !ok { + continue + } + if size += len(k) + len(v); size > views.PageBytes && len(out.Registrations) > 0 { + out.Capped, out.Next = true, keyCursor+after + return out, nil + } + out.Registrations, after = append(out.Registrations, reg), k + } + } + if in.Next == "" && !out.Capped { + out.Total = int64(len(out.Registrations)) } return out, nil } diff --git a/modules/mesh-delivery-indexer/internal/index/registrations_tools.go b/modules/mesh-delivery-indexer/internal/index/registrations_tools.go index 9baa5cf5b..0a61d5375 100644 --- a/modules/mesh-delivery-indexer/internal/index/registrations_tools.go +++ b/modules/mesh-delivery-indexer/internal/index/registrations_tools.go @@ -43,27 +43,37 @@ func RegistrationTools(registrations, proposals Store, ask func(key string, valu // 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) + read := 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) + } return []stdio.Tool{ - {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.VerbRegistrations, Run: read}, + {Name: RegistrationsTool, Description: "The registrations (design 47 H2 §806), as the seat mesh-catalog's verb registrations answers them: " + + "every module's and every source-only one, filtered by module or repository (owner/name) while it reads, at most 768 KB a page " + + "(capped), the rest read from the cursor next; one module's with every version (history).", + Input: map[string]any{"type": "object", "properties": map[string]any{ + "module": map[string]any{"type": "string", "description": "one module; absent, every registration"}, + "repository": map[string]any{"type": "string", "description": "only the registrations of this repository, owner/name"}, + "history": map[string]any{"type": "boolean", "description": "with every version of the one module"}, + "next": map[string]any{"type": "string", "description": "the cursor the previous page answered"}}}, + Run: read}, {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)}, diff --git a/modules/mesh-delivery-indexer/internal/index/registrations_tools_test.go b/modules/mesh-delivery-indexer/internal/index/registrations_tools_test.go index f9be83ff9..98b77ccbd 100644 --- a/modules/mesh-delivery-indexer/internal/index/registrations_tools_test.go +++ b/modules/mesh-delivery-indexer/internal/index/registrations_tools_test.go @@ -4,12 +4,28 @@ import ( "context" "encoding/json" "errors" + "fmt" + "slices" + "strings" "testing" "time" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + stdio "git.novox.be/novox/mesh-sdk/go" ) +// pagedStore is a store whose Page answers the pages given, by cursor, and records the cursors asked. +type pagedStore struct { + Store + pages map[string]stdio.StatePage + asked []string +} + +func (p *pagedStore) Page(cursor string, _ int, _ time.Duration) (stdio.StatePage, error) { + p.asked = append(p.asked, cursor) + return p.pages[cursor], nil +} + // 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) { @@ -41,4 +57,72 @@ func TestTheRegistrationsVerbIsAnsweredFromItsStateNotAskedOfTheIndexer(t *testi 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) } + + // Design 47 H2 §806: indexer_registrations answers as the verb, filtered by module and repository while it reads, at most + // 768 KB a page, capped with the cursor next; a state that pages is read from the bus's cursor. + t.Run("filtered and paged", func(t *testing.T) { + ctx := context.Background() + big := MemoryStore() + var want []string + for i := range 12 { + origin := "novox/mesh-catalog" + if i%3 == 0 { + origin = "novox/mesh-sdk" + } + module := fmt.Sprintf("m%02d", i) + data, _ := json.Marshal(meshcatalog.Registration{Module: module, Origin: origin, Path: strings.Repeat("p", 100<<10)}) + if err := big.Create(ctx, RegistrationKey(module), data); err != nil { + t.Fatal(err) + } + if origin == "novox/mesh-catalog" { + want = append(want, module) + } + } + named := func(tools []stdio.Tool) func(map[string]any) (any, error) { + for _, tl := range tools { + if tl.Name == RegistrationsTool { + return tl.Run + } + } + t.Fatalf("no tool %s", RegistrationsTool) + return nil + } + run := named(RegistrationTools(big, MemoryStore(), ask, time.Now, nil)) + var got []string + pages := 0 + for next := ""; ; pages++ { + raw, err := run(map[string]any{"repository": "novox/mesh-catalog", "next": next}) + a, _ := raw.(meshcatalog.RegistrationsAnswer) + if err != nil || a.Capped != (a.Next != "") { + t.Fatalf("page %d = %+v (%v), want capped exactly when a cursor follows", pages, a, err) + } + for _, r := range a.Registrations { + got = append(got, r.Module) + } + if next = a.Next; next == "" { + break + } + } + if !slices.Equal(got, want) || pages == 0 { + t.Errorf("the pages hold %v in %d pages after the first, want %v over more than one page", got, pages, want) + } + if a, _ := run(map[string]any{"module": "m00", "repository": "novox/mesh-catalog"}); len(a.(meshcatalog.RegistrationsAnswer).Registrations) != 0 { + t.Errorf("m00 of novox/mesh-sdk answered for the repository novox/mesh-catalog: %+v", a) + } + reg := func(module, origin string) stdio.StateEntry { + data, _ := json.Marshal(meshcatalog.Registration{Module: module, Origin: origin}) + return stdio.StateEntry{Key: RegistrationKey(module), Value: data} + } + pager := &pagedStore{Store: MemoryStore(), pages: map[string]stdio.StatePage{ + "": {Entries: []stdio.StateEntry{reg("a", "novox/x"), reg("b", "novox/y")}, Next: "c1"}, + "c1": {Entries: []stdio.StateEntry{reg("c", "novox/x")}}}} + run = named(RegistrationTools(pager, MemoryStore(), ask, time.Now, nil)) + first, _ := run(map[string]any{"repository": "novox/x"}) + second, _ := run(map[string]any{"repository": "novox/x", "next": "c1"}) + f, g := first.(meshcatalog.RegistrationsAnswer), second.(meshcatalog.RegistrationsAnswer) + if len(f.Registrations) != 1 || f.Registrations[0].Module != "a" || f.Next != "c1" || !f.Capped || + len(g.Registrations) != 1 || g.Registrations[0].Module != "c" || g.Next != "" || !slices.Equal(pager.asked, []string{"", "c1"}) { + t.Errorf("the paged read answered %+v then %+v, asking %v, want a then c of novox/x by the bus's cursor", f, g, pager.asked) + } + }) } diff --git a/modules/mesh-delivery-indexer/manifest_test.go b/modules/mesh-delivery-indexer/manifest_test.go index 99f0974c0..ac6d421df 100644 --- a/modules/mesh-delivery-indexer/manifest_test.go +++ b/modules/mesh-delivery-indexer/manifest_test.go @@ -209,8 +209,8 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build index.CatalogRevisionTool, index.CatalogRevisionsTool, index.CandidateGraphsTool, index.RecomputeTool, index.DropCandidateGraphTool, index.EntryIndexTool, index.EntryPinsTool, index.NamedDropTool, // design 47 G §675, H-A-204 index.ProposalsTool, index.ProposalDropTool, index.SeedAgainTool, index.InputsTool, index.PinsTool, index.PinDropTool, index.PendingTool, index.TakeInPendingTool, index.TakeInAgainTool, index.TakeInSkipTool, index.RunsTool, index.RunDropTool, // design 47 G §667, §8, §579, §64 (A-194) - index.DryRunsTool) // design 47 H2 §804 - if !reflect.DeepEqual(m.Tools, want) || len(want) != 45 || !slices.Contains(m.Tools, "modules") { + index.DryRunsTool, index.RegistrationsTool) // design 47 H2 §804, §806 + if !reflect.DeepEqual(m.Tools, want) || len(want) != 46 || !slices.Contains(m.Tools, "modules") { t.Errorf("tools = %v, want %v", m.Tools, want) } // Design 47 G §2, §9: every version of every registration is kept with no age limit, 64 MiB, on the old streams section. diff --git a/modules/mesh-delivery-indexer/module.json b/modules/mesh-delivery-indexer/module.json index 8926fa796..b6a7943b6 100644 --- a/modules/mesh-delivery-indexer/module.json +++ b/modules/mesh-delivery-indexer/module.json @@ -71,7 +71,8 @@ "indexer_take_in_skip", "indexer_runs", "indexer_run_drop", - "indexer_dry_runs" + "indexer_dry_runs", + "indexer_registrations" ], "consumes": [ "go-package-registry.published", From 7ed668fa53d525027b21b2ddd0b2a1e6f77becd6 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 01:32:06 +0100 Subject: [PATCH 05/16] I7: a catalog entry carries its manifest's class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The gate reads a mover's class from its catalog entry when it opens the delivery record, so the indexer writes the manifest's class there. Builds: design 47 H2 §810; H-A-394 (1), H-A-431 (1) --- .../mesh-delivery-indexer/internal/index/catalog_graph.go | 5 +++-- .../internal/index/catalog_graph_test.go | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_graph.go b/modules/mesh-delivery-indexer/internal/index/catalog_graph.go index 906f2263f..93ff2d057 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_graph.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_graph.go @@ -27,13 +27,14 @@ const CatalogEntryLayout = 1 // 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 -// and what the indexer computes its next revision from (Inputs: the lead's ruling on milestone 47/G finding 1), so that +// and what the indexer computes its next revision from (Inputs: the lead's ruling on milestone 47/G finding 1), and its +// manifest's class, core or leaf, absent for none (design 47 H2 §810, H-A-394 (1): the gate reads it), so that // 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: meshcatalogclient.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)} + Serves: n.Serves, LeftOut: n.LeftOut, Main: MainOf(m), Contributes: contributesOf(m), Class: m.Class} // requires names every requirement as catalogue.Manifest.Wants lists them, optional ones and those only contributes names // included, since contributing to a requirement is requiring it (design 47 G §709, A-229). for _, r := range m.Wants() { diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_graph_test.go b/modules/mesh-delivery-indexer/internal/index/catalog_graph_test.go index 36cb65242..69dca5113 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_graph_test.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_graph_test.go @@ -106,7 +106,11 @@ func TestAnEntryNamesWhatItContributesToAndEveryRequirement(t *testing.T) { if n := graph.NodeOf(e); !reflect.DeepEqual(n.Requires, []string{"database", graph.BusState, "route"}) { t.Errorf("the node's requires = %v, want the optional cache left out", n.Requires) } - if e := CatalogEntryOf("kv", meshcatalog.ModulesByModuleValue{}, catalogue.Manifest{}, "", graph.Node{}); e.Contributes != nil { - t.Errorf("an entry of a manifest contributing nothing carries contributes %v", e.Contributes) + if e := CatalogEntryOf("kv", meshcatalog.ModulesByModuleValue{}, catalogue.Manifest{}, "", graph.Node{}); e.Contributes != nil || e.Class != "" { + t.Errorf("an entry of a manifest contributing nothing and naming no class carries contributes %v, class %q", e.Contributes, e.Class) + } + // Design 47 H2 §810, H-A-394 (1): the entry carries its manifest's class, which the gate reads. + if e := CatalogEntryOf("kv", meshcatalog.ModulesByModuleValue{}, catalogue.Manifest{Class: catalogue.ClassCore}, "", graph.Node{}); e.Class != catalogue.ClassCore { + t.Errorf("the entry of a core manifest carries the class %q, want core", e.Class) } } From 40c2870a716cb751395c14579c21b09da1349e57 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 01:35:56 +0100 Subject: [PATCH 06/16] I4: a release re-pins once, at its reservation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The builder's version-reserved writes the series' numbered version with the contents of the module's entry commit, so acceptedSeries and releasedPins pin it; the indexer keeps each reservation in heard (reserved.., reserved-keep) and gathers a revision's reservations until its pipeline's start, its first step-ended or the expiry of settling. (reserved-settle), then keeps one re-pin revision of that branch. The release's package-published moves no fingerprint; a pipeline-ended not passed withdraws its reservations to the newest released version. Builds: design 47 H2 §805; H-A-418, H-A-420, H-A-424, H-A-436 --- .../cmd/mesh-delivery-indexer/main.go | 53 +++ .../cmd/mesh-delivery-indexer/versions.go | 32 ++ .../internal/index/candidates.go | 4 + .../internal/index/packages_values.go | 9 + .../internal/index/pins.go | 15 +- .../internal/index/repin_test.go | 63 +++ .../internal/index/reserved.go | 432 ++++++++++++++++++ .../internal/index/series.go | 18 +- .../internal/index/toolchains.go | 27 +- .../internal/index/versions.go | 5 +- .../mesh-delivery-indexer/manifest_test.go | 8 +- modules/mesh-delivery-indexer/module.json | 20 +- 12 files changed, 669 insertions(+), 17 deletions(-) create mode 100644 modules/mesh-delivery-indexer/internal/index/reserved.go 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 043bad17d..352505c32 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -92,6 +92,16 @@ func (s awaitedStore) Create(ctx context.Context, key string, value []byte) erro return st.Create(ctx, key, value) } +// CreateTTL creates key living ttl: the state is declared key-ttl (index.TTLStore, design 47 H2 §805). +func (s awaitedStore) CreateTTL(ctx context.Context, key string, value []byte, ttl time.Duration) error { + st, err := s.store() + if err != nil { + return err + } + _, err = st.kv.Create(ctx, key, value, jetstream.KeyTTL(ttl)) + return conflict(err) +} + func (s awaitedStore) Update(ctx context.Context, key string, value []byte, revision uint64) error { st, err := s.store() if err != nil { @@ -346,6 +356,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro Named: namedVia(calls.Call), Trunk: trunkVia(calls.Call), BranchHead: branchHeadVia(calls.Call), Contains: containsVia(calls.Call), Read: readVia(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), Heard: heardStore, Runs: awaitedStore{b: runs}, Graph: graph, + // How long a reservation is kept and how long its gathering waits at most (design 47 H2 §805, H-A-424). + ReservedKeep: reservedSetting("reserved-keep", index.DefaultReservedKeep, logger.Printf), + ReservedSettle: reservedSetting("reserved-settle", index.DefaultReservedSettle, logger.Printf), 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). @@ -571,6 +584,36 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro if err := hub.Handle(meshbuilds.SubjectPackagePublished, func(m jetstream.Msg) { heardPackagePublished(ctx, ix, m, logger.Printf) }); err != nil { return err } + // A release re-pins once, at its reservation (design 47 H2 §805): the builder's version-reserved, and the step-ended of + // a pipeline whose reservations settle then. + if err := hub.Handle(meshbuilds.SubjectVersionReserved, func(m jetstream.Msg) { heardVersionReserved(ctx, ix, m, logger.Printf) }); err != nil { + return err + } + if err := hub.Handle(meshbuilds.SubjectStepEndedAll, func(m jetstream.Msg) { heardBuildStepEnded(ctx, ix, m, logger.Printf) }); err != nil { + return err + } + // A gathering's key settling. settles it when its time to live ends: the watch of heard hands the bus's + // expiry marker over (H-A-436); a gathering a restart cut settles once heard is bound. + heardStore.b.Ready(func(kv jetstream.KeyValue) { + eachHeard := func(e jetstream.KeyValueEntry) { + if e.Operation() != jetstream.KeyValuePurge { + return + } + if err := ix.Expired(ctx, e.Key()); err != nil { + logger.Printf("versions: %s expired and its reservations are not re-pinned: %v", e.Key(), err) + } + } + if hw, err := settle(ctx, kv, eachHeard); err != nil { + process.NotWatched(logger.Printf, index.Bucket(cred.Module, index.HeardState), err, "no gathering of reservations settles at its bound until the indexer starts again") + } else { + go func() { errs <- follow(ctx, hw, eachHeard) }() + } + go func() { + if err := ix.GatherKept(ctx); err != nil { + logger.Printf("versions: the reservations kept before the start are not settled again: %v", err) + } + }() + }) if err := hub.Handle(meshbuilds.SubjectToolchainAgreed, func(m jetstream.Msg) { heardToolchainAgreed(ctx, ix, m, logger.Printf) }); err != nil { return err } @@ -641,3 +684,13 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro return err } } + +// reservedSetting is the setting key read as a duration (stdio.SettingDuration); one that does not read is said and takes def. +func reservedSetting(key string, def time.Duration, logf func(string, ...any)) time.Duration { + d, err := stdio.SettingDuration(key, def) + if err != nil { + logf("%v: %s is taken", err, def) + return def + } + return d +} 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 0e60ef7fd..fa9a746b2 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/versions.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/versions.go @@ -98,6 +98,38 @@ func heardPackagePublished(ctx context.Context, ix *index.Indexer, m jetstream.M _ = m.Ack() } +// heardVersionReserved takes one version-reserved of the seat mesh-builds in (design 47 H2 §805): one that does not decode +// is said and acknowledged; one that cannot be kept is left, so the bus gives it again. +func heardVersionReserved(ctx context.Context, ix *index.Indexer, m jetstream.Msg, logf func(string, ...any)) { + var e meshbuilds.VersionReservedEvent + if err := json.Unmarshal(m.Data(), &e); err != nil { + logf("%s holds what is no version-reserved, left: %v", m.Subject(), err) + _ = m.Ack() + return + } + if err := ix.HearVersionReserved(ctx, e); err != nil { + logf("versions: the version-reserved of %s %s could not be kept, so the bus gives it again: %v", e.Artifact, e.Version, err) + leftForBus(m, fmt.Sprintf("the version-reserved of %s %s", e.Artifact, e.Version), err, logf) + return + } + _ = m.Ack() +} + +// heardBuildStepEnded settles the reservations of the step's pipeline, if they gather (design 47 H2 §805, H-A-424 (1)): +// the builder reserves every mover before it asks the first build. A settle that fails is said; its bound settles again. +func heardBuildStepEnded(ctx context.Context, ix *index.Indexer, m jetstream.Msg, logf func(string, ...any)) { + var e meshbuilds.StepEnded + if err := json.Unmarshal(m.Data(), &e); err != nil { + logf("%s holds what is no step-ended, left: %v", m.Subject(), err) + _ = m.Ack() + return + } + if err := ix.Settle(ctx, e.Pipeline); err != nil { + logf("versions: the reservations of %s are not re-pinned at its step-ended: %v", e.Pipeline, err) + } + _ = m.Ack() +} + // heardToolchainAgreed keeps the newest toolchain-agreed of its language (A-68); one that does not decode is said and // acknowledged, one that cannot be kept is left, so the bus gives it again. func heardToolchainAgreed(ctx context.Context, ix *index.Indexer, m jetstream.Msg, logf func(string, ...any)) { diff --git a/modules/mesh-delivery-indexer/internal/index/candidates.go b/modules/mesh-delivery-indexer/internal/index/candidates.go index 4f4df5137..bb94bccbe 100644 --- a/modules/mesh-delivery-indexer/internal/index/candidates.go +++ b/modules/mesh-delivery-indexer/internal/index/candidates.go @@ -192,6 +192,10 @@ type Indexer struct { runMu sync.Mutex // one run event at a time (runcandidates.go) heldFull atomic.Bool // a take-in is held because the catalog store is full: room is said when it has room again (RoomAgain) pendingMu sync.Mutex // one take-in step at a time: a merge, a group's end, the start and a hand act (pending.go) + // ReservedKeep is how long a reservation is kept in the state heard, and ReservedSettle how long after a revision's + // first reservation its gathering settles at the latest: the settings reserved-keep and reserved-settle (design 47 H2 + // §805, H-A-424); zero takes the default. + ReservedKeep, ReservedSettle time.Duration } func (ix *Indexer) logf(format string, args ...any) { diff --git a/modules/mesh-delivery-indexer/internal/index/packages_values.go b/modules/mesh-delivery-indexer/internal/index/packages_values.go index bc511574e..3ac6cbd38 100644 --- a/modules/mesh-delivery-indexer/internal/index/packages_values.go +++ b/modules/mesh-delivery-indexer/internal/index/packages_values.go @@ -178,3 +178,12 @@ func contentsOfPublished(p meshcatalog.PackagesByModuleValue) *meshcatalog.Packa } return c } + +// publishedOfNumbered is a series' numbered version's contents as the value of a per-module packages key (the same fields). +func publishedOfNumbered(c meshcatalog.PackagesByPackageSeriesValueNumberedContents) meshcatalog.PackagesByModuleValue { + p := meshcatalog.PackagesByModuleValue{At: c.At, Commit: c.Commit, Dir: c.Dir, Module: c.Module, Repository: c.Repository, Requires: c.Requires, V: c.V} + for _, d := range c.Packages { + p.Packages = append(p.Packages, meshcatalog.PackagesByModuleValuePackagesItem{Package: d.Package, Digest: d.Digest}) + } + return p +} diff --git a/modules/mesh-delivery-indexer/internal/index/pins.go b/modules/mesh-delivery-indexer/internal/index/pins.go index 92a543d29..309015e2d 100644 --- a/modules/mesh-delivery-indexer/internal/index/pins.go +++ b/modules/mesh-delivery-indexer/internal/index/pins.go @@ -83,7 +83,14 @@ func (ix *Indexer) HeardPins(ctx context.Context, started *runner.PipelineStarte } switch { case started != nil && started.Revision > 0 && started.Pipeline != "": - return ix.pin(ctx, PinKey(started.Branch, started.Revision), PipelineRecord(started.Pipeline)) + if err := ix.pin(ctx, PinKey(started.Branch, started.Revision), PipelineRecord(started.Pipeline)); err != nil { + return err + } + // The reservations of the pipeline's revision settle at its start, if they gather (design 47 H2 §805, H-A-424 (1)). + if err := ix.Settle(ctx, BranchObject(started.Branch, started.Revision)); err != nil { + ix.logf("versions: the reservations of %s are not re-pinned at its pipeline-started: %v", BranchObject(started.Branch, started.Revision), err) + } + return nil case ended != nil && ended.Revision > 0 && ended.Pipeline != "": // A passed pipeline's release pins the revision its movers' entries live in, before the pipeline's own pin is freed, // one record per mover that released a version in it (H-A-168, H-A-170, H-A-173); a mover that released none, and a run @@ -98,6 +105,12 @@ func (ix *Indexer) HeardPins(ctx context.Context, started *runner.PipelineStarte } } } + // A pipeline that did not pass withdraws the reservations its revision holds (design 47 H2 §805, H-A-418 (1)). + if ended.Outcome != runner.PipelineEndedOutcomePassed { + if err := ix.Withdraw(ctx, ended.Branch, ended.Revision); err != nil { + return fmt.Errorf("the reservations of %s are not withdrawn: %w", BranchObject(ended.Branch, ended.Revision), err) + } + } record := PipelineRecord(ended.Pipeline) if err := ix.unpin(ctx, PinKey(ended.Branch, ended.Revision), record); err != nil { return err diff --git a/modules/mesh-delivery-indexer/internal/index/repin_test.go b/modules/mesh-delivery-indexer/internal/index/repin_test.go index 584c37083..c9b58fb78 100644 --- a/modules/mesh-delivery-indexer/internal/index/repin_test.go +++ b/modules/mesh-delivery-indexer/internal/index/repin_test.go @@ -2,11 +2,13 @@ package index import ( "context" + "fmt" "slices" "strings" "testing" "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/meshbuilds" "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-sdk/go/catalogue" @@ -97,4 +99,65 @@ func TestAReleaseRepinsAnEntryNamingItsPackageWithNoPin(t *testing.T) { said[0].CallKind != meshcatalog.CatalogRevisionEventCallKindRelease || said[1].Module != "mesh-sdk" || said[1].Version != "0.1.27" { t.Errorf("said %+v, want catalog-revision of each branch with the release's call", said) } + + // Design 47 H2 §805, H-A-418, H-A-420, H-A-424, H-A-436: a pipeline reserving twenty packages of mesh-sdk in main's + // revision 2 keeps one re-pin revision of main when its gathering settles, at its first step-ended; its release then + // keeps none on main, and a pipeline that did not pass withdraws its reservations back to the newest released version. + ix.Files = func(_ context.Context, _, _ string, dirs []string) (map[string]map[string]string, error) { + out := map[string]map[string]string{} + for _, d := range dirs { + out[d] = map[string]string{"go.mod": strings.Repeat("d", 40), "sdk.go": strings.Repeat("e", 40)} + } + return out, nil + } + heard := newMem() + ix.Heard = heard + revision := BranchObject("main", 2) + newest := func() int64 { + rev, _, _, err := readNewestOf(ctx, ix.Revisions, "main") + if err != nil { + t.Fatal(err) + } + return rev.Revision + } + for i := range 20 { + e := meshbuilds.VersionReservedEvent{Module: "mesh-sdk", Artifact: fmt.Sprintf("mesh-sdk:p%d", i), Path: "mesh-sdk/go", Version: "0.1.28", Revision: revision} + if err := ix.HearVersionReserved(ctx, e); err != nil { + t.Fatal(err) + } + } + if _, _, open, _ := heard.Get(ctx, SettlingKey(revision)); !open || newest() != 2 { + t.Fatalf("twenty reservations: gathering open %v, main's newest %d, want open and no revision kept before it settles", open, newest()) + } + if err := ix.Settle(ctx, revision); err != nil || newest() != 3 { + t.Fatalf("the gathering settled (%v) keeping main's newest %d, want one re-pin revision, 3", err, newest()) + } + if now, _ := moduleOf(t, mods, "g"); now.Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.28" { + t.Errorf("g after the reservations is pinned %v, want v0.1.28", now.Packages) + } + if err := ix.Settle(ctx, revision); err != nil || newest() != 3 { + t.Errorf("a second step-ended settled (%v) keeping main's newest %d, want still 3", err, newest()) + } + if _, err := ix.HearVersion(ctx, HeardVersion{Package: "mesh-sdk/go", GoModule: "git.novox.be/novox/mesh-sdk/go", Version: "0.1.28", Commit: strings.Repeat("1", 40), Published: true}); err != nil { + t.Fatal(err) + } + if _, err := ix.Repin(ctx, "mesh-sdk", "0.1.28"); err != nil || newest() != 3 { + t.Errorf("the release of the reserved 0.1.28 re-pinned (%v) keeping main's newest %d, want no revision more", err, newest()) + } + next := BranchObject("main", 3) + if err := ix.HearVersionReserved(ctx, meshbuilds.VersionReservedEvent{Module: "mesh-sdk", Artifact: "mesh-sdk:p0", Path: "mesh-sdk/go", Version: "0.1.29", Revision: next}); err != nil { + t.Fatal(err) + } + if err := ix.Settle(ctx, next); err != nil || newest() != 4 { + t.Fatalf("the reservation of 0.1.29 settled (%v) keeping main's newest %d, want 4", err, newest()) + } + if err := ix.Withdraw(ctx, "main", 3); err != nil || newest() != 5 { + t.Fatalf("the withdrawal (%v) kept main's newest %d, want 5", err, newest()) + } + if now, _ := moduleOf(t, mods, "g"); now.Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.28" { + t.Errorf("g after the withdrawal is pinned %v, want the newest released v0.1.28", now.Packages) + } + if _, _, kept, _ := heard.Get(ctx, ReservedKey(next, "mesh-sdk")); kept { + t.Errorf("the withdrawn reservation is still kept") + } } diff --git a/modules/mesh-delivery-indexer/internal/index/reserved.go b/modules/mesh-delivery-indexer/internal/index/reserved.go new file mode 100644 index 000000000..20540d277 --- /dev/null +++ b/modules/mesh-delivery-indexer/internal/index/reserved.go @@ -0,0 +1,432 @@ +package index + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "maps" + "slices" + "strings" + "time" + + "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" + "git.novox.be/novox/mesh-sdk/go/keys" +) + +// A release re-pins once, at its reservation (design 47 H2 §805; H-A-418, H-A-420, H-A-424). The builder says +// version-reserved when it reserves a package's number, naming the revision `.` its pipeline runs. The indexer +// writes the series' numbered version with the contents read at the commit of the module's entry in that revision, so +// acceptedSeries and releasedPins pin it, and keeps the reservation in its state heard under +// `reserved..`, each key living reserved-keep. It gathers a pipeline's reservations per revision and +// writes one re-pin revision of that revision's branch when the gathering settles: at the first pipeline-started or +// step-ended of that pipeline heard after them, or at the expiry of the key settling., written reserved-settle +// after the first. The release's package-published then +// moves no fingerprint. A pipeline-ended not passed whose revision holds reservations withdraws them: the series' +// numbered goes back to its newest released version and the importers are re-pinned to it. + +// ReservedPrefix begins every key of the state heard holding a revision's reservations of one module. +const ReservedPrefix = "reserved." + +// The defaults of the settings reserved-keep and reserved-settle (H-A-424 (1), (2)). +const ( + DefaultReservedKeep = 24 * time.Hour + DefaultReservedSettle = 30 * time.Second +) + +// ReservedKey is the key of module's reservations in revision, `reserved..`, the module escaped as a +// key's name is. +func ReservedKey(revision, module string) string { + return ReservedPrefix + revision + "." + keys.EscapeName(module) +} + +// Reservation is one version-reserved as the indexer keeps it. +type Reservation struct { + Artifact string `json:"artifact"` + Path string `json:"path"` + Version string `json:"version"` + Fingerprint string `json:"fingerprint,omitempty"` +} + +// Reserved is the value of a reserved key: a module's reservations in one revision. +type Reserved struct { + V int `json:"v"` + Revision string `json:"revision"` + Module string `json:"module"` + Reservations []Reservation `json:"reservations"` + At time.Time `json:"at"` +} + +// TTLStore is a Store that writes a new key with its own time to live (a state declared `key-ttl`). +type TTLStore interface { + CreateTTL(ctx context.Context, key string, value []byte, ttl time.Duration) error +} + +// SettlingPrefix begins the key of the state heard that holds a revision's gathering open, `settling.`, written +// with the key-ttl reserved-settle at its first reservation: its expiry, heard through the indexer's watch of heard +// (Expired), settles the gathering; the indexer holds no timer (ADR 0437 §8; H-A-436). +const SettlingPrefix = "settling." + +// SettlingKey is the key holding revision's gathering open. +func SettlingKey(revision string) string { return SettlingPrefix + revision } + +// HearVersionReserved takes one version-reserved in: the series' numbered version, the reservation kept and the revision's +// gathering begun. An error leaves the event for the bus to give again. +func (ix *Indexer) HearVersionReserved(ctx context.Context, e meshbuilds.VersionReservedEvent) error { + if ix.Heard == nil { + return errors.New("the indexer keeps no state " + HeardState) + } + _, ok, err := ix.branchOfRevision(ctx, e.Revision) + if err != nil { + return err + } + if !ok { + ix.logf("versions: the version-reserved of %s %s names the revision %q, which is of no watched branch: left", e.Artifact, e.Version, e.Revision) + return nil + } + if err := ix.keepNumbered(ctx, e); err != nil { + return err + } + if err := ix.keepReservation(ctx, e); err != nil { + return err + } + ix.logf("versions: %s reserved %s %s in %s; its importers are re-pinned once the pipeline's reservations settle", e.Module, e.Path, e.Version, e.Revision) + return ix.gather(ctx, e.Revision) +} + +// branchOfRevision is the watched branch (the trunk among them) whose revision name is revision, `.`. +func (ix *Indexer) branchOfRevision(ctx context.Context, revision string) (string, bool, error) { + branches, err := ix.watchedBranches(ctx) + if err != nil { + return "", false, err + } + if !slices.Contains(branches, TrunkBranch) { + branches = append(branches, TrunkBranch) + } + for _, b := range branches { + if _, ok := BranchRevisionOf(b, revision); ok { + return b, true, nil + } + } + return "", false, nil +} + +// seriesOfPath is the series key and value of the package path names in series: the key whose name or Go module is path. +func (ix *Indexer) seriesOfPath(ctx context.Context, path, series string) (string, SeriesPackage, bool) { + all := ix.SeriesAll(ctx) + for _, key := range slices.Sorted(maps.Keys(all)) { + if s := all[key]; s.Series == series && (s.Name == path || s.GoModule == path) { + return key, s, true + } + } + return SeriesKey(path, series), SeriesPackage{}, false +} + +// keepNumbered writes the reserved version as its series' numbered one, with the contents read at the commit of the +// module's entry in the event's revision (H-A-418 (2)); an older version than the numbered held changes nothing. +func (ix *Indexer) keepNumbered(ctx context.Context, e meshbuilds.VersionReservedEvent) error { + series, ok := SeriesOf(e.Version) + if ix.Packages == nil || e.Path == "" || !ok { + return nil + } + key, s, _ := ix.seriesOfPath(ctx, e.Path, series) + v := SeriesVersion{Version: strings.TrimPrefix(e.Version, "v"), Fingerprint: e.Fingerprint} + if ix.Revisions != nil { + _, entries, err := ReadRevision(ctx, ix.Revisions, e.Revision) + if err != nil { + return fmt.Errorf("the revision %s of %s's reservation: %w", e.Revision, e.Module, err) + } + if i := slices.IndexFunc(entries, func(x meshcatalog.CatalogEntry) bool { return x.Module == e.Module }); i >= 0 { + v.Commit = entries[i].Commit + if s.GoModule != "" && v.Commit != "" && ix.Files != nil { + got, err := ix.packagesAt(ctx, entries[i].Repository, v.Commit, []string{s.GoModule}, nil) + switch p, found := got[s.GoModule]; { + case err != nil: + ix.logf("versions: %s %s's contents at %.12s are not read, so its importers are not pinned to it before its publish: %v", e.Path, e.Version, v.Commit, err) + case !found: + ix.logf("versions: the forge's listing at %.12s holds no Go module %s, so %s's importers are not pinned to it before its publish", v.Commit, s.GoModule, e.Version) + default: + p.At = ptr(ix.now().UTC()) + v.Contents = contentsOfPublished(p) + } + } + } else { + ix.logf("versions: the revision %s holds no entry of %s, so %s %s is numbered with no contents", e.Revision, e.Module, e.Path, e.Version) + } + } + return write(ctx, ix.Packages, key, func(value []byte, found bool) ([]byte, bool, error) { + held := SeriesPackage{V: keys.Version, Name: e.Path, Series: series} + if found { + if err := json.Unmarshal(value, &held); err != nil { + return nil, false, err + } + } + if n := held.Numbered; n != nil && (CompareVersions("v"+n.Version, "v"+v.Version) > 0 || n.Version == v.Version && n.Contents != nil) { + return nil, false, nil + } + held.Numbered = numberedOf(v) + held.At = ptr(ix.now()) + next, err := json.Marshal(held) + return next, false, err + }) +} + +// keepReservation keeps e under its revision and module in the state heard, the key living reserved-keep: a module's +// further reservation in the revision is added to its key, which is written again with its time to live. +func (ix *Indexer) keepReservation(ctx context.Context, e meshbuilds.VersionReservedEvent) error { + key := ReservedKey(e.Revision, e.Module) + r := Reservation{Artifact: e.Artifact, Path: e.Path, Version: e.Version, Fingerprint: e.Fingerprint} + for range writeTries { + value, rev, found, err := ix.Heard.Get(ctx, key) + if err != nil { + return err + } + held := Reserved{V: keys.Version, Revision: e.Revision, Module: e.Module, At: ix.now().UTC()} + if found { + if err := json.Unmarshal(value, &held); err != nil { + return fmt.Errorf("heard.%s: %w", key, err) + } + if slices.Contains(held.Reservations, r) { + return nil + } + } + held.Reservations = append(held.Reservations, r) + data, err := json.Marshal(held) + if err != nil { + return err + } + if found { + if err := ix.Heard.Delete(ctx, key, rev); errors.Is(err, ErrConflict) { + continue + } else if err != nil { + return err + } + } + err = ix.createTTL(ctx, key, data) + if errors.Is(err, ErrConflict) { + continue + } + return err + } + return fmt.Errorf("heard.%s: %w", key, ErrConflict) +} + +// createTTL creates key in the state heard living reserved-keep (createTTLFor). +func (ix *Indexer) createTTL(ctx context.Context, key string, data []byte) error { + keep := ix.ReservedKeep + if keep <= 0 { + keep = DefaultReservedKeep + } + return ix.createTTLFor(ctx, key, data, keep) +} + +// createTTLFor creates key in the state heard living ttl; a store that keeps no time to live per key keeps it with none, +// said. +func (ix *Indexer) createTTLFor(ctx context.Context, key string, data []byte, ttl time.Duration) error { + if st, ok := ix.Heard.(TTLStore); ok { + return st.CreateTTL(ctx, key, data, ttl) + } + ix.logf("versions: the state %s keeps no time to live per key here, so %s is kept with none", HeardState, key) + return ix.Heard.Create(ctx, key, data) +} + +// reservedOf are the reservations revision holds, by module. +func (ix *Indexer) reservedOf(ctx context.Context, revision string) (map[string]Reserved, map[string]uint64, error) { + if ix.Heard == nil { + return nil, nil, nil + } + all, err := ix.Heard.Keys(ctx) + if err != nil { + return nil, nil, err + } + out, revs := map[string]Reserved{}, map[string]uint64{} + prefix := ReservedPrefix + revision + "." + for _, key := range all { + if !strings.HasPrefix(key, prefix) { + continue + } + value, rev, found, err := ix.Heard.Get(ctx, key) + if err != nil { + return nil, nil, err + } + var r Reserved + if !found || json.Unmarshal(value, &r) != nil || r.Revision != revision { + continue + } + out[key], revs[key] = r, rev + } + return out, revs, nil +} + +// gather begins revision's gathering, if none is open: the key settling., living reserved-settle. +func (ix *Indexer) gather(ctx context.Context, revision string) error { + settle := ix.ReservedSettle + if settle <= 0 { + settle = DefaultReservedSettle + } + data, err := json.Marshal(map[string]any{"revision": revision, "at": ix.now().UTC()}) + if err != nil { + return err + } + err = ix.createTTLFor(ctx, SettlingKey(revision), data, settle) + if errors.Is(err, ErrConflict) { + return nil // a gathering is open already + } + return err +} + +// GatherKept settles, at the start, every revision the state heard holds reservations of whose gathering is not open any +// more: a settle cut by a restart is made then (one that moves nothing keeps no revision). An open one settles at its +// expiry or its pipeline's next word. +func (ix *Indexer) GatherKept(ctx context.Context) error { + if ix.Heard == nil { + return nil + } + all, err := ix.Heard.Keys(ctx) + if err != nil { + return err + } + revisions := map[string]bool{} + for _, key := range all { + if !strings.HasPrefix(key, ReservedPrefix) { + continue + } + value, _, found, err := ix.Heard.Get(ctx, key) + var r Reserved + if err != nil || !found || json.Unmarshal(value, &r) != nil || slices.Contains(all, SettlingKey(r.Revision)) { + continue + } + revisions[r.Revision] = true + } + var errs []error + for _, revision := range slices.Sorted(maps.Keys(revisions)) { + errs = append(errs, ix.settleNow(ctx, revision)) + } + return errors.Join(errs...) +} + +// Settle settles revision's gathering, if one is open (a pipeline-started or step-ended of its pipeline): its key goes, and +// every importer of the modules it reserved is re-pinned in one revision of its branch. None open settles nothing. +func (ix *Indexer) Settle(ctx context.Context, revision string) error { + if ix.Heard == nil { + return nil + } + key := SettlingKey(revision) + _, rev, found, err := ix.Heard.Get(ctx, key) + if err != nil || !found { + return err + } + if err := ix.Heard.Delete(ctx, key, rev); errors.Is(err, ErrConflict) { + return nil // settled by another word, or by its expiry + } else if err != nil { + return err + } + return ix.settleNow(ctx, revision) +} + +// Expired takes in a key of the state heard that its time to live ended, as the watch of heard hands it over: a +// gathering's key settles that gathering (H-A-436); any other key is passed over. +func (ix *Indexer) Expired(ctx context.Context, key string) error { + revision, ok := strings.CutPrefix(key, SettlingPrefix) + if !ok { + return nil + } + return ix.settleNow(ctx, revision) +} + +// settleNow re-pins every importer of the modules revision reserved in one revision of its branch. +func (ix *Indexer) settleNow(ctx context.Context, revision string) error { + held, _, err := ix.reservedOf(ctx, revision) + if err != nil || len(held) == 0 { + return err + } + branch, ok, err := ix.branchOfRevision(ctx, revision) + if err != nil || !ok { + return err + } + modules := modulesOf(held) + _, err = ix.repinModules(ctx, branch, modules, reservedCall(revision, len(modules), false)) + return err +} + +// Withdraw takes a pipeline-ended not passed of branch's revision in: each reservation the revision holds is withdrawn, its +// series' numbered set back to the newest released version, its importers re-pinned to that, and its key deleted. +func (ix *Indexer) Withdraw(ctx context.Context, branch string, revision int64) error { + if ix.Heard == nil { + return nil + } + name := BranchObject(branch, revision) + if _, rev, found, err := ix.Heard.Get(ctx, SettlingKey(name)); err == nil && found { + _ = ix.Heard.Delete(ctx, SettlingKey(name), rev) // the gathering is withdrawn with it + } + held, revs, err := ix.reservedOf(ctx, name) + if err != nil || len(held) == 0 { + return err + } + for _, r := range held { + for _, one := range r.Reservations { + if err := ix.withdrawNumbered(ctx, one); err != nil { + return err + } + } + } + modules := modulesOf(held) + if _, err := ix.repinModules(ctx, branch, modules, reservedCall(name, len(modules), true)); err != nil { + return err + } + for key, rev := range revs { + if err := ix.Heard.Delete(ctx, key, rev); err != nil && !errors.Is(err, ErrConflict) { + return err + } + } + ix.logf("versions: the %d reservations of %s are withdrawn, their importers re-pinned to the newest released versions", len(held), name) + return nil +} + +// withdrawNumbered sets the series' numbered version back to its newest released one while it is the version r reserved. +func (ix *Indexer) withdrawNumbered(ctx context.Context, r Reservation) error { + series, ok := SeriesOf(r.Version) + if ix.Packages == nil || !ok { + return nil + } + key, _, found := ix.seriesOfPath(ctx, r.Path, series) + if !found { + return nil + } + return write(ctx, ix.Packages, key, func(value []byte, found bool) ([]byte, bool, error) { + var s SeriesPackage + if !found || json.Unmarshal(value, &s) != nil || s.Numbered == nil || s.Numbered.Version != strings.TrimPrefix(r.Version, "v") { + return nil, false, nil + } + s.Numbered = nil + if s.Newest != nil { + s.Numbered = numberedOf(*s.Newest) + } + s.At = ptr(ix.now()) + next, err := json.Marshal(s) + return next, false, err + }) +} + +// modulesOf are the modules of a revision's reservations, sorted. +func modulesOf(held map[string]Reserved) []string { + var out []string + for _, r := range held { + if !slices.Contains(out, r.Module) { + out = append(out, r.Module) + } + } + slices.Sort(out) + return out +} + +// reservedCall is the call of the re-pin revision of a revision's reservations: a release's re-pin, made at its reservation +// (§805), or at their withdrawal. +func reservedCall(revision string, modules int, withdrawn bool) revisionCall { + call := fmt.Sprintf("release of %s's %d reserved modules", revision, modules) + if withdrawn { + call = fmt.Sprintf("release of %s's %d reserved modules withdrawn", revision, modules) + } + return revisionCall{Call: call, Kind: meshcatalog.CatalogRevisionCallKindRelease} +} diff --git a/modules/mesh-delivery-indexer/internal/index/series.go b/modules/mesh-delivery-indexer/internal/index/series.go index 8b61e4828..c6df3fa9e 100644 --- a/modules/mesh-delivery-indexer/internal/index/series.go +++ b/modules/mesh-delivery-indexer/internal/index/series.go @@ -177,7 +177,8 @@ func acceptedSeries(series map[string]SeriesPackage, m catalogue.Manifest, repos var pins sdkstep.PackageVersions for _, key := range slices.Sorted(maps.Keys(series)) { s := series[key] - if s.GoModule == "" || s.Newest == nil || s.Newest.Contents == nil || m.AcceptedSeries(s.Name) != s.Series { + pinned := pinnedVersion(s) + if s.GoModule == "" || pinned == nil || pinned.Contents == nil || m.AcceptedSeries(s.Name) != s.Series { continue } if repo, _, ok := trunk.PackageRepository(s.GoModule); !ok || trunk.SameRepository(repo, repository) { @@ -186,8 +187,8 @@ func acceptedSeries(series map[string]SeriesPackage, m catalogue.Manifest, repos if out == nil { out, pins = maps.Clone(published), sdkstep.PackageVersions{} } - p := publishedOfContents(*s.Newest.Contents) - version := "v" + s.Newest.Version + p := publishedOfContents(*pinned.Contents) + version := "v" + pinned.Version p.Commit = version out[s.GoModule], pins[s.GoModule] = p, version } @@ -197,6 +198,17 @@ func acceptedSeries(series map[string]SeriesPackage, m catalogue.Manifest, repos return out, pins } +// pinnedVersion is the version of a series its users are pinned to: its numbered one when a reservation wrote it with its +// contents and it is newer than the newest released (design 47 H2 §805, H-A-418 (2), H-A-424 (4)), else the newest; nil +// for none. +func pinnedVersion(s SeriesPackage) *SeriesVersion { + if n := s.Numbered; n != nil && n.Contents != nil && (s.Newest == nil || CompareVersions("v"+s.Newest.Version, "v"+n.Version) < 0) { + p := publishedOfNumbered(*n.Contents) + return &SeriesVersion{Version: n.Version, Commit: n.Commit, Digest: n.Digest, Fingerprint: n.Fingerprint, Contents: contentsOfPublished(p)} + } + return s.Newest +} + // KeepPackageNames writes, at a trunk merge, each package artifact's name in its own ecosystem into its series key // (design 32): a Go package's module path from the go.mod under its paths at the merge commit, a TypeScript package's // package.json name, each read through the forge. The key keeps what it held and gains the name and the module and diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index 8300429f3..394a2851a 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -645,10 +645,16 @@ func (ix *Indexer) Repin(ctx context.Context, module, version string) (int, erro return named, nil } -// repinBranch re-pins branch's importers of module at version: the trunk in place, another branch as a dry run over its -// revision view, whose scratch goes once it is kept (design 47 H2 §804). It answers how many modules it named. +// repinBranch re-pins branch's importers of module at version (repinModules). func (ix *Indexer) repinBranch(ctx context.Context, branch, module, version string) (int, error) { - x, call := ix, releaseCall(module, version) + return ix.repinModules(ctx, branch, []string{module}, releaseCall(module, version)) +} + +// repinModules re-pins branch's importers of modules in one revision kept with call: the trunk in place, another branch +// as a dry run over its revision view, whose scratch goes once it is kept (design 47 H2 §804, §805). It answers how many +// modules it named. +func (ix *Indexer) repinModules(ctx context.Context, branch string, modules []string, call revisionCall) (int, error) { + x := ix if !isTrunkBranch(branch) { view, nodes, _, err := BranchView(ctx, ix.Revisions, branch) if err != nil { @@ -660,12 +666,19 @@ func (ix *Indexer) repinBranch(ctx context.Context, branch, module, version stri d.ix.Logf = func(format string, args ...any) { ix.logf("re-pin of "+branch+": "+format, args...) } x = d.ix } - only, err := x.repinned(ctx, module) - if err != nil || len(only) == 0 { - return 0, err + only := map[string]bool{} + for _, module := range modules { + some, err := x.repinned(ctx, module) + if err != nil { + return 0, err + } + maps.Copy(only, some) + } + if len(only) == 0 { + return 0, nil } x.recompute.Lock() - err = x.recomputeLocked(ctx, nil, nil, "", only) + err := x.recomputeLocked(ctx, nil, nil, "", only) x.recompute.Unlock() if err != nil { return len(only), err diff --git a/modules/mesh-delivery-indexer/internal/index/versions.go b/modules/mesh-delivery-indexer/internal/index/versions.go index 52a08b239..71336e1f3 100644 --- a/modules/mesh-delivery-indexer/internal/index/versions.go +++ b/modules/mesh-delivery-indexer/internal/index/versions.go @@ -395,10 +395,11 @@ func releasedPins(versions sdkstep.PackageVersions, series map[string]SeriesPack } out[p] = "" for _, s := range series { - if s.GoModule != p || s.Newest == nil || s.Series != m.AcceptedSeries(s.Name) { + pinned := pinnedVersion(s) + if s.GoModule != p || pinned == nil || s.Series != m.AcceptedSeries(s.Name) { continue } - v := strings.TrimPrefix(s.Newest.Version, "v") + v := strings.TrimPrefix(pinned.Version, "v") if _, ok := versionParts(v); ok && (out[p] == "" || compareVersions(v, strings.TrimPrefix(out[p], "v")) > 0) { out[p] = "v" + v } diff --git a/modules/mesh-delivery-indexer/manifest_test.go b/modules/mesh-delivery-indexer/manifest_test.go index ac6d421df..acdaa0f5b 100644 --- a/modules/mesh-delivery-indexer/manifest_test.go +++ b/modules/mesh-delivery-indexer/manifest_test.go @@ -72,6 +72,7 @@ type manifest struct { Scope string `json:"scope"` Serves []string `json:"serves"` } `json:"claims"` + Config map[string]any `json:"config"` // the settings (design 47 H2 §805) Tools []string `json:"tools"` Emits []string `json:"emits"` Consumes []string `json:"consumes"` @@ -133,8 +134,9 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build if !slices.Equal(m.Uses, []string{"operator-channel"}) || !slices.Contains(m.Invokes, "seat:mesh-module-assigner.assignments") || !slices.Contains(m.Invokes, "seat:mesh-module-assigner.placement") { t.Errorf("uses = %v, invokes = %v, want the seat operator-channel used and seat:mesh-module-assigner.assignments invoked", m.Uses, m.Invokes) } - // 1126 note 76: heard keeps the last 64 FORGE messages the indexer handled, for indexer_heard. - if want := []state{{Name: "candidates", History: 10}, {Name: "heard", History: 64}, {Name: "manifests", History: 1}, {Name: "predefined", History: 5}, {Name: "taken", History: 1}, {Name: "takeins", History: 1}, {Name: "oldsections", History: 1}, {Name: index.RunsState, History: 1}, {Name: index.PackagesState, History: index.PackagesHistory}, + // 1126 note 76: heard keeps the last 64 FORGE messages the indexer handled, for indexer_heard; 8 MiB, each reservation + // and each gathering of them a key of its own time to live (design 47 H2 §805, H-A-420 (3), H-A-436). + if want := []state{{Name: "candidates", History: 10}, {Name: "heard", History: 64, MaxMiB: 8, KeyTTL: true}, {Name: "manifests", History: 1}, {Name: "predefined", History: 5}, {Name: "taken", History: 1}, {Name: "takeins", History: 1}, {Name: "oldsections", History: 1}, {Name: index.RunsState, History: 1}, {Name: index.PackagesState, History: index.PackagesHistory}, {Name: views.MarksState, History: 1}, {Name: index.FindingsState, History: 5}, {Name: views.StatusState, History: 1}, {Name: index.RequirementsState, History: 5}, {Name: index.SeatDefinitionsState, History: 5}, {Name: index.EntryIndexState, History: 1, MaxMiB: 8}, {Name: index.NamedState, History: 1, MaxMiB: 4}, // design 47 G §695 @@ -173,7 +175,7 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build // "Reads FORGE" is a consumes of the indexer's stream: the broker grants only buckets by reads (mesh-control // internal/broker/state.go:62-93). // The registry seats' published fill each (§413: no consume of version.numbered) package's series (DLV-I5, design 51 *The versions*). - if want := []string{"go-package-registry.published", "mesh-build-go.toolchain.reported", "mesh-build-node.toolchain.reported", "mesh-builds.package-published", "mesh-builds.toolchain-agreed", "mesh-catalog.catalog-revision", "mesh-catalog.registration-changed", "mesh-catalog.room", "mesh-conditions.findings-asked", + if want := []string{"go-package-registry.published", "mesh-build-go.toolchain.reported", "mesh-build-node.toolchain.reported", "mesh-builds.package-published", "mesh-builds.step-ended", "mesh-builds.toolchain-agreed", "mesh-builds.version-reserved", "mesh-catalog.catalog-revision", "mesh-catalog.registration-changed", "mesh-catalog.room", "mesh-conditions.findings-asked", "mesh-delivery.source-moved", "mesh-pipeline-runner.pipeline-ended", "mesh-pipeline-runner.pipeline-started", "mesh-pipeline-runner.run-started", "mesh-wants.pipeline-wanted", "mesh-wants.wait-ended", "mesh-wants.wanted", "node-build-go.step-ended", "node-engine.running", "npm-package-registry.published", "operator-channel.decided", "seat:mesh-module-assigner.views.assignments", "seat:mesh-module-assigner.views.seat-holders"}; !reflect.DeepEqual(sorted(m.Consumes), want) { t.Errorf("consumes = %v, want %v", m.Consumes, want) } diff --git a/modules/mesh-delivery-indexer/module.json b/modules/mesh-delivery-indexer/module.json index b6a7943b6..dc1ad3aac 100644 --- a/modules/mesh-delivery-indexer/module.json +++ b/modules/mesh-delivery-indexer/module.json @@ -82,6 +82,8 @@ "seat:mesh-module-assigner.views.assignments", "seat:mesh-module-assigner.views.seat-holders", "mesh-builds.package-published", + "mesh-builds.version-reserved", + "mesh-builds.step-ended", "mesh-builds.toolchain-agreed", "node-build-go.step-ended", "mesh-wants.wait-ended", @@ -98,9 +100,25 @@ "operator-channel.decided", "npm-package-registry.published" ], + "config": { + "reserved-keep": { + "type": "string", + "description": "how long the indexer keeps a pipeline's reservation of a package's version in its state heard (reserved..), a Go duration (design 47 H2 §805, H-A-424 (2)).", + "trusted": false, + "default": "24h", + "runtime": true + }, + "reserved-settle": { + "type": "string", + "description": "how long after a revision's first reservation its importers are re-pinned at the latest, when no pipeline-started or step-ended of its pipeline came first, a Go duration (design 47 H2 §805, H-A-424 (1), H-A-436).", + "trusted": false, + "default": "30s", + "runtime": true + } + }, "state": [ { "name": "candidates", "history": 10 }, - { "name": "heard", "history": 64 }, + { "name": "heard", "history": 64, "max-mib": 8, "key-ttl": true }, { "name": "manifests", "history": 1 }, { "name": "predefined", "history": 5 }, { "name": "taken", "history": 1 }, From ba54f82a701d0c957db9909ba2b83b4356c32bb6 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 01:49:26 +0100 Subject: [PATCH 07/16] I6 (1): the judge refuses an uncapped delivery store and a seat claim with no class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A delivery module (one claiming a seat of the delivery system, read from the seat list's definitions) is refused for a state, log or objects entry with no cap, in its old section or in requires; a seat-claiming manifest names class core or leaf; finding-events is 8 MiB, 7 days; the objects template takes max-age-days. internal/beside says a group's check reads the catalog member's head beside it, main only when the catalog is not in the group. Red until the captured catalog is refreshed (I6 (5)): judge TestRulesSecrets/EveryCatalogueIdentityFitsWhatItRequires, TestRulesSecrets/ParseManifestForInputsReadsAValueFallingBackToAPredefinedKey, TestRulesPlacement/TheCataloguesBarPlacesBlocksAndItsShapeCoversEveryShow, TestRulesBus/NoCatalogueManifestNamesAnInstallation; internal/index TestAnArtifactOfNoToolchainHasNoLanguageAndNoLock, TestAMergedManifestIsKeptOnceByItsDigestAndNamedByTheModule, TestAModuleWithNoToolchainArtifactGetsItsFingerprintAtOnce, TestAManifestFallingBackToAPredefinedKeyIsRead (each a captured catalog manifest with no class, or finding-events at 16). Builds: design 47 H2 §814, §820, §783; H-A-394 (1), H-A-411 (1) (4), H-A-415 (1), H-A-428, H-A-430 (3), H-A-434 --- .../internal/beside/beside.go | 5 +- .../internal/index/inputs_test.go | 2 + .../internal/index/toolchains_test.go | 2 +- .../mesh-delivery-indexer/judge/busstate.go | 8 +- .../judge/busstate_test.go | 3 +- .../judge/g_words_test.go | 20 ++++- modules/mesh-delivery-indexer/judge/gwords.go | 7 +- modules/mesh-delivery-indexer/judge/judge.go | 1 + .../mesh-delivery-indexer/judge/judge_test.go | 4 +- modules/mesh-delivery-indexer/judge/rules.go | 2 + .../mesh-delivery-indexer/judge/rules_test.go | 58 +++++++------- modules/mesh-delivery-indexer/judge/stores.go | 79 +++++++++++++++++++ 12 files changed, 148 insertions(+), 43 deletions(-) create mode 100644 modules/mesh-delivery-indexer/judge/stores.go diff --git a/modules/mesh-delivery-indexer/internal/beside/beside.go b/modules/mesh-delivery-indexer/internal/beside/beside.go index d1cd8ffdd..dbc5d3250 100644 --- a/modules/mesh-delivery-indexer/internal/beside/beside.go +++ b/modules/mesh-delivery-indexer/internal/beside/beside.go @@ -21,8 +21,9 @@ // read mesh-sdk and mesh-catalog. None reads mesh-controller, which ended by its unassignment (novox/hq // ADR 0590). In a mesh where either module has no source repository nothing is // cloned, and these tests fail loudly with "not beside this check": a cause in the setup, not in the -// change. And in a delivery group that holds a mesh-catalog pull request, these tests read the -// catalogue's main, not the group's head. +// change. In a delivery group that holds a mesh-catalog member, these tests read that member's head, the +// sibling the group's check places in MESH_CHECK_BESIDE, and the catalogue's main only when the catalogue is +// not in the group: a group is judged against its own heads (ADR 0573 §2; design 47 H2 §814, H-A-428). // - Anywhere else, the test judges against the copy captured in this repository's testdata/beside, at the // commit testdata/beside/CAPTURED names. Never against a developer's own checkout: to judge one, set // MESH_CHECK_BESIDE to the directory holding it, as the check does. diff --git a/modules/mesh-delivery-indexer/internal/index/inputs_test.go b/modules/mesh-delivery-indexer/internal/index/inputs_test.go index cfd34caaa..5b1dd2af0 100644 --- a/modules/mesh-delivery-indexer/internal/index/inputs_test.go +++ b/modules/mesh-delivery-indexer/internal/index/inputs_test.go @@ -160,7 +160,9 @@ func TestAContextIsNotPinned(t *testing.T) { // 1450 (the rule 1444 keeps: conte // build-agent's manifest from mesh-controller at f2d7bc94 has an image artifact built from a context in another repository. // Its claim of the retired seat node-build-agent is read as a claim of a build seat: the parser refuses a retired seat // since R4g (mesh-sdk A9a), and the claim is not what this test is about. + // It names no class, which a seat-claiming manifest names since design 47 H2 §814: given here. raw := strings.ReplaceAll(fixture(t, "controller-f2d7bc94-build-agent"), `"node-build-agent"`, `"node-build-go"`) + raw = strings.Replace(raw, `"claims"`, `"class": "core", "claims"`, 1) in := inputsOf("build-agent", raw, "t", nil, noBases) if in.Kept == nil || in.None2 != None2Context { t.Errorf("kept %+v none2 %q, want none2 %q", in.Kept, in.None2, None2Context) diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go index 059aa977b..5daee1f26 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go @@ -208,7 +208,7 @@ func theBuildModuleOfALanguageIsTheHolderOfItsBuildSeat(t *testing.T) { t.Errorf("two seats building go and two holders of node-build-node: %+v %q, want none, both said", by, problems) } // The indexer finds them among the manifests it holds, and a report of a module that holds no build seat is left out. - builder := `{"module":"go-builds","version":"1","claims":[{"name":"node-build-go"}],"streams":[{"name":"toolchains-go","events":["toolchain.**"]}]}` + builder := `{"module":"go-builds","version":"1","class":"core","claims":[{"name":"node-build-go"}],"streams":[{"name":"toolchains-go","events":["toolchain.**"]}]}` ix, _ := newFormIndexer(t, mod{"avahi", catalogueManifest(t, "avahi")}, mod{"go-builds", builder}) ix.UseBuildModules(nil) got, err := ix.BuildModulesNow(context.Background(), defs) diff --git a/modules/mesh-delivery-indexer/judge/busstate.go b/modules/mesh-delivery-indexer/judge/busstate.go index ef911ecdf..b287c2676 100644 --- a/modules/mesh-delivery-indexer/judge/busstate.go +++ b/modules/mesh-delivery-indexer/judge/busstate.go @@ -87,10 +87,12 @@ var busTemplates = map[string]busTemplate{ }, catalogue.TemplateObjects: { storage: catalogue.StorageObjectStore, - fixed: "what happens when full (a new object is refused) and that objects are kept for good", + fixed: "what happens when full (a new object is refused)", + // max-age-days is how long the bus keeps an object; absent, objects are kept for good (design 47 H2 §820; H-A-434). options: map[string]optionRule{ - catalogue.OptionCapMiB: {kind: optionInt, least: catalogue.ObjectsLeastMiB, most: catalogue.ObjectsMostMiB, required: true}, - catalogue.OptionGrant: {kind: optionText}, + catalogue.OptionCapMiB: {kind: optionInt, least: catalogue.ObjectsLeastMiB, most: catalogue.ObjectsMostMiB, required: true}, + catalogue.OptionAgeDays: {kind: optionInt, least: 1, most: 3650}, + catalogue.OptionGrant: {kind: optionText}, }, }, catalogue.TemplateLedger: { diff --git a/modules/mesh-delivery-indexer/judge/busstate_test.go b/modules/mesh-delivery-indexer/judge/busstate_test.go index 8616e4253..6c526d7b9 100644 --- a/modules/mesh-delivery-indexer/judge/busstate_test.go +++ b/modules/mesh-delivery-indexer/judge/busstate_test.go @@ -27,7 +27,7 @@ func TestBusStateIsJudgedOnce(t *testing.T) { // 1966/AC8: a state, a log, objects and a ledger within bounds {"within bounds", manifest(`{"name":"cache","storage":"key-value","template":"state","options":{"history":8,"key-ttl":true}},` + `{"name":"audit","storage":"stream","template":"log","options":{"max-mib":64,"max-age-days":365}},` + - `{"name":"files","storage":"object-store","template":"objects","options":{"max-mib":2048}},` + ledger), nil}, + `{"name":"files","storage":"object-store","template":"objects","options":{"max-mib":2048,"max-age-days":7}},` + ledger), nil}, // Design 47: every kept data may say its form and its catch-up tool, in an old section and in `requires` by template, // and is accepted as read; one saying neither reads as before. {"a form and a catch-up tool on every kept kind", `{"module":"a","version":"1.0","tools":["a_take_in"],` + @@ -60,6 +60,7 @@ func TestBusStateIsJudgedOnce(t *testing.T) { {"deliveries 11", manifest(`{"name":"x","storage":"stream","template":"work-queue","options":{"events":["job"],"max-deliveries":11}}`), []string{"\"x\"", "\"max-deliveries\" is 11", "1 to 10"}}, {"duplicates past the age", manifest(`{"name":"x","storage":"stream","template":"work-queue","options":{"events":["job"],"max-age-days":1,"duplicates":86401}}`), []string{"\"x\"", "\"duplicates\"", "longer than the queue's age of 1 days"}}, {"log age 3651", manifest(`{"name":"x","storage":"stream","template":"log","options":{"max-age-days":3651}}`), []string{"\"x\"", "\"max-age-days\" is 3651"}}, + {"objects age 3651 (H2 §820)", manifest(`{"name":"x","storage":"object-store","template":"objects","options":{"max-mib":64,"max-age-days":3651}}`), []string{"\"x\"", "\"max-age-days\" is 3651"}}, {"objects without a cap", manifest(`{"name":"x","storage":"object-store","template":"objects"}`), []string{"\"x\"", "\"max-mib\" is missing"}}, {"when full given as an option", manifest(`{"name":"x","storage":"stream","template":"log","options":{"when-full":"drop-oldest"}}`), []string{"\"x\"", "\"when-full\"", "fixed"}}, // A-277: a state's max-mib is an option of its template; an approvals state is §677's (key-ttl, 48 hours, at most 64 MiB). diff --git a/modules/mesh-delivery-indexer/judge/g_words_test.go b/modules/mesh-delivery-indexer/judge/g_words_test.go index 7e74fe5a8..6f08177e6 100644 --- a/modules/mesh-delivery-indexer/judge/g_words_test.go +++ b/modules/mesh-delivery-indexer/judge/g_words_test.go @@ -2,6 +2,7 @@ package judge import ( "git.novox.be/novox/mesh-sdk/go/catalogue" + "git.novox.be/novox/mesh-sdk/go/seatdef" "regexp" "strings" "testing" @@ -9,6 +10,9 @@ import ( // Design 47 G §368, §386, §387, §89: the manifest validator reads the manifests' new words before any manifest uses them. func TestTheJudgeReadsMilestoneGsWords(t *testing.T) { + was := deliverySeats.Load() + useDeliverySeats([]seatdef.Definition{{Seat: "thing", Domain: deliveryDomain}}) + t.Cleanup(func() { deliverySeats.Store(was) }) for _, row := range []struct { name string raw string @@ -33,12 +37,24 @@ func TestTheJudgeReadsMilestoneGsWords(t *testing.T) { `"streams":[{"name":"a-findings","events":["finding-written"],"retention":"history"}],"consumes":["mesh-conditions.findings-asked"]}`, want: "old sections"}, {name: "another part's findings in its requires (§529)", raw: `{"module":"a","version":"1.0","consumes":["mesh-conditions.findings-asked"],"requires":[` + `{"name":"findings","storage":"key-value","template":"state"},` + - `{"name":"finding-events","storage":"stream","template":"events","options":{"events":["finding-written.*","finding-cleared.*","findings-stated.*"],"max-age-days":7,"max-mib":16}}]}`}, + `{"name":"finding-events","storage":"stream","template":"events","options":{"events":["finding-written.*","finding-cleared.*","findings-stated.*"],"max-age-days":7,"max-mib":8}}]}`}, {name: "another part's findings without the finding events (§529)", raw: `{"module":"a","version":"1.0","consumes":["mesh-conditions.findings-asked"],"requires":[` + `{"name":"findings","storage":"key-value","template":"state"}]}`, want: "finding-events"}, {name: "another part's finding events not kept 7 days (§529)", raw: `{"module":"a","version":"1.0","consumes":["mesh-conditions.findings-asked"],"requires":[` + `{"name":"findings","storage":"key-value","template":"state"},` + - `{"name":"finding-events","storage":"stream","template":"events","options":{"events":["finding-written.*","finding-cleared.*","findings-stated.*"],"max-age-days":30,"max-mib":16}}]}`, want: "max-age-days"}, + `{"name":"finding-events","storage":"stream","template":"events","options":{"events":["finding-written.*","finding-cleared.*","findings-stated.*"],"max-age-days":30,"max-mib":8}}]}`, want: "max-age-days"}, + {name: "another part's finding events of 16 MiB (H2 §820, H-A-411 (1))", raw: `{"module":"a","version":"1.0","consumes":["mesh-conditions.findings-asked"],"requires":[` + + `{"name":"findings","storage":"key-value","template":"state"},` + + `{"name":"finding-events","storage":"stream","template":"events","options":{"events":["finding-written.*","finding-cleared.*","findings-stated.*"],"max-age-days":7,"max-mib":16}}]}`, want: "max-mib"}, + {name: "a delivery module's uncapped old-section state (H2 §814)", raw: `{"module":"d","version":"1.0","class":"core","claims":[{"name":"thing","scope":"mesh"}],"state":["s"]}`, want: `state "s" in its old section names none`}, + {name: "a delivery module's uncapped state in requires (H2 §814)", raw: `{"module":"d","version":"1.0","class":"core","claims":[{"name":"thing","scope":"mesh"}],` + + `"requires":[{"name":"s","storage":"key-value","template":"state"}]}`, want: `state "s" in ` + "`requires`"}, + {name: "a delivery module's uncapped objects (H2 §814)", raw: `{"module":"d","version":"1.0","class":"core","claims":[{"name":"thing","scope":"mesh"}],"objects":[{"name":"o"}]}`, want: `objects "o"`}, + {name: "a foundation part's capped old-section state (H2 §814)", raw: `{"module":"mesh-delivery-builder","version":"1.0","class":"core","claims":[{"name":"thing","scope":"mesh"}],"state":[{"name":"s","max-mib":8}]}`}, + {name: "an uncapped state of a module claiming no delivery seat (H2 §814)", raw: `{"module":"a","version":"1.0","state":["s"]}`}, + {name: "a seat-claiming manifest with no class (H2 §810, §814)", raw: `{"module":"d","version":"1.0","claims":[{"name":"thing","scope":"mesh"}]}`, want: "no `class`"}, + {name: "a seat-claiming manifest of another class (H2 §810, §814)", raw: `{"module":"d","version":"1.0","class":"middle","claims":[{"name":"thing","scope":"mesh"}]}`, want: `class "middle"`}, + {name: "a seat-claiming leaf (H2 §810)", raw: `{"module":"d","version":"1.0","class":"leaf","claims":[{"name":"thing","scope":"mesh"}]}`}, } { module := "a" if m := regexp.MustCompile(`"module":"([a-z-]+)"`).FindStringSubmatch(row.raw); m != nil { diff --git a/modules/mesh-delivery-indexer/judge/gwords.go b/modules/mesh-delivery-indexer/judge/gwords.go index a1fe4b7b1..dc5c9c34c 100644 --- a/modules/mesh-delivery-indexer/judge/gwords.go +++ b/modules/mesh-delivery-indexer/judge/gwords.go @@ -88,7 +88,8 @@ func gWordsProblems(m catalogue.Manifest) []string { } // findingEventsProblems judges the entry `finding-events` of a part that is no foundation part: it lists the three finding -// events in its option `events` and keeps them 7 days and 16 MiB (design 47 G §529). +// events in its option `events` and keeps them 7 days and 8 MiB (design 47 G §529, H2 §820; H-A-411 (1)); the template +// `events` drops the oldest when full. func findingEventsProblems(module string, e catalogue.BusStateEntry) []string { var problems []string var listed []string @@ -100,9 +101,9 @@ func findingEventsProblems(module string, e catalogue.BusStateEntry) []string { problems = append(problems, fmt.Sprintf("%s's %s does not list the event %q in its `events` (design 47 G §529)", module, FindingEventsEntry, want)) } } - for option, want := range map[string]string{"max-age-days": "7", "max-mib": "16"} { + for option, want := range map[string]string{"max-age-days": "7", "max-mib": "8"} { if got := strings.TrimSpace(string(e.Options[option])); got != want { - problems = append(problems, fmt.Sprintf("%s's %s sets %s to %q, not %s (design 47 G §529)", module, FindingEventsEntry, option, got, want)) + problems = append(problems, fmt.Sprintf("%s's %s sets %s to %q, not %s (design 47 G §529, H2 §820)", module, FindingEventsEntry, option, got, want)) } } slices.Sort(problems) diff --git a/modules/mesh-delivery-indexer/judge/judge.go b/modules/mesh-delivery-indexer/judge/judge.go index bd352368c..42a2b4984 100644 --- a/modules/mesh-delivery-indexer/judge/judge.go +++ b/modules/mesh-delivery-indexer/judge/judge.go @@ -290,6 +290,7 @@ func UseSeatList(defs []seatdef.Definition) { seatsMu.Lock() // not while a pass judges with seats put over the list (WithSeats) defer seatsMu.Unlock() catalogue.UseSeats(catalogue.SeatsFromDefinitions(defs)) + useDeliverySeats(defs) } // TrunkCase is the case of a request holding the catalogue as the trunk holds it (the checker's JudgeTrunk). diff --git a/modules/mesh-delivery-indexer/judge/judge_test.go b/modules/mesh-delivery-indexer/judge/judge_test.go index 58f7c1587..4113c30e9 100644 --- a/modules/mesh-delivery-indexer/judge/judge_test.go +++ b/modules/mesh-delivery-indexer/judge/judge_test.go @@ -43,7 +43,7 @@ func TestTheJudge(t *testing.T) { {name: "a claimed seat's module with tools of its own", raws: map[string]string{ "def": `{"module":"def","version":"1.0","seats":[{"name":"enrolment","scope":"mesh","serves":["issue","again"]}]}`, - "enrolment": `{"module":"enrolment","version":"1.0","claims":[{"name":"enrolment","scope":"mesh","serves":["issue","again"]}],` + + "enrolment": `{"module":"enrolment","version":"1.0","class":"core","claims":[{"name":"enrolment","scope":"mesh","serves":["issue","again"]}],` + `"tools":["enrolment_first_views","enrolment_first_view_again"]}`}}, } { raws := map[string][]byte{"node-engine": []byte(engineManifest("node-engine"))} // a revision has one claim of the seat node-engine (§527) @@ -185,7 +185,7 @@ func engineManifest(module string) string { for _, v := range seat.Serves { verbs = append(verbs, `"`+v.Name+`"`) } - return `{"module":"` + module + `","version":"1.0","claims":[{"name":"node-engine","scope":"node","serves":[` + strings.Join(verbs, ",") + `]}]}` + return `{"module":"` + module + `","version":"1.0","class":"core","claims":[{"name":"node-engine","scope":"node","serves":[` + strings.Join(verbs, ",") + `]}]}` } // Design 47 G §508, §527: one module of a revision claims the seat node-engine; a second is refused naming both, and none diff --git a/modules/mesh-delivery-indexer/judge/rules.go b/modules/mesh-delivery-indexer/judge/rules.go index d675cb5f6..9aef082ca 100644 --- a/modules/mesh-delivery-indexer/judge/rules.go +++ b/modules/mesh-delivery-indexer/judge/rules.go @@ -2599,6 +2599,8 @@ func parseManifest(raw []byte, predefined catalogue.PredefinedList) (catalogue.M m.SetPredefined(predefined) problems := gWordsProblems(m) + problems = append(problems, deliveryStoreProblems(m)...) + problems = append(problems, classProblems(m)...) if !name.MatchString(m.Module) { problems = append(problems, fmt.Sprintf( "%q is not a usable module name: lower-case letters, digits, dashes and dots", m.Module)) diff --git a/modules/mesh-delivery-indexer/judge/rules_test.go b/modules/mesh-delivery-indexer/judge/rules_test.go index 8d6a0a41e..a82cdca43 100644 --- a/modules/mesh-delivery-indexer/judge/rules_test.go +++ b/modules/mesh-delivery-indexer/judge/rules_test.go @@ -261,7 +261,7 @@ func caseAClaimOnASeatAnotherModuleDeclaresIsAccepted(t *testing.T) { // would say it where no consumer hears it, so the manifest is refused, naming the seat's subject; the seat's // holder saying nothing of its own is accepted. holder := func(emits string) []byte { - return []byte(`{"module":"mesh-self-check","version":"1.0","emits":` + emits + `,"claims":[{"name":"mesh-self-check","scope":"mesh","serves":["doctor","probes"]}]}`) + return []byte(`{"module":"mesh-self-check","version":"1.0","emits":` + emits + `,"class":"core","claims":[{"name":"mesh-self-check","scope":"mesh","serves":["doctor","probes"]}]}`) } if _, err := ParseManifest(holder(`["checked"]`)); err == nil || !strings.Contains(err.Error(), "mesh.seat.mesh-self-check.event.checked") { t.Errorf("a seat's event listed as the module's own: %v", err) @@ -383,7 +383,7 @@ func caseAContributionPlaceholderOutsideTheHolderIsRefused(t *testing.T) { if _, err := ParseManifest([]byte(raw)); err == nil || !strings.Contains(err.Error(), "laptop does not claim node-hotkeys") { t.Errorf("a placeholder outside the holder was accepted: %v", err) } - raw = `{"module":"triggerhappy","claims":[{"name":"node-hotkeys"}],"resources":[{"id":"t","type":"file","path":"/etc/t","content":"${contribution:node-hotkeys:keys}"}]}` + raw = `{"module":"triggerhappy","class":"core","claims":[{"name":"node-hotkeys"}],"resources":[{"id":"t","type":"file","path":"/etc/t","content":"${contribution:node-hotkeys:keys}"}]}` if _, err := ParseManifest([]byte(raw)); err == nil || !strings.Contains(err.Error(), "it receives trigger") { t.Errorf("a placeholder for a kind the seat does not receive was accepted: %v", err) } @@ -508,7 +508,7 @@ func caseADeliveringSeatIsOnlyHeldByAModuleThatProvides(t *testing.T) { // would be the answer anyway, and every consumer would be sent to it. // And refused at registration, where the seat set is the store's: what a seat delivers is // data, so a compiled copy of it may not be what refuses a build (novox/hq ADR 0122). - raw := []byte(`{"module":"thing","version":"1.0","claims":[{"name":"git","scope":"mesh"}]}`) + raw := []byte(`{"module":"thing","version":"1.0","class":"core","claims":[{"name":"git","scope":"mesh"}]}`) m, err := ParseManifest(raw) if err != nil { t.Fatalf("the parser judged what a seat delivers: %v", err) @@ -723,7 +723,7 @@ func caseAHolderOfNodeFilesDeclaringRunsAsIsRefused(t *testing.T) { // carry — as the operator's account — is refused at parse. func caseAHolderOfNodeReadsWithoutAnAccountOfItsOwnIsRefused(t *testing.T) { _, err := ParseManifest([]byte(`{"module": "reads", "version":"1.0", - "claims": [{"name": "node-reads", "scope": "node"}]}`)) + "class":"core","claims":[{"name": "node-reads", "scope": "node"}]}`)) if err == nil || !strings.Contains(err.Error(), "runs-as") || !strings.Contains(err.Error(), "0310") { t.Errorf("a holder of node-reads without runs-as was not refused for it: %v", err) } @@ -745,7 +745,7 @@ func caseAHolderPlacesEveryCombinationOnceWithATemplateThatRendersEveryExample(t if template != "" { renders = `,"renders":{"block":` + string(tb) + `}` } - return `{"module":"a-bar","claims":[{"name":"node-bar"` + renders + `}],"resources":[` + strings.Join(res, ",") + `]}` + return `{"module":"a-bar","class":"core","claims":[{"name":"node-bar"` + renders + `}],"resources":[` + strings.Join(res, ",") + `]}` } all := "${contribution:node-bar:block:bar=bottom,place=resources}${contribution:node-bar:block:bar=bottom,place=status}" + "${contribution:node-bar:block:bar=top,place=resources}${contribution:node-bar:block:bar=top,place=status}" @@ -1304,7 +1304,7 @@ func caseAModuleDeclaresItsOwnSeatAndHoldsIt(t *testing.T) { // what it means (novox/hq ADR 0121). But it may not define one in the mesh's own namespace. func caseAModuleDefinesAndClaimsItsOwnSeat(t *testing.T) { ok := []byte(`{"module":"showcase","version":"1.0","seats":[{"name":"the-showcase","scope":"node"}],` + - `"claims":[{"name":"the-showcase","scope":"node"}]}`) + `"class":"core","claims":[{"name":"the-showcase","scope":"node"}]}`) if _, err := ParseManifest(ok); err != nil { t.Fatalf("a module could not define and claim its own seat: %v", err) } @@ -1321,7 +1321,7 @@ func caseAModuleDefinesAndClaimsItsOwnSeat(t *testing.T) { } // A module may not carve its seat out of the mesh's own namespace. bad := []byte(`{"module":"x","version":"1.0","seats":[{"name":"node-mine","scope":"node"}],` + - `"claims":[{"name":"node-mine","scope":"node"}]}`) + `"class":"core","claims":[{"name":"node-mine","scope":"node"}]}`) if _, err := ParseManifest(bad); err == nil || !strings.Contains(err.Error(), "own namespace") { t.Fatalf("a module defined a seat in the mesh's namespace and was not refused: %v", err) } @@ -2266,14 +2266,14 @@ func caseAnUnknownPlaceholderKeyIsRefused(t *testing.T) { {"${shell:tcsh:first}", "names ${shell:tcsh:first}; shell code is ${shell::}"}, {"${shell:zsh}", "names ${shell:zsh}; shell code is ${shell::}"}, } { - raw := `{"module":"holder","claims":[{"name":"node-environment","scope":"node"},{"name":"node-login-shell","scope":"node"}],` + + raw := `{"module":"holder","class":"core","claims":[{"name":"node-environment","scope":"node"},{"name":"node-login-shell","scope":"node"}],` + `"resources":[{"id":"rc","type":"file","path":"/etc/rc","content":"` + c.content + `"}]}` if _, err := ParseManifest([]byte(raw)); err == nil || !strings.Contains(err.Error(), c.want) { t.Errorf("%s was accepted: %v", c.content, err) } } // And outside a file's content, where nothing could be placed. - raw := `{"module":"holder","claims":[{"name":"node-environment","scope":"node"}],` + + raw := `{"module":"holder","class":"core","claims":[{"name":"node-environment","scope":"node"}],` + `"resources":[{"id":"rc","type":"file","path":"/etc/${environment:posix}","content":"x"}]}` if _, err := ParseManifest([]byte(raw)); err == nil || !strings.Contains(err.Error(), "names ${environment:posix} in its path; the environment and the shell's code are placed only in a file's content") { @@ -2408,7 +2408,7 @@ func caseAPackageParsesLikeABundleAndNeedsALanguage(t *testing.T) { } { raw := `{"module":"a","version":"1.0","build":{"artifacts":[` + c.artifact + `]}}` if before, ok := strings.CutSuffix(c.artifact, claims); ok { - raw = `{"module":"a","version":"1.0","claims":[{"name":"mesh-vault","scope":"mesh"}],"build":{"artifacts":[` + before + `]}}` + raw = `{"module":"a","version":"1.0","class":"core","claims":[{"name":"mesh-vault","scope":"mesh"}],"build":{"artifacts":[` + before + `]}}` } _, err := ParseManifest([]byte(raw)) switch { @@ -2560,7 +2560,7 @@ func caseAProcessBusNamesOnlyTheModulesOwn(t *testing.T) { func caseAProcessBusNeverServesOrHoldsASeat(t *testing.T) { for name, c := range map[string]struct{ bus, says string }{ "holds": {`{"emits":["mail.send.sent"],"holds":["mail-sender"]}`, "holds"}, - "claims": {`{"emits":["mail.send.sent"],"claims":["mail-sender"]}`, "claims"}, + "claims": {`{"emits":["mail.send.sent"],"class":"core","claims":["mail-sender"]}`, "claims"}, "seat": {`{"emits":["mail.send.sent"],"seat":"mail-sender"}`, "seat"}, } { _, err := ParseManifest([]byte(mailSenderProcessManifest(t, c.bus))) @@ -2610,7 +2610,7 @@ func caseAProcessDeclaresItsBusAndIsAccepted(t *testing.T) { // process's, named after its binary and kept through resolution; a removal is from the closed set, alone, and the // bus module's (mesh-broker) alone. toolsIn := func(claims, bus, mode, where string) string { - return `{"module":"nats","version":"1.0","claims":` + claims + `,"own-secrets":{"broker":"${dir:mesh-state}/broker",` + + return `{"module":"nats","version":"1.0","class":"core","claims":` + claims + `,"own-secrets":{"broker":"${dir:mesh-state}/broker",` + `"broker-nats-tools":"${dir:tools-secret}/broker-nats-tools"},"resources":[{"id":"mesh-state","type":"directory",` + `"mode":"0700","place":"mesh","unknown":"program"},{"id":"tools-secret","type":"directory","mode":"` + mode + `","path":"` + where + `","unknown":"program"}],"build":{"artifacts":[{"name":"tools","kind":"bundle",` + @@ -3276,10 +3276,10 @@ func caseAManifestCarryingWaitsIsAFieldNotKnown(t *testing.T) { func caseAMarkNothingEnforcesIsRefused(t *testing.T) { const bundle = `"build":{"artifacts":[{"name":"tools","kind":"bundle","language":"typescript","entrypoints":["tools/index.js"]}]}` const oc = `"uses":["operator-channel"]` - shell := `{"module":"zsh","claims":[{"name":"node-login-shell","scope":"node","serves":["execute"]}],"tools":["zsh_config"],` + bundle + shell := `{"module":"zsh","class":"core","claims":[{"name":"node-login-shell","scope":"node","serves":["execute"]}],"tools":["zsh_config"],` + bundle for _, row := range []struct{ name, manifest, want string }{ {"a tool its tools do not list", `{"module":"shop","tools":["sell"],"needs-approval":["refund"],` + oc + `,` + bundle + `}`, "its tools do not list"}, - {"a verb its claims do not serve", `{"module":"shop","claims":[{"name":"shop-till","serves":["price"]}],"tools":["price"],"needs-approval":["shop-till.refund"],` + oc + `,` + bundle + `}`, "does not serve"}, + {"a verb its claims do not serve", `{"module":"shop","class":"core","claims":[{"name":"shop-till","serves":["price"]}],"tools":["price"],"needs-approval":["shop-till.refund"],` + oc + `,` + bundle + `}`, "does not serve"}, {"a marked tool without operator-channel", `{"module":"shop","tools":["sell"],"needs-approval":["sell"],` + bundle + `}`, "without operator-channel"}, {"a held seat verb its seat marks without operator-channel", shell + `}`, "without operator-channel"}, {"every bundle run by its own process", `{"module":"shop","tools":["sell"],"needs-approval":["sell"],` + oc + `,` + bundle + @@ -4130,7 +4130,7 @@ func caseNodeBuildAgentIsRetiredForTheBuildSeats(t *testing.T) { t.Errorf("the mesh still defines %s", gone) } } - _, err := ParseManifest([]byte(`{"module":"build-agent","version":"1.0","claims":[{"name":"node-build-agent","scope":"node"}]}`)) + _, err := ParseManifest([]byte(`{"module":"build-agent","version":"1.0","class":"core","claims":[{"name":"node-build-agent","scope":"node"}]}`)) if err == nil || !strings.Contains(err.Error(), `"node-build-agent", which is retired`) || !strings.Contains(err.Error(), "node-build-go") { t.Fatalf("the claim is not refused naming its replacement: %v", err) } @@ -4193,7 +4193,7 @@ func caseNoModuleMayDeclareTheLoginShell(t *testing.T) { } // And a shell module claiming the mesh's seat, serving execute, is what the seat is for. m, err := ParseManifest([]byte(`{"module":"zsh","tools":["execute"],"uses":["operator-channel"],` + - `"claims":[{"name":"node-login-shell","scope":"node"}]}`)) + `"class":"core","claims":[{"name":"node-login-shell","scope":"node"}]}`)) if err != nil { t.Fatal(err) } @@ -4506,7 +4506,7 @@ func caseAStoreHolderThatBuildsIsNotRefusedByItsManifest(t *testing.T) { // nothing, so it is refused at the parser rather than silently dropped. func caseTheBussAccountSaysNothingOnTheBus(t *testing.T) { raw := []byte(`{"module":"bus","version":"1.0","provides":[{"name":"mesh-bus","scope":"mesh"}], - "claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"}, + "class":"core","claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"}, "emits":["something.happened"]}`) _, err := ParseManifest(raw) if err == nil || !strings.Contains(err.Error(), "granted the bus's snapshot API and nothing else") { @@ -4514,7 +4514,7 @@ func caseTheBussAccountSaysNothingOnTheBus(t *testing.T) { } // Nor what it invokes, with no bundle for the runtime to ask on its behalf. unbundledInvoke := []byte(`{"module":"bus","version":"1.0","provides":[{"name":"mesh-bus","scope":"mesh"}], - "claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"}, + "class":"core","claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"}, "invokes":["seat:mesh-hand-acts.hand-act"]}`) if _, err := ParseManifest(unbundledInvoke); err == nil || !strings.Contains(err.Error(), "its invokes would be granted nothing") { t.Fatalf("a bus module with no bundle declaring what it invokes was not refused, or not for the reason: %v", err) @@ -4525,7 +4525,7 @@ func caseTheBussAccountSaysNothingOnTheBus(t *testing.T) { // ships one may declare them. The shape of mesh-catalog's modules/nats/module.json at fc5b849d, cut to the // parts the rule reads, was refused and held every bus user list from 2026-11-02 01:35. nats := []byte(`{"module":"nats","version":"1.0","provides":[{"name":"mesh-bus","scope":"mesh","credential":{"form":"none"}}], - "claims":[{"name":"mesh-broker","scope":"mesh"}], + "class":"core","claims":[{"name":"mesh-broker","scope":"mesh"}], "own-secrets":{"broker":"/run/broker","broker-nats-tools":"${dir:tools-secret}/broker-nats-tools"}, "resources":[{"id":"tools-secret","type":"directory","path":"/var/lib/mesh/nats-tools","mode":"0711","unknown":"program"}], "emits":["consumer-removed","bucket-keys-removed","stream-removed","bucket-expiry-set"], @@ -4551,7 +4551,7 @@ func caseTheBussAccountSaysNothingOnTheBus(t *testing.T) { // Its tools bundle says what it emits (novox/hq ADR 0357): the node's runtime carries the bundle and is // granted the module's events, so a bus module that ships one may declare them. bundled := []byte(`{"module":"bus","version":"1.0","provides":[{"name":"mesh-bus","scope":"mesh"}], - "claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"}, + "class":"core","claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"}, "emits":["bus.slow-consumer"],"tools":["bus_streams"], "build":{"artifacts":[{"name":"tools","kind":"bundle","language":"go","system":"arch","from":"cmd/t","binary":"t"}]}}`) m, err := ParseManifest(bundled) @@ -4577,7 +4577,7 @@ func caseTheBussAccountSaysNothingOnTheBus(t *testing.T) { // parts the rule reads. keeper := func(bus string, more string) []byte { return []byte(`{"module":"nats","version":"1.0","provides":[{"name":"mesh-bus","scope":"mesh"}], - "claims":[{"name":"mesh-broker","scope":"mesh","serves":["list"]}],"own-secrets":{"broker":"/run/broker"}, + "class":"core","claims":[{"name":"mesh-broker","scope":"mesh","serves":["list"]}],"own-secrets":{"broker":"/run/broker"}, "tools":["nats_server"],"consumes":["mesh-catalog.manifest-accepted"],"uses":["operator-channel"], "state":[{"name":"requests","history":5}],"streams":[{"name":"broker-events","events":["created"]}], "emits":["consumer-removed"], @@ -4621,7 +4621,7 @@ func caseTheBussAccountSaysNothingOnTheBus(t *testing.T) { } quiet := []byte(`{"module":"bus","version":"1.0","provides":[{"name":"mesh-bus","scope":"mesh"}], - "claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"}, + "class":"core","claims":[{"name":"mesh-broker","scope":"mesh"}],"own-secrets":{"broker":"/run/broker"}, "tools":["bus_streams"]}`) m, err = ParseManifest(quiet) if err != nil { @@ -4974,7 +4974,7 @@ func caseTheParserDoesNotJudgeWhatOnlyTheStoreKnows(t *testing.T) { catalogue.UseSeats([]catalogue.Seat{{Name: "mesh-broker", Scope: catalogue.ScopeMesh, Delivers: "mesh-bus", Decision: "test"}}) raw := []byte(`{"module":"a-bus","version":"1.0",` + `"provides":[{"name":"mesh-bus","scope":"mesh","credential":{"form":"none"}}],` + - `"claims":[{"name":"mesh-broker","scope":"mesh"}]}`) + `"class":"core","claims":[{"name":"mesh-broker","scope":"mesh"}]}`) m, err := ParseManifest(raw) if err != nil { @@ -5185,13 +5185,13 @@ func caseTheSessionsFilesArePlacedByTheDisplayServersHolderAlone(t *testing.T) { {`{"name":"node-display-server"}`, "${shell:zsh:normal}", "does not claim node-login-shell"}, {`{"name":"node-display-server"}`, "${shell:xsession:normal}", "the session's file one of xinitrc, xresources"}, } { - raw := `{"module":"holder","claims":[` + c.claims + `],"resources":[{"id":"rc","type":"file","path":"/etc/rc","content":"` + + raw := `{"module":"holder","class":"core","claims":[` + c.claims + `],"resources":[{"id":"rc","type":"file","path":"/etc/rc","content":"` + c.content + `"}]}` if _, err := ParseManifest([]byte(raw)); err == nil || !strings.Contains(err.Error(), c.want) { t.Errorf("%s with claims [%s]: want %q, got %v", c.content, c.claims, c.want, err) } } - if _, err := ParseManifest([]byte(`{"module":"xorg","claims":[{"name":"node-display-server"}],` + + if _, err := ParseManifest([]byte(`{"module":"xorg","class":"core","claims":[{"name":"node-display-server"}],` + `"resources":[{"id":"rc","type":"file","path":"/home/op/.xinitrc","content":"${shell:xinitrc:last}"}]}`)); err != nil { t.Errorf("the display server's holder could not place the session's slots: %v", err) } @@ -5259,7 +5259,7 @@ func caseTheUplinkIsANodeSeatThatDeliversNothing(t *testing.T) { t.Fatalf("the uplink is %+v, not a node seat delivering nothing by ADR 0117", seat) } // And a manager's module can hold it without providing anything. - raw := []byte(`{"module":"networkmanager","version":"1.0","claims":[{"name":"node-uplink","scope":"node"}]}`) + raw := []byte(`{"module":"networkmanager","version":"1.0","class":"core","claims":[{"name":"node-uplink","scope":"node"}]}`) if _, err := ParseManifest(raw); err != nil { t.Fatalf("a network manager's module could not hold the uplink: %v", err) } @@ -5573,7 +5573,7 @@ func problemsFor(t *testing.T, shelf catalogue.Shelf) string { } func claimed(claims string) []byte { - return []byte(`{"module":"thing","version":"1.0","provides":[{"name":"npm-package-registry","scope":"mesh","credential":{"form":"none"}}],"claims":` + claims + `}`) + return []byte(`{"module":"thing","version":"1.0","provides":[{"name":"npm-package-registry","scope":"mesh","credential":{"form":"none"}}],"class":"core","claims":` + claims + `}`) } func hostnameSeat(t *testing.T) catalogue.Seat { @@ -6098,7 +6098,7 @@ func mod(name string, provides, requires, capabilities []string, claims ...catal } const collectorZsh = `{"module":"zsh","version":"1.0","moved":true, - "claims":[{"name":"node-login-shell","scope":"node"}], + "class":"core","claims":[{"name":"node-login-shell","scope":"node"}], "collections":[{"name":"widgets","comment":"#"}], "build":{"artifacts":[{"name":"files","kind":"archive","from":"files"}]}, "resources":[{"id":"rc","type":"file","path":"${machine:account-home}/.zshrc","owner":"${machine:account}", @@ -6660,7 +6660,7 @@ func caseOneModuleClaimsTheNodeEnginesSeat(t *testing.T) { t.Cleanup(func() { catalogue.UseSeats(was) }) catalogue.UseSeats([]catalogue.Seat{{Name: NodeEngineSeat, Scope: catalogue.ScopeNode, Decision: "test", HeldByTheEngine: true}}) engine := func(module string) []byte { - return []byte(`{"module":"` + module + `","version":"1.0","claims":[{"name":"node-engine","scope":"node"}]}`) + return []byte(`{"module":"` + module + `","version":"1.0","class":"core","claims":[{"name":"node-engine","scope":"node"}]}`) } for _, row := range []struct { name string diff --git a/modules/mesh-delivery-indexer/judge/stores.go b/modules/mesh-delivery-indexer/judge/stores.go new file mode 100644 index 000000000..17edbbf89 --- /dev/null +++ b/modules/mesh-delivery-indexer/judge/stores.go @@ -0,0 +1,79 @@ +package judge + +import ( + "fmt" + "slices" + "sync/atomic" + + "git.novox.be/novox/mesh-sdk/go/catalogue" + "git.novox.be/novox/mesh-sdk/go/seatdef" +) + +// The manifest check of design 47 H2 §814 and §810: every kept store of a delivery module names its cap (§812), and a +// module that claims a seat names its class (H-A-394 (1), H-A-411 (4)). + +// deliveryDomain is the glossary domain of the delivery system's seats, as a seat definition names it (seatdef.Domains). +const deliveryDomain = "Delivery" + +// deliverySeats are the seats of the seat list the judge judges against whose definition is of the delivery system, +// by name: set with the list (UseSeatList), read by deliveryStoreProblems. +var deliverySeats atomic.Pointer[map[string]bool] + +// useDeliverySeats keeps the delivery system's seats of defs (deliverySeats). +func useDeliverySeats(defs []seatdef.Definition) { + seats := map[string]bool{} + for _, d := range defs { + if d.Domain == deliveryDomain { + seats[d.Seat] = true + } + } + deliverySeats.Store(&seats) +} + +// deliverySeatOf is the first seat of the delivery system m claims, by the seat list's definitions; "" for none. +func deliverySeatOf(m catalogue.Manifest) string { + seats := deliverySeats.Load() + if seats == nil { + return "" + } + for _, c := range m.Claims { + if (*seats)[c.Name] { + return c.Name + } + } + return "" +} + +// deliveryStoreProblems refuses each state, log and objects entry of a delivery module (one whose manifest claims a seat +// of the delivery system) that names no cap, in its old section or in `requires` alike (design 47 H2 §812, §814): a +// foundation part's old-section entry names its cap in that section. +func deliveryStoreProblems(m catalogue.Manifest) []string { + seat := deliverySeatOf(m) + if seat == "" { + return nil + } + var problems []string + for _, u := range m.UncappedStores() { + where := "in `requires`" + if u.OldSection { + where = "in its old section" + } + problems = append(problems, fmt.Sprintf("%s claims the seat %s of the delivery system, so every store it keeps names its cap; "+ + "its %s %q %s names none (design 47 H2 §812, §814)", m.Module, seat, u.Kind, u.Name, where)) + } + return problems +} + +// classProblems refuses a manifest that claims a seat and names no class, or a class that is neither core nor leaf +// (design 47 H2 §810, §814; H-A-394 (1)). +func classProblems(m catalogue.Manifest) []string { + if len(m.Claims) == 0 || slices.Contains([]string{catalogue.ClassCore, catalogue.ClassLeaf}, m.Class) { + return nil + } + if m.Class == "" { + return []string{fmt.Sprintf("%s claims a seat and names no `class`; a module that claims a seat names `class` %s or %s "+ + "(design 47 H2 §810, §814)", m.Module, catalogue.ClassCore, catalogue.ClassLeaf)} + } + return []string{fmt.Sprintf("%s names the class %q; a class is %s or %s (design 47 H2 §810, §814)", m.Module, m.Class, + catalogue.ClassCore, catalogue.ClassLeaf)} +} From 92ba593639a52d209950022f0bb30de2599cdcc9 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 01:57:10 +0100 Subject: [PATCH 08/16] I6 (2a): the seat mesh-catalog's seat-list hands the seat list's bytes in chunks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit seat-list is a chunked read verb, as input is: input call (128 random bits), answer digest (the list's sha256, its object's name in seat-lists), size and chunks, then the bytes on the call's chunk subject. The object name leaves the answer. The seat's form rises to 4; regenerated with seatgen, -check clean; the fixtures read so. Builds: design 47 H2 §814, §820; H-A-441, H-A-443 (1) --- .../go/seats/meshcatalog/contract.go | 16 +++++----- .../go/seats/meshcatalog/contract_test.go | 4 ++- .../seats/mesh-catalog/fixtures/verbs.json | 15 ++++++--- .../seats/mesh-catalog/seat.json | 31 +++++++++++++------ .../ts/seats/meshcatalog/index.d.ts | 10 +++--- 5 files changed, 50 insertions(+), 26 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go index 19cadc72e..43d307e91 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go @@ -14,13 +14,13 @@ const Seat = "mesh-catalog" // Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): // a reader of a value of another form says "form N, this reader knows M". -const Form = 3 +const Form = 4 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "3" - generatedFieldsDigest = "ActingRule=8a83ce7e0457 Artifact=78b05c1a9ec3 ArtifactPackage=2a3a660a934d ArtifactRef=a2f06147f4b6 BuildEdge=76f0684e254a BuildEdges=d2b95000259e BuildEdgesByModuleBranchValue=4fdf7cc1e723 CandidatesByGroupValue=9ea8c6c580d2 CandidatesByGroupValuePullsItem=90fb03643258 CandidatesByGroupValuePullsItemFpsValue=4c6783201aa3 CatalogEntry=c0a4ea25d523 CatalogRevision=d1ecaaa484af CatalogRevisionDefinitionsItem=77fcff620d48 CatalogRevisionEvent=710cbc5bfff1 CatalogRevisionsByBranchRevisionValue=17e54f635d35 CatalogRevisionsByCandidateGroupHeadsValue=17e54f635d35 CatalogRevisionsByEntryDigestValue=8755036a3051 DependentsAnswer=7538f2f5e68e Edge=7242732afaef EntryAnswer=805c2ff28e1c EntryInputs=76a7f8690dd2 EntryRef=ff109e5089e1 Fill=80f442916429 FillingEvent=5bd4df78ed84 FingerprintInputs=99a6df7f991f FullEvent=5bd4df78ed84 Head=774b4bf88ba4 InputAnswer=cd41ee65565d InputsByTimeDigestValue=a2f06147f4b6 ManifestsByDigestValue=51b3822b29c6 ModuleAnswer=499a03ce9b27 ModuleAnswerModule=c0f679e09f08 ModulesAnswer=6d119571c69e ModulesAnswerModulesItem=a70f39c60b67 ModulesByModuleValue=fc7530ba893a ModulesByModuleValueInputs2=99a6df7f991f Outdated=e820214f66bc OutdatedAnswer=275fb25266b9 OutdatedDependency=dc35dca1b683 PackagesByModuleValue=2b62574b709f PackagesByModuleValuePackagesItem=a7d30558470d PackagesByPackageSeriesValue=07421d8d3411 PackagesByPackageSeriesValueNewest=aba144994370 PackagesByPackageSeriesValueNewestContents=eca2ccf56913 PackagesByPackageSeriesValueNewestContentsPackagesItem=a7d30558470d PackagesByPackageSeriesValueNumbered=c8ffc628599c PackagesByPackageSeriesValueNumberedContents=0def6c0794ee PackagesByPackageSeriesValueNumberedContentsPackagesItem=a7d30558470d Policy=719e2f460c6f PolicyAnswer=46cdf8430557 PredefinedByListValue=ec8e3febe8ac ProvidesAnswer=7538f2f5e68e RegisterAnswer=46cdf8430557 Registration=ef03d1b2e73f RegistrationAsked=55adba349c24 RegistrationChangedEvent=99a3268edf41 RegistrationHistoryByModuleVersionValue=0999b5bb7dc7 RegistrationHistoryBySourceOwnerNameVersionValue=0999b5bb7dc7 RegistrationsAnswer=8849ef618cf3 RegistrationsByModuleValue=0999b5bb7dc7 RegistrationsBySourceOwnerNameValue=0999b5bb7dc7 RevisionAnswer=258ea5124931 RoomEvent=5bd4df78ed84 SeatDefinitionChangedEvent=e271d24d58f7 SeatDefinitionRemovedEvent=f7d6171111e6 SeatDefinitionsAnswer=0fd6a59fec59 SeatDefinitionsAnswerEntry=d006f68d2be5 SeatDefinitionsAnswerSeatsItem=e271d24d58f7 SeatListAnswer=912c0cebcf0a SourceCheck=d1ed7cbbd579 StepStatuses=4f50aa633e61 TakeInEntry=545ec1528499 ToolchainUsed=43b6d42376fb UnwatchAnswer=46cdf8430557 VersionArtifact=438c49a392b0 VersionEdge=b0f80e83f4dc VersionEntry=33f5b00dbda9 VersionReleasedEvent=4ccf1ea90e7f VersionsAnswer=b59e6e057e7b VersionsByModuleVersionValue=e546dfadb913 VersionsFilledEvent=4cc437912dc3 WatchAnswer=46cdf8430557" + generatedForms = "4" + generatedFieldsDigest = "ActingRule=8a83ce7e0457 Artifact=78b05c1a9ec3 ArtifactPackage=2a3a660a934d ArtifactRef=a2f06147f4b6 BuildEdge=76f0684e254a BuildEdges=d2b95000259e BuildEdgesByModuleBranchValue=4fdf7cc1e723 CandidatesByGroupValue=9ea8c6c580d2 CandidatesByGroupValuePullsItem=90fb03643258 CandidatesByGroupValuePullsItemFpsValue=4c6783201aa3 CatalogEntry=c0a4ea25d523 CatalogRevision=d1ecaaa484af CatalogRevisionDefinitionsItem=77fcff620d48 CatalogRevisionEvent=710cbc5bfff1 CatalogRevisionsByBranchRevisionValue=17e54f635d35 CatalogRevisionsByCandidateGroupHeadsValue=17e54f635d35 CatalogRevisionsByEntryDigestValue=8755036a3051 DependentsAnswer=7538f2f5e68e Edge=7242732afaef EntryAnswer=805c2ff28e1c EntryInputs=76a7f8690dd2 EntryRef=ff109e5089e1 Fill=80f442916429 FillingEvent=5bd4df78ed84 FingerprintInputs=99a6df7f991f FullEvent=5bd4df78ed84 Head=774b4bf88ba4 InputAnswer=cd41ee65565d InputsByTimeDigestValue=a2f06147f4b6 ManifestsByDigestValue=51b3822b29c6 ModuleAnswer=499a03ce9b27 ModuleAnswerModule=c0f679e09f08 ModulesAnswer=6d119571c69e ModulesAnswerModulesItem=a70f39c60b67 ModulesByModuleValue=fc7530ba893a ModulesByModuleValueInputs2=99a6df7f991f Outdated=e820214f66bc OutdatedAnswer=275fb25266b9 OutdatedDependency=dc35dca1b683 PackagesByModuleValue=2b62574b709f PackagesByModuleValuePackagesItem=a7d30558470d PackagesByPackageSeriesValue=07421d8d3411 PackagesByPackageSeriesValueNewest=aba144994370 PackagesByPackageSeriesValueNewestContents=eca2ccf56913 PackagesByPackageSeriesValueNewestContentsPackagesItem=a7d30558470d PackagesByPackageSeriesValueNumbered=c8ffc628599c PackagesByPackageSeriesValueNumberedContents=0def6c0794ee PackagesByPackageSeriesValueNumberedContentsPackagesItem=a7d30558470d Policy=719e2f460c6f PolicyAnswer=46cdf8430557 PredefinedByListValue=ec8e3febe8ac ProvidesAnswer=7538f2f5e68e RegisterAnswer=46cdf8430557 Registration=ef03d1b2e73f RegistrationAsked=55adba349c24 RegistrationChangedEvent=99a3268edf41 RegistrationHistoryByModuleVersionValue=0999b5bb7dc7 RegistrationHistoryBySourceOwnerNameVersionValue=0999b5bb7dc7 RegistrationsAnswer=8849ef618cf3 RegistrationsByModuleValue=0999b5bb7dc7 RegistrationsBySourceOwnerNameValue=0999b5bb7dc7 RevisionAnswer=258ea5124931 RoomEvent=5bd4df78ed84 SeatDefinitionChangedEvent=e271d24d58f7 SeatDefinitionRemovedEvent=f7d6171111e6 SeatDefinitionsAnswer=0fd6a59fec59 SeatDefinitionsAnswerEntry=d006f68d2be5 SeatDefinitionsAnswerSeatsItem=e271d24d58f7 SeatListAnswer=04477a8044b1 SourceCheck=d1ed7cbbd579 StepStatuses=4f50aa633e61 TakeInEntry=545ec1528499 ToolchainUsed=43b6d42376fb UnwatchAnswer=46cdf8430557 VersionArtifact=438c49a392b0 VersionEdge=b0f80e83f4dc VersionEntry=33f5b00dbda9 VersionReleasedEvent=4ccf1ea90e7f VersionsAnswer=b59e6e057e7b VersionsByModuleVersionValue=e546dfadb913 VersionsFilledEvent=4cc437912dc3 WatchAnswer=46cdf8430557" ) const ( @@ -1232,17 +1232,19 @@ type SeatDefinitionsAnswer struct { // SeatListInput is what seat-list takes. type SeatListInput struct { + // 128 random bits the caller chooses: the subject token of this send's chunks and acknowledgements + Call string `json:"call"` } // SeatListAnswer is what seat-list answers. type SeatListAnswer struct { - // the seat list's digest + // how many chunks are sent + Chunks int64 `json:"chunks"` + // the seat list's sha256, the object's name in seat-lists Digest string `json:"digest"` // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). Form int64 `json:"form,omitempty"` - // the object's name in seat-lists - Object string `json:"object"` - // the object's size in bytes + // the seat list's size in bytes Size int64 `json:"size"` } diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go index 7116d74ee..9981aea73 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go @@ -185,7 +185,9 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v RegistrationsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "registrations answers a capped page with a source-only registration and the next cursor", subject: "", given: "{\"capped\":true,\"next\":\"c-121\",\"registrations\":[{\"at\":\"2026-11-22T00:10:00Z\",\"branches\":[\"main\"],\"by\":\"operator@workstation\",\"check\":{\"seat\":\"node-build-go\",\"step\":\"unit\"},\"origin\":\"novox/hq\",\"policy\":{\"steps\":{\"approval\":\"bypass\",\"review\":\"optional\",\"unit\":\"required\"}},\"v\":1,\"version\":1,\"warrant\":\"ask-m2kx9a1b3c4d6a\"}],\"total\":118}", wire: "{\"capped\":true,\"next\":\"c-121\",\"registrations\":[{\"at\":\"2026-11-22T00:10:00Z\",\"branches\":[\"main\"],\"by\":\"operator@workstation\",\"check\":{\"seat\":\"node-build-go\",\"step\":\"unit\"},\"origin\":\"novox/hq\",\"policy\":{\"steps\":{\"approval\":\"bypass\",\"review\":\"optional\",\"unit\":\"required\"}},\"v\":1,\"version\":1,\"warrant\":\"ask-m2kx9a1b3c4d6a\"}],\"total\":118}", decode: func(b []byte) (any, error) { var v RegistrationsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "seat-list answers the seat list's object by its digest", subject: "", given: "{\"digest\":\"sha256:eeee\",\"object\":\"sha256-eeee\",\"size\":412345}", wire: "{\"digest\":\"sha256:eeee\",\"object\":\"sha256-eeee\",\"size\":412345}", + {name: "seat-list asks the seat list's bytes on a call's chunks", subject: "", given: "{\"call\":\"0123456789abcdef0123456789abcdef\"}", wire: "{\"call\":\"0123456789abcdef0123456789abcdef\"}", + decode: func(b []byte) (any, error) { var v SeatListInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "seat-list answers the seat list's digest, size and how many chunks carry its bytes", subject: "", given: "{\"chunks\":1,\"digest\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"size\":412345}", wire: "{\"chunks\":1,\"digest\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"size\":412345}", decode: func(b []byte) (any, error) { var v SeatListAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/verbs.json index 542c676bf..10c49b397 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/verbs.json @@ -485,12 +485,19 @@ } }, { - "name": "seat-list answers the seat list's object by its digest", + "name": "seat-list asks the seat list's bytes on a call's chunks", + "of": "verb:seat-list.input", + "given": { + "call": "0123456789abcdef0123456789abcdef" + } + }, + { + "name": "seat-list answers the seat list's digest, size and how many chunks carry its bytes", "of": "verb:seat-list.answer", "given": { - "digest": "sha256:eeee", - "size": 412345, - "object": "sha256-eeee" + "chunks": 1, + "digest": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", + "size": 412345 } } ] diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json index da8e95508..5a656ddc1 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json @@ -256,34 +256,45 @@ { "name": "seat-list", "class": "read", - "description": "The seat list the mesh holds, as one object in the holder's objects seat-lists, one object per digest (design 47 H2 §814): the manifest validator program takes it by address, so a run by hand reads what the live validate reads. Reads only.", + "description": "The trunk's seat list as the mesh holds it, the object of the holder's objects seat-lists of that digest (design 47 H2 §814, §820; H-A-441, H-A-443): its digest and size, then its bytes (the definitions resolved, a JSON array in the form of a composer request's seats, sorted by seat) in chunks of at most 512 KiB on the chunk subject of the call, each acknowledged by the caller on the ack subject within 30 seconds. A validate run's asker fills the request's seats from these bytes. Reads only.", "input": { "type": "object", - "properties": {} + "properties": { + "call": { + "type": "string", + "description": "128 random bits the caller chooses: the subject token of this send's chunks and acknowledgements", + "minLength": 1 + } + }, + "required": [ + "call" + ] }, "answer": { "type": "object", "properties": { "digest": { "type": "string", - "description": "the seat list's digest" + "description": "the seat list's sha256, the object's name in seat-lists" }, "size": { "type": "integer", "minimum": 0, - "description": "the object's size in bytes" + "description": "the seat list's size in bytes" }, - "object": { - "type": "string", - "description": "the object's name in seat-lists" + "chunks": { + "type": "integer", + "minimum": 0, + "description": "how many chunks are sent" } }, "required": [ "digest", "size", - "object" + "chunks" ] - } + }, + "chunks": true }, { "name": "revision", @@ -2725,5 +2736,5 @@ ] } }, - "form": 3 + "form": 4 } 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 19e3606ab..6862be0b2 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts @@ -699,17 +699,19 @@ export interface SeatDefinitionsAnswer { /** is what seat-list takes. */ export interface SeatListInput { + /** 128 random bits the caller chooses: the subject token of this send's chunks and acknowledgements */ + "call": string; } /** is what seat-list answers. */ export interface SeatListAnswer { - /** the seat list's digest */ + /** how many chunks are sent */ + "chunks": number; + /** the seat list's sha256, the object's name in seat-lists */ "digest": string; /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ "form"?: number; - /** the object's name in seat-lists */ - "object": string; - /** the object's size in bytes */ + /** the seat list's size in bytes */ "size": number; } From c8ba486318817e4141b8b54ad678ca378e75dbb3 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 02:00:07 +0100 Subject: [PATCH 09/16] I6 (2b): the indexer keeps the seat list as one object and hands it by seat-list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At each trunk seat-definition move (said or not) the indexer writes the trunk's definitions, resolved, as one JSON array sorted by seat into its objects seat-lists under its sha256, when not held, and deletes every object but the newest two, never the one just kept; one journal line per write and delete. Its process serves the chunked verb seat-list: digest, size and chunks, then the object's bytes; a list not kept yet is refused naming it. The manifest serves seat-list and declares seat-lists in its old objects section at 64 MiB. composer.Request gains seat-list, the digest of the bytes Seats were filled from; the judge reads Seats alone. Builds: design 47 H2 §814, §820; H-A-441, H-A-443 (1) --- .../cmd/mesh-delivery-indexer/main.go | 10 +- .../cmd/mesh-delivery-indexer/objects.go | 23 +++ .../cmd/mesh-delivery-indexer/seatlist.go | 20 ++- .../mesh-delivery-indexer/seatlist_test.go | 26 ++- .../internal/index/seatlists.go | 162 ++++++++++++++++++ .../internal/index/seatlists_test.go | 123 +++++++++++++ .../mesh-delivery-indexer/manifest_test.go | 12 +- modules/mesh-delivery-indexer/module.json | 4 +- .../mesh-delivery-sdk/composer/composer.go | 4 + .../composer/composer_test.go | 5 + 10 files changed, 373 insertions(+), 16 deletions(-) create mode 100644 modules/mesh-delivery-indexer/internal/index/seatlists.go create mode 100644 modules/mesh-delivery-indexer/internal/index/seatlists_test.go 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 352505c32..b43acbc05 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -318,13 +318,16 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro seatDefs := process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.SeatDefinitionsState), "no seat definition is kept", logger.Printf) marks := process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, views.MarksState), "no change is said on the views family, so every reader waits on its first view", logger.Printf) seatBus := &seatBus{defs: awaitedSource{ctx, seatDefs}, marks: awaitedSource{ctx, marks}} + // The seat lists, one object per digest (design 47 H2 §814, §820; H-A-441, H-A-443), kept at each trunk definition's move + // and handed by the verb seat-list. + seatLists := newBusObjects(js, cred, index.SeatListsObjects) // The build modules are found again at every change of the seat list (buildmodules.go), once the indexer is made. var buildFollow atomic.Pointer[buildModulesFollow] seatReader, saySeats := followSeatList(seatBus, saySeatDefinition(js, cred), logger.Printf, func() { if b := buildFollow.Load(); b != nil { go b.refresh() // never inside the reader's change: the refresh reads the reader's definitions } - }) + }, seatLists) readWhenBound(seatReader, seatDefs, marks) var fillFollow atomic.Pointer[versionsFill] // Kept while named (design 47 G §675): the want and the running build that name a fingerprint, heard below. @@ -336,9 +339,10 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro inputsStore := awaitedStore{b: process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.InputsState), "no input of a run ask is kept, so the verb input answers none", logger.Printf)} inObjects := &inputObjects{js: js, module: cred.Module} stopInput, err := calls.AnswerSeat(meshcatalog.Seat, seatlist.Definition(seatReader.Reader, meshcatalog.Seat), map[string]process.SeatHandler{ - meshcatalog.VerbInput: index.InputVerb(inputsStore, inObjects, conn, buscalls.SeatAckWithin, logger.Printf)}) + meshcatalog.VerbInput: index.InputVerb(inputsStore, inObjects, conn, buscalls.SeatAckWithin, logger.Printf), + meshcatalog.VerbSeatList: index.SeatListVerb(seatBus.defs, seatLists, conn, buscalls.SeatAckWithin, logger.Printf)}) if err != nil { - return fmt.Errorf("answering the verb input: %w", err) + return fmt.Errorf("answering the verbs input and seat-list: %w", err) } defer stopInput() // The state takeins: hand acts ask there (watched below), and a running take-in keeps what it waits on (H2 §803, H-A-409). 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 6cc947290..8b306ec4a 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/objects.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/objects.go @@ -14,6 +14,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + "git.novox.be/novox/mesh-sdk/go/buscalls" "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/process" "git.novox.be/novox/mesh-sdk/go/views" @@ -109,6 +110,28 @@ func (b *busObjects) Names(ctx context.Context) ([]string, error) { return names, nil } +// List is every object the store holds, a deleted one left out (index.SeatLists). +func (b *busObjects) List(ctx context.Context) ([]buscalls.ObjectInfo, error) { + o, err := b.open(ctx) + if err != nil { + return nil, err + } + infos, err := o.List(ctx) + if errors.Is(err, jetstream.ErrNoObjectsFound) { + return []buscalls.ObjectInfo{}, nil + } + if err != nil { + return nil, err + } + out := make([]buscalls.ObjectInfo, 0, len(infos)) + for _, i := range infos { + if !i.Deleted { + out = append(out, buscalls.ObjectInfo{Name: i.Name, Size: i.Size, Chunks: i.Chunks, Digest: i.Digest, Modified: i.ModTime}) + } + } + return out, nil +} + func (b *busObjects) Fill(ctx context.Context) (int64, int64, error) { o, err := b.open(ctx) if err != nil { diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist.go index 9c25c0283..69fa8d95e 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist.go @@ -110,18 +110,26 @@ func (b *seatBus) said(c index.SeatDefinitionChanged) { // seatlist.Part, novox/hq ADR 0636 §7), which gives catalogue what it holds at every change, and wraps say so that each move // the indexer says is also heard by the reader. Its two tools are not served: the indexer's process serves no request // subject (ADR 0437 §4), and its list is its own state seat-definitions, which indexer_seat_definition and the seat's verb -// seat-definitions read. It returns the part, whose status the indexer's health can show. -func followSeatList(bus *seatBus, say func(context.Context, index.SeatDefinitionChanged) error, logf func(string, ...any), changed func()) (*seatlist.Part, func(context.Context, index.SeatDefinitionChanged) error) { +// seat-definitions read. It returns the part, whose status the indexer's health can show. At each trunk definition's move, +// said or not, the seat list is kept as one object in lists, the objects seat-lists (design 47 H2 §814, §820, H-A-441), a +// failure said in logf. +func followSeatList(bus *seatBus, say func(context.Context, index.SeatDefinitionChanged) error, logf func(string, ...any), changed func(), lists index.SeatLists) (*seatlist.Part, func(context.Context, index.SeatDefinitionChanged) error) { part := seatlist.NewPart(toolPrefix) part.Follow(bus, changed, logf) return part, func(ctx context.Context, c index.SeatDefinitionChanged) error { - if err := say(ctx, c); err != nil { - return err + if c.Source != index.SourceTrunk { // only a trunk's definition is the seat list's + return say(ctx, c) } - if c.Source == index.SourceTrunk { // only a trunk's definition is the seat list's + err := say(ctx, c) + if err == nil { bus.said(c) } - return nil + if lists != nil { + if _, kerr := index.KeepSeatList(ctx, bus.defs, lists, logf); kerr != nil { + logf("the seat list is not kept in %s after %s moved: %v", index.SeatListsObjects, c.Seat, kerr) + } + } + return err } } diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist_test.go index 1eb5b65e0..2b5b6c514 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist_test.go @@ -1,7 +1,10 @@ package main import ( + "context" "errors" + "fmt" + "strings" "sync" "testing" "time" @@ -10,6 +13,8 @@ import ( "git.novox.be/novox/mesh-sdk/go/seatlist" "git.novox.be/novox/mesh-sdk/go/views" + + "mesh-delivery-indexer/internal/index" ) type unboundSource struct { @@ -44,7 +49,17 @@ func (b *awaitedFake) Ready(f func(jetstream.KeyValue)) { b.ready = append(b.rea func TestTheSeatListIsReadAgainWhenItsStatesAreBound(t *testing.T) { src := &unboundSource{} bus := &seatBus{defs: src, marks: src} - part, _ := followSeatList(bus, nil, t.Logf, nil) + var mu sync.Mutex + var unkept []string + logf := func(f string, a ...any) { + t.Logf(f, a...) + if strings.HasPrefix(f, "the seat list is not kept") { + mu.Lock() + unkept = append(unkept, fmt.Sprintf(f, a...)) + mu.Unlock() + } + } + part, say := followSeatList(bus, func(context.Context, index.SeatDefinitionChanged) error { return nil }, logf, nil, &busObjects{}) reader := part.Reader() <-reader.Ready() if reader.Status().Heard { @@ -76,5 +91,14 @@ func TestTheSeatListIsReadAgainWhenItsStatesAreBound(t *testing.T) { if _, ok := seatlist.Definition(part.Reader, "no-such-seat")(); ok { t.Error("a seat the list does not hold is answered a definition") } + // Design 47 H2 §814 (H-A-441): a trunk definition's move keeps the seat list in seat-lists, a pull request's does not; here + // the list holds no definition, so the keeping is refused and said. + _ = say(context.Background(), index.SeatDefinitionChanged{Seat: "a", Source: "pull-7", Digest: "d"}) + _ = say(context.Background(), index.SeatDefinitionChanged{Seat: "a", Source: index.SourceTrunk, Digest: "d"}) + mu.Lock() + defer mu.Unlock() + if len(unkept) != 1 || !strings.Contains(unkept[0], "holds no trunk definition") { + t.Errorf("the moves kept the seat list as %q, want one try, for the trunk's", unkept) + } var _ seatlist.Bus = bus } diff --git a/modules/mesh-delivery-indexer/internal/index/seatlists.go b/modules/mesh-delivery-indexer/internal/index/seatlists.go new file mode 100644 index 000000000..6c7593630 --- /dev/null +++ b/modules/mesh-delivery-indexer/internal/index/seatlists.go @@ -0,0 +1,162 @@ +package index + +import ( + "context" + "crypto/sha256" + "encoding/hex" + "encoding/json" + "errors" + "fmt" + "slices" + "strings" + "time" + + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + + "git.novox.be/novox/mesh-sdk/go/buscalls" + "git.novox.be/novox/mesh-sdk/go/views" +) + +// The seat list as one object (design 47 H2 §814, §820; H-A-441): the trunk's seat definitions, resolved with their +// includes, as one JSON array in composer.Request.Seats' form sorted by seat, kept in the indexer's objects seat-lists +// under its digest (the sha256 of those bytes), written at each trunk seat-definition-changed or -removed; every object +// but the newest two is deleted at each new list. The seat mesh-catalog's verb seat-list hands its digest, size and bytes, and +// a validate run's asker fills its request's seats from them, so every run of one seat list judges the same bytes. + +// SeatListsObjects is the indexer's objects store of seat lists, in its old objects section (a foundation part, ADR 0619 +// §2): 64 MiB, one object per digest. +const SeatListsObjects = "seat-lists" + +// seatListsKept is how many seat lists the objects keep: the newest two. +const seatListsKept = 2 + +// SeatLists is the objects seat-lists as the indexer's process reaches them, to write, prune and hand out. +type SeatLists interface { + // Put stores data whole under name, replacing one of that name. + Put(ctx context.Context, name string, data []byte) error + // Get is the object's bytes; ErrNoObject when it holds none of that name. + Get(ctx context.Context, name string) ([]byte, error) + // Delete removes the object; one it does not hold is no error. + Delete(ctx context.Context, name string) error + // List is every object the store holds, a deleted one left out. + List(ctx context.Context) ([]buscalls.ObjectInfo, error) +} + +// SeatListOf is the trunk's seat list as the object holds it, and its digest: each trunk definition resolved, in the +// order of its seat's name. A list with no seat is an error: no validator judges by an empty list. +func SeatListOf(defs views.Source) ([]byte, string, error) { + keys, err := defs.Keys() + if err != nil { + return nil, "", fmt.Errorf("the %s state cannot be listed: %w", SeatDefinitionsState, err) + } + type seatDef struct { + seat string + def json.RawMessage + } + var seats []seatDef + for _, key := range keys { + seat, ok := strings.CutSuffix(key, "."+SourceTrunk) + if !ok || strings.HasPrefix(key, outOfStepPrefix) { + continue + } + v, ok, err := defs.Get(key) + if err != nil { + return nil, "", fmt.Errorf("%s.%s cannot be read: %w", SeatDefinitionsState, key, err) + } + if !ok || v == nil { + continue + } + var e SeatDefinitionEntry + if err := json.Unmarshal(v.Value, &e); err != nil || e.Digest == "" || len(e.Definition) == 0 { + continue // an entry that holds no definition is no seat of the list + } + seats = append(seats, seatDef{seat, e.Definition}) + } + slices.SortFunc(seats, func(a, b seatDef) int { return strings.Compare(a.seat, b.seat) }) + list := make([]json.RawMessage, 0, len(seats)) + for _, s := range seats { + list = append(list, s.def) + } + if len(list) == 0 { + return nil, "", fmt.Errorf("the %s state holds no trunk definition, so there is no seat list", SeatDefinitionsState) + } + raw, err := json.Marshal(list) + if err != nil { + return nil, "", err + } + sum := sha256.Sum256(raw) + return raw, hex.EncodeToString(sum[:]), nil +} + +// KeepSeatList writes the trunk's seat list into seat-lists under its digest when the objects do not hold it, then deletes +// every object but the newest two, never the list just kept. It answers the list's digest; each write and each delete is +// one line in logf. +func KeepSeatList(ctx context.Context, defs views.Source, o SeatLists, logf func(string, ...any)) (string, error) { + raw, digest, err := SeatListOf(defs) + if err != nil { + return "", err + } + held, err := o.List(ctx) + if err != nil { + return "", fmt.Errorf("the objects %s cannot be listed: %w", SeatListsObjects, err) + } + if !slices.ContainsFunc(held, func(i buscalls.ObjectInfo) bool { return i.Name == digest }) { + if err := o.Put(ctx, digest, raw); err != nil { + return "", fmt.Errorf("the seat list %s cannot be kept in %s: %w", digest, SeatListsObjects, err) + } + logf("seat list %s kept in %s (%d bytes)", digest, SeatListsObjects, len(raw)) + if held, err = o.List(ctx); err != nil { + return digest, fmt.Errorf("the objects %s cannot be listed: %w", SeatListsObjects, err) + } + } + slices.SortFunc(held, func(a, b buscalls.ObjectInfo) int { return b.Modified.Compare(a.Modified) }) // newest first + kept := 0 + for _, i := range held { + if i.Name == digest || kept < seatListsKept { + kept++ + continue + } + if err := o.Delete(ctx, i.Name); err != nil { + return digest, fmt.Errorf("the seat list %s cannot be deleted from %s: %w", i.Name, SeatListsObjects, err) + } + logf("seat list %s deleted from %s: only the newest %d are kept", i.Name, SeatListsObjects, seatListsKept) + } + return digest, nil +} + +// SeatListVerb is the seat mesh-catalog's verb seat-list, served by the indexer's process (H-A-443: the owner hands its +// objects, ADR 0596): the trunk's seat list's digest and size, then the bytes of its object in seat-lists in chunks of at +// most buscalls.SeatChunkBytes on the call's chunk subjects, each acknowledged before the next. A list the objects do not +// hold yet is refused naming it, never answered with other bytes. A caller that does not acknowledge within within ends +// the send, said in logf. +func SeatListVerb(defs views.Source, o SeatLists, line buscalls.ChunkLine, within time.Duration, logf func(string, ...any)) func(caller string, body json.RawMessage) (any, error) { + return func(_ string, raw json.RawMessage) (any, error) { + var in meshcatalog.SeatListInput + if err := json.Unmarshal(raw, &in); err != nil { + return nil, fmt.Errorf("the arguments are not JSON: %w", err) + } + if !callToken.MatchString(in.Call) { + return nil, errors.New("call is one token of 16 to 64 letters, digits, - or _: 128 random bits the caller chooses") + } + ctx := context.Background() + _, digest, err := SeatListOf(defs) + if err != nil { + return nil, err + } + body, err := o.Get(ctx, digest) + if errors.Is(err, ErrNoObject) { + return nil, fmt.Errorf("the seat list %s is not kept in %s yet: it is written at the trunk's next seat-definition change", digest, SeatListsObjects) + } + if err != nil { + return nil, fmt.Errorf("the seat list %s cannot be read from %s: %w", digest, SeatListsObjects, err) + } + send := buscalls.SeatChunks{Seat: meshcatalog.Seat, Verb: meshcatalog.VerbSeatList, Call: in.Call} + total := int64((len(body) + buscalls.SeatChunkBytes - 1) / buscalls.SeatChunkBytes) + go func() { // the send subscribes to the acknowledgements itself and ends when every chunk is sent or one is not acknowledged + if err := send.Send(line, body, within, logf); err != nil { + logf("the send %s of the seat list %s: %v", in.Call, digest, err) + } + }() + return meshcatalog.SeatListAnswer{Digest: digest, Size: int64(len(body)), Chunks: total}, nil + } +} diff --git a/modules/mesh-delivery-indexer/internal/index/seatlists_test.go b/modules/mesh-delivery-indexer/internal/index/seatlists_test.go new file mode 100644 index 000000000..d00f43b52 --- /dev/null +++ b/modules/mesh-delivery-indexer/internal/index/seatlists_test.go @@ -0,0 +1,123 @@ +package index + +import ( + "context" + "crypto/sha256" + "encoding/hex" + "encoding/json" + "errors" + "slices" + "strings" + "testing" + "time" + + "github.com/nats-io/nats.go" + + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + + "git.novox.be/novox/mesh-sdk/go/buscalls" + "git.novox.be/novox/mesh-sdk/go/views" +) + +// memSeatLists is seat-lists in memory; each put is a second newer than the last. +type memSeatLists struct { + objects map[string][]byte + at map[string]time.Time + clock time.Time +} + +func (m *memSeatLists) Put(_ context.Context, name string, data []byte) error { + m.clock = m.clock.Add(time.Second) + m.objects[name], m.at[name] = data, m.clock + return nil +} + +func (m *memSeatLists) Get(_ context.Context, name string) ([]byte, error) { + d, ok := m.objects[name] + if !ok { + return nil, ErrNoObject + } + return d, nil +} + +func (m *memSeatLists) Delete(_ context.Context, name string) error { + delete(m.objects, name) + return nil +} + +func (m *memSeatLists) List(context.Context) ([]buscalls.ObjectInfo, error) { + out := []buscalls.ObjectInfo{} + for n, d := range m.objects { + out = append(out, buscalls.ObjectInfo{Name: n, Size: uint64(len(d)), Modified: m.at[n]}) + } + return out, nil +} + +func (m *memSeatLists) names() []string { + var out []string + for n := range m.objects { + out = append(out, n) + } + slices.Sort(out) + return out +} + +// noLine is a chunk line that hears nothing, so a send ends at once, said. +type noLine struct{} + +func (noLine) Publish(string, []byte) error { return nil } +func (noLine) Subscribe(string, nats.MsgHandler) (*nats.Subscription, error) { + return nil, errors.New("no bus in this test") +} + +// Design 47 H2 §814, §820 (H-A-441, H-A-443): the trunk's seat list is one object of seat-lists named by its sha256, in the +// order of its seats, kept at each new list with the newest two, and handed by the verb seat-list. +func TestTheSeatListIsOneObjectByItsDigest(t *testing.T) { + entry := func(seat, source, def string) *views.Entry { + raw, _ := json.Marshal(SeatDefinitionEntry{Seat: seat, Source: source, Digest: "d-" + seat, Definition: json.RawMessage(def)}) + return &views.Entry{Value: raw} + } + defs := memSource{ + SeatDefinitionKey("a-b"): entry("a-b", SourceTrunk, `{"seat":"a-b"}`), + SeatDefinitionKey("a"): entry("a", SourceTrunk, `{"seat":"a"}`), + "a.pull-7": entry("a", "pull-7", `{"seat":"a","pull":7}`), + outOfStepPrefix + "c." + SourceTrunk: entry("c", SourceTrunk, `{"seat":"c"}`), + } + want := `[{"seat":"a"},{"seat":"a-b"}]` // by seat, not by key: "a-b.trunk" sorts before "a.trunk" + sum := sha256.Sum256([]byte(want)) + digest := hex.EncodeToString(sum[:]) + raw, got, err := SeatListOf(defs) + if err != nil || string(raw) != want || got != digest { + t.Fatalf("SeatListOf = %s %s (%v), want %s %s", raw, got, err, want, digest) + } + if _, _, err := SeatListOf(memSource{}); err == nil { + t.Error("an empty seat list was given a digest") + } + + lists := &memSeatLists{objects: map[string][]byte{}, at: map[string]time.Time{}} + verb := SeatListVerb(defs, lists, noLine{}, time.Second, t.Logf) + if _, err := verb("", json.RawMessage(`{"call":"0123456789abcdef0123456789abcdef"}`)); err == nil || !strings.Contains(err.Error(), "not kept in seat-lists yet") { + t.Errorf("a list not kept yet was answered: %v", err) + } + for _, old := range []string{"old-1", "old-2", "old-3"} { + _ = lists.Put(context.Background(), old, []byte("[]")) + } + if d, err := KeepSeatList(context.Background(), defs, lists, t.Logf); err != nil || d != digest { + t.Fatalf("KeepSeatList = %s (%v), want %s", d, err, digest) + } + if names := lists.names(); !slices.Equal(names, []string{digest, "old-3"}) || string(lists.objects[digest]) != want { + t.Errorf("seat-lists holds %v, want the list kept and the newest other", names) + } + before := lists.at[digest] + if _, err := KeepSeatList(context.Background(), defs, lists, t.Logf); err != nil || !lists.at[digest].Equal(before) || len(lists.objects) != 2 { + t.Errorf("the same list kept again was written again, or another deleted: %v %v", lists.names(), err) + } + + if _, err := verb("", json.RawMessage(`{"call":"x"}`)); err == nil || !strings.Contains(err.Error(), "128 random bits") { + t.Errorf("a call that is no token was taken: %v", err) + } + a, err := verb("", json.RawMessage(`{"call":"0123456789abcdef0123456789abcdef"}`)) + if err != nil || a != (meshcatalog.SeatListAnswer{Digest: digest, Size: int64(len(want)), Chunks: 1}) { + t.Errorf("seat-list = %+v (%v), want its digest, size and one chunk", a, err) + } +} diff --git a/modules/mesh-delivery-indexer/manifest_test.go b/modules/mesh-delivery-indexer/manifest_test.go index acdaa0f5b..39223ee20 100644 --- a/modules/mesh-delivery-indexer/manifest_test.go +++ b/modules/mesh-delivery-indexer/manifest_test.go @@ -149,9 +149,11 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build // capped at 512 MiB, under the local name the indexer opens. W4.14 (design 47, Reverted): their form is 1. Design 47 H // §742 (H-A-105): no catch-up tool of the indexer's follows a restore, indexer_take_in having gone with the builder-log // index; the gate's gate_head_take is the one hand take of a head. - if len(m.Objects) != 1 || m.Objects[0].Name != index.CatalogRevisionsObjects || m.Objects[0].MaxMiB != 512 || - m.Objects[0].Form != 1 || m.Objects[0].CatchUp != "" { - t.Errorf("objects = %+v, want %s capped at 512 MiB, form 1, no catch-up tool", m.Objects, index.CatalogRevisionsObjects) + // Design 47 H2 §814, §820 (H-A-441): the seat lists, one object per digest, 64 MiB, in the old section too. + if len(m.Objects) != 2 || m.Objects[0].Name != index.CatalogRevisionsObjects || m.Objects[0].MaxMiB != 512 || + m.Objects[0].Form != 1 || m.Objects[0].CatchUp != "" || m.Objects[1].Name != index.SeatListsObjects || m.Objects[1].MaxMiB != 64 { + t.Errorf("objects = %+v, want %s capped at 512 MiB, form 1, no catch-up tool, and %s at 64 MiB", m.Objects, + index.CatalogRevisionsObjects, index.SeatListsObjects) } // D-11 (ADR 0634 §1): the holders and buckets the indexer names (internal/index/names.go) are its manifest's: its own // name and states with their revisions, and the states it reads, each as `.`. @@ -306,8 +308,8 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build // ADR 0604 §2, ADR 0636 §4: it holds the seat mesh-catalog, serving its four verbs and seat-definitions from its tools // bundle (which stays without a request subject); ADR 0663 §1: and revision, in the same runtime of its own. if len(m.Claims) != 1 || m.Claims[0].Name != index.CatalogSeat || m.Claims[0].Scope != catalogue.ScopeMesh || - !slices.Equal(m.Claims[0].Serves, []string{"modules", "module", "provides", "dependents", index.SeatDefinitionsVerb, "revision", "entry", "registrations", "register", "policy", "watch", "unwatch", "versions", "outdated", "input"}) { - t.Errorf("claims = %+v, want mesh-catalog with its seven verbs (entry: design 47 G §675)", m.Claims) + !slices.Equal(m.Claims[0].Serves, []string{"modules", "module", "provides", "dependents", index.SeatDefinitionsVerb, "seat-list", "revision", "entry", "registrations", "register", "policy", "watch", "unwatch", "versions", "outdated", "input"}) { + t.Errorf("claims = %+v, want mesh-catalog with its verbs (entry: design 47 G §675; seat-list: H2 §814)", m.Claims) } for _, e := range []string{index.SeatDefinitionChangedEvent, index.SeatDefinitionRemovedEvent} { if slices.Contains(m.Emits, e) { diff --git a/modules/mesh-delivery-indexer/module.json b/modules/mesh-delivery-indexer/module.json index dc1ad3aac..e28281ab1 100644 --- a/modules/mesh-delivery-indexer/module.json +++ b/modules/mesh-delivery-indexer/module.json @@ -13,6 +13,7 @@ "provides", "dependents", "seat-definitions", + "seat-list", "revision", "entry", "registrations", @@ -147,7 +148,8 @@ { "name": "mesh-delivery-indexer-findings", "events": ["finding-written.*", "finding-cleared.*", "findings-stated.*"], "max-age-days": 7, "max-mib": 16 } ], "objects": [ - { "name": "catalog-revisions", "max-mib": 512, "form": 1 } + { "name": "catalog-revisions", "max-mib": 512, "form": 1 }, + { "name": "seat-lists", "max-mib": 64 } ], "emits": [ "take-in.pending", diff --git a/modules/mesh-delivery-sdk/composer/composer.go b/modules/mesh-delivery-sdk/composer/composer.go index 019708074..eac635813 100644 --- a/modules/mesh-delivery-sdk/composer/composer.go +++ b/modules/mesh-delivery-sdk/composer/composer.go @@ -67,6 +67,10 @@ type Request struct { // them (the definitions of the seat mesh-catalog, resolved), raw so that this package names no seat (ADR 0635 §4, ADR 0636 // §1). The judge and the composer read them. None is no list at hand: a composer handed none judges no machine (ADR 0636 §1). Seats []json.RawMessage `json:"seats,omitempty"` + // SeatList is the sha256 of the bytes Seats were filled from: the object of the seat mesh-catalog's seat-list, or a + // revision's own definitions in the same form (design 47 H2 §814; H-A-441, H-A-443), so a verdict says which seat list + // judged it. The asker fetches the bytes and fills Seats before the run; the judge reads Seats alone. Empty is none named. + SeatList string `json:"seat-list,omitempty"` // BlameTries bounds the composer's search for the modules a machine that does not compose blames: it composes at // most this many times more, the assigner's setting blame-tries, since the composer has no settings of its own // (design 47 G §721, §729; A-469i). None is no search: the composer blames only what its composition holds or diff --git a/modules/mesh-delivery-sdk/composer/composer_test.go b/modules/mesh-delivery-sdk/composer/composer_test.go index c8c80c300..b14d35f09 100644 --- a/modules/mesh-delivery-sdk/composer/composer_test.go +++ b/modules/mesh-delivery-sdk/composer/composer_test.go @@ -63,6 +63,11 @@ func TestAManifestIsItsBytesOrItsDigest(t *testing.T) { if back, derr := Decode(wire); err != nil || derr != nil || back.BlameTries != 20 || !strings.Contains(string(wire), `"blame_tries":20`) { t.Errorf("blame_tries 20 went as %s and read back %d (%v, %v)", wire, back.BlameTries, err, derr) } + // Design 47 H2 §814 (H-A-441): the seat list a request's seats were filled from reads back by its digest. + wire, err = json.Marshal(Request{V: Version, SeatList: "0123abcd"}) + if back, derr := Decode(wire); err != nil || derr != nil || back.SeatList != "0123abcd" || !strings.Contains(string(wire), `"seat-list":"0123abcd"`) { + t.Errorf("seat-list went as %s and read back %q (%v, %v)", wire, back.SeatList, err, derr) + } // H3 (design 47 G A-470j, A-470k): a case's none, each module the revision gives no fingerprint with its none words, // reads back whole; a case naming none leaves the field off the wire. wire, err = json.Marshal(Request{V: Version, Cases: []Case{{Name: "change", Manifests: map[string]Manifest{}, From a343fddfe7ed577a3f477361eefa47711c945feb Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 02:03:04 +0100 Subject: [PATCH 10/16] I6 (1): the indexer's integration fixtures that claim a seat name their class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The whole indexer's hand manifests of a build module and of the assigner's holder claim a seat, so they name class core, as the judge now asks; with none, every take-in of those tests refused them and waited out its bound. Builds: design 47 H2 §814; H-A-394 (1) --- .../cmd/mesh-delivery-indexer/integration_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 c9bd95909..52fdda675 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 @@ -522,7 +522,7 @@ func seedBuildModules(t *testing.T, ctx context.Context, js jetstream.JetStream, if _, err := defs.Put(ctx, b.seat+".trunk", entry); err != nil { t.Fatal(err) } - manifest := `{"module":"` + b.module + `","version":"1","claims":[{"name":"` + b.seat + `","scope":"node","serves":["current","drop","pause","resume"]}],` + + manifest := `{"module":"` + b.module + `","version":"1","class":"core","claims":[{"name":"` + b.seat + `","scope":"node","serves":["current","drop","pause","resume"]}],` + `"streams":[{"name":"` + b.stream + `","events":["toolchain.**"]}]}` digest := meshcatalogclient.ManifestDigest([]byte(manifest)) mkey, err := meshcatalogclient.ManifestsKey(digest) @@ -564,7 +564,7 @@ func seedClaimant(t *testing.T, ctx context.Context, js jetstream.JetStream, man } } seedAssignerSeat(t, ctx, js) - manifest := `{"module":"` + assignerHolderModule + `","version":"1","claims":[{"name":"` + meshmoduleassigner.Seat + `","scope":"mesh"}]}` + manifest := `{"module":"` + assignerHolderModule + `","version":"1","class":"core","claims":[{"name":"` + meshmoduleassigner.Seat + `","scope":"mesh"}]}` digest := meshcatalogclient.ManifestDigest([]byte(manifest)) mkey, err := meshcatalogclient.ManifestsKey(digest) if err != nil { From 381934396b8deaadeaa095fe4694fe1c9730e107 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 02:04:18 +0100 Subject: [PATCH 11/16] I6 (2c): the indexer keeps the seat list at its start too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Once the seat definitions' state is bound at the start, the indexer keeps the seat list in seat-lists, so seat-list answers from the first delivery and never refuses "not kept yet" for want of a trunk definition's move. Builds: design 47 H2 §814, §820; H-A-447 --- .../cmd/mesh-delivery-indexer/main.go | 1 + .../cmd/mesh-delivery-indexer/seatlist.go | 11 +++++++++++ .../cmd/mesh-delivery-indexer/seatlist_test.go | 12 +++++++++++- .../internal/index/seatlists.go | 5 +++-- 4 files changed, 26 insertions(+), 3 deletions(-) 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 b43acbc05..51e04cb50 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -329,6 +329,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro } }, seatLists) readWhenBound(seatReader, seatDefs, marks) + keepSeatListAtStart(ctx, seatDefs, seatBus.defs, seatLists, logger.Printf) var fillFollow atomic.Pointer[versionsFill] // Kept while named (design 47 G §675): the want and the running build that name a fingerprint, heard below. named := index.NewNamed(awaitedStore{b: process.AwaitBucket(ctx, js, conn, index.Bucket(cred.Module, index.NamedState), "no entry is kept for a want or a running build that names it", logger.Printf)}, logger.Printf) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist.go index 69fa8d95e..05ab36fcf 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist.go @@ -147,5 +147,16 @@ func readWhenBound(part *seatlist.Part, states ...bucket) { } } +// keepSeatListAtStart keeps the seat list in lists once the seat definitions' state is bound at the indexer's start, so the +// verb seat-list answers from the first delivery and not only after a trunk definition's move (design 47 H2 §814; H-A-447). +// A list that cannot be kept is said in logf. +func keepSeatListAtStart(ctx context.Context, state bucket, defs views.Source, lists index.SeatLists, logf func(string, ...any)) { + state.Ready(func(jetstream.KeyValue) { + if _, err := index.KeepSeatList(ctx, defs, lists, logf); err != nil { + logf("the seat list is not kept in %s at the start: %v", index.SeatListsObjects, err) + } + }) +} + // toolPrefix is the prefix of the indexer's tools, its manifest's slug. const toolPrefix = "indexer" diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist_test.go index 2b5b6c514..19c917d23 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/seatlist_test.go @@ -53,7 +53,7 @@ func TestTheSeatListIsReadAgainWhenItsStatesAreBound(t *testing.T) { var unkept []string logf := func(f string, a ...any) { t.Logf(f, a...) - if strings.HasPrefix(f, "the seat list is not kept") { + if strings.HasPrefix(f, "the seat list is not kept in %s after") { mu.Lock() unkept = append(unkept, fmt.Sprintf(f, a...)) mu.Unlock() @@ -100,5 +100,15 @@ func TestTheSeatListIsReadAgainWhenItsStatesAreBound(t *testing.T) { if len(unkept) != 1 || !strings.Contains(unkept[0], "holds no trunk definition") { t.Errorf("the moves kept the seat list as %q, want one try, for the trunk's", unkept) } + // H-A-447: and once the state is bound at the start, with no move. + started, atStart := &awaitedFake{}, "" + keepSeatListAtStart(context.Background(), started, src, &busObjects{}, func(f string, a ...any) { atStart = fmt.Sprintf(f, a...) }) + if atStart != "" || len(started.ready) != 1 { + t.Fatalf("the seat list was kept before its state was bound: %q", atStart) + } + started.ready[0](nil) + if !strings.Contains(atStart, "at the start") || !strings.Contains(atStart, "holds no trunk definition") { + t.Errorf("the start kept the seat list as %q, want one try", atStart) + } var _ seatlist.Bus = bus } diff --git a/modules/mesh-delivery-indexer/internal/index/seatlists.go b/modules/mesh-delivery-indexer/internal/index/seatlists.go index 6c7593630..e7011e01e 100644 --- a/modules/mesh-delivery-indexer/internal/index/seatlists.go +++ b/modules/mesh-delivery-indexer/internal/index/seatlists.go @@ -19,7 +19,8 @@ import ( // The seat list as one object (design 47 H2 §814, §820; H-A-441): the trunk's seat definitions, resolved with their // includes, as one JSON array in composer.Request.Seats' form sorted by seat, kept in the indexer's objects seat-lists -// under its digest (the sha256 of those bytes), written at each trunk seat-definition-changed or -removed; every object +// under its digest (the sha256 of those bytes), written at the indexer's start (H-A-447) and at each trunk +// seat-definition-changed or -removed; every object // but the newest two is deleted at each new list. The seat mesh-catalog's verb seat-list hands its digest, size and bytes, and // a validate run's asker fills its request's seats from them, so every run of one seat list judges the same bytes. @@ -145,7 +146,7 @@ func SeatListVerb(defs views.Source, o SeatLists, line buscalls.ChunkLine, withi } body, err := o.Get(ctx, digest) if errors.Is(err, ErrNoObject) { - return nil, fmt.Errorf("the seat list %s is not kept in %s yet: it is written at the trunk's next seat-definition change", digest, SeatListsObjects) + return nil, fmt.Errorf("the seat list %s is not kept in %s yet: it is written at the indexer's start and at each trunk seat-definition move", digest, SeatListsObjects) } if err != nil { return nil, fmt.Errorf("the seat list %s cannot be read from %s: %w", digest, SeatListsObjects, err) From f838a6c34c2a08c22483b7c0df77492d9a363d10 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 02:05:29 +0100 Subject: [PATCH 12/16] I6 (3): the indexer's manifest names its class, a cap on every state, and the kept-call pace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit class core (it claims mesh-catalog). Every state names its cap. Fills read with the bus module's nats_buckets on novox, 2026-11-22 ~02:20 CET (its show answers only entries the bus module made, not old sections): candidates 3,963,006 B (3.78 MiB) -> 16 MiB; manifests 5,463,959 B (5.21 MiB) -> 32 MiB; seat-definitions 4,392,352 B (4.19 MiB) -> 32 MiB; at 8 MiB, each at or below 2 MiB: packages 767,959; takeins 468,577; findings 293,571; registrations 111,058; inputs 26,473; taken 5,595; predefined 4,215; requirements 3,945; view-marks 3,068; first-views 1,554; oldsections 256; runs 152; held 140; build-edges 0. Seventeen states, not the sixteen the handover counted. The findings stream keeps 8 MiB, 7 days. kept-call-pace-first 1s and kept-call-pace-max 30s, runtime settings, as it makes kept calls. Builds: design 47 H2 §775, §783, §810, §812, §814, §820; H-A-394 (1), H-A-411 (1) (2), H-A-437 --- .../mesh-delivery-indexer/manifest_test.go | 29 ++++++++--- modules/mesh-delivery-indexer/module.json | 51 ++++++++++++------- 2 files changed, 55 insertions(+), 25 deletions(-) diff --git a/modules/mesh-delivery-indexer/manifest_test.go b/modules/mesh-delivery-indexer/manifest_test.go index 39223ee20..c8c49cd36 100644 --- a/modules/mesh-delivery-indexer/manifest_test.go +++ b/modules/mesh-delivery-indexer/manifest_test.go @@ -14,6 +14,7 @@ import ( "testing" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer/takein" + "git.novox.be/novox/mesh-sdk/go/busretry" "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/views" @@ -58,6 +59,7 @@ type stream struct { type manifest struct { Module string `json:"module"` Version string `json:"version"` + Class string `json:"class"` // core, as it claims a seat (design 47 H2 §810, §814; H-A-394 (1)) Slug string `json:"slug"` RunsAs string `json:"runs-as"` Streams []stream `json:"streams"` @@ -136,12 +138,15 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build } // 1126 note 76: heard keeps the last 64 FORGE messages the indexer handled, for indexer_heard; 8 MiB, each reservation // and each gathering of them a key of its own time to live (design 47 H2 §805, H-A-420 (3), H-A-436). - if want := []state{{Name: "candidates", History: 10}, {Name: "heard", History: 64, MaxMiB: 8, KeyTTL: true}, {Name: "manifests", History: 1}, {Name: "predefined", History: 5}, {Name: "taken", History: 1}, {Name: "takeins", History: 1}, {Name: "oldsections", History: 1}, {Name: index.RunsState, History: 1}, {Name: index.PackagesState, History: index.PackagesHistory}, - {Name: views.MarksState, History: 1}, {Name: index.FindingsState, History: 5}, {Name: views.StatusState, History: 1}, - {Name: index.RequirementsState, History: 5}, {Name: index.SeatDefinitionsState, History: 5}, + // Design 47 H2 §814, §820 (H-A-411 (2), H-A-437): every state names its cap, 8 MiB where the live fill (novox, 2026-11-22) + // is a quarter of it or less, else the smallest power of two above four times the fill: candidates 3.78 MiB at 16, + // manifests 5.21 MiB and seat-definitions 4.19 MiB at 32. + if want := []state{{Name: "candidates", History: 10, MaxMiB: 16}, {Name: "heard", History: 64, MaxMiB: 8, KeyTTL: true}, {Name: "manifests", History: 1, MaxMiB: 32}, {Name: "predefined", History: 5, MaxMiB: 8}, {Name: "taken", History: 1, MaxMiB: 8}, {Name: "takeins", History: 1, MaxMiB: 8}, {Name: "oldsections", History: 1, MaxMiB: 8}, {Name: index.RunsState, History: 1, MaxMiB: 8}, {Name: index.PackagesState, History: index.PackagesHistory, MaxMiB: 8}, + {Name: views.MarksState, History: 1, MaxMiB: 8}, {Name: index.FindingsState, History: 5, MaxMiB: 8}, {Name: views.StatusState, History: 1, MaxMiB: 8}, + {Name: index.RequirementsState, History: 5, MaxMiB: 8}, {Name: index.SeatDefinitionsState, History: 5, MaxMiB: 32}, {Name: index.EntryIndexState, History: 1, MaxMiB: 8}, {Name: index.NamedState, History: 1, MaxMiB: 4}, // design 47 G §695 - {Name: index.RegistrationsState, History: 1}, {Name: index.ProposalsState, History: 1, MaxMiB: 4}, - {Name: index.VersionsState, History: 1, MaxMiB: 64}, {Name: index.BuildEdgesState, History: 1}, {Name: index.InputsState, History: 1}, {Name: index.PinsState, History: 1, MaxMiB: index.PinsCapMiB}, {Name: index.HeldState, History: 1}, + {Name: index.RegistrationsState, History: 1, MaxMiB: 8}, {Name: index.ProposalsState, History: 1, MaxMiB: 4}, + {Name: index.VersionsState, History: 1, MaxMiB: 64}, {Name: index.BuildEdgesState, History: 1, MaxMiB: 8}, {Name: index.InputsState, History: 1, MaxMiB: 8}, {Name: index.PinsState, History: 1, MaxMiB: index.PinsCapMiB}, {Name: index.HeldState, History: 1, MaxMiB: 8}, {Name: index.DryRunsState, History: 1, TTL: 3600, MaxMiB: 16}}; !reflect.DeepEqual(m.State, want) { // DLV-I7, DLV-I17; design 47 H2 §804, §820 t.Errorf("state = %+v, want %+v", m.State, want) } @@ -219,8 +224,18 @@ func TestManifestDeclarations(t *testing.T) { // 1238/AC1, 1444 (reads the build } // Design 47 G §2, §9: every version of every registration is kept with no age limit, 64 MiB, on the old streams section. if len(m.Streams) != 2 || m.Streams[0].Name != index.RegistrationHistoryStream || m.Streams[0].Retention != "history" || m.Streams[0].MaxMiB != 64 || - m.Streams[1].Name != m.Module+"-findings" || m.Streams[1].MaxAgeDays != 7 || m.Streams[1].MaxMiB != 16 { - t.Errorf("streams = %+v, want registration-history keeping its history, 64 MiB, and the findings stream (§387)", m.Streams) + m.Streams[1].Name != m.Module+"-findings" || m.Streams[1].MaxAgeDays != 7 || m.Streams[1].MaxMiB != 8 { + t.Errorf("streams = %+v, want registration-history keeping its history, 64 MiB, and the findings stream at 8 MiB (§387, H2 §783)", m.Streams) + } + // Design 47 H2 §810, §814 (H-A-394 (1)): it claims a seat, so its class is core. §775: it makes kept calls, so it declares + // the kept-call pace, 1 s to 30 s, read while it runs. + if m.Class != "core" { + t.Errorf("class = %q, want core", m.Class) + } + for key, def := range map[string]string{busretry.PaceFirstSetting: "1s", busretry.PaceMaxSetting: "30s"} { + if c, _ := m.Config[key].(map[string]any); c["default"] != def || c["runtime"] != true || c["type"] != "string" { + t.Errorf("config %s = %v, want a runtime string setting defaulting to %s", key, m.Config[key], def) + } } // Design 47 G §368: version is MAJOR.MINOR (0.1 while none is published, §368); §295, §299: the catalog revisions' form and // the catch-up tool beside it (checked above). diff --git a/modules/mesh-delivery-indexer/module.json b/modules/mesh-delivery-indexer/module.json index e28281ab1..965ea9527 100644 --- a/modules/mesh-delivery-indexer/module.json +++ b/modules/mesh-delivery-indexer/module.json @@ -1,6 +1,7 @@ { "module": "mesh-delivery-indexer", "version": "0.1", + "class": "core", "slug": "indexer", "runs-as": "mesh-delivery-indexer", "claims": [ @@ -102,6 +103,20 @@ "npm-package-registry.published" ], "config": { + "kept-call-pace-first": { + "type": "string", + "description": "the first wait before a kept call is made again after a transport fault, doubling to kept-call-pace-max, a Go duration (design 47 H2 §775).", + "trusted": false, + "default": "1s", + "runtime": true + }, + "kept-call-pace-max": { + "type": "string", + "description": "the longest wait between two tries of a kept call after a transport fault, a Go duration (design 47 H2 §775).", + "trusted": false, + "default": "30s", + "runtime": true + }, "reserved-keep": { "type": "string", "description": "how long the indexer keeps a pipeline's reservation of a package's version in its state heard (reserved..), a Go duration (design 47 H2 §805, H-A-424 (2)).", @@ -118,34 +133,34 @@ } }, "state": [ - { "name": "candidates", "history": 10 }, + { "name": "candidates", "history": 10, "max-mib": 16 }, { "name": "heard", "history": 64, "max-mib": 8, "key-ttl": true }, - { "name": "manifests", "history": 1 }, - { "name": "predefined", "history": 5 }, - { "name": "taken", "history": 1 }, - { "name": "takeins", "history": 1 }, - { "name": "oldsections", "history": 1 }, - { "name": "runs", "history": 1 }, - { "name": "packages", "history": 5 }, - { "name": "view-marks", "history": 1 }, - { "name": "findings", "history": 5 }, - { "name": "first-views", "history": 1 }, - { "name": "requirements", "history": 5 }, - { "name": "seat-definitions", "history": 5 }, + { "name": "manifests", "history": 1, "max-mib": 32 }, + { "name": "predefined", "history": 5, "max-mib": 8 }, + { "name": "taken", "history": 1, "max-mib": 8 }, + { "name": "takeins", "history": 1, "max-mib": 8 }, + { "name": "oldsections", "history": 1, "max-mib": 8 }, + { "name": "runs", "history": 1, "max-mib": 8 }, + { "name": "packages", "history": 5, "max-mib": 8 }, + { "name": "view-marks", "history": 1, "max-mib": 8 }, + { "name": "findings", "history": 5, "max-mib": 8 }, + { "name": "first-views", "history": 1, "max-mib": 8 }, + { "name": "requirements", "history": 5, "max-mib": 8 }, + { "name": "seat-definitions", "history": 5, "max-mib": 32 }, { "name": "entry-index", "history": 1, "max-mib": 8 }, { "name": "named", "history": 1, "max-mib": 4 }, - { "name": "registrations", "history": 1 }, + { "name": "registrations", "history": 1, "max-mib": 8 }, { "name": "proposals", "history": 1, "max-mib": 4 }, { "name": "versions", "history": 1, "max-mib": 64 }, - { "name": "build-edges", "history": 1 }, - { "name": "inputs", "history": 1 }, + { "name": "build-edges", "history": 1, "max-mib": 8 }, + { "name": "inputs", "history": 1, "max-mib": 8 }, { "name": "pins", "history": 1, "max-mib": 4 }, - { "name": "held", "history": 1 }, + { "name": "held", "history": 1, "max-mib": 8 }, { "name": "dry-runs", "history": 1, "ttl-seconds": 3600, "max-mib": 16 } ], "streams": [ { "name": "registration-history", "events": ["registration.*"], "retention": "history", "max-mib": 64 }, - { "name": "mesh-delivery-indexer-findings", "events": ["finding-written.*", "finding-cleared.*", "findings-stated.*"], "max-age-days": 7, "max-mib": 16 } + { "name": "mesh-delivery-indexer-findings", "events": ["finding-written.*", "finding-cleared.*", "findings-stated.*"], "max-age-days": 7, "max-mib": 8 } ], "objects": [ { "name": "catalog-revisions", "max-mib": 512, "form": 1 }, From 6b0ccc5d27ce8e2d80ba5c217eff4c4dcc2fd1c4 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 02:07:36 +0100 Subject: [PATCH 13/16] I6 (4a): the indexer builds no candidate for a source-only check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A run member or mover named source.. is a source-only registration's check, which the runner runs as one step: StartRun builds it no candidate and keeps no run, and its pipeline-ended keeps none either. Builds: design 47 H2 §815; H-A-438, H-A-442 --- .../internal/index/runcandidates.go | 21 +++++++++++++++---- .../internal/index/runcandidates_test.go | 19 +++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/runcandidates.go b/modules/mesh-delivery-indexer/internal/index/runcandidates.go index 9353b42b1..74d365871 100644 --- a/modules/mesh-delivery-indexer/internal/index/runcandidates.go +++ b/modules/mesh-delivery-indexer/internal/index/runcandidates.go @@ -67,7 +67,9 @@ func (r Run) done() bool { } // StartRun takes a run on request in, as the runner said it started: its members are kept in the state runs and its -// candidate is written; a run every member of which has ended already (its ends heard first) is dropped instead. +// candidate is written; a run every member of which has ended already (its ends heard first) is dropped instead. A member +// that is a source-only registration (its module the key source..) gets no candidate: the runner runs its check +// as one step (design 47 H2 §815; H-A-442), so a run of such members alone keeps and writes nothing. func (ix *Indexer) StartRun(ctx context.Context, e meshpipelinerunner.RunStarted) error { group, err := RunGroup(e.Run) if err != nil { @@ -76,9 +78,13 @@ func (ix *Indexer) StartRun(ctx context.Context, e meshpipelinerunner.RunStarted if len(e.Members) == 0 { return fmt.Errorf("%w: the run %s names no member", ErrUnreadable, e.Run) } + members := slices.DeleteFunc(slices.Clone(e.Members), func(m meshpipelinerunner.Member) bool { return isSourceMember(m.Module) }) + if len(members) == 0 { + return nil // a source-only check: no candidate, no run kept + } ix.runMu.Lock() defer ix.runMu.Unlock() - r, err := ix.updateRun(ctx, group, func(r *Run) { r.Members = slices.Clone(e.Members) }) + r, err := ix.updateRun(ctx, group, func(r *Run) { r.Members = members }) if err != nil { return err } @@ -88,11 +94,18 @@ func (ix *Indexer) StartRun(ctx context.Context, e meshpipelinerunner.RunStarted return ix.writeRunCandidate(ctx, group, r.Members) } +// isSourceMember says a run's member or mover is a source-only registration, named by its key source.. +// (design 47 H2 §815; H-A-438). +func isSourceMember(module string) bool { + _, _, source := meshcatalog.ParseRegistrationsBySourceOwnerNameKey(module) + return source +} + // EndRunPipeline takes one pipeline-ended in: of a run's pipeline, its module is kept as ended, and once every member's has // ended the candidate and the run's key are removed. A pipeline of no run is none of this. func (ix *Indexer) EndRunPipeline(ctx context.Context, e meshpipelinerunner.PipelineEnded) error { - if e.Run == "" { - return nil + if e.Run == "" || !slices.ContainsFunc(e.Movers, func(m meshpipelinerunner.MoverEnded) bool { return !isSourceMember(m.Module) }) { + return nil // no run, or a source-only check's, which keeps no run (StartRun) } group, err := RunGroup(e.Run) if err != nil { diff --git a/modules/mesh-delivery-indexer/internal/index/runcandidates_test.go b/modules/mesh-delivery-indexer/internal/index/runcandidates_test.go index 3d4403852..553a8196d 100644 --- a/modules/mesh-delivery-indexer/internal/index/runcandidates_test.go +++ b/modules/mesh-delivery-indexer/internal/index/runcandidates_test.go @@ -114,6 +114,25 @@ func TestARunsCandidateIsBuiltOnItsStartAndDroppedWhenEveryMembersPipelineEnded( t.Errorf("candidates %v, want none", k) } }) + // Design 47 H2 §815 (H-A-438, H-A-442): a source-only check's member is its registration's key; the runner runs it as one + // step, so the indexer builds it no candidate and keeps no run, at its start or its end. + t.Run("a source-only check gets no candidate and no run", func(t *testing.T) { + ix, cands, runs, _ := bed(t) + source := started + source.Members = []meshpipelinerunner.Member{{Module: "source.novox.hq", Commit: c1}} + if err := ix.StartRun(ctx, source); err != nil { + t.Errorf("a source-only check's start: %v", err) + } + if err := ix.EndRunPipeline(ctx, ended("source.novox.hq")); err != nil { + t.Error(err) + } + if k, _ := cands.Keys(ctx); len(k) != 0 { + t.Errorf("candidates %v, want none", k) + } + if k, _ := runs.Keys(ctx); len(k) != 0 { + t.Errorf("runs %v, want none", k) + } + }) t.Run("a member's take-in starts from its own branch only when its registration watches it", func(t *testing.T) { reg := meshcatalog.Registration{Branches: []string{"main", "beta"}} for branch, want := range map[string]string{"beta": "beta", "main": TrunkBranch, "feature/1966-x": TrunkBranch, "": TrunkBranch} { From 3e90604eb488b167d16049f754a99096d2cc48fb Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 02:16:59 +0100 Subject: [PATCH 14/16] D (H-A-450): register's refused names holds-manifest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A source-only registration whose repository holds a manifest is refused by a value the enum names, so a caller registers its module instead. The seat's form rises to 5; regenerated with seatgen, -check clean. Builds: design 47 H2 §815; H-A-450 (1) --- .../go/seats/meshcatalog/contract.go | 9 +++++---- .../mesh-delivery-contracts/seats/mesh-catalog/seat.json | 7 ++++--- .../ts/seats/meshcatalog/index.d.ts | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go index 43d307e91..9656f5df7 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go @@ -14,13 +14,13 @@ const Seat = "mesh-catalog" // Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): // a reader of a value of another form says "form N, this reader knows M". -const Form = 4 +const Form = 5 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "4" - generatedFieldsDigest = "ActingRule=8a83ce7e0457 Artifact=78b05c1a9ec3 ArtifactPackage=2a3a660a934d ArtifactRef=a2f06147f4b6 BuildEdge=76f0684e254a BuildEdges=d2b95000259e BuildEdgesByModuleBranchValue=4fdf7cc1e723 CandidatesByGroupValue=9ea8c6c580d2 CandidatesByGroupValuePullsItem=90fb03643258 CandidatesByGroupValuePullsItemFpsValue=4c6783201aa3 CatalogEntry=c0a4ea25d523 CatalogRevision=d1ecaaa484af CatalogRevisionDefinitionsItem=77fcff620d48 CatalogRevisionEvent=710cbc5bfff1 CatalogRevisionsByBranchRevisionValue=17e54f635d35 CatalogRevisionsByCandidateGroupHeadsValue=17e54f635d35 CatalogRevisionsByEntryDigestValue=8755036a3051 DependentsAnswer=7538f2f5e68e Edge=7242732afaef EntryAnswer=805c2ff28e1c EntryInputs=76a7f8690dd2 EntryRef=ff109e5089e1 Fill=80f442916429 FillingEvent=5bd4df78ed84 FingerprintInputs=99a6df7f991f FullEvent=5bd4df78ed84 Head=774b4bf88ba4 InputAnswer=cd41ee65565d InputsByTimeDigestValue=a2f06147f4b6 ManifestsByDigestValue=51b3822b29c6 ModuleAnswer=499a03ce9b27 ModuleAnswerModule=c0f679e09f08 ModulesAnswer=6d119571c69e ModulesAnswerModulesItem=a70f39c60b67 ModulesByModuleValue=fc7530ba893a ModulesByModuleValueInputs2=99a6df7f991f Outdated=e820214f66bc OutdatedAnswer=275fb25266b9 OutdatedDependency=dc35dca1b683 PackagesByModuleValue=2b62574b709f PackagesByModuleValuePackagesItem=a7d30558470d PackagesByPackageSeriesValue=07421d8d3411 PackagesByPackageSeriesValueNewest=aba144994370 PackagesByPackageSeriesValueNewestContents=eca2ccf56913 PackagesByPackageSeriesValueNewestContentsPackagesItem=a7d30558470d PackagesByPackageSeriesValueNumbered=c8ffc628599c PackagesByPackageSeriesValueNumberedContents=0def6c0794ee PackagesByPackageSeriesValueNumberedContentsPackagesItem=a7d30558470d Policy=719e2f460c6f PolicyAnswer=46cdf8430557 PredefinedByListValue=ec8e3febe8ac ProvidesAnswer=7538f2f5e68e RegisterAnswer=46cdf8430557 Registration=ef03d1b2e73f RegistrationAsked=55adba349c24 RegistrationChangedEvent=99a3268edf41 RegistrationHistoryByModuleVersionValue=0999b5bb7dc7 RegistrationHistoryBySourceOwnerNameVersionValue=0999b5bb7dc7 RegistrationsAnswer=8849ef618cf3 RegistrationsByModuleValue=0999b5bb7dc7 RegistrationsBySourceOwnerNameValue=0999b5bb7dc7 RevisionAnswer=258ea5124931 RoomEvent=5bd4df78ed84 SeatDefinitionChangedEvent=e271d24d58f7 SeatDefinitionRemovedEvent=f7d6171111e6 SeatDefinitionsAnswer=0fd6a59fec59 SeatDefinitionsAnswerEntry=d006f68d2be5 SeatDefinitionsAnswerSeatsItem=e271d24d58f7 SeatListAnswer=04477a8044b1 SourceCheck=d1ed7cbbd579 StepStatuses=4f50aa633e61 TakeInEntry=545ec1528499 ToolchainUsed=43b6d42376fb UnwatchAnswer=46cdf8430557 VersionArtifact=438c49a392b0 VersionEdge=b0f80e83f4dc VersionEntry=33f5b00dbda9 VersionReleasedEvent=4ccf1ea90e7f VersionsAnswer=b59e6e057e7b VersionsByModuleVersionValue=e546dfadb913 VersionsFilledEvent=4cc437912dc3 WatchAnswer=46cdf8430557" + generatedForms = "5" + generatedFieldsDigest = "ActingRule=8a83ce7e0457 Artifact=78b05c1a9ec3 ArtifactPackage=2a3a660a934d ArtifactRef=a2f06147f4b6 BuildEdge=76f0684e254a BuildEdges=d2b95000259e BuildEdgesByModuleBranchValue=4fdf7cc1e723 CandidatesByGroupValue=9ea8c6c580d2 CandidatesByGroupValuePullsItem=90fb03643258 CandidatesByGroupValuePullsItemFpsValue=4c6783201aa3 CatalogEntry=c0a4ea25d523 CatalogRevision=d1ecaaa484af CatalogRevisionDefinitionsItem=77fcff620d48 CatalogRevisionEvent=710cbc5bfff1 CatalogRevisionsByBranchRevisionValue=17e54f635d35 CatalogRevisionsByCandidateGroupHeadsValue=17e54f635d35 CatalogRevisionsByEntryDigestValue=8755036a3051 DependentsAnswer=7538f2f5e68e Edge=7242732afaef EntryAnswer=805c2ff28e1c EntryInputs=76a7f8690dd2 EntryRef=ff109e5089e1 Fill=80f442916429 FillingEvent=5bd4df78ed84 FingerprintInputs=99a6df7f991f FullEvent=5bd4df78ed84 Head=774b4bf88ba4 InputAnswer=cd41ee65565d InputsByTimeDigestValue=a2f06147f4b6 ManifestsByDigestValue=51b3822b29c6 ModuleAnswer=499a03ce9b27 ModuleAnswerModule=c0f679e09f08 ModulesAnswer=6d119571c69e ModulesAnswerModulesItem=a70f39c60b67 ModulesByModuleValue=fc7530ba893a ModulesByModuleValueInputs2=99a6df7f991f Outdated=e820214f66bc OutdatedAnswer=275fb25266b9 OutdatedDependency=dc35dca1b683 PackagesByModuleValue=2b62574b709f PackagesByModuleValuePackagesItem=a7d30558470d PackagesByPackageSeriesValue=07421d8d3411 PackagesByPackageSeriesValueNewest=aba144994370 PackagesByPackageSeriesValueNewestContents=eca2ccf56913 PackagesByPackageSeriesValueNewestContentsPackagesItem=a7d30558470d PackagesByPackageSeriesValueNumbered=c8ffc628599c PackagesByPackageSeriesValueNumberedContents=0def6c0794ee PackagesByPackageSeriesValueNumberedContentsPackagesItem=a7d30558470d Policy=719e2f460c6f PolicyAnswer=46cdf8430557 PredefinedByListValue=ec8e3febe8ac ProvidesAnswer=7538f2f5e68e RegisterAnswer=46cdf8430557 Registration=ef03d1b2e73f RegistrationAsked=b529a0e1c5ca RegistrationChangedEvent=99a3268edf41 RegistrationHistoryByModuleVersionValue=0999b5bb7dc7 RegistrationHistoryBySourceOwnerNameVersionValue=0999b5bb7dc7 RegistrationsAnswer=8849ef618cf3 RegistrationsByModuleValue=0999b5bb7dc7 RegistrationsBySourceOwnerNameValue=0999b5bb7dc7 RevisionAnswer=258ea5124931 RoomEvent=5bd4df78ed84 SeatDefinitionChangedEvent=e271d24d58f7 SeatDefinitionRemovedEvent=f7d6171111e6 SeatDefinitionsAnswer=0fd6a59fec59 SeatDefinitionsAnswerEntry=d006f68d2be5 SeatDefinitionsAnswerSeatsItem=e271d24d58f7 SeatListAnswer=04477a8044b1 SourceCheck=d1ed7cbbd579 StepStatuses=4f50aa633e61 TakeInEntry=545ec1528499 ToolchainUsed=43b6d42376fb UnwatchAnswer=46cdf8430557 VersionArtifact=438c49a392b0 VersionEdge=b0f80e83f4dc VersionEntry=33f5b00dbda9 VersionReleasedEvent=4ccf1ea90e7f VersionsAnswer=b59e6e057e7b VersionsByModuleVersionValue=e546dfadb913 VersionsFilledEvent=4cc437912dc3 WatchAnswer=46cdf8430557" ) const ( @@ -924,7 +924,7 @@ type RegistrationAsked struct { // every value the change moves, as the ask names it ("nats:program unit: required -> bypass") Lines []string `json:"lines,omitempty"` Module string `json:"module"` - // why no ask was raised + // why no ask was raised; holds-manifest: a source-only registration whose repository holds a module.json at its root or under modules/ at the branch's head (design 47 H2 §815; H-A-450) Refused string `json:"refused,omitempty"` // the refusal in words, naming the branch, the step or the module Words string `json:"words,omitempty"` @@ -938,6 +938,7 @@ const ( RegistrationAskedRefusedReviewRequired = "review required" RegistrationAskedRefusedUnknownModule = "unknown module" RegistrationAskedRefusedNothingMoves = "nothing moves" + RegistrationAskedRefusedHoldsManifest = "holds-manifest" ) // SourceCheck is the check of a source-only registration: a build seat and a step kind, run at the repository's root, never a free command (design 47 H2 §815). diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json index 5a656ddc1..f40e97993 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json @@ -2297,9 +2297,10 @@ "placed", "review required", "unknown module", - "nothing moves" + "nothing moves", + "holds-manifest" ], - "description": "why no ask was raised" + "description": "why no ask was raised; holds-manifest: a source-only registration whose repository holds a module.json at its root or under modules/ at the branch's head (design 47 H2 §815; H-A-450)" }, "words": { "type": "string", @@ -2736,5 +2737,5 @@ ] } }, - "form": 4 + "form": 5 } 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 6862be0b2..9b2e9b0ea 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts @@ -469,8 +469,8 @@ export interface RegistrationAsked { /** every value the change moves, as the ask names it ("nats:program unit: required -> bypass") */ "lines"?: string[]; "module": string; - /** why no ask was raised */ - "refused"?: "unprotected branch" | "reserved branch name" | "placed" | "review required" | "unknown module" | "nothing moves"; + /** why no ask was raised; holds-manifest: a source-only registration whose repository holds a module.json at its root or under modules/ at the branch's head (design 47 H2 §815; H-A-450) */ + "refused"?: "unprotected branch" | "reserved branch name" | "placed" | "review required" | "unknown module" | "nothing moves" | "holds-manifest"; /** the refusal in words, naming the branch, the step or the module */ "words"?: string; } From 5e94328066198d72cf4fd5d6f1c57b6ad1c8e967 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 02:16:59 +0100 Subject: [PATCH 15/16] I7 (4b): a repository with no module registers as a source alone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit register takes the source form (a check of a build seat and a step kind, no module, no path, one branch) and keeps it, its history and its registration-changed under source... One whose tree at the branch's head holds a module.json at its root or under modules/, read through the seat git's trees, is refused holds-manifest. A move of its branch is taken in with no movers. Builds: design 47 H2 §815, §806; H-A-349 DQ-9, H-A-438, H-A-450 --- .../cmd/mesh-delivery-indexer/registry.go | 8 +- .../takein_integration_test.go | 24 +++ .../internal/index/registrations.go | 160 +++++++++++++++--- .../internal/index/registrations_test.go | 65 +++++++ .../internal/index/takein_source_test.go | 15 ++ 5 files changed, 248 insertions(+), 24 deletions(-) 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 4ab8eb42e..0cba481d9 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/registry.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/registry.go @@ -57,7 +57,9 @@ func newRegistry(js jetstream.JetStream, conn *nats.Conn, cred process.Account, if err != nil { return err } - _, err = js.Publish(ctx, historySubject(cred.Module, r.Module), data, jetstream.WithMsgID(fmt.Sprintf("%s.%d", r.Module, r.Version))) + // A source-only registration's versions are kept under its key source.. (design 47 H2 §815). + name := index.RegistrationName(r) + _, err = js.Publish(ctx, historySubject(cred.Module, name), data, jetstream.WithMsgID(fmt.Sprintf("%s.%d", name, r.Version))) if err == 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) @@ -105,6 +107,10 @@ func newRegistry(js jetstream.JetStream, conn *nats.Conn, cred process.Account, Say: func(_ context.Context, e meshcatalog.RegistrationChangedEvent) error { return publishAs(conn, cred, seatEventSubject(meshcatalog.EventRegistrationChanged), fmt.Sprintf("%s-%s-%d", meshcatalog.EventRegistrationChanged, e.Module, e.Version), e) }, + // The directories of a commit that hold a module.json, the seat git's trees (design 47 H2 §815; H-A-450). + ModuleDirs: func(repository, commit string) ([]string, error) { + return trunkVia(call)(context.Background(), repository, commit) + }, Placement: func(module string) ([]mma.ModulePlacement, error) { raw, err := call("seat:"+mma.Seat+"."+mma.VerbPlacement, mma.PlacementInput{Module: module}) if err != nil { diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go index 474cfc4f8..f15db48e4 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go @@ -625,6 +625,30 @@ func TestIndexerWhole(t *testing.T) { if _, _, err := index.ReadRevision(ctx, objects, "gamma.1"); err != nil { t.Errorf("gamma.1 is not kept: %v", err) } + + // Design 47 H2 §815: a source-only registration, kept under source.., watches its branch as any registration + // does, and a move of that branch by its repository, which holds no manifest, is taken in with no movers. + const hqCommit = "4444444444444444444444444444444444444444" + forge.put(hqCommit, repoAt{trees: map[string]string{}}) + watchBranch(t, ctx, js, "delta") + source, _ := json.Marshal(meshcatalog.Registration{V: 1, Origin: "novox/hq", Branches: []string{"delta"}, + Check: &meshcatalog.SourceCheck{Seat: meshcatalog.SourceCheckSeatNodeBuildGo, Step: meshcatalog.SourceCheckStepUnit}}) + if _, err := regs.Put(ctx, meshcatalog.RegistrationsBySourceOwnerNameKey("novox", "hq"), source); err != nil { + t.Fatal(err) + } + if _, err := js.Publish(ctx, meshcatalog.SubjectRegistrationChanged, []byte(`{"module":"source.novox.hq"}`)); err != nil { + t.Fatal(err) + } + sayMoved(t, ctx, js, "delta", 1, c10, true) + heard.next(t, "delta", 1) + moved, _ := json.Marshal(meshdelivery.SourceMovedEvent{V: 1, Branch: "delta", Source: 2, Call: "00112233445566aa", + Heads: []meshdelivery.SourceMovedEventHeadsItem{{Repository: "novox/hq", Commit: hqCommit}}}) + if _, err := js.Publish(ctx, meshdelivery.SubjectSourceMoved("delta", "2"), moved); err != nil { + t.Fatal(err) + } + if hq := heard.next(t, "delta", 2); len(hq.Entries) != 0 || hq.Revision != 2 { + t.Errorf("the move of novox/hq on delta said %+v, want revision 2 with no movers", hq) + } } // toolNamed is the tool of that name. diff --git a/modules/mesh-delivery-indexer/internal/index/registrations.go b/modules/mesh-delivery-indexer/internal/index/registrations.go index 9b0205979..41135a24b 100644 --- a/modules/mesh-delivery-indexer/internal/index/registrations.go +++ b/modules/mesh-delivery-indexer/internal/index/registrations.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "path" "slices" "sort" "strings" @@ -107,8 +108,68 @@ func ProposalKey(verb, module, branch string) string { return k } -// RegistrationKey is a module's key in registrations. -func RegistrationKey(module string) string { return keys.EscapeName(module) } +// RegistrationKey is a registration's key in registrations: a module's name escaped as a key's name is, and a source-only +// registration's name, its key source.., as it stands (design 47 H2 §815; H-A-349 DQ-9). +func RegistrationKey(module string) string { + if isSourceMember(module) { + return module + } + return keys.EscapeName(module) +} + +// RegistrationName is the name a registration is kept, asked and said under: its module, or for a source-only registration +// (a check and no module) its key source.. from its origin (design 47 H2 §815; H-A-438). Empty when a +// source-only registration's origin is not /. +func RegistrationName(reg meshcatalog.Registration) string { + if reg.Check == nil || reg.Module != "" { + return reg.Module + } + owner, name, ok := strings.Cut(trunk.RepositoryName(reg.Origin), "/") + if !ok || owner == "" || name == "" || strings.ContainsAny(owner+name, "./") { + return "" + } + return meshcatalog.RegistrationsBySourceOwnerNameKey(owner, name) +} + +// sourceForm refuses a source-only registration that is not of its form (design 47 H2 §815): it names no module and no +// path, one branch at most (none takes the default branch), and a check of a build seat and a step kind the seat names. +func sourceForm(reg meshcatalog.Registration) error { + if reg.Module != "" || reg.Path != "" { + return errors.New("a source-only registration (check) names no module and no path: a module registers with its manifest's path instead") + } + if len(reg.Branches) > 1 { + return fmt.Errorf("a source-only registration watches one branch, not %d", len(reg.Branches)) + } + if !slices.Contains([]string{meshcatalog.SourceCheckSeatNodeBuildGo, meshcatalog.SourceCheckSeatNodeBuildNode, meshcatalog.SourceCheckSeatNodeBuildImage}, reg.Check.Seat) { + return fmt.Errorf("the check's seat %q is no build seat (node-build-go, node-build-node or node-build-image)", reg.Check.Seat) + } + if !slices.Contains([]string{meshcatalog.SourceCheckStepLint, meshcatalog.SourceCheckStepUnit, meshcatalog.SourceCheckStepIntegration}, reg.Check.Step) { + return fmt.Errorf("the check's step %q is no step kind (lint, unit or integration)", reg.Check.Step) + } + if RegistrationName(reg) == "" { + return fmt.Errorf("a source-only registration's origin is its repository as /, not %q", reg.Origin) + } + return nil +} + +// holdsManifest is the manifest a repository holds at a commit, read through the seat git's trees (design 47 H2 §815; +// H-A-450): a module.json at the tree's root or under modules/; empty when it holds none. +func (r *Registry) holdsManifest(repository, commit string) (string, error) { + if r.ModuleDirs == nil { + return "", errors.New("the trees of a repository are not asked of the seat git, so no source-only registration is judged") + } + dirs, err := r.ModuleDirs(repository, commit) + if err != nil { + return "", fmt.Errorf("the seat git does not answer the trees of %s at %.12s: %w", repository, commit, err) + } + slices.Sort(dirs) + for _, d := range dirs { + if d == "" || d == "." || strings.HasPrefix(d, "modules/") { + return path.Join(d, ModuleManifest), nil + } + } + return "", nil +} // Registry is the registrations and the trusted changes of them. Its parts are the indexer's: the two states, the history // stream, the event, the seat git's branch, the seat operator-channel's ask. @@ -128,6 +189,9 @@ type Registry struct { Pruned func(ctx context.Context, module string, watched []string) error // Branch reads a branch through the seat git; an empty branch asks the repository's default branch. Branch func(repository, branch string) (gitseat.BranchAnswer, error) + // ModuleDirs reads the directories of a commit that hold a module.json through the seat git's trees, the root as "": a + // source-only registration whose repository holds a manifest is refused (design 47 H2 §815; H-A-450). + ModuleDirs func(repository, commit string) ([]string, error) // Placement reads a module's placements through the seat mesh-module-assigner's verb placement: one per watched branch a row // of its assignments names, with the nodes that run the module from it (design 47 G §704, A-62). Placement func(module string) ([]mma.ModulePlacement, error) @@ -192,7 +256,7 @@ func (r *Registry) RegistrationsAnswer(ctx context.Context, in meshcatalog.Regis out := meshcatalog.RegistrationsAnswer{Registrations: []meshcatalog.Registration{}} repository := trunk.RepositoryName(strings.TrimSpace(in.Repository)) keep := func(reg meshcatalog.Registration) bool { - return (in.Module == "" || reg.Module == in.Module) && (repository == "" || trunk.SameRepository(reg.Origin, repository)) + return (in.Module == "" || RegistrationName(reg) == in.Module) && (repository == "" || trunk.SameRepository(reg.Origin, repository)) } if in.Module != "" { reg, found, err := r.Registration(ctx, in.Module) @@ -335,30 +399,37 @@ func compose(verb string, cur meshcatalog.Registration, found bool, change json. } next := in.Registration next.Version, next.Warrant, next.By, next.At = 0, "", "", nil + name := RegistrationName(next) var lines []string if !found { - 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)...) + lines = append(lines, fmt.Sprintf("%s: registered from %s, watching %s", name, next.Origin, strings.Join(next.Branches, ", "))) + if next.Check != nil { + lines = append(lines, fmt.Sprintf("%s: checked by the step %s on the seat %s", name, next.Check.Step, next.Check.Seat)) + } + lines = append(lines, stepLines(name+" ", meshcatalog.StepStatuses{}, next.Policy.Steps)...) return next, lines, nil } if cur.Origin != next.Origin { - lines = append(lines, fmt.Sprintf("%s: origin %s -> %s", next.Module, cur.Origin, next.Origin)) + lines = append(lines, fmt.Sprintf("%s: origin %s -> %s", name, cur.Origin, next.Origin)) } if cur.Path != next.Path { - lines = append(lines, fmt.Sprintf("%s: manifest path %s -> %s", next.Module, cur.Path, next.Path)) + lines = append(lines, fmt.Sprintf("%s: manifest path %s -> %s", name, cur.Path, next.Path)) + } + if was, now := checkWords(cur.Check), checkWords(next.Check); was != now { + lines = append(lines, fmt.Sprintf("%s: check %s -> %s", name, was, now)) } for _, b := range next.Branches { if !slices.Contains(cur.Branches, b) { - lines = append(lines, fmt.Sprintf("%s: watches %s", next.Module, b)) + lines = append(lines, fmt.Sprintf("%s: watches %s", name, b)) } } for _, b := range cur.Branches { if !slices.Contains(next.Branches, b) { - lines = append(lines, fmt.Sprintf("%s: stops watching %s", next.Module, b)) + lines = append(lines, fmt.Sprintf("%s: stops watching %s", name, b)) } } - lines = append(lines, stepLines(next.Module+" ", cur.Policy.Steps, next.Policy.Steps)...) - lines = append(lines, artifactLines(next.Module, cur.Policy, next.Policy)...) + lines = append(lines, stepLines(name+" ", cur.Policy.Steps, next.Policy.Steps)...) + lines = append(lines, artifactLines(name, cur.Policy, next.Policy)...) return next, lines, nil case verbPolicy: var in meshcatalog.PolicyInput @@ -402,6 +473,14 @@ func compose(verb string, cur meshcatalog.Registration, found bool, change json. return cur, nil, fmt.Errorf("%q is no change of a registration", verb) } +// checkWords says a source-only registration's check as a line names it: none for a module's. +func checkWords(c *meshcatalog.SourceCheck) string { + if c == nil { + return "none" + } + return c.Step + " on " + c.Seat +} + func artifactLines(module string, old, next meshcatalog.Policy) []string { names := map[string]bool{} for k := range old.Artifacts { @@ -433,7 +512,12 @@ func (r *Registry) Propose(ctx context.Context, verb, caller string, change json if err := json.Unmarshal(change, &in); err != nil { return meshcatalog.RegistrationAsked{}, fmt.Errorf("register takes a registration: %w", err) } - module, why = in.Registration.Module, in.Why + if in.Registration.Check != nil { + if err := sourceForm(in.Registration); err != nil { + return meshcatalog.RegistrationAsked{}, err + } + } + module, why = RegistrationName(in.Registration), in.Why case verbPolicy: var in meshcatalog.PolicyInput if err := json.Unmarshal(change, &in); err != nil { @@ -464,6 +548,10 @@ func (r *Registry) Propose(ctx context.Context, verb, caller string, change json if verb != verbRegister && !found { return refused(module, meshcatalog.RegistrationAskedRefusedUnknownModule, module+" is not registered: register it first"), nil } + // A source-only registration watches one branch (design 47 H2 §815). + if verb == verbWatch && cur.Check != nil && !slices.Contains(cur.Branches, branch) && len(cur.Branches) > 0 { + return meshcatalog.RegistrationAsked{}, fmt.Errorf("%s is a source-only registration, which watches one branch (%s)", module, strings.Join(cur.Branches, ", ")) + } // An unwatch of a branch a placement names is refused, naming the placement (§704, A-62). if verb == verbUnwatch { if r.Placement == nil { @@ -484,9 +572,10 @@ func (r *Registry) Propose(ctx context.Context, verb, caller string, change json if verb == verbRegister { var in meshcatalog.RegisterInput _ = json.Unmarshal(change, &in) - if in.Registration.Origin == "" || in.Registration.Path == "" { + if in.Registration.Origin == "" || (in.Registration.Path == "" && in.Registration.Check == nil) { return meshcatalog.RegistrationAsked{}, errors.New("name the registration's origin and the path of its manifest") } + head := "" if len(in.Registration.Branches) == 0 { a, err := r.Branch(in.Registration.Origin, "") if err != nil { @@ -495,11 +584,34 @@ func (r *Registry) Propose(ctx context.Context, verb, caller string, change json if a.Error != "" || a.Branch == "" { return meshcatalog.RegistrationAsked{}, fmt.Errorf("the default branch of %s is not read: %s", in.Registration.Origin, a.Error) } - in.Registration.Branches = []string{a.Branch} + in.Registration.Branches, head = []string{a.Branch}, a.Head if change, err = json.Marshal(in); err != nil { return meshcatalog.RegistrationAsked{}, err } } + // A source-only registration of a repository that holds a manifest is refused: its module registers instead + // (design 47 H2 §815; H-A-450), judged from the tree at the branch's head through the seat git. + if in.Registration.Check != nil { + branch := in.Registration.Branches[0] + if head == "" { + a, err := r.Branch(in.Registration.Origin, branch) + if err != nil { + return meshcatalog.RegistrationAsked{}, fmt.Errorf("the seat git does not answer the branch %s of %s: %w", branch, in.Registration.Origin, err) + } + if a.Error != "" || a.Head == "" { + return meshcatalog.RegistrationAsked{}, fmt.Errorf("the head of the branch %s of %s is not read: %s", branch, in.Registration.Origin, a.Error) + } + head = a.Head + } + held, err := r.holdsManifest(in.Registration.Origin, head) + if err != nil { + return meshcatalog.RegistrationAsked{}, err + } + if held != "" { + return refused(module, meshcatalog.RegistrationAskedRefusedHoldsManifest, + fmt.Sprintf("%s holds %s at %.12s of %s: a repository with a manifest registers its module, not a source alone", in.Registration.Origin, held, head, branch)), nil + } + } } steps := []meshcatalog.StepStatuses{} switch verb { @@ -837,14 +949,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 + // A source-only registration is kept, said and pruned under its key source.. (§815; H-A-438). + name := RegistrationName(next) 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)) + r.logf("registration %s version %d: %s (%s since its start)", name, 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) + return fmt.Errorf("the version %d of %s is not kept on %s, so it is not written: %w", next.Version, name, RegistrationHistoryStream, err) } step("kept on " + RegistrationHistoryStream) } @@ -852,10 +966,10 @@ func (r *Registry) write(ctx context.Context, key string, p Proposal, next meshc if err != nil { return err } - err = write(ctx, r.Registrations, RegistrationKey(next.Module), func(old []byte, found bool) ([]byte, bool, error) { + err = write(ctx, r.Registrations, RegistrationKey(name), func(old []byte, found bool) ([]byte, bool, error) { var cur meshcatalog.Registration if found && json.Unmarshal(old, &cur) == nil && cur.Version != p.Was { - return nil, false, fmt.Errorf("the registration of %s is at version %d, not %d", next.Module, cur.Version, p.Was) + return nil, false, fmt.Errorf("the registration of %s is at version %d, not %d", name, cur.Version, p.Was) } return data, false, nil }) @@ -865,21 +979,21 @@ func (r *Registry) write(ctx context.Context, key string, p Proposal, next meshc 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 err := r.Say(ctx, meshcatalog.RegistrationChangedEvent{V: 1, Module: name, 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", name, next.Version, err) } } // 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 err := r.Pruned(ctx, name, next.Branches); err != nil { + r.logf("the builds of %s on the branches it no longer watches are not pruned: %v", name, 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))) + return r.endKey(ctx, key, p, ProposalApplied, fmt.Sprintf("applied as version %d of %s on %s", next.Version, name, occ.Says(w))) } // Restart reads each open key at the indexer's start (§667 A restart): a decided ask is applied or ended, an open one waited on, diff --git a/modules/mesh-delivery-indexer/internal/index/registrations_test.go b/modules/mesh-delivery-indexer/internal/index/registrations_test.go index 07d5c47c8..48ecfd1d8 100644 --- a/modules/mesh-delivery-indexer/internal/index/registrations_test.go +++ b/modules/mesh-delivery-indexer/internal/index/registrations_test.go @@ -189,6 +189,71 @@ func TestRegistrationsAreWrittenOnTheirWarrantOnly(t *testing.T) { if un, _ := g.r.Propose(ctx, "policy", "s@n", pol("zz", meshcatalog.StepStatuses{Unit: "bypass"})); un.Refused != meshcatalog.RegistrationAskedRefusedUnknownModule { t.Fatalf("a policy of an unregistered module: %+v", un) } + // Design 47 H2 §815 (H-A-349 DQ-9, H-A-438, H-A-450): a repository with no module registers as a source alone, kept, kept in + // the history and said under source..; one whose tree at the branch's head holds a module.json at its root or + // under modules/ is refused holds-manifest, and a registration not of the source form is an error. + t.Run("a source-only registration", func(t *testing.T) { + g := newRegRig() + const head = "0123456789abcdef0123456789abcdef01234567" + dirs := map[string][]string{"novox/hq": {"tools/x"}, "novox/root": {""}, "novox/mods": {"cmd", "modules/x"}} + var asked []string + g.r.Branch = func(repo, branch string) (gitseat.BranchAnswer, error) { + if branch == "" { + branch = "main" + } + return gitseat.BranchAnswer{Branch: branch, Repository: repo, Head: head}, nil + } + g.r.ModuleDirs = func(repo, commit string) ([]string, error) { + asked = append(asked, repo+"@"+commit) + return dirs[repo], nil + } + check := &meshcatalog.SourceCheck{Seat: meshcatalog.SourceCheckSeatNodeBuildGo, Step: meshcatalog.SourceCheckStepUnit} + source := func(origin string, edit func(*meshcatalog.Registration)) json.RawMessage { + r := meshcatalog.Registration{Origin: origin, Check: check, Policy: meshcatalog.Policy{Steps: meshcatalog.StepStatuses{Unit: "required"}}} + if edit != nil { + edit(&r) + } + return mustJSON(meshcatalog.RegisterInput{Registration: r}) + } + for _, origin := range []string{"novox/root", "novox/mods"} { + got, err := g.r.Propose(ctx, "register", "s@n", source(origin, nil)) + if err != nil || got.Refused != meshcatalog.RegistrationAskedRefusedHoldsManifest || got.Ask != "" || !strings.Contains(got.Words, "module.json") { + t.Errorf("%s: %+v, %v; want refused holds-manifest naming its module.json and no ask", origin, got, err) + } + } + for name, edit := range map[string]func(*meshcatalog.Registration){ + "a module": func(r *meshcatalog.Registration) { r.Module = "hq" }, + "a path": func(r *meshcatalog.Registration) { r.Path = "module.json" }, + "two branches": func(r *meshcatalog.Registration) { r.Branches = []string{"main", "beta"} }, + "a free seat": func(r *meshcatalog.Registration) { r.Check = &meshcatalog.SourceCheck{Seat: "sh", Step: "unit"} }, + } { + if got, err := g.r.Propose(ctx, "register", "s@n", source("novox/hq", edit)); err == nil { + t.Errorf("a source-only registration naming %s: %+v, want an error", name, got) + } + } + got, err := g.r.Propose(ctx, "register", "s@n", source("novox/hq", nil)) + if err != nil || got.Ask == "" || got.Module != "source.novox.hq" || !strings.Contains(strings.Join(got.Lines, "\n"), "source.novox.hq: checked by the step unit on the seat node-build-go") { + t.Fatalf("register a source: %+v, %v; want an ask of source.novox.hq naming its check", got, err) + } + if len(asked) == 0 || asked[len(asked)-1] != "novox/hq@"+head { + t.Errorf("the trees read %v, want novox/hq at the default branch's head", asked) + } + g.decide(t, got.Ask, "approve") + if v, _, found, _ := g.r.Registrations.Get(ctx, "source.novox.hq"); !found || !strings.Contains(string(v), `"check":{"seat":"node-build-go","step":"unit"}`) || strings.Contains(string(v), `"module"`) { + t.Fatalf("registrations under source.novox.hq: %s (%t), want the source form with no module", v, found) + } + if len(g.history) != 1 || RegistrationName(g.history[0]) != "source.novox.hq" || len(g.events) != 1 || g.events[0].Module != "source.novox.hq" { + t.Fatalf("history %+v, events %+v; want one version and registration-changed of source.novox.hq", g.history, g.events) + } + for _, in := range []meshcatalog.RegistrationsInput{{Module: "source.novox.hq"}, {Repository: "novox/hq"}} { + if a, err := g.r.RegistrationsAnswer(ctx, in); err != nil || len(a.Registrations) != 1 || a.Registrations[0].Branches[0] != "main" { + t.Errorf("registrations %+v: %+v, %v; want the source alone, watching main", in, a, err) + } + } + if w, err := g.r.Propose(ctx, "watch", "s@n", mustJSON(meshcatalog.WatchInput{Module: "source.novox.hq", Branch: "beta"})); err == nil { + t.Errorf("a second branch of a source-only registration: %+v, want an error", w) + } + }) } func mustJSON(v any) json.RawMessage { b, _ := json.Marshal(v); return b } diff --git a/modules/mesh-delivery-indexer/internal/index/takein_source_test.go b/modules/mesh-delivery-indexer/internal/index/takein_source_test.go index f0da42a54..3386f2592 100644 --- a/modules/mesh-delivery-indexer/internal/index/takein_source_test.go +++ b/modules/mesh-delivery-indexer/internal/index/takein_source_test.go @@ -105,6 +105,21 @@ func TestASourceRevisionIsTakenInAsOneRevision(t *testing.T) { if _, err := ix.TakeInSource(ctx, old); !errors.Is(err, ErrOldForm) { t.Errorf("a source-moved with no call answered %v, want ErrOldForm", err) } + // Design 47 H2 §815: a move of a source-only registration's branch (a repository with no manifest) is taken in as a + // take-in with no movers. + read := ix.Read + ix.Read = func(ctx context.Context, repository, sha, dir string) (RepoRead, error) { + if repository == "novox/hq" { + return RepoRead{Root: "1111111111111111111111111111111111111111", Trees: map[string]string{}, Manifests: map[string]string{}}, nil + } + return read(ctx, repository, sha, dir) + } + hq := meshdelivery.SourceMovedEvent{V: 1, Branch: "main", Source: 9, Call: "00112233445566aa", + Heads: []meshdelivery.SourceMovedEventHeadsItem{{Repository: "novox/hq", Commit: "2222222222222222222222222222222222222222"}}} + if src, err := ix.TakeInSource(ctx, hq); err != nil || len(src.Entries) != 0 || src.Revision != 3 || src.Source != 9 { + t.Errorf("a source-only repository's move said %+v (%v), want revision 3 of source 9 with no movers", src, err) + } + ix.Read = read // Design 47 H2 §803, H-A-409: a take-in says what it waits on, in the journal, in takeins and past five minutes as a finding. t.Run("a take-in says what it waits on", func(t *testing.T) { running := newMem() From ce6c39e46cdb69a1909fad84a944ad75af4fe6a2 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 02:31:52 +0100 Subject: [PATCH 16/16] I6 (5): the judge's tests read the catalogue at the group's head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The captured catalogue beside the judge (testdata/beside) is re-archived from mesh-catalog 30a3e665 (feat/47-H2, the delivery group's catalogue head), so the judge's rules are tested against manifests that name their class where they claim a seat; the catalogue fixtures of judge and internal/index move from 835bf22b and a67f0196 to 30a3e665 (ca-trust refreshed; avahi, audit-logger and netcheck kept at a67f0196, which they still match). Tested against mesh-sdk a323a3fd (seatlisttest holds the group's definitions); the build seats' check now holds current, pause and resume among the verbs the seats' definitions serve, which have grown since 1887. Builds: design 47 H2 §814, H-A-428, H-A-452 --- .../internal/index/manifests_test.go | 11 +- .../internal/index/predefined_test.go | 6 +- ...> catalogue-30a3e665-ca-trust.module.json} | 3 +- ...atalogue-30a3e665-claude-code.module.json} | 73 +- .../catalogue-30a3e665-dunst.module.json} | 3 +- ...n => catalogue-30a3e665-xterm.module.json} | 3 +- .../mesh-delivery-indexer/judge/rules_test.go | 12 +- ...atalogue-30a3e665-claude-code.module.json} | 73 +- .../catalogue-30a3e665-dunst.module.json} | 3 +- ...n => catalogue-30a3e665-xterm.module.json} | 3 +- .../testdata/beside/CAPTURED | 9 +- .../modules/adwaita/module.json.captured | 3 +- .../artifact-store-tools/files/store-address | 1 + .../artifact-store-tools/module.json.captured | 104 ++- .../asus-zephyrus-g14/module.json.captured | 3 +- .../modules/audit-logger/module.json.captured | 3 +- .../modules/avahi/module.json.captured | 3 +- .../modules/baserow/module.json.captured | 3 +- .../modules/betterbird/files/accounts.json | 3 - .../modules/betterbird/files/betterbird | 10 - .../betterbird/files/configuration.json | 6 - .../files/eu.betterbird.Betterbird.desktop | 25 - .../modules/betterbird/files/prefs.json | 3 - .../modules/betterbird/files/tags.json | 3 - .../modules/betterbird/module.json.captured | 253 ------ .../modules/blueman/module.json.captured | 3 +- .../modules/bluetooth/module.json.captured | 3 +- .../modules/brother/files/bucket.json | 3 + .../modules/brother/files/fetch.json | 3 + .../modules/brother/module.json.captured | 45 +- .../modules/buildah/module.json.captured | 25 + .../modules/ca-trust/module.json.captured | 3 +- .../modules/claude-code/files/claude-agent | 6 +- .../modules/claude-code/module.json.captured | 77 +- .../claude-licence-manager/files/database.url | 1 - .../files/settings.json | 8 +- .../module.json.captured | 228 +++-- .../modules/clipmenu/module.json.captured | 3 +- .../modules/confluence/module.json.captured | 3 +- .../modules/cups/module.json.captured | 3 +- .../modules/dbus/module.json.captured | 3 +- .../modules/desk-channel/module.json.captured | 3 +- .../modules/dev-tools/module.json.captured | 3 +- .../modules/disk-load/module.json.captured | 30 +- .../modules/distribution/module.json.captured | 223 ++++- .../modules/dmenu/module.json.captured | 3 +- .../modules/dnsmasq/files/dnsmasq.conf | 6 +- .../modules/dnsmasq/files/mesh.conf | 11 +- .../modules/dnsmasq/module.json.captured | 24 +- .../docker-compose/module.json.captured | 3 +- .../modules/docker/files/daemon.json | 2 +- .../modules/docker/module.json.captured | 6 +- .../modules/dunst/module.json.captured | 3 +- .../modules/fail2ban/module.json.captured | 3 +- .../mesh-catalog/modules/feh/files/fehbg | 4 +- .../modules/feh/module.json.captured | 3 +- .../modules/flatpak/module.json.captured | 3 +- .../modules/fonts/module.json.captured | 3 +- .../modules/forticlient/module.json.captured | 3 +- .../modules/gitea/files/config.json | 2 +- .../modules/gitea/files/repositories.json | 2 +- .../modules/gitea/files/server.env | 5 + .../modules/gitea/module.json.captured | 301 +++++-- .../modules/gitlab/module.json.captured | 3 +- .../gnome-keyring/module.json.captured | 3 +- .../modules/go/module.json.captured | 8 +- .../modules/grafana/module.json.captured | 3 +- .../modules/hello-web/module.json.captured | 3 +- .../home-assistant/module.json.captured | 3 +- .../modules/hostname/module.json.captured | 3 +- .../modules/i3/module.json.captured | 3 +- .../i3status-rust/module.json.captured | 3 +- .../modules/icecast/module.json.captured | 3 +- .../modules/influxdb/module.json.captured | 6 +- .../modules/invoicing/module.json.captured | 3 +- .../modules/jira/module.json.captured | 3 +- .../files/90-mesh-kernel-boot-entries.hook | 13 + .../modules/kernel/files/boot-entries.sh | 133 +++ .../modules/kernel/files/initramfs.sh | 71 ++ .../files/mesh-kernel-boot-entries.service | 22 + .../files/mesh-kernel-initramfs.service | 22 + .../modules/kernel/files/mesh-microcode.conf | 8 + .../modules/kernel/files/modules-load.conf | 4 + .../modules/kernel/module.json.captured | 113 ++- .../modules/keycloak/module.json.captured | 7 +- .../modules/lab/files/forge.gitconfig | 5 + .../modules/lab/files/forge.known_hosts | 1 + .../mesh-catalog/modules/lab/files/forge.ssh | 10 + .../mesh-catalog/modules/lab/files/lab.env | 2 +- .../modules/lab/module.json.captured | 41 +- .../modules/lemurs/module.json.captured | 3 +- .../modules/letta/module.json.captured | 3 +- .../local-model-consumer/module.json.captured | 3 +- .../modules/localization/module.json.captured | 3 +- .../modules/logrotate/module.json.captured | 3 +- .../modules/mailu/module.json.captured | 70 +- .../modules/marrytts/module.json.captured | 3 +- .../modules/matrix/module.json.captured | 3 +- .../memory-pressure/module.json.captured | 3 +- .../modules/mesh-build-go/files/settings.json | 5 + .../mesh-build-go/module.json.captured | 203 ++++- .../modules/mesh-build-image/files/forge | 7 + .../modules/mesh-build-image/files/gitconfig | 2 + .../mesh-build-image/files/known_hosts | 1 + .../mesh-build-image/files/settings.json | 5 + .../mesh-build-image/module.json.captured | 206 +++++ .../mesh-build-node/files/settings.json | 5 + .../mesh-build-node/module.json.captured | 130 ++- .../modules/mesh-catalog/module.json.captured | 23 +- .../modules/mesh-cli/files/console | 1 + .../modules/mesh-cli/module.json.captured | 20 +- .../mesh-conditions/module.json.captured | 116 +++ .../modules/mesh-config/module.json.captured | 86 +- .../mesh-delivery-gate/files/settings.json | 4 + .../mesh-delivery-gate/module.json.captured | 541 ++++++++++-- .../modules/mesh-files/module.json.captured | 10 +- .../mesh-hand-acts/module.json.captured | 66 ++ .../modules/mesh-healers/module.json.captured | 101 +++ .../modules/mesh-issues/files/settings.json | 33 +- .../modules/mesh-issues/module.json.captured | 69 +- .../modules/mesh-knowledge/files/readers.json | 3 + .../mesh-knowledge/files/settings.json | 3 +- .../mesh-knowledge/module.json.captured | 199 ++++- .../mesh-mail-notifier/module.json.captured | 3 +- .../mesh-mail-reader/files/callers.json | 3 - .../mesh-mail-reader/module.json.captured | 25 +- .../mesh-mail-web/module.json.captured | 3 +- .../modules/mesh-mail/module.json.captured | 3 +- .../module.json.captured | 4 +- .../mesh-provisioner/module.json.captured | 81 +- .../modules/mesh-reads/module.json.captured | 3 +- .../mesh-recovery/files/dump-wait-minutes | 1 + .../mesh-recovery/files/expire-every-hours | 1 + .../mesh-recovery/files/point-keep-days | 1 + .../modules/mesh-recovery/files/points-cap | 1 + .../mesh-recovery/files/points-filling-mark | 1 + .../files/snapshot-restore-wait-minutes | 1 + .../mesh-recovery/module.json.captured | 322 +++++++ .../mesh-self-check/module.json.captured | 123 +++ .../modules/mesh-vault/module.json.captured | 88 +- .../modules/mesh-watcher/module.json.captured | 41 +- .../modules/messenger/files/settings.json | 5 +- .../modules/messenger/module.json.captured | 54 +- .../modules/minio/files/object-store.json | 6 + .../modules/minio/module.json.captured | 77 +- .../modules/model-usage/module.json.captured | 3 +- .../modules/mongodb/module.json.captured | 6 +- .../modules/mosquitto/module.json.captured | 6 +- .../modules/mounts/module.json.captured | 36 +- .../modules/mssql/module.json.captured | 6 +- .../modules/n8n/module.json.captured | 3 +- .../modules/nats/files/settings.json | 4 + .../modules/nats/module.json.captured | 321 ++++++- .../modules/netcheck/module.json.captured | 4 +- .../networkmanager/module.json.captured | 3 +- .../nextcloud-client/module.json.captured | 3 +- .../modules/nextcloud/files/config.json | 7 +- .../modules/nextcloud/module.json.captured | 15 +- .../modules/nfs-server/module.json.captured | 73 +- .../modules/nftables/module.json.captured | 32 +- .../modules/nm-applet/module.json.captured | 3 +- .../modules/node-env/module.json.captured | 3 +- .../modules/nodejs/module.json.captured | 8 +- .../modules/nodered/module.json.captured | 3 +- .../modules/ollama/module.json.captured | 8 +- .../modules/only-office/files/server.env | 1 + .../modules/only-office/module.json.captured | 139 ++- .../openai-consumer/module.json.captured | 3 +- .../modules/openrazer/module.json.captured | 3 +- .../modules/pacman/files/keeper.json | 5 + .../files/mesh-pacman-weekly-upgrade.service | 12 - .../files/mesh-pacman-weekly-upgrade.timer | 11 - .../modules/pacman/files/reflector.conf | 8 +- .../modules/pacman/module.json.captured | 181 +++- .../modules/photos-eef/module.json.captured | 3 +- .../modules/photos-filip/module.json.captured | 3 +- .../modules/picom/module.json.captured | 3 +- .../polychromatic/module.json.captured | 3 +- .../modules/postgres/module.json.captured | 34 +- .../modules/power/module.json.captured | 45 +- .../system/halt.target.d/mesh-power.conf | 8 + .../system/poweroff.target.d/mesh-power.conf | 8 + .../system/reboot.target.d/mesh-power.conf | 8 + .../powerlevel10k/module.json.captured | 3 +- .../modules/records/module.json.captured | 5 +- .../modules/redis/module.json.captured | 6 +- .../modules/restic/module.json.captured | 3 +- .../modules/rofi/module.json.captured | 3 +- .../route-adapter/module.json.captured | 7 +- .../modules/screen-lock/module.json.captured | 3 +- .../modules/searxng/module.json.captured | 3 +- .../modules/sensors/module.json.captured | 3 +- .../modules/showcase/module.json.captured | 8 +- .../modules/slack/module.json.captured | 3 +- .../modules/snapd/module.json.captured | 3 +- .../modules/ssh-client/module.json.captured | 3 +- .../modules/sshd/module.json.captured | 3 +- .../modules/step-ca/module.json.captured | 8 +- .../modules/sudo/module.json.captured | 3 +- .../modules/supabase/module.json.captured | 3 +- .../systemd-networkd/module.json.captured | 3 +- .../systemd-resolved/module.json.captured | 12 +- .../modules/systemd/module.json.captured | 18 +- .../modules/telegram/module.json.captured | 3 +- .../modules/time-sync/module.json.captured | 3 +- .../modules/triggerhappy/module.json.captured | 3 +- .../modules/umami/module.json.captured | 8 +- .../modules/unifi/module.json.captured | 3 +- .../modules/website/module.json.captured | 3 +- .../modules/xclip/module.json.captured | 3 +- .../modules/xdg/module.json.captured | 3 +- .../modules/xorg/module.json.captured | 8 +- .../modules/xterm/files/xresources-normal | 56 +- .../modules/xterm/module.json.captured | 172 +++- .../modules/zfs/files/all-syslog.sh | 52 ++ .../modules/zfs/files/config.json | 1 + .../zfs/files/resilver_finish-start-scrub.sh | 20 + .../mesh-catalog/modules/zfs/files/scrub.conf | 6 - .../modules/zfs/files/zed-functions.sh | 825 ++++++++++++++++++ .../modules/zfs/files/zed-mesh.conf | 4 + .../mesh-catalog/modules/zfs/files/zed.rc | 7 + .../mesh-catalog/modules/zfs/files/zfs.conf | 5 + .../modules/zfs/module.json.captured | 690 +++++++++++++-- .../zsh-autosuggestions/module.json.captured | 3 +- .../module.json.captured | 3 +- .../modules/zsh/module.json.captured | 1 + .../beside/mesh-catalog/predefined.json | 5 + 227 files changed, 6836 insertions(+), 1143 deletions(-) rename modules/mesh-delivery-indexer/internal/index/testdata/{catalogue-a67f0196-ca-trust.module.json => catalogue-30a3e665-ca-trust.module.json} (96%) rename modules/mesh-delivery-indexer/internal/index/testdata/{catalogue-835bf22b-claude-code.module.json => catalogue-30a3e665-claude-code.module.json} (79%) rename modules/mesh-delivery-indexer/{judge/testdata/catalogue-835bf22b-dunst.module.json => internal/index/testdata/catalogue-30a3e665-dunst.module.json} (98%) rename modules/mesh-delivery-indexer/internal/index/testdata/{catalogue-835bf22b-xterm.module.json => catalogue-30a3e665-xterm.module.json} (99%) rename modules/mesh-delivery-indexer/judge/testdata/{catalogue-835bf22b-claude-code.module.json => catalogue-30a3e665-claude-code.module.json} (79%) rename modules/mesh-delivery-indexer/{internal/index/testdata/catalogue-835bf22b-dunst.module.json => judge/testdata/catalogue-30a3e665-dunst.module.json} (98%) rename modules/mesh-delivery-indexer/judge/testdata/{catalogue-835bf22b-xterm.module.json => catalogue-30a3e665-xterm.module.json} (99%) create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/artifact-store-tools/files/store-address delete mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/accounts.json delete mode 100755 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/betterbird delete mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/configuration.json delete mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/eu.betterbird.Betterbird.desktop delete mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/prefs.json delete mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/tags.json delete mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/module.json.captured create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/brother/files/bucket.json create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/brother/files/fetch.json create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/buildah/module.json.captured delete mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-licence-manager/files/database.url create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/90-mesh-kernel-boot-entries.hook create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/boot-entries.sh create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/initramfs.sh create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/mesh-kernel-boot-entries.service create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/mesh-kernel-initramfs.service create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/mesh-microcode.conf create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/modules-load.conf create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/forge.gitconfig create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/forge.known_hosts create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/forge.ssh create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-go/files/settings.json create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/forge create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/gitconfig create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/known_hosts create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/settings.json create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/module.json.captured create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-node/files/settings.json create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-cli/files/console create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-conditions/module.json.captured create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-delivery-gate/files/settings.json create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-hand-acts/module.json.captured create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-healers/module.json.captured create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-knowledge/files/readers.json delete mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-reader/files/callers.json create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/dump-wait-minutes create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/expire-every-hours create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/point-keep-days create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/points-cap create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/points-filling-mark create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/snapshot-restore-wait-minutes create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/module.json.captured create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-self-check/module.json.captured create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/minio/files/object-store.json create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nats/files/settings.json create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/keeper.json delete mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/mesh-pacman-weekly-upgrade.service delete mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/mesh-pacman-weekly-upgrade.timer create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/templates/systemd/system/halt.target.d/mesh-power.conf create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/templates/systemd/system/poweroff.target.d/mesh-power.conf create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/templates/systemd/system/reboot.target.d/mesh-power.conf create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/all-syslog.sh create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/config.json create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/resilver_finish-start-scrub.sh delete mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/scrub.conf create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zed-functions.sh create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zed-mesh.conf create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zed.rc create mode 100644 modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zfs.conf diff --git a/modules/mesh-delivery-indexer/internal/index/manifests_test.go b/modules/mesh-delivery-indexer/internal/index/manifests_test.go index f2c92a6fd..8566583f0 100644 --- a/modules/mesh-delivery-indexer/internal/index/manifests_test.go +++ b/modules/mesh-delivery-indexer/internal/index/manifests_test.go @@ -9,7 +9,8 @@ import ( ) // The manifests these tests carry are real files, copied unchanged into testdata: the module.json of modules of -// mesh-catalog at its main commit a67f01963f0d9ef0913a63720b89e573ca7a16ef (testdata/catalogue-a67f0196-.module.json) +// mesh-catalog at its main commit a67f01963f0d9ef0913a63720b89e573ca7a16ef (testdata/catalogue-a67f0196-.module.json), +// at 30a3e665e0070ae5b0ebfede985da5759af8affd for those that claim a seat (testdata/catalogue-30a3e665-.module.json) // and of build-agent from mesh-controller at its main commit f2d7bc94 (testdata/controller-f2d7bc94-build-agent.module.json). func fixture(t *testing.T, name string) string { t.Helper() @@ -20,8 +21,14 @@ func fixture(t *testing.T, name string) string { return string(b) } +// catalogueManifest is a module's captured module.json of mesh-catalog: ca-trust's at 30a3e665, the group's catalogue head +// of design 47 H2 (it claims a seat, so it names its class, §810, §814; H-A-430 (3)), every other at a67f0196. func catalogueManifest(t *testing.T, module string) string { - return fixture(t, "catalogue-a67f0196-"+module) + at := "a67f0196" + if module == "ca-trust" { + at = "30a3e665" + } + return fixture(t, "catalogue-"+at+"-"+module) } // avahiGoSum is the sha256 of modules/avahi/go.sum in mesh-catalog at a67f0196 (sha256sum of that file). diff --git a/modules/mesh-delivery-indexer/internal/index/predefined_test.go b/modules/mesh-delivery-indexer/internal/index/predefined_test.go index a08ad11d3..2a30782b2 100644 --- a/modules/mesh-delivery-indexer/internal/index/predefined_test.go +++ b/modules/mesh-delivery-indexer/internal/index/predefined_test.go @@ -7,10 +7,10 @@ import ( // Issue 1751: a manifest whose config value falls back to a predefined key (novox/hq ADR 0348) is read by the indexer, so // the module gets its new-form inputs. The manifests are claude-code's, dunst's and xterm's module.json from mesh-catalog -// at 835bf22b. +// at 30a3e665. func TestAManifestFallingBackToAPredefinedKeyIsRead(t *testing.T) { // 1751 for _, module := range []string{"claude-code", "dunst", "xterm"} { - raw := fixture(t, "catalogue-835bf22b-"+module) + raw := fixture(t, "catalogue-30a3e665-"+module) if !strings.Contains(raw, `"predefined"`) { t.Fatalf("%s: the fixture names no predefined key", module) } @@ -20,7 +20,7 @@ func TestAManifestFallingBackToAPredefinedKeyIsRead(t *testing.T) { // 1751 } } // A predefined key of another type than its value is still refused: the read judges what it can. - raw := strings.Replace(fixture(t, "catalogue-835bf22b-xterm"), `"predefined": "font-size"`, `"predefined": "font-size", "trusted": "yes"`, 1) + raw := strings.Replace(fixture(t, "catalogue-30a3e665-xterm"), `"predefined": "font-size"`, `"predefined": "font-size", "trusted": "yes"`, 1) if in := inputsOf("xterm", raw, "newtree", nil, func(string) (string, string) { return "", "none" }); in.Kept != nil { t.Errorf("inputs = %+v, want a manifest the catalogue refuses still refused", in) } diff --git a/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-a67f0196-ca-trust.module.json b/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-30a3e665-ca-trust.module.json similarity index 96% rename from modules/mesh-delivery-indexer/internal/index/testdata/catalogue-a67f0196-ca-trust.module.json rename to modules/mesh-delivery-indexer/internal/index/testdata/catalogue-30a3e665-ca-trust.module.json index b3c9dc930..eed1faf32 100644 --- a/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-a67f0196-ca-trust.module.json +++ b/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-30a3e665-ca-trust.module.json @@ -1,6 +1,7 @@ { "module": "ca-trust", - "version": "1", + "version": "0.1", + "class": "core", "slug": "catrust", "capabilities": [ "service-manager" diff --git a/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-835bf22b-claude-code.module.json b/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-30a3e665-claude-code.module.json similarity index 79% rename from modules/mesh-delivery-indexer/internal/index/testdata/catalogue-835bf22b-claude-code.module.json rename to modules/mesh-delivery-indexer/internal/index/testdata/catalogue-30a3e665-claude-code.module.json index 3b62d219b..fd0a9fc56 100644 --- a/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-835bf22b-claude-code.module.json +++ b/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-30a3e665-claude-code.module.json @@ -1,6 +1,7 @@ { "module": "claude-code", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, "slug": "agent", "capabilities": [ @@ -11,6 +12,25 @@ { "name": "gitea-read", "optional": true + }, + { + "name": "finding-events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } + }, + { + "name": "findings", + "storage": "key-value", + "template": "state" } ], "binds": { @@ -22,6 +42,31 @@ "uses": [ "operator-channel" ], + "invokes": [ + "seat:mesh-hand-acts.warranted", + "seat:mesh-hand-acts.hand-act", + "seat:mesh-catalog.seat-definitions", + "seat:mesh-catalog.revision", + "seat:mesh-catalog.registrations", + "seat:mesh-delivery.source", + "mesh-delivery-assigner.assigner_read_assignments", + "seat:anthropic-licence-manager.bindings", + "seat:anthropic-licence-manager.current", + "seat:mesh-vault.get", + "seat:operator-channel.notify" + ], + "consumes": [ + "mesh-catalog.catalog-revision", + "mesh-catalog.registration-changed", + "mesh-delivery.source-moved", + "mesh-delivery-assigner.views.assignments", + "mesh-catalog.seat-definition-changed", + "mesh-catalog.seat-definition-removed", + "mesh-conditions.findings-asked", + "claude-licence-manager.holdings.asked", + "claude-licence-manager.binding.changed.*", + "mesh-vault.secret-changed" + ], "state": [ "servers", "holdings", @@ -31,13 +76,13 @@ "memory", "waits" ], - "reads": [ - "claude-licence-manager.bindings" + "emits": [ + "judged", + "holdings-changed" ], "tools": [ "claude_code_status", "claude_code_render", - "claude_code_guard", "claude_code_pull", "claude_code_grant", "claude_code_add_api_key", @@ -83,7 +128,11 @@ "claude_code_home_removed", "claude_code_home_restore", "claude_code_judge", - "claude_code_judged" + "claude_code_judged", + "claude_code_first_views", + "claude_code_first_view_again", + "claude_code_seat_list", + "claude_code_seat_list_again" ], "data": { "own": [ @@ -210,7 +259,16 @@ "path": "${dir:state}/settings.json", "mode": "0600", "owner": "${machine:account}", - "takes-config": ["role", "mcp_servers", "managed_settings", "instructions", "output_styles", "skills", "commands", "agents"], + "takes-config": [ + "role", + "mcp_servers", + "managed_settings", + "instructions", + "output_styles", + "skills", + "commands", + "agents" + ], "merge": "json", "template": "files/settings.json" } @@ -236,7 +294,8 @@ "env": { "MESH_CLAUDE_CODE_STATE": "${dir:state}", "MESH_CLAUDE_CODE_FACTS": "${dir:state}/facts.json", - "MESH_CLAUDE_CODE_SETTINGS": "${dir:state}/settings.json" + "MESH_CLAUDE_CODE_SETTINGS": "${dir:state}/settings.json", + "MESH_CLAUDE_CODE_FORGE": "${dir:state}/gitea-read.secret" } }, { diff --git a/modules/mesh-delivery-indexer/judge/testdata/catalogue-835bf22b-dunst.module.json b/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-30a3e665-dunst.module.json similarity index 98% rename from modules/mesh-delivery-indexer/judge/testdata/catalogue-835bf22b-dunst.module.json rename to modules/mesh-delivery-indexer/internal/index/testdata/catalogue-30a3e665-dunst.module.json index 0c6983b4d..7821e3f9d 100644 --- a/modules/mesh-delivery-indexer/judge/testdata/catalogue-835bf22b-dunst.module.json +++ b/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-30a3e665-dunst.module.json @@ -1,6 +1,7 @@ { "module": "dunst", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-835bf22b-xterm.module.json b/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-30a3e665-xterm.module.json similarity index 99% rename from modules/mesh-delivery-indexer/internal/index/testdata/catalogue-835bf22b-xterm.module.json rename to modules/mesh-delivery-indexer/internal/index/testdata/catalogue-30a3e665-xterm.module.json index b65be8eb9..195510057 100644 --- a/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-835bf22b-xterm.module.json +++ b/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-30a3e665-xterm.module.json @@ -1,6 +1,7 @@ { "module": "xterm", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/judge/rules_test.go b/modules/mesh-delivery-indexer/judge/rules_test.go index a82cdca43..433413f0a 100644 --- a/modules/mesh-delivery-indexer/judge/rules_test.go +++ b/modules/mesh-delivery-indexer/judge/rules_test.go @@ -4147,12 +4147,16 @@ func caseNodeBuildAgentIsRetiredForTheBuildSeats(t *testing.T) { if !s.Yields { t.Errorf("%s does not yield (ADR 0553)", name) } + // The seat's definition is the catalogue's (mesh-contracts'), and it serves more than these since (drop, + // kept-artifact, steps, output, answer): the retirement holds current, pause and resume among them. var verbs []string for _, v := range s.Serves { verbs = append(verbs, v.Name) } - if strings.Join(verbs, ",") != "current,pause,resume" { - t.Errorf("%s serves %v", name, verbs) + for _, want := range []string{"current", "pause", "resume"} { + if !slices.Contains(verbs, want) { + t.Errorf("%s serves %v, without %s", name, verbs, want) + } } } // The build seats are the seats that yield, and no other (ADR 0553 §1). @@ -4302,13 +4306,13 @@ func caseOnlyChannelAndIntakeAreKinded(t *testing.T) { } // The indexer and the builder hold no published list of predefined keys; a manifest whose config values fall back to -// one (claude-code, dunst, xterm at mesh-catalog 835bf22b) is still read for its build's and fingerprint's inputs +// one (claude-code, dunst, xterm at mesh-catalog 30a3e665) is still read for its build's and fingerprint's inputs // (issue 1751). func caseParseManifestForInputsReadsAValueFallingBackToAPredefinedKey(t *testing.T) { // issue 1751 was := catalogue.ReplacePublished(nil) // the indexer's and the builder's case: no published list defer catalogue.ReplacePublished(was) for _, module := range []string{"claude-code", "dunst", "xterm"} { - raw, err := os.ReadFile("testdata/catalogue-835bf22b-" + module + ".module.json") + raw, err := os.ReadFile("testdata/catalogue-30a3e665-" + module + ".module.json") if err != nil { t.Fatal(err) } diff --git a/modules/mesh-delivery-indexer/judge/testdata/catalogue-835bf22b-claude-code.module.json b/modules/mesh-delivery-indexer/judge/testdata/catalogue-30a3e665-claude-code.module.json similarity index 79% rename from modules/mesh-delivery-indexer/judge/testdata/catalogue-835bf22b-claude-code.module.json rename to modules/mesh-delivery-indexer/judge/testdata/catalogue-30a3e665-claude-code.module.json index 3b62d219b..fd0a9fc56 100644 --- a/modules/mesh-delivery-indexer/judge/testdata/catalogue-835bf22b-claude-code.module.json +++ b/modules/mesh-delivery-indexer/judge/testdata/catalogue-30a3e665-claude-code.module.json @@ -1,6 +1,7 @@ { "module": "claude-code", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, "slug": "agent", "capabilities": [ @@ -11,6 +12,25 @@ { "name": "gitea-read", "optional": true + }, + { + "name": "finding-events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } + }, + { + "name": "findings", + "storage": "key-value", + "template": "state" } ], "binds": { @@ -22,6 +42,31 @@ "uses": [ "operator-channel" ], + "invokes": [ + "seat:mesh-hand-acts.warranted", + "seat:mesh-hand-acts.hand-act", + "seat:mesh-catalog.seat-definitions", + "seat:mesh-catalog.revision", + "seat:mesh-catalog.registrations", + "seat:mesh-delivery.source", + "mesh-delivery-assigner.assigner_read_assignments", + "seat:anthropic-licence-manager.bindings", + "seat:anthropic-licence-manager.current", + "seat:mesh-vault.get", + "seat:operator-channel.notify" + ], + "consumes": [ + "mesh-catalog.catalog-revision", + "mesh-catalog.registration-changed", + "mesh-delivery.source-moved", + "mesh-delivery-assigner.views.assignments", + "mesh-catalog.seat-definition-changed", + "mesh-catalog.seat-definition-removed", + "mesh-conditions.findings-asked", + "claude-licence-manager.holdings.asked", + "claude-licence-manager.binding.changed.*", + "mesh-vault.secret-changed" + ], "state": [ "servers", "holdings", @@ -31,13 +76,13 @@ "memory", "waits" ], - "reads": [ - "claude-licence-manager.bindings" + "emits": [ + "judged", + "holdings-changed" ], "tools": [ "claude_code_status", "claude_code_render", - "claude_code_guard", "claude_code_pull", "claude_code_grant", "claude_code_add_api_key", @@ -83,7 +128,11 @@ "claude_code_home_removed", "claude_code_home_restore", "claude_code_judge", - "claude_code_judged" + "claude_code_judged", + "claude_code_first_views", + "claude_code_first_view_again", + "claude_code_seat_list", + "claude_code_seat_list_again" ], "data": { "own": [ @@ -210,7 +259,16 @@ "path": "${dir:state}/settings.json", "mode": "0600", "owner": "${machine:account}", - "takes-config": ["role", "mcp_servers", "managed_settings", "instructions", "output_styles", "skills", "commands", "agents"], + "takes-config": [ + "role", + "mcp_servers", + "managed_settings", + "instructions", + "output_styles", + "skills", + "commands", + "agents" + ], "merge": "json", "template": "files/settings.json" } @@ -236,7 +294,8 @@ "env": { "MESH_CLAUDE_CODE_STATE": "${dir:state}", "MESH_CLAUDE_CODE_FACTS": "${dir:state}/facts.json", - "MESH_CLAUDE_CODE_SETTINGS": "${dir:state}/settings.json" + "MESH_CLAUDE_CODE_SETTINGS": "${dir:state}/settings.json", + "MESH_CLAUDE_CODE_FORGE": "${dir:state}/gitea-read.secret" } }, { diff --git a/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-835bf22b-dunst.module.json b/modules/mesh-delivery-indexer/judge/testdata/catalogue-30a3e665-dunst.module.json similarity index 98% rename from modules/mesh-delivery-indexer/internal/index/testdata/catalogue-835bf22b-dunst.module.json rename to modules/mesh-delivery-indexer/judge/testdata/catalogue-30a3e665-dunst.module.json index 0c6983b4d..7821e3f9d 100644 --- a/modules/mesh-delivery-indexer/internal/index/testdata/catalogue-835bf22b-dunst.module.json +++ b/modules/mesh-delivery-indexer/judge/testdata/catalogue-30a3e665-dunst.module.json @@ -1,6 +1,7 @@ { "module": "dunst", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/judge/testdata/catalogue-835bf22b-xterm.module.json b/modules/mesh-delivery-indexer/judge/testdata/catalogue-30a3e665-xterm.module.json similarity index 99% rename from modules/mesh-delivery-indexer/judge/testdata/catalogue-835bf22b-xterm.module.json rename to modules/mesh-delivery-indexer/judge/testdata/catalogue-30a3e665-xterm.module.json index b65be8eb9..195510057 100644 --- a/modules/mesh-delivery-indexer/judge/testdata/catalogue-835bf22b-xterm.module.json +++ b/modules/mesh-delivery-indexer/judge/testdata/catalogue-30a3e665-xterm.module.json @@ -1,6 +1,7 @@ { "module": "xterm", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/CAPTURED b/modules/mesh-delivery-indexer/testdata/beside/CAPTURED index 2b692aa87..755ff6d8e 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/CAPTURED +++ b/modules/mesh-delivery-indexer/testdata/beside/CAPTURED @@ -8,15 +8,12 @@ private addresses. That is acceptable while mesh-sdk is private; if it ever goes a second place to clean besides the catalogue itself. Only what go/catalogue's tests read is captured (R4b, issue 1379), copied here from mesh-sdk with the judge's tests -(issue 1585). mesh-host refreshed 2026-11-01 from its main, the catalogue 2026-10-21 from its main; before that it +(issue 1585). mesh-host refreshed 2026-11-01 from its main, the catalogue 2026-11-22 from its feat/47-H2 (milestone 47/H2's group); before that it was mesh-controller's copy, which still held two modules that had left the catalogue. -mesh-catalog b5dbfbb784507e211372a7c9640d91f7d6dadd84 modules/*/module.json, modules/*/files/**, modules/*/templates/**, predefined.json +mesh-catalog 30a3e665e0070ae5b0ebfede985da5759af8affd (feat/47-H2, the delivery group's catalogue head; design 47 H2 + H-A-428, H-A-430 (3)) modules/*/module.json, modules/*/files/**, modules/*/templates/**, predefined.json mesh-host 233bb23bbcb1a829ce2a6164a31a5c5cc4f3d950 internal/apply/placement_guard.go -mesh-catalog 2d5358b8 (milestone 47/G's AM-K1) modules/zsh/module.json alone: the login shell uses operator-channel for - its seat's marked execute (design 46 approval mark §21), which the validator requires (§4) -mesh-catalog cd3b8fe8 (restic's secrets-owner, ADR 0680) modules/restic/module.json and modules/restic/files/** alone: its - processes run as the operator account, so the validator (ADR 0680 §3) needs the secrets-owner it names To move them, from mesh-delivery's modules/mesh-delivery-indexer directory, with the two repositories checked out beside mesh-delivery: diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/adwaita/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/adwaita/module.json.captured index bf81c8331..44bbe78dd 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/adwaita/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/adwaita/module.json.captured @@ -1,6 +1,7 @@ { "module": "adwaita", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/artifact-store-tools/files/store-address b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/artifact-store-tools/files/store-address new file mode 100644 index 000000000..71418ef2a --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/artifact-store-tools/files/store-address @@ -0,0 +1 @@ +${seat:container-image-registry:reach} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/artifact-store-tools/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/artifact-store-tools/module.json.captured index 208329cd5..26622f54e 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/artifact-store-tools/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/artifact-store-tools/module.json.captured @@ -1,26 +1,64 @@ { "module": "artifact-store-tools", - "version": "1", + "version": "0.1", + "class": "core", + "packages": { + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds": "0.1" + }, + "claims": [ + { + "name": "mesh-artifact-sweep", + "scope": "mesh", + "serves": [ + "artifacts", + "held", + "collect", + "mirrors", + "images" + ] + } + ], "invokes": [ - "seat:mesh-controller.artifacts", - "seat:mesh-controller.collect", - "mesh-catalog.catalog_modules", - "mesh-catalog.catalog_module" + "seat:mesh-hand-acts.hand-act", + "seat:mesh-catalog.modules", + "seat:mesh-catalog.module", + "mesh-delivery-assigner.assigner_read_wants", + "mesh-delivery-indexer.indexer_read_manifests", + "seat:oci-artifact-registry.hold", + "seat:oci-artifact-registry.release", + "seat:oci-artifact-registry.remove", + "seat:container-image-registry.hold", + "seat:container-image-registry.release", + "seat:container-image-registry.remove", + "seat:container-image-registry.list", + "seat:oci-artifact-registry.list" + ], + "reads": [ + "mesh-delivery-builder.builds", + "mesh-delivery-builder.build-log", + "node-engine.have" + ], + "consumes": [ + "mesh-delivery-assigner.views.wants", + "mesh-delivery-indexer.views.manifests", + "mesh-conditions.findings-asked" ], "tools": [ "artifact_store_repositories", "artifact_store_usage", "artifact_store_references", - "artifact_store_collect" + "artifact_store_collect", + "artifact_store_first_views", + "artifact_store_first_view_again" ], - "config": { - "older-store-names": { - "type": "string", - "description": "The names the artifact store had before, as host names or host:port separated by spaces, or none when it had no other. artifact_store_references reads every definition under these as well as under the store's current name, so an image a definition pins under one is said to be named by a definition (novox/hq issue 323).", - "pattern": "none|[A-Za-z0-9.:-]+( [A-Za-z0-9.:-]+)*", - "default": "none" - } - }, + "config": { + "older-store-names": { + "type": "string", + "description": "The names the artifact store had before, as host names or host:port separated by spaces, or none when it had no other. artifact_store_references reads every definition under these as well as under the store's current name, so an image a definition pins under one is said to be named by a definition (novox/hq issue 323).", + "pattern": "none|[A-Za-z0-9.:-]+( [A-Za-z0-9.:-]+)*", + "default": "none" + } + }, "resources": [ { "id": "state", @@ -36,6 +74,14 @@ "mode": "0600", "trusted": false, "template": "files/store-names" + }, + { + "id": "store-address", + "type": "file", + "path": "${dir:state}/store-address", + "mode": "0600", + "trusted": false, + "template": "files/store-address" } ], "build": { @@ -51,8 +97,8 @@ "artifact-store-tools" ], "env": { - "MESH_ARTIFACT_STORE_CONTAINER": "mesh-registry", - "MESH_ARTIFACT_STORE_NAMES_FILE": "${dir:state}/store-names" + "MESH_ARTIFACT_STORE_NAMES_FILE": "${dir:state}/store-names", + "MESH_ARTIFACT_STORE_ADDRESS_FILE": "${dir:state}/store-address" } }, { @@ -61,5 +107,29 @@ "from": "files" } ] - } + }, + "requires": [ + { + "name": "findings", + "storage": "key-value", + "template": "state", + "options": { + "max-mib": 8 + } + }, + { + "name": "finding-events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } + } + ] } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/asus-zephyrus-g14/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/asus-zephyrus-g14/module.json.captured index d1ee8d3b8..4055b81cd 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/asus-zephyrus-g14/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/asus-zephyrus-g14/module.json.captured @@ -1,6 +1,7 @@ { "module": "asus-zephyrus-g14", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, "templates": "templates", "capabilities": [ diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/audit-logger/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/audit-logger/module.json.captured index 122b94e75..4314b5af2 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/audit-logger/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/audit-logger/module.json.captured @@ -1,6 +1,7 @@ { "module": "audit-logger", - "version": "1", + "version": "0.1", + "class": "leaf", "slug": "audit", "consumes": [ "**" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/avahi/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/avahi/module.json.captured index de99c7c9c..b73cbcca7 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/avahi/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/avahi/module.json.captured @@ -1,6 +1,7 @@ { "module": "avahi", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager", "service-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/baserow/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/baserow/module.json.captured index 811962180..ef7de33b6 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/baserow/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/baserow/module.json.captured @@ -1,6 +1,7 @@ { "module": "baserow", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "container-runtime" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/accounts.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/accounts.json deleted file mode 100644 index e182cc3d4..000000000 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/accounts.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "accounts": {} -} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/betterbird b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/betterbird deleted file mode 100755 index 3ce088a86..000000000 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/betterbird +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# Betterbird's start, written by the mesh (module betterbird, novox/hq ADR 0316). Replaced at every push. -# -# Before Betterbird starts, the module's tools place its user.js in the profile (the settings prefs, accounts, identities, calendars, -# address-books and tags) and write what Betterbird rewrites itself: the account lists and each declared account's filters. They do -# it only while no Betterbird of this account runs, because Betterbird rewrites its saved preferences when it quits; a -# second start while one runs only hands over to it. What the preparation could not do it says here, and -# betterbird_check says it too. Betterbird starts either way: its configuration never holds the mail back. -/usr/local/lib/mesh-betterbird/betterbird-tools prepare || echo "betterbird: the mesh's preparation did not complete; betterbird_check says why" >&2 -exec /opt/betterbird/betterbird "$@" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/configuration.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/configuration.json deleted file mode 100644 index 702044623..000000000 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/configuration.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "identities": {}, - "calendars": {}, - "address-books": {}, - "filters": {} -} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/eu.betterbird.Betterbird.desktop b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/eu.betterbird.Betterbird.desktop deleted file mode 100644 index e409fcf82..000000000 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/eu.betterbird.Betterbird.desktop +++ /dev/null @@ -1,25 +0,0 @@ -[Desktop Entry] -Version=1.0 -Type=Application -Name=Betterbird -GenericName=Mail Client -Comment=Send and receive mail with Betterbird -Exec=/usr/local/bin/betterbird %u -Icon=/opt/betterbird/chrome/icons/default/default128.png -Terminal=false -Categories=Network;Email; -MimeType=message/rfc822;x-scheme-handler/mailto;application/x-xpinstall;application/x-extension-ics;text/calendar;text/vcard;text/x-vcard;x-scheme-handler/webcal;x-scheme-handler/webcals;x-scheme-handler/mid; -StartupNotify=true -StartupWMClass=eu.betterbird.Betterbird -Keywords=Email;E-mail;Calendar;Thunderbird; -Actions=ComposeMessage;OpenAddressBook; -# Written by the mesh (module betterbird, novox/hq ADR 0316 §3), in place of the community package's entry: -# it starts Betterbird through the module's start, and names the icon in the installation, with no link. - -[Desktop Action ComposeMessage] -Name=Write new message -Exec=/usr/local/bin/betterbird -compose - -[Desktop Action OpenAddressBook] -Name=Open address book -Exec=/usr/local/bin/betterbird -addressbook diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/prefs.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/prefs.json deleted file mode 100644 index 45fd9732c..000000000 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/prefs.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "prefs": {} -} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/tags.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/tags.json deleted file mode 100644 index 4772f099f..000000000 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/files/tags.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "tags": {} -} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/module.json.captured deleted file mode 100644 index 891f88322..000000000 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/betterbird/module.json.captured +++ /dev/null @@ -1,253 +0,0 @@ -{ - "module": "betterbird", - "version": "1", - "upgrade": { - "policy": "record", - "why": "a new build may remove the community package betterbird-bin and replaces the installation in /opt/betterbird, which a running Betterbird has open: the switch on each node and every upgrade wait for the operator, who quits Betterbird first and then pushes (novox/hq ADR 0316 §4, §5)" - }, - "requires": [ - "x11-display" - ], - "invokes": [ - "seat:mesh-controller.settings", - "seat:mesh-controller.nodes", - "seat:mesh-controller.node", - "betterbird.betterbird_derive" - ], - "tools": [ - "betterbird_status", - "betterbird_prefs", - "betterbird_config", - "betterbird_config_apply", - "betterbird_user_js", - "betterbird_log", - "betterbird_restart", - "betterbird_check", - "betterbird_accounts", - "betterbird_identities", - "betterbird_calendars", - "betterbird_address_books", - "betterbird_filters", - "betterbird_tags", - "betterbird_derive", - "betterbird_drift", - "betterbird_reminder_test" - ], - "config": { - "prefs": { - "type": "object", - "description": "Betterbird's preferences the operator sets, by their own names (mailnews.*, calendar.* and the like), laid into prefs.json; an account's, a server's and a tag's are refused, as accounts, the four kinds and tags own them (novox/hq ADR 0329 §6).", - "trusted": true, - "default": {} - }, - "accounts": { - "type": "object", - "description": "The mail accounts Betterbird is set up with, each by a name of the operator's: its address, its sender's name and its incoming and outgoing servers; no password, token or cookie (novox/hq ADR 0329 §2).", - "trusted": true, - "default": {} - }, - "identities": { - "type": "object", - "description": "The identities beside an account's own, each by a name of the operator's: the address and name it sends as, its signature as a list of lines, and the profile's key to adopt on a node.", - "trusted": true, - "default": {} - }, - "calendars": { - "type": "object", - "description": "The calendars Betterbird shows, each by a name of the operator's: where it is and how it is reached, and the profile's key to adopt on a node.", - "trusted": true, - "default": {} - }, - "address-books": { - "type": "object", - "description": "The address books Betterbird uses, each by a name of the operator's: where it is and how it is reached, and the profile's key to adopt on a node.", - "trusted": true, - "default": {} - }, - "filters": { - "type": "object", - "description": "The message filters of each account, by account: what each matches and what it does with the mail.", - "trusted": true, - "default": {} - }, - "tags": { - "type": "object", - "description": "The tags Betterbird offers, each by its own key: its name, colour and order; trusted since issue 751, so a change to it is the operator's to approve.", - "trusted": true, - "default": {} - } - }, - "resources": [ - { - "id": "configuration-dir", - "type": "directory", - "path": "${machine:account-home}/.config/betterbird", - "owner": "${machine:account}", - "mode": "0755", - "unknown": "move-out", - "knows": ["accounts-record.json", "configuration-record.json", "kept/"] - }, - { - "id": "prefs", - "type": "file", - "path": "${machine:account-home}/.config/betterbird/prefs.json", - "owner": "${machine:account}", - "mode": "0644", - "merge": "json", - "takes-config": [ - "prefs" - ], - "template": "files/prefs.json", - "trusted": true - }, - { - "id": "accounts", - "type": "file", - "path": "${machine:account-home}/.config/betterbird/accounts.json", - "owner": "${machine:account}", - "mode": "0600", - "merge": "json", - "takes-config": [ - "accounts" - ], - "template": "files/accounts.json", - "trusted": true - }, - { - "id": "configuration", - "type": "file", - "path": "${machine:account-home}/.config/betterbird/configuration.json", - "owner": "${machine:account}", - "mode": "0600", - "merge": "json", - "takes-config": [ - "identities", - "calendars", - "address-books", - "filters" - ], - "template": "files/configuration.json", - "trusted": true - }, - { - "id": "tags", - "type": "file", - "path": "${machine:account-home}/.config/betterbird/tags.json", - "owner": "${machine:account}", - "mode": "0644", - "merge": "json", - "takes-config": [ - "tags" - ], - "template": "files/tags.json", - "trusted": true - }, - { - "id": "community-package", - "type": "package", - "package": "betterbird-bin", - "absent": true - }, - { - "id": "installation", - "type": "archive", - "path": "/opt/betterbird", - "artifact": "archive", - "unknown": "program" - }, - { - "id": "owl", - "type": "archive", - "path": "/opt/betterbird/owl", - "artifact": "owl", - "unknown": "program" - }, - { - "id": "policies", - "type": "archive", - "path": "/opt/betterbird/distribution", - "artifact": "distribution", - "unknown": "program" - }, - { - "id": "spelling", - "type": "archive", - "path": "/opt/betterbird/defaults/pref", - "artifact": "defaults", - "unknown": "program" - }, - { - "id": "preparation", - "type": "archive", - "path": "/usr/local/lib/mesh-betterbird", - "artifact": "tools", - "unknown": "program" - }, - { - "id": "start", - "type": "file", - "path": "/usr/local/bin/betterbird", - "mode": "0755", - "template": "files/betterbird" - }, - { - "id": "launcher", - "type": "file", - "path": "/usr/local/share/applications/eu.betterbird.Betterbird.desktop", - "mode": "0644", - "template": "files/eu.betterbird.Betterbird.desktop" - } - ], - "build": { - "artifacts": [ - { - "name": "tools", - "kind": "bundle", - "language": "go", - "system": "arch", - "from": "cmd/betterbird-tools", - "binary": "betterbird-tools", - "loads": [ - "betterbird-tools" - ] - }, - { - "name": "archive", - "kind": "archive", - "url": "https://www.betterbird.eu/downloads/LinuxArchive/betterbird-153.4.0esr-bb10.en-US.linux-x86_64.tar.xz", - "sha256": "38dd24890a66b4cf9a45bc24e15192e00c26b929e1bb8df7974c16a4539129e2", - "version": "153.4.0esr-bb10", - "within": "betterbird", - "names-on-purpose": { - "www.betterbird.eu": "Betterbird's project publishes its Linux release there; the build seat fetches it once, by its pinned sha256 (novox/hq ADR 0316 §2)" - } - }, - { - "name": "owl", - "kind": "archive", - "url": "https://www.beonex.com/owl/owl.xpi", - "sha256": "a54cc3d52113b34f97942ee19190947dee23561e2217f18db3d80ac023991221", - "version": "1.5.6.1", - "file": "owl.xpi", - "names-on-purpose": { - "www.beonex.com": "Owl's vendor publishes its xpi there; the build seat fetches it once, by its pinned sha256 (novox/hq ADR 0316 §6)" - } - }, - { - "name": "distribution", - "kind": "archive", - "from": "install/distribution" - }, - { - "name": "defaults", - "kind": "archive", - "from": "install/defaults-pref" - }, - { - "name": "files", - "kind": "archive", - "from": "files" - } - ] - } -} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/blueman/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/blueman/module.json.captured index 73a764068..c896e7afb 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/blueman/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/blueman/module.json.captured @@ -1,6 +1,7 @@ { "module": "blueman", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/bluetooth/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/bluetooth/module.json.captured index dfaabf10a..8d908e6b5 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/bluetooth/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/bluetooth/module.json.captured @@ -1,6 +1,7 @@ { "module": "bluetooth", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager", "service-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/brother/files/bucket.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/brother/files/bucket.json new file mode 100644 index 000000000..b72b23313 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/brother/files/bucket.json @@ -0,0 +1,3 @@ +{ + "bucket": "${bound:s3-bucket:bucket}" +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/brother/files/fetch.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/brother/files/fetch.json new file mode 100644 index 000000000..abef425fc --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/brother/files/fetch.json @@ -0,0 +1,3 @@ +{ + "mesh-range": "${machine:mesh-range}" +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/brother/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/brother/module.json.captured index 57559d56c..158ea6898 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/brother/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/brother/module.json.captured @@ -1,8 +1,22 @@ { "module": "brother", - "version": "1", + "version": "0.1", + "class": "core", "requires": [ - "s3-bucket" + { + "name": "s3-bucket", + "shares": [ + { + "to": "seat:node-files", + "methods": [ + "put" + ] + } + ] + } + ], + "invokes": [ + "seat:node-files.upload" ], "binds": { "s3-bucket": "${dir:state}/store-binding.json" @@ -199,6 +213,21 @@ "mode": "0600", "template": "files/store.json" }, + { + "id": "bucket", + "type": "file", + "path": "${dir:state}/bucket.json", + "mode": "0644", + "template": "files/bucket.json" + }, + { + "id": "fetch", + "type": "file", + "path": "${dir:state}/fetch.json", + "owner": "brother-device", + "mode": "0600", + "template": "files/fetch.json" + }, { "id": "device", "type": "process", @@ -213,11 +242,13 @@ "BROTHER_SETTINGS": "${dir:state}/settings.json", "BROTHER_ADMIN_PASSWORD": "${dir:state}/admin-password.secret", "BROTHER_BROKER": "${dir:state}/broker-device.secret", - "BROTHER_STORE": "${dir:state}/store.json" + "BROTHER_STORE": "${dir:state}/store.json", + "BROTHER_FETCH": "${dir:state}/fetch.json" }, "restart-on": [ "settings", - "store" + "store", + "fetch" ], "bus": { "queues": [ @@ -228,6 +259,9 @@ ], "emits": [ "scan.added" + ], + "invokes": [ + "seat:document-converter.convert" ] }, "health": { @@ -267,7 +301,8 @@ "brother" ], "env": { - "BROTHER_SETTINGS": "${dir:state}/settings.json" + "BROTHER_SETTINGS": "${dir:state}/settings.json", + "BROTHER_BUCKET": "${dir:state}/bucket.json" } }, { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/buildah/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/buildah/module.json.captured new file mode 100644 index 000000000..4f2cdad59 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/buildah/module.json.captured @@ -0,0 +1,25 @@ +{ + "module": "buildah", + "version": "0.1", + "class": "leaf", + "capabilities": [ + "package-manager", + "user-namespaces" + ], + "provides": [ + { + "name": "rootless-image-build", + "reach": "machine", + "credential": { + "form": "none" + } + } + ], + "resources": [ + { + "id": "buildah", + "type": "package", + "package": "buildah" + } + ] +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/ca-trust/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/ca-trust/module.json.captured index b3c9dc930..eed1faf32 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/ca-trust/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/ca-trust/module.json.captured @@ -1,6 +1,7 @@ { "module": "ca-trust", - "version": "1", + "version": "0.1", + "class": "core", "slug": "catrust", "capabilities": [ "service-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-code/files/claude-agent b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-code/files/claude-agent index e3d330f2b..0281cdb39 100755 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-code/files/claude-agent +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-code/files/claude-agent @@ -5,9 +5,5 @@ agent='${machine:agent-account}' if [ "$(id -un)" = "$agent" ]; then exec claude "$@" fi -# Another account, the operator's, becomes the agent's through its own sudo: the person is the authority. The -# operator's override of the guard travels only when it is set in this shell, as it would reach claude. -if [ -n "$MESH_GUARD_OVERRIDE" ]; then - exec sudo -iu "$agent" env MESH_GUARD_OVERRIDE="$MESH_GUARD_OVERRIDE" claude "$@" -fi +# Another account, the operator's, becomes the agent's through its own sudo: the person is the authority. exec sudo -iu "$agent" claude "$@" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-code/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-code/module.json.captured index b869d0124..fd0a9fc56 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-code/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-code/module.json.captured @@ -1,6 +1,7 @@ { "module": "claude-code", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, "slug": "agent", "capabilities": [ @@ -11,6 +12,25 @@ { "name": "gitea-read", "optional": true + }, + { + "name": "finding-events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } + }, + { + "name": "findings", + "storage": "key-value", + "template": "state" } ], "binds": { @@ -22,21 +42,47 @@ "uses": [ "operator-channel" ], + "invokes": [ + "seat:mesh-hand-acts.warranted", + "seat:mesh-hand-acts.hand-act", + "seat:mesh-catalog.seat-definitions", + "seat:mesh-catalog.revision", + "seat:mesh-catalog.registrations", + "seat:mesh-delivery.source", + "mesh-delivery-assigner.assigner_read_assignments", + "seat:anthropic-licence-manager.bindings", + "seat:anthropic-licence-manager.current", + "seat:mesh-vault.get", + "seat:operator-channel.notify" + ], + "consumes": [ + "mesh-catalog.catalog-revision", + "mesh-catalog.registration-changed", + "mesh-delivery.source-moved", + "mesh-delivery-assigner.views.assignments", + "mesh-catalog.seat-definition-changed", + "mesh-catalog.seat-definition-removed", + "mesh-conditions.findings-asked", + "claude-licence-manager.holdings.asked", + "claude-licence-manager.binding.changed.*", + "mesh-vault.secret-changed" + ], "state": [ "servers", "holdings", "config", "proposals", "questions", - "memory" + "memory", + "waits" ], - "reads": [ - "claude-licence-manager.bindings" + "emits": [ + "judged", + "holdings-changed" ], "tools": [ "claude_code_status", "claude_code_render", - "claude_code_guard", "claude_code_pull", "claude_code_grant", "claude_code_add_api_key", @@ -67,6 +113,7 @@ "claude_code_proposals", "claude_code_ask", "claude_code_answer", + "claude_code_wait", "claude_code_settings_get", "claude_code_settings_set", "claude_code_settings_clear", @@ -81,7 +128,11 @@ "claude_code_home_removed", "claude_code_home_restore", "claude_code_judge", - "claude_code_judged" + "claude_code_judged", + "claude_code_first_views", + "claude_code_first_view_again", + "claude_code_seat_list", + "claude_code_seat_list_again" ], "data": { "own": [ @@ -208,7 +259,16 @@ "path": "${dir:state}/settings.json", "mode": "0600", "owner": "${machine:account}", - "takes-config": ["role", "mcp_servers", "managed_settings", "instructions", "output_styles", "skills", "commands", "agents"], + "takes-config": [ + "role", + "mcp_servers", + "managed_settings", + "instructions", + "output_styles", + "skills", + "commands", + "agents" + ], "merge": "json", "template": "files/settings.json" } @@ -234,7 +294,8 @@ "env": { "MESH_CLAUDE_CODE_STATE": "${dir:state}", "MESH_CLAUDE_CODE_FACTS": "${dir:state}/facts.json", - "MESH_CLAUDE_CODE_SETTINGS": "${dir:state}/settings.json" + "MESH_CLAUDE_CODE_SETTINGS": "${dir:state}/settings.json", + "MESH_CLAUDE_CODE_FORGE": "${dir:state}/gitea-read.secret" } }, { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-licence-manager/files/database.url b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-licence-manager/files/database.url deleted file mode 100644 index dc59da9a2..000000000 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-licence-manager/files/database.url +++ /dev/null @@ -1 +0,0 @@ -postgresql://${bound:postgres-database:as}:${secret:postgres-database}@${bound:postgres-database:at}:${bound:postgres-database:port}/${bound:postgres-database:as} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-licence-manager/files/settings.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-licence-manager/files/settings.json index 5d4aed520..fc6df9b3a 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-licence-manager/files/settings.json +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-licence-manager/files/settings.json @@ -3,5 +3,11 @@ "floor_minutes": 60, "failures_to_notify": 3, "cooldown_hours": 24, - "refresh_warn_days": 3 + "refresh_warn_days": 3, + "switch_auto": true, + "switch_at_pct": 99, + "room_below_pct": 90, + "warn_at_pct": 90, + "usage_minutes": 5, + "usage_stale_minutes": 15 } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-licence-manager/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-licence-manager/module.json.captured index a55da31e2..5b6c70668 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-licence-manager/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/claude-licence-manager/module.json.captured @@ -1,29 +1,86 @@ { "module": "claude-licence-manager", - "version": "1", + "version": "0.1", + "class": "core", "slug": "licmgr", + "runs-as": "claude-licence-manager", "requires": [ - "postgres-database", - "secret" + { + "name": "licences", + "storage": "key-value", + "template": "state", + "options": { + "history": 1 + } + }, + { + "name": "bindings", + "storage": "key-value", + "template": "state", + "options": { + "history": 8 + } + }, + { + "name": "leases", + "storage": "key-value", + "template": "state", + "options": { + "history": 1, + "key-ttl": true + } + }, + { + "name": "offered", + "storage": "key-value", + "template": "state", + "options": { + "history": 1, + "key-ttl": true + } + }, + { + "name": "carried", + "storage": "key-value", + "template": "state", + "options": { + "history": 1 + } + }, + { + "name": "conditions", + "storage": "key-value", + "template": "state", + "options": { + "history": 1 + } + } ], - "contributes": { - "postgres-database": { - "name": "claude_licences", - "readable": [ - "audit", - "binding" - ] - } - }, - "binds": { - "postgres-database": "${dir:state}/database.json" - }, - "secrets": { - "postgres-database": "${dir:state}/database.secret", - "secret": { - "grant-key": "${dir:state}/grant.key" + "logs": [ + { + "name": "usage", + "max-age-days": 35, + "max-mib": 256 + }, + { + "name": "audit", + "max-mib": 64 } + ], + "own-secrets": { + "broker": "${dir:state}/broker" }, + "secrets-owner": "claude-licence-manager", + "uses": [ + "operator-channel" + ], + "invokes": [ + "seat:operator-channel.tell", + "seat:mesh-vault.licence-put", + "seat:mesh-vault.get", + "seat:mesh-config.config", + "claude-code.claude_code_grant" + ], "seats": [ { "name": "anthropic-licence-manager", @@ -63,18 +120,14 @@ "emits": [ "licence.adopted", "licence.refused", - "licence.bound", "licence.switched", - "licence.released", - "licence.rotated", "licence.failing", - "usage.read" + "usage.read", + "binding.changed", + "holdings.asked" ], - "state": [ - "bindings" - ], - "reads": [ - "claude-code.holdings" + "consumes": [ + "claude-code.holdings-changed" ], "config": { "cadence_minutes": { @@ -111,69 +164,130 @@ "minimum": 0, "trusted": true, "default": 3 + }, + "switch_auto": { + "type": "boolean", + "description": "Whether the manager moves every consumer off a licence whose weekly usage reaches switch_at_pct, to the licence with the most room; off, it still raises its no-room and near-limit conditions.", + "trusted": true, + "default": true + }, + "switch_at_pct": { + "type": "number", + "description": "The weekly usage of a licence, in percent, at which its consumers are moved to the licence with the most room.", + "minimum": 1, + "maximum": 100, + "trusted": true, + "default": 99 + }, + "room_below_pct": { + "type": "number", + "description": "What the weekly usage of a licence must be below, in percent, for it to be a target of a switch.", + "minimum": 1, + "maximum": 100, + "trusted": true, + "default": 90 + }, + "warn_at_pct": { + "type": "number", + "description": "The weekly usage of a licence with consumers, in percent, at which it is warned about once.", + "minimum": 1, + "maximum": 100, + "trusted": true, + "default": 90 + }, + "usage_minutes": { + "type": "number", + "description": "How often each subscription's usage is read, in minutes.", + "minimum": 1, + "maximum": 60, + "trusted": true, + "default": 5 + }, + "usage_stale_minutes": { + "type": "number", + "description": "How old a subscription's last successful usage reading may grow before its room is not known and it is said, in minutes.", + "minimum": 5, + "maximum": 180, + "trusted": true, + "default": 15 } }, "resources": [ + { + "id": "account", + "type": "user", + "name": "claude-licence-manager", + "shell": "/usr/bin/nologin", + "home": "/var/lib/claude-licence-manager" + }, { "id": "state", "type": "directory", "mode": "0700", + "owner": "claude-licence-manager", "place": ".", "unknown": "program" }, - { - "id": "database-url", - "type": "file", - "path": "${dir:state}/database.url", - "mode": "0600", - "template": "files/database.url" - }, { "id": "settings", "type": "file", "path": "${dir:state}/settings.json", "mode": "0600", - "takes-config": ["cadence_minutes", "floor_minutes", "failures_to_notify", "cooldown_hours", "refresh_warn_days"], + "owner": "claude-licence-manager", + "takes-config": [ + "cadence_minutes", + "floor_minutes", + "failures_to_notify", + "cooldown_hours", + "refresh_warn_days", + "switch_auto", + "switch_at_pct", + "room_below_pct", + "warn_at_pct", + "usage_minutes", + "usage_stale_minutes" + ], "merge": "json", "template": "files/settings.json" - }, - { - "id": "prepare", - "type": "process", - "name": "claude-licence-manager-prepare", - "artifact": "code", - "run": [ - "./claude-licence-manager", - "prepare" - ], - "run-once": true, - "env": { - "DATABASE_URL_FILE": "${dir:state}/database.url" - }, - "restart-on": [ - "database-url" - ] } ], + "tools": [ + "licences_switches", + "licences_read_usage", + "licences_switch_now", + "licences_settings", + "licences_kept", + "licences_resync", + "licences_conditions" + ], "build": { "artifacts": [ { - "name": "code", + "name": "manager", "kind": "bundle", "language": "go", "system": "arch", - "from": "cmd/claude-licence-manager", + "from": "cmd/manager", "binary": "claude-licence-manager", "loads": [ "claude-licence-manager" ], "env": { - "DATABASE_URL_FILE": "${dir:state}/database.url", "MESH_LICENCE_STATE": "${dir:state}", - "MESH_LICENCE_KEY_FILE": "${dir:state}/grant.key", "MESH_LICENCE_SETTINGS": "${dir:state}/settings.json" } }, + { + "name": "tools", + "kind": "bundle", + "language": "go", + "system": "arch", + "from": "cmd/tools", + "binary": "claude-licence-manager-tools", + "loads": [ + "claude-licence-manager-tools" + ] + }, { "name": "files", "kind": "archive", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/clipmenu/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/clipmenu/module.json.captured index 30ec9c0cf..168f925de 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/clipmenu/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/clipmenu/module.json.captured @@ -1,6 +1,7 @@ { "module": "clipmenu", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/confluence/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/confluence/module.json.captured index caa0d1be2..26dbb3333 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/confluence/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/confluence/module.json.captured @@ -1,6 +1,7 @@ { "module": "confluence", - "version": "1", + "version": "0.1", + "class": "leaf", "slug": "confl", "own-secrets": { "token": "${dir:state}/token" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/cups/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/cups/module.json.captured index 01a482288..2156e3bbc 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/cups/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/cups/module.json.captured @@ -1,6 +1,7 @@ { "module": "cups", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager", "service-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dbus/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dbus/module.json.captured index c0e28b3e4..9bdd57ba8 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dbus/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dbus/module.json.captured @@ -1,6 +1,7 @@ { "module": "dbus", - "version": "1", + "version": "0.1", + "class": "core", "capabilities": [ "package-manager", "service-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/desk-channel/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/desk-channel/module.json.captured index 115ce6202..bf8b4487a 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/desk-channel/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/desk-channel/module.json.captured @@ -1,6 +1,7 @@ { "module": "desk-channel", - "version": "1", + "version": "0.1", + "class": "core", "slug": "desk", "runs-as": "desk-channel", "claims": [ diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dev-tools/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dev-tools/module.json.captured index 094f83363..754963765 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dev-tools/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dev-tools/module.json.captured @@ -1,6 +1,7 @@ { "module": "dev-tools", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/disk-load/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/disk-load/module.json.captured index e50253e6e..f19a46849 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/disk-load/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/disk-load/module.json.captured @@ -1,12 +1,17 @@ { "module": "disk-load", - "version": "1", + "version": "0.1", + "class": "leaf", "tools": [ "disk_load", "disk_top", "disk_filesystems", + "disk_folders", "disk_devices", - "cpu_top" + "cpu_top", + "disk_readings", + "disk_round", + "disk_measure" ], "build": { "artifacts": [ @@ -20,7 +25,26 @@ "loads": [ "disk-load" ] + }, + { + "name": "diskreadings", + "kind": "package", + "language": "go", + "paths": [ + "diskreadings" + ], + "series": "0.1" } ] - } + }, + "state": [ + "readings", + { + "name": "rounds", + "per-machine": true + } + ], + "reads": [ + "mesh-host.data" + ] } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/distribution/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/distribution/module.json.captured index eb9f7c246..6941af2d1 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/distribution/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/distribution/module.json.captured @@ -1,36 +1,96 @@ { "module": "distribution", - "version": "1", + "version": "0.1", + "class": "core", "provides": [ { "name": "artifact-store", - "scope": "mesh" + "scope": "mesh", + "credential": { + "form": "none" + } } ], + "serves": { + "artifact-store": { + "port": 5100 + } + }, "claims": [ + { + "name": "container-image-registry", + "scope": "mesh", + "serves": [ + "hold", + "list", + "mirror", + "publish", + "publish-part", + "release", + "remove", + "tags", + "versions" + ] + }, + { + "name": "oci-artifact-registry", + "scope": "mesh", + "serves": [ + "hold", + "list", + "publish", + "publish-part", + "release", + "remove", + "versions" + ] + }, { "name": "mesh-artifact-store", "scope": "mesh" } ], + "tools": [ + "registry_direct_writes", + "registry_health", + "registry_holds", + "registry_incoming", + "registry_mirrors", + "registry_old_name" + ], + "invokes": [ + "seat:mesh-builds.reserved", + "mesh-delivery-view.node_haves", + "seat:node-engine.manifest-reads", + "seat:mesh-hand-acts.hand-act", + "seat:mesh-catalog.entry", + "seat:mesh-catalog.registrations", + "seat:mesh-catalog.revision", + "seat:mesh-delivery.source", + "seat:mesh-module-assigner.assignments" + ], + "consumes": [ + "mesh-delivery-view.delivered", + "node-engine.manifest-reads-changed", + "mesh-conditions.findings-asked", + "mesh-catalog.catalog-revision", + "mesh-catalog.registration-changed", + "mesh-delivery.source-moved" + ], "capabilities": [ "container-runtime" ], "own-secrets": { "broker": "/var/lib/mesh/registry/broker" }, - "serves": { - "artifact-store": { - "port": 5000 - } - }, + "secrets-owner": "distribution", "listens": [ { "name": "registry", - "port": 5000, + "port": 5100, "protocol": "tcp", "from": "mesh", - "why": "every machine pulls images and artifacts from here" + "why": "every machine pulls images and artifacts from here; distribution's program serves it in front of the store" } ], "data": { @@ -46,19 +106,28 @@ ] }, "resources": [ + { + "id": "account", + "type": "user", + "name": "distribution", + "shell": "/usr/bin/nologin", + "home": "/var/lib/mesh/registry" + }, { "id": "state", "type": "directory", "path": "/var/lib/mesh/registry", "mode": "0700", - "unknown": "program" + "unknown": "program", + "owner": "distribution" }, { "id": "registry-data", "type": "directory", "path": "/var/lib/mesh-registry", "mode": "0700", - "unknown": "program" + "unknown": "program", + "owner": "distribution" }, { "id": "store", @@ -66,13 +135,47 @@ "name": "mesh-registry", "image": "registry@sha256:a3d8aaa63ed8681a604f1dea0aa03f100d5895b6a58ace528858a7b332415373", "ports": [ - "5000:5000" + "127.0.0.1:5001:5001" ], "volumes": [ "/var/lib/mesh-registry:/var/lib/registry" ], "env": { + "REGISTRY_HTTP_ADDR": ":5001", "REGISTRY_STORAGE_DELETE_ENABLED": "true" + }, + "health": { + "kind": "http", + "endpoint": "registry", + "path": "/v2/", + "status": 200, + "interval": "60s", + "timeout": "10s", + "looks": 2, + "grace": "90s" + } + }, + { + "id": "program", + "type": "process", + "name": "distribution", + "artifact": "program", + "run": [ + "./distribution" + ], + "env": { + "MESH_BROKER_FILE": "/var/lib/mesh/registry/broker", + "MESH_REGISTRY_LOOPBACK": "http://127.0.0.1:5001", + "MESH_REGISTRY_LISTEN": ":5100" + }, + "user": "distribution", + "health": { + "kind": "tool", + "tool": "registry_health", + "interval": "60s", + "timeout": "10s", + "looks": 2, + "grace": "90s" } }, { @@ -92,5 +195,99 @@ "store" ] } - ] + ], + "build": { + "artifacts": [ + { + "name": "program", + "kind": "bundle", + "language": "go", + "system": "arch", + "from": "cmd/distribution", + "binary": "distribution" + }, + { + "name": "tools", + "kind": "bundle", + "language": "go", + "system": "arch", + "from": "cmd/distribution-tools", + "binary": "distribution-tools", + "loads": [ + "distribution-tools" + ], + "env": { + "MESH_REGISTRY_CONTAINER": "mesh-registry" + } + } + ] + }, + "streams": [ + { + "name": "distribution-findings", + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 16 + }, + { + "name": "distribution-events", + "events": [ + "old-name-closed", + "direct-writes-closed" + ], + "max-age-days": 7, + "max-mib": 16 + } + ], + "objects": [ + { + "name": "incoming", + "max-mib": 8192 + } + ], + "state": [ + { + "name": "transfers", + "max-mib": 8 + }, + { + "name": "idle", + "key-ttl": true, + "max-mib": 8 + }, + { + "name": "holds", + "max-mib": 8 + }, + { + "name": "windows", + "max-mib": 8 + }, + { + "name": "mirrors", + "max-mib": 8 + }, + { + "name": "findings", + "max-mib": 8 + }, + { + "name": "taken", + "key-ttl": true, + "max-mib": 8 + } + ], + "config": { + "ask-taken-bound": { + "type": "string", + "description": "How long the registry keeps the id of a publish ask it took, as a duration such as 10m (design 47 H2 §775): a publish given again with that id within it acts not again but answers the transfer as it stands. The largest caller's bound, the pipeline runner's ask-unanswered-bound, by default.", + "trusted": false, + "runtime": true, + "default": "10m" + } + } } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dmenu/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dmenu/module.json.captured index aeeb3ce09..71d0c4172 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dmenu/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dmenu/module.json.captured @@ -1,6 +1,7 @@ { "module": "dmenu", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dnsmasq/files/dnsmasq.conf b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dnsmasq/files/dnsmasq.conf index 10f3926af..0169182e3 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dnsmasq/files/dnsmasq.conf +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dnsmasq/files/dnsmasq.conf @@ -57,12 +57,12 @@ listen-address=127.0.0.1 # upstreams would find itself, and every query it could not answer locally would # loop until its receive queue filled. That is not theoretical: it filled with # 15KB of queries and every lookup on the machine hung. no-resolv makes that loop -# impossible: the upstreams are the two lines below, and nothing on the machine +# impossible: the upstreams are the two lines below (the module's settings upstream-resolver-first and -second), and nothing on the machine # can redirect them. The mesh's own names never reach them: the local= line in # the file above stops them here, answered or refused. no-resolv -server=1.1.1.1 -server=8.8.8.8 +server=${config:upstream-resolver-first} +server=${config:upstream-resolver-second} # Both upstreams validate DNSSEC and say so with the Authenticated Data bit, # and this passes that bit down rather than dropping it, which dnsmasq does diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dnsmasq/files/mesh.conf b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dnsmasq/files/mesh.conf index 96d8d7d61..7f86d122e 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dnsmasq/files/mesh.conf +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dnsmasq/files/mesh.conf @@ -1,14 +1,15 @@ # Written by the mesh (module dnsmasq, novox/hq issue 348). Replaced on every push. # # The resolver binds its addresses once, at start (bind-interfaces), so it starts only once this -# machine's private address is there: it waits up to 80 seconds for it, and a start that found it -# missing is tried again every ten seconds rather than left failed. +# machine's private address is there: a start that finds it missing fails after at most two seconds and +# is tried again every ten seconds (Restart=on-failure, no start limit) until the tunnel has brought it. +# It does not order itself After= or Wants= network-online.target, and its wait is short: the packaged +# unit is Before= network-online.target and nss-lookup.target, and the tunnel is ordered after them, so +# a long wait would hold the tunnel back and a drop-in ordering would be a cycle (issue 1126). [Unit] -After=network-online.target -Wants=network-online.target StartLimitIntervalSec=0 [Service] -ExecStartPre=/usr/bin/sh -c 'for i in $(seq 1 80); do ip -4 -o addr show to ${machine:address} | grep -q . && exit 0; sleep 1; done; echo "${machine:address} is not on this machine" >&2; exit 1' +ExecStartPre=/usr/bin/sh -c 'for i in $(seq 1 2); do ip -4 -o addr show to ${machine:address} | grep -q . && exit 0; sleep 1; done; echo "${machine:address} is not on this machine" >&2; exit 1' Restart=on-failure RestartSec=10s diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dnsmasq/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dnsmasq/module.json.captured index 58cc0da56..8516bb620 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dnsmasq/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dnsmasq/module.json.captured @@ -1,6 +1,7 @@ { "module": "dnsmasq", - "version": "1", + "version": "0.1", + "class": "core", "upgrade": { "policy": "record", "why": "the mesh's resolver: a build that breaks it can stop a machine resolving the bus, and then neither the gate's rollback nor a push reaches it (hq ADR 0236, issue 260)" @@ -9,7 +10,10 @@ { "name": "wildcard-resolution", "scope": "mesh", - "identity": false + "identity": false, + "credential": { + "form": "none" + } } ], "requires": [ @@ -35,6 +39,22 @@ "dnsmasq_names", "dnsmasq_resolve" ], + "config": { + "upstream-resolver-first": { + "type": "string", + "description": "The first public resolver this resolver forwards to for every name that is not the mesh's own, as an IP address. It is placed as a server line beside no-resolv, so it must never be an address that resolves through this machine; both upstreams should validate DNSSEC, since the authenticated-data bit is passed down (ADR 0194, ADR 0223). Set per node or for the whole mesh.", + "trusted": false, + "pattern": "^[0-9A-Fa-f.:]+$", + "default": "1.1.1.1" + }, + "upstream-resolver-second": { + "type": "string", + "description": "The second public resolver this resolver forwards to, as an IP address, tried beside the first so one upstream being down does not stop name resolution. The same rules as upstream-resolver-first.", + "trusted": false, + "pattern": "^[0-9A-Fa-f.:]+$", + "default": "8.8.8.8" + } + }, "listens": [ { "name": "dns-udp", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/docker-compose/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/docker-compose/module.json.captured index 2f576b4ba..92caf5835 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/docker-compose/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/docker-compose/module.json.captured @@ -1,6 +1,7 @@ { "module": "docker-compose", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/docker/files/daemon.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/docker/files/daemon.json index 83750f4bd..c8fb9c7ee 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/docker/files/daemon.json +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/docker/files/daemon.json @@ -1 +1 @@ -{"live-restore": true, "insecure-registries": ["${seat:mesh-artifact-store:reach}"], "log-driver": "json-file", "log-opts": {"max-size": "${config:log-max-size}", "max-file": "${config:log-max-file}"}} +{"live-restore": true, "insecure-registries": ["${seat:container-image-registry:reach}"], "log-driver": "json-file", "log-opts": {"max-size": "${config:log-max-size}", "max-file": "${config:log-max-file}"}} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/docker/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/docker/module.json.captured index a3a75e090..c4be0284b 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/docker/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/docker/module.json.captured @@ -1,13 +1,14 @@ { "module": "docker", - "version": "1", + "version": "0.1", + "class": "core", "capabilities": [ "package-manager", "service-manager", "privileged" ], "invokes": [ - "seat:mesh-controller.images" + "seat:mesh-artifact-sweep.images" ], "claims": [ { @@ -33,6 +34,7 @@ "docker_disk_usage", "docker_networks", "docker_volumes", + "docker_volumes_remove_anonymous", "docker_events", "docker_daemon_config", "docker_unlabelled", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dunst/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dunst/module.json.captured index 0c6983b4d..7821e3f9d 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dunst/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/dunst/module.json.captured @@ -1,6 +1,7 @@ { "module": "dunst", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/fail2ban/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/fail2ban/module.json.captured index 446395f2c..1fe831870 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/fail2ban/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/fail2ban/module.json.captured @@ -1,6 +1,7 @@ { "module": "fail2ban", - "version": "1", + "version": "0.1", + "class": "core", "capabilities": [ "firewall" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/feh/files/fehbg b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/feh/files/fehbg index a3159bbb3..a78c8b9cf 100755 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/feh/files/fehbg +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/feh/files/fehbg @@ -1,6 +1,6 @@ #!/bin/sh -# The wallpaper (module feh, novox/hq ADR 0208). Owned by the mesh: replaced at every push. The +# The wallpaper (module feh, novox/hq ADR 0208). Owned by the mesh: replaced at every delivery. The # session's start runs it, and so may anything that wants the declared wallpaper back. The image is # the module's own, in ~/.local/share/feh/wallpapers. feh_set changes the wallpaper for a session -# without touching this file. +# without touching this file (design 47 H1, proof 1 (second run): delivered by its pipeline, 2026-11-21). feh --no-fehbg --bg-fill "$HOME/.local/share/feh/wallpapers/default.jpg" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/feh/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/feh/module.json.captured index d6e44073b..49dada45b 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/feh/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/feh/module.json.captured @@ -1,6 +1,7 @@ { "module": "feh", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/flatpak/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/flatpak/module.json.captured index 76d47213d..da3d6ae04 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/flatpak/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/flatpak/module.json.captured @@ -1,6 +1,7 @@ { "module": "flatpak", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/fonts/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/fonts/module.json.captured index b2958da8a..14b7463c2 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/fonts/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/fonts/module.json.captured @@ -1,6 +1,7 @@ { "module": "fonts", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/forticlient/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/forticlient/module.json.captured index 631d3faf7..c849b0fe4 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/forticlient/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/forticlient/module.json.captured @@ -1,6 +1,7 @@ { "module": "forticlient", - "version": "1", + "version": "0.1", + "class": "leaf", "upgrade": { "policy": "record", "why": "its adapter routes the company's domains on the machine a person works on: a build that breaks it cuts the person off from work names until a person pushes the next (hq ADR 0236, ADR 0247)" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/files/config.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/files/config.json index 0967ef424..7ee627f89 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/files/config.json +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/files/config.json @@ -1 +1 @@ -{} +{"main-mergers": ["jschoubben"]} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/files/repositories.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/files/repositories.json index 36626ccc9..a8293008f 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/files/repositories.json +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/files/repositories.json @@ -1 +1 @@ -{"repositories": ${config:repositories}} +{"repositories": ${config:repositories}, "keep-main-rules": ${config:keep-main-rules}} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/files/server.env b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/files/server.env index 8cb88e22e..164b0c40b 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/files/server.env +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/files/server.env @@ -5,3 +5,8 @@ GITEA__database__NAME=${bound:postgres-database:as} GITEA__database__USER=${bound:postgres-database:as} GITEA__database__PASSWD=${secret:postgres-database} GITEA__webhook__ALLOWED_HOST_LIST=172.17.0.1 +# Issue 1966: cap the forge's own pool; the store's 100 connections are shared by every module on this machine. +# SSH git operations go through the forge's private API, so this pool carries them. +GITEA__database__MAX_OPEN_CONNS=${config:database-max-open-connections} +GITEA__database__MAX_IDLE_CONNS=${config:database-max-idle-connections} +GITEA__database__CONN_MAX_LIFETIME=${config:database-connection-lifetime} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/module.json.captured index 118224cd6..04d479f64 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitea/module.json.captured @@ -1,6 +1,7 @@ { "module": "gitea", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "requires": [ "postgres-database", @@ -41,14 +42,9 @@ "emits": [ "repo.created", "issue.opened", - "pull.merged", - "pull.updated", - "pull.closed", "forge.push", "forge.create", - "forge.delete", "forge.fork", - "forge.status", "forge.pull-request.opened", "forge.pull-request.reopened", "forge.pull-request.synchronized", @@ -85,10 +81,6 @@ "forge.wiki.changed", "forge.other" ], - "consumes": [ - "mesh-controller.checked", - "node-build-agent.started" - ], "listens": [ { "name": "web", @@ -122,24 +114,61 @@ "git": { "scheme": "http", "port": 3000 + }, + "go-package-registry": { + "scheme": "http", + "port": 3000, + "go-path": "/api/packages/novox/go" } }, - "receives": { - "npm-package-registry": "${dir:grants}/npm.json" - }, - "grants": { - "npm-package-registry": "${dir:grants}" - }, "claims": [ { "name": "npm-package-registry", - "scope": "mesh" + "scope": "mesh", + "serves": [ + "publish", + "publish-part", + "remove", + "versions" + ] + }, + { + "name": "go-package-registry", + "scope": "mesh", + "serves": [ + "publish", + "publish-part", + "remove", + "versions" + ] }, { "name": "git", - "scope": "mesh" + "scope": "mesh", + "serves": [ + "pull", + "branch", + "open-pulls", + "tags", + "trees", + "file", + "contains", + "statuses", + "status", + "comment", + "view", + "note", + "merge-pull", + "tag" + ] } ], + "uses": [ + "operator-channel" + ], + "needs-approval": [ + "gitea_branch_protection_loosen" + ], "data": { "own": [ { @@ -148,16 +177,29 @@ "class": "valuable", "why": "every repository, its issues and attachments, and the package registry" } - ], - "consumers": { - "npm-package-registry": { - "class": "rebuildable", - "in": "data", - "why": "a consumer's packages are published again from its source" - } - } + ] }, "config": { + "database-max-open-connections": { + "type": "number", + "description": "The most connections the forge's own database pool holds open to the store. The store's 100 connections are shared by every module on its machine, and the forge's git operations over ssh go through the forge's private API, which this pool carries: 40 leaves room for the others.", + "trusted": false, + "minimum": 1, + "default": 40 + }, + "database-max-idle-connections": { + "type": "number", + "description": "The connections the forge's database pool keeps idle, ready for the next request. They count against the store's 100 connections, shared on its machine, so keep this well under the open-connection cap.", + "trusted": false, + "minimum": 0, + "default": 10 + }, + "database-connection-lifetime": { + "type": "string", + "description": "How long the forge's database pool keeps one connection before it closes and reopens it, as a duration such as 5m. A shorter lifetime gives back connections of the store's 100 connections, shared on its machine, sooner.", + "trusted": false, + "default": "5m" + }, "url": { "type": "string", "description": "The address the module's tools reach the forge at, as a URL; unset, the code falls back to its environment, else this machine's gitea on its port.", @@ -170,11 +212,53 @@ "trusted": true, "default": {} }, + "call-retention": { + "type": "number", + "description": "How many days the forge module keeps a merge call in its state calls (design 47 H §766): a call older than this is deleted when a new call is written, oldest first.", + "trusted": false, + "minimum": 1, + "default": 30 + }, + "keep-main-rules": { + "type": "boolean", + "description": "Whether the module keeps main's branch protection as the mesh wants it. True: when the tools' account's token is minted, main's rule in every repository of the organisation novox is put to no push and the tools' account alone merging, and each apply of the `repositories` value narrows the main rule of the repositories it lists, requiring no status. False (the default): the module changes no existing repository's branch protection, whoever set it at the forge, but takes away a required status it finds on a rule covering main, once (ADR 0534 §1); a repository listed in `repositories` that does not exist is still made, with its first protection.", + "trusted": true, + "default": false + }, "repositories": { "type": "object", - "description": "The repositories of the organisation novox the mesh holds (ADR 0428): each by name, {\"\": {\"private\": true, \"description\": \"...\"}}. One that does not exist is made by the module's setup login under its own account, its main protected and given a first commit (a README naming the description and a merge-check.sh), its rule narrowed to no push and the tools' merge requiring mesh/repo-check and mesh/merge-gate, and only then moved into the organisation; one that exists only has main's rule put right, its statuses kept. A repository taken out of the value is never touched.", + "description": "The repositories of the organisation novox the mesh holds (ADR 0428): each by name, {\"\": {\"private\": true, \"description\": \"...\"}}. One that does not exist is made by the module's setup login under its own account, its main protected and given a first commit (a README naming the description ), its rule narrowed to no push, the tools' account and main-mergers alone merging, and no status required (ADR 0534), and only then moved into the organisation; one that exists only has main's rule put right so. Every other repository has the statuses its main requires taken off; nothing else of a repository out of the value is touched. With keep-main-rules false a listed repository that exists likewise has only its required statuses taken off, once.", "trusted": true, "default": {} + }, + "main-mergers": { + "type": "list", + "description": "The forge logins that may merge into main beside the tools' account, on every repository of the organisation (ADR 0534 §2): the operator's own, so the operator can always merge by hand at the forge. The tools' account is always on main's merge whitelist; no agent's account belongs here.", + "trusted": true, + "default": [ + "jschoubben" + ] + }, + "ask-taken-bound": { + "type": "string", + "description": "How long the forge module keeps the id of an act of the seat git it took, as a duration such as 10m (design 47 H2 §775): an act given again with that id within it acts not again but answers what the forge holds of it. The largest caller's bound, the pipeline runner's ask-unanswered-bound, by default.", + "trusted": false, + "runtime": true, + "default": "10m" + }, + "token-ttl": { + "type": "string", + "description": "How old the forge module's token of an account may grow, as a duration such as 24h (design 47 H2 \u00a7808): a token the vault has kept longer than this, by its changed-at, is minted again, one process at a time, and the one it replaces is deleted at the forge.", + "trusted": false, + "runtime": true, + "default": "24h" + }, + "mint-lease": { + "type": "string", + "description": "How long one process of the forge module may hold the lease to mint a token, as a duration such as 60s (design 47 H2 \u00a7808): the lease key mint in the state token-lease lives this long, so a process that died holding it is replaced after it, and a process that finds it taken waits at most this long.", + "trusted": false, + "runtime": true, + "default": "60s" } }, "facts": { @@ -213,12 +297,6 @@ "place": ".", "unknown": "program" }, - { - "id": "grants", - "type": "directory", - "mode": "0700", - "unknown": "program" - }, { "id": "server-env", "type": "file", @@ -236,6 +314,9 @@ { "id": "server", "type": "container", + "restart-on": [ + "server-env" + ], "health": { "kind": "http", "endpoint": "web", @@ -248,7 +329,8 @@ "env": { "DB_TYPE": "postgres", "USER_UID": "1000", - "USER_GID": "1000" + "USER_GID": "1000", + "SSH_MAX_STARTUPS": "100:30:200" }, "env-file": [ "${dir:state}/server.env" @@ -303,7 +385,10 @@ "template": "files/config.json", "merge": "json", "takes-config": [ - "url" + "url", + "keep-main-rules", + "main-mergers", + "call-retention" ] }, { @@ -366,24 +451,35 @@ "MESH_GITEA_ADMIN_PASSWORD_FILE": "${dir:state}/admin.secret", "MESH_GITEA_TOOLS_USER": "mesh-tools", "MESH_REPOSITORIES_FILE": "${dir:mesh-state}/repositories.json", - "MESH_REPOSITORIES_OUTCOME": "${dir:runtime-state}/repositories-outcome.json" + "MESH_REPOSITORIES_OUTCOME": "${dir:runtime-state}/repositories-outcome.json", + "MESH_GITEA_CONFIG_FILE": "${dir:mesh-state}/config.json" }, "restart-on": [ - "repositories-file" + "repositories-file", + "runtime-config" ] } ], "provides": [ { "name": "npm-package-registry", - "scope": "mesh", - "identity": { - "max": 40, - "in": "a Gitea user name" - } + "credential": { + "form": "none" + }, + "scope": "mesh" + }, + { + "name": "go-package-registry", + "credential": { + "form": "none" + }, + "scope": "mesh" }, { "name": "git", + "credential": { + "form": "none" + }, "scope": "mesh" }, { @@ -396,7 +492,11 @@ }, { "name": "forge-account", - "scope": "mesh" + "credential": { + "form": "none" + }, + "scope": "mesh", + "answered-by": "helper" } ], "build": { @@ -405,15 +505,16 @@ "name": "code", "kind": "bundle", "language": "typescript", + "needs": [ + "mesh-delivery-assigner:program" + ], "entrypoints": [ "index.js", - "tools/index.js", - "provisioner/index.js" + "tools/index.js" ], "loads": [ "index.js", - "tools/index.js", - "provisioner/index.js" + "tools/index.js" ], "env": { "MESH_GITEA_URL": "http://127.0.0.1:${port:3000}", @@ -422,26 +523,25 @@ "MESH_GITEA_ADMIN_PASSWORD_FILE": "${dir:state}/admin.secret", "MESH_GITEA_TOOLS_USER": "mesh-tools", "MESH_GITEA_STATE_DIR": "${dir:runtime-state}", - "MESH_RECEIVES": "${dir:grants}/npm.json", "MESH_GITEA_HOOK_URL": "http://172.17.0.1:3047", "MESH_GITEA_HOOK_PORT": "3047", "MESH_GITEA_HOOK_HOST": "172.17.0.1" } }, { - "name": "npm-registry", + "name": "package-registry", "kind": "bundle", "language": "go", "system": "arch", - "from": "cmd/npm-registry", - "binary": "npm-registry", + "from": "cmd/package-registry", + "binary": "package-registry", "loads": [ - "npm-registry" + "package-registry" ], "env": { "MESH_GITEA_URL": "http://127.0.0.1:${port:3000}", - "MESH_GITEA_ADMIN_USER": "mesh-admin", - "MESH_GITEA_ADMIN_PASSWORD_FILE": "${dir:state}/admin.secret", + "MESH_GITEA_TOOLS_USER": "mesh-tools", + "MESH_GITEA_PACKAGES_USER": "mesh-packages", "MESH_NPM_OWNER": "novox" } }, @@ -458,7 +558,6 @@ "env": { "MESH_GITEA_URL": "http://127.0.0.1:${port:3000}", "MESH_GITEA_TOOLS_USER": "mesh-tools", - "MESH_GITEA_TOKEN_FILE": "${dir:runtime-state}/token", "MESH_GITEA_PATCH_DIR": "${dir:forge-patches}" } }, @@ -522,6 +621,7 @@ "MESH_GITEA_ADMIN_PASSWORD_FILE": "${dir:state}/admin.secret", "MESH_GITEA_ORIGINS_FILE": "${dir:mesh-state}/origins", "MESH_GITEA_SSH_PORT": "222", + "MESH_GITEA_HOST_KEY_FILE": "${dir:data}/ssh/ssh_host_ed25519_key.pub", "MESH_FORGE_HOST_FILE": "/etc/gitea/forge-host" } } @@ -535,13 +635,96 @@ } ], "state": [ - "bound", - "announced" + { + "name": "bound", + "max-mib": 8 + }, + { + "name": "announced", + "max-mib": 8 + }, + { + "name": "findings", + "max-mib": 8 + }, + { + "name": "first-views", + "history": 1, + "max-mib": 8 + }, + { + "name": "transfers", + "max-mib": 8 + }, + { + "name": "idle", + "key-ttl": true, + "max-mib": 8 + }, + { + "name": "failed-steps", + "history": 1, + "max-mib": 8 + }, + { + "name": "calls", + "history": 1, + "max-mib": 8 + }, + { + "name": "taken", + "key-ttl": true, + "max-mib": 8 + }, + { + "name": "token-lease", + "key-ttl": true, + "max-mib": 1 + } ], "reads": [ - "mesh-controller.assignments", + "mesh-provisioner.plans", + "mesh-provisioner.provisions", "ssh-client.keys", "mesh-build-go.keys", - "mesh-build-node.keys" + "mesh-build-node.keys", + "mesh-build-image.keys" + ], + "invokes": [ + "seat:mesh-catalog.revision", + "seat:mesh-catalog.registrations", + "seat:mesh-hand-acts.hand-act", + "seat:mesh-builds.reserved", + "seat:mesh-vault.own-put", + "seat:mesh-vault.get" + ], + "consumes": [ + "mesh-catalog.catalog-revision", + "mesh-catalog.registration-changed", + "mesh-pipeline-runner.step-ended.*.*.*", + "git.branch-moved", + "git.pull-updated", + "git.pull-closed", + "git.pull-merged", + "mesh-conditions.findings-asked", + "mesh-vault.secret-changed" + ], + "streams": [ + { + "name": "gitea-findings", + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } + ], + "objects": [ + { + "name": "incoming", + "max-mib": 2048 + } ] } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitlab/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitlab/module.json.captured index 3cb33fb27..7bded31ca 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitlab/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gitlab/module.json.captured @@ -1,6 +1,7 @@ { "module": "gitlab", - "version": "1", + "version": "0.1", + "class": "leaf", "own-secrets": { "token": "${dir:state}/token" }, diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gnome-keyring/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gnome-keyring/module.json.captured index 9f75b9ff4..a7b663deb 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gnome-keyring/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/gnome-keyring/module.json.captured @@ -1,6 +1,7 @@ { "module": "gnome-keyring", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/go/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/go/module.json.captured index 48a6bf57e..10cb723e5 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/go/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/go/module.json.captured @@ -1,13 +1,17 @@ { "module": "go", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager" ], "provides": [ { "name": "go-toolchain", - "reach": "machine" + "reach": "machine", + "credential": { + "form": "none" + } } ], "resources": [ diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/grafana/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/grafana/module.json.captured index 1cbf995fd..8acd7b622 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/grafana/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/grafana/module.json.captured @@ -1,6 +1,7 @@ { "module": "grafana", - "version": "1", + "version": "0.1", + "class": "leaf", "emits": [ "alert.firing" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/hello-web/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/hello-web/module.json.captured index 005578cd5..d6cf28b03 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/hello-web/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/hello-web/module.json.captured @@ -1,7 +1,8 @@ { "module": "hello-web", "slug": "hello", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "container-runtime" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/home-assistant/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/home-assistant/module.json.captured index 9c4f99db9..fad6eec97 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/home-assistant/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/home-assistant/module.json.captured @@ -1,6 +1,7 @@ { "module": "home-assistant", - "version": "1", + "version": "0.1", + "class": "leaf", "slug": "hass", "capabilities": [ "container-runtime" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/hostname/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/hostname/module.json.captured index e84e7be25..dc9a84014 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/hostname/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/hostname/module.json.captured @@ -1,6 +1,7 @@ { "module": "hostname", - "version": "1", + "version": "0.1", + "class": "core", "claims": [ { "name": "node-hostname", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/i3/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/i3/module.json.captured index 1ec924268..315b77deb 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/i3/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/i3/module.json.captured @@ -1,6 +1,7 @@ { "module": "i3", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/i3status-rust/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/i3status-rust/module.json.captured index 1e07556b1..4e85779f9 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/i3status-rust/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/i3status-rust/module.json.captured @@ -1,6 +1,7 @@ { "module": "i3status-rust", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/icecast/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/icecast/module.json.captured index 6f9ab549e..ca6de7876 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/icecast/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/icecast/module.json.captured @@ -1,6 +1,7 @@ { "module": "icecast", - "version": "1", + "version": "0.1", + "class": "leaf", "requires": [ "route", "secret" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/influxdb/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/influxdb/module.json.captured index 53389a5f5..80d2f225a 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/influxdb/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/influxdb/module.json.captured @@ -1,12 +1,16 @@ { "module": "influxdb", - "version": "1", + "version": "0.1", + "class": "leaf", "provides": [ { "name": "influxdb-api", "scope": "mesh", "identity": { "in": "an InfluxDB v1 authorization" + }, + "credential": { + "form": "pair" } } ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/invoicing/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/invoicing/module.json.captured index 29670a3e6..f56e75359 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/invoicing/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/invoicing/module.json.captured @@ -1,6 +1,7 @@ { "module": "invoicing", - "version": "1", + "version": "0.1", + "class": "leaf", "slug": "invoice", "capabilities": [ "container-runtime" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/jira/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/jira/module.json.captured index 9f98dd835..3d48f9f63 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/jira/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/jira/module.json.captured @@ -1,6 +1,7 @@ { "module": "jira", - "version": "1", + "version": "0.1", + "class": "leaf", "own-secrets": { "token": "${dir:state}/token" }, diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/90-mesh-kernel-boot-entries.hook b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/90-mesh-kernel-boot-entries.hook new file mode 100644 index 000000000..d671caaf1 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/90-mesh-kernel-boot-entries.hook @@ -0,0 +1,13 @@ +# Module kernel, novox/hq ADR 0508 §9, issue 1841. After a kernel image is installed, upgraded or removed, the +# fallback kernel's boot entry (or the GRUB menu) is placed again. Written by the mesh; change the module. +[Trigger] +Operation = Install +Operation = Upgrade +Operation = Remove +Type = Path +Target = usr/lib/modules/*/vmlinuz + +[Action] +Description = Placing the fallback kernel on the boot menu +When = PostTransaction +Exec = ${dir:state}/boot-entries run diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/boot-entries.sh b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/boot-entries.sh new file mode 100644 index 000000000..ed174906b --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/boot-entries.sh @@ -0,0 +1,133 @@ +#!/bin/sh +# The fallback kernel's place on this machine's boot menu (module kernel, novox/hq ADR 0508 §9 and §10, +# issue 1841). Written by the mesh and run as root by mesh-kernel-boot-entries.service at boot and when the +# module is applied, and by the pacman hook 90-mesh-kernel-boot-entries.hook after a kernel is installed, +# upgraded or removed. Replaced on every push; change the module, never this file. +# +# boot-entries run [ [ []]] +# +# The three are arguments only so the module's tests can run this against a stand-in tree. +# +# It reads from the machine which loader booted it, never from a setting: +# systemd-boot the EFI variable LoaderEntrySelected is present: the entry mesh-linux-lts.conf is written +# from the command line the machine booted with. +# GRUB /boot/grub/grub.cfg exists and that variable does not: the menu is generated again, only +# when the set of kernels in /boot differs from the menu's. +# neither it fails loudly. The default entry is never touched. +# And a pacman hook of someone else's that copies kernel images to one fixed name in /boot is moved into this +# module's state first (ADR 0508 §10): it would put the fallback kernel in the default kernel's place. +set -eu + +root=/ +state='${dir:state}' +[ $# -ge 2 ] && root=$(printf '%s' "$2" | sed 's|/$||') +[ $# -ge 3 ] && state=$3 +boot=$root/boot +hooks=$root/etc/pacman.d/hooks +efivar=$root/sys/firmware/efi/efivars/LoaderEntrySelected-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f +ours=90-mesh-kernel-boot-entries.hook +# The fallback kernel and its initramfs are about 72 MB in /boot (issue 1836): less room fails the unit +# before a package writes half of them. +need_kib=98304 +[ $# -ge 4 ] && need_kib=$4 + +[ $# -ge 1 ] && [ "$1" = run ] || { + echo "usage: boot-entries run [ [ []]]" >&2 + exit 2 +} + +# A hook that is not ours, triggered by kernel images, whose action copies to one fixed name in /boot. +copies_kernels() { + grep -Eqi '^[[:space:]]*Target[[:space:]]*=.*(vmlinuz|usr/lib/modules)' "$1" && + grep -Eq '^[[:space:]]*Exec[[:space:]]*=.*(cp|install|ln|rsync)[[:space:]].*/boot/[A-Za-z0-9._+-]+([^A-Za-z0-9._+/%$*-]|$)' "$1" +} + +if [ -d "$hooks" ]; then + for hook in "$hooks"/*.hook; do + [ -f "$hook" ] || continue + [ "$(basename "$hook")" = "$ours" ] && continue + copies_kernels "$hook" || continue + mkdir -p "$state/taken-over" + mv -f "$hook" "$state/taken-over/$(basename "$hook")" + echo "taken over: the pacman hook $(basename "$hook") copied kernel images to one fixed name in /boot; moved to $state/taken-over/ so each kernel keeps its own package's name" + done +fi + +if [ -e "$efivar" ]; then + loader=systemd-boot +elif [ -f "$boot/grub/grub.cfg" ]; then + loader=grub +else + echo "no boot loader found: the machine was not booted by systemd-boot (no LoaderEntrySelected variable) and there is no $boot/grub/grub.cfg; the fallback kernel has no menu to be placed on" >&2 + exit 1 +fi + +# Room first, only while the fallback kernel is not in /boot yet. +if [ ! -e "$boot/vmlinuz-linux-lts" ]; then + free=$(df -Pk "$boot" | awk 'NR==2 {print $4}') + [ -n "$free" ] || free=0 + if [ "$free" -lt "$need_kib" ]; then + echo "$boot has $free KiB free and the fallback kernel needs $need_kib KiB: free room there before the kernel is installed" >&2 + exit 1 + fi +fi + +case "$loader" in +systemd-boot) + entries=$boot/loader/entries + cmdline=$(sed -e 's/BOOT_IMAGE=[^ ]*//g' -e 's/initrd=[^ ]*//g' "$root/proc/cmdline" | tr -s ' \n' ' ' | sed -e 's/^ //' -e 's/ $//') + [ -n "$cmdline" ] || { + echo "$root/proc/cmdline holds no command line to boot the fallback kernel with" >&2 + exit 1 + } + want=$( + echo "title Arch Linux (linux-lts, fallback)" + echo "linux /vmlinuz-linux-lts" + for ucode in intel-ucode.img amd-ucode.img; do + [ -e "$boot/$ucode" ] && echo "initrd /$ucode" + done + echo "initrd /initramfs-linux-lts.img" + echo "options $cmdline" + ) + mkdir -p "$entries" + if [ "$(cat "$entries/mesh-linux-lts.conf" 2>/dev/null || true)" = "$want" ]; then + echo "systemd-boot: mesh-linux-lts.conf, as it was" + else + printf '%s\n' "$want" >"$entries/mesh-linux-lts.conf" + echo "systemd-boot: wrote $entries/mesh-linux-lts.conf from the command line the machine booted with; the default entry is as it was" + fi + ;; +grub) + cfg=$boot/grub/grub.cfg + menu=$(sed -n 's|^[[:space:]]*linux[[:space:]]*\(/boot\)\{0,1\}/\(vmlinuz-[^[:space:]]*\).*|\2|p' "$cfg" | sort -u) + have=$(cd "$boot" && ls -d vmlinuz-* 2>/dev/null | sort -u || true) + if [ "$menu" = "$have" ]; then + echo "grub: the menu lists the kernels in /boot, left as it is" + else + # GRUB lists kernels in reverse version order, so the fallback kernel would come first and become the + # default entry: the kernel the machine booted is put first (GRUB_TOP_LEVEL; /etc/default/grub still + # overrides it when it sets one), the fallback kernel never. + top=$(tr ' ' '\n' <"$root/proc/cmdline" | sed -n 's|^BOOT_IMAGE=\(.*\)$|\1|p' | head -n 1) + top=$(printf '%s' "$top" | sed 's|.*/||') + case "$top" in + vmlinuz-linux-lts | "") top= ;; + esac + [ -n "$top" ] && [ -e "$boot/$top" ] || top= + if [ -z "$top" ]; then + if [ -e "$boot/vmlinuz-linux" ]; then + top=vmlinuz-linux + else + top=$(printf '%s\n' $have | grep -v '^vmlinuz-linux-lts$' | head -n 1 || true) + fi + fi + if [ -n "$top" ]; then + GRUB_TOP_LEVEL=/boot/$top grub-mkconfig -o "$cfg" + else + grub-mkconfig -o "$cfg" + fi + first=$top + [ -n "$first" ] || first="the menu's own order" + echo "grub: the kernels in /boot changed ($(echo $have | tr '\n' ' ')); the menu is generated again with $first first; the default entry is as it was" + fi + ;; +esac diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/initramfs.sh b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/initramfs.sh new file mode 100644 index 000000000..d7d82c185 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/initramfs.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# The initramfs images as the mesh builds them (module kernel, novox/hq issue 1977). Run by +# mesh-kernel-initramfs.service: +# +# initramfs apply [ [ [ []]]] +# +# `apply` builds every image again (mkinitcpio -P) when the drop-in differs from the one the images were last built +# with, kept in the state as `initramfs-built`, and records the drop-in only after mkinitcpio succeeded. Later +# kernel upgrades build the images through the distribution's own hook, with the drop-in in place. +# +# A preset that names the default configuration (ALL_config="/etc/mkinitcpio.conf") makes mkinitcpio pass -c and skip +# mkinitcpio.conf.d, so the drop-in is never read: before building, that line is taken out of the preset, a copy of +# the preset kept in the state's taken-over directory (novox/hq ADR 0508 §10's way with a file the mesh did not +# write); any other ALL_config is left and named. After building, every image must hold microcode in its first +# 64 KiB (the early uncompressed archive), else the unit fails and records nothing. The arguments are only for the +# module's tests. +set -eu + +dropin=/etc/mkinitcpio.conf.d/mesh-microcode.conf +state='${dir:state}' +[ $# -ge 2 ] && dropin=$2 +[ $# -ge 3 ] && state=$3 +presets=/etc/mkinitcpio.d +boot=/boot +[ $# -ge 4 ] && presets=$4 +[ $# -ge 5 ] && boot=$5 + +[ $# -ge 1 ] && [ "$1" = apply ] || { + echo "usage: initramfs apply [ []]" >&2 + exit 2 +} +[ -f "$dropin" ] || { + echo "initramfs: $dropin is not there, so the images cannot be built with the microcode hook" >&2 + exit 1 +} +if [ -f "$state/initramfs-built" ] && cmp -s "$dropin" "$state/initramfs-built"; then + echo "initramfs: the images were built with this drop-in, as it was" + exit 0 +fi +for preset in "$presets"/*.preset; do + [ -f "$preset" ] || continue + if grep -qx 'ALL_config="/etc/mkinitcpio.conf"' "$preset"; then + mkdir -p "$state/taken-over" + cp "$preset" "$state/taken-over/$(basename "$preset")" + grep -vx 'ALL_config="/etc/mkinitcpio.conf"' "$preset" >"$preset.new" || true + cat "$preset.new" >"$preset" + rm -f "$preset.new" + echo "initramfs: $preset named the default configuration, which skips mkinitcpio.conf.d; that line is taken out, a copy is in $state/taken-over" + elif grep -q '^ALL_config=' "$preset"; then + echo "initramfs: $preset sets $(grep '^ALL_config=' "$preset" | head -n 1), so the microcode drop-in may not be read; left as it is" + fi +done +if ! mkinitcpio -P; then + echo "initramfs: mkinitcpio failed; nothing recorded, the next start tries again" >&2 + exit 1 +fi +missing= +for img in "$boot"/initramfs-*.img; do + [ -e "$img" ] || continue + if ! head -c 65536 "$img" >"$state/image-head.tmp" || ! grep -aq 'kernel/x86/microcode/' "$state/image-head.tmp"; then + missing="$missing $(basename "$img")" + fi +done +rm -f "$state/image-head.tmp" +if [ -n "$missing" ]; then + echo "initramfs: mkinitcpio ran, but no microcode is in the early archive of:$missing; nothing recorded" >&2 + exit 1 +fi +cp "$dropin" "$state/initramfs-built.new" +mv "$state/initramfs-built.new" "$state/initramfs-built" +echo "initramfs: the images are built with the microcode drop-in" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/mesh-kernel-boot-entries.service b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/mesh-kernel-boot-entries.service new file mode 100644 index 000000000..56cfa3194 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/mesh-kernel-boot-entries.service @@ -0,0 +1,22 @@ +[Unit] +Description=The fallback kernel's place on this machine's boot menu +# Module kernel, novox/hq ADR 0508 §9, issue 1841. Starting this unit reads which loader booted the machine and +# places the fallback kernel's boot entry (systemd-boot) or generates the menu again (GRUB); it fails, and says +# why, when there is no loader or the boot partition has no room. The kernel packages are declared after this +# unit, so the entry is in place before they are installed. +After=local-fs.target +Wants=local-fs.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=${dir:state}/boot-entries run +# It writes the boot partition, the pacman hook directory and its own state, and nothing else. +ProtectSystem=strict +ReadWritePaths=/boot ${dir:state} /etc/pacman.d/hooks +ProtectHome=yes +PrivateNetwork=yes +NoNewPrivileges=yes + +[Install] +WantedBy=multi-user.target diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/mesh-kernel-initramfs.service b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/mesh-kernel-initramfs.service new file mode 100644 index 000000000..c1a2515c3 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/mesh-kernel-initramfs.service @@ -0,0 +1,22 @@ +[Unit] +Description=The initramfs images with the CPU's current microcode +# Module kernel, novox/hq issue 1977. Starting this unit builds the images again when the microcode drop-in +# changed since they were last built; a failed mkinitcpio fails the unit. The microcode packages are declared +# before this unit. +After=local-fs.target +Wants=local-fs.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=${dir:state}/initramfs apply +# It writes the boot partition, the presets and its own state; mkinitcpio keeps its work in a private /tmp. +ProtectSystem=strict +ReadWritePaths=/boot /etc/mkinitcpio.d ${dir:state} +PrivateTmp=yes +ProtectHome=yes +PrivateNetwork=yes +NoNewPrivileges=yes + +[Install] +WantedBy=multi-user.target diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/mesh-microcode.conf b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/mesh-microcode.conf new file mode 100644 index 000000000..a718205b7 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/mesh-microcode.conf @@ -0,0 +1,8 @@ +# Module kernel, novox/hq issue 1977. mkinitcpio reads this after /etc/mkinitcpio.conf: it adds the microcode +# hook, which puts the CPU's current microcode (amd-ucode) at the front of every initramfs, so +# every boot entry loads it, the default one too. HOOKS that name it already are left as they are. +# Written by the mesh; change the module. +case "$(declare -p HOOKS)" in +*'"microcode"'*) ;; +*) HOOKS+=(microcode) ;; +esac diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/modules-load.conf b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/modules-load.conf new file mode 100644 index 000000000..eccad6ce8 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/files/modules-load.conf @@ -0,0 +1,4 @@ +# Written by the mesh's kernel module (systemd-modules-load reads it at boot). +# tun: buildah's network for a RUN line (pasta) and every other user-space tunnel open /dev/net/tun. +# Loaded at boot, so an upgrade that removes the running kernel's modules cannot keep it out later. +tun diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/module.json.captured index 67d321564..97a21caed 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/kernel/module.json.captured @@ -1,6 +1,7 @@ { "module": "kernel", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "service-manager" ], @@ -13,7 +14,8 @@ } }, "tools": [ - "kernel_huge_pages" + "kernel_huge_pages", + "kernel_boot" ], "resources": [ { @@ -53,6 +55,113 @@ "health": { "kind": "unit" } + }, + { + "id": "boot-entries", + "type": "file", + "path": "${dir:state}/boot-entries", + "mode": "0755", + "trusted": true, + "template": "files/boot-entries.sh" + }, + { + "id": "boot-unit", + "type": "file", + "path": "/etc/systemd/system/mesh-kernel-boot-entries.service", + "mode": "0644", + "template": "files/mesh-kernel-boot-entries.service" + }, + { + "id": "boot-hook", + "type": "file", + "path": "/etc/pacman.d/hooks/90-mesh-kernel-boot-entries.hook", + "mode": "0644", + "template": "files/90-mesh-kernel-boot-entries.hook" + }, + { + "id": "boot-apply", + "type": "service", + "unit": "mesh-kernel-boot-entries.service", + "state": "running", + "boot": "enabled", + "restart-on": [ + "boot-unit", + "boot-entries" + ], + "health": { + "kind": "unit" + } + }, + { + "id": "linux-lts", + "type": "package", + "package": "linux-lts" + }, + { + "id": "linux-lts-headers", + "type": "package", + "package": "linux-lts-headers" + }, + { + "id": "modules-load", + "type": "file", + "path": "/etc/modules-load.d/mesh-kernel.conf", + "mode": "0644", + "template": "files/modules-load.conf" + }, + { + "id": "modules-keep", + "type": "package", + "package": "kernel-modules-hook" + }, + { + "id": "modules-cleanup", + "type": "service", + "unit": "linux-modules-cleanup.service", + "state": "stopped", + "boot": "enabled" + }, + { + "id": "amd-ucode", + "type": "package", + "package": "amd-ucode" + }, + { + "id": "microcode-hook", + "type": "file", + "path": "/etc/mkinitcpio.conf.d/mesh-microcode.conf", + "mode": "0644", + "template": "files/mesh-microcode.conf" + }, + { + "id": "initramfs", + "type": "file", + "path": "${dir:state}/initramfs", + "mode": "0755", + "trusted": true, + "template": "files/initramfs.sh" + }, + { + "id": "initramfs-unit", + "type": "file", + "path": "/etc/systemd/system/mesh-kernel-initramfs.service", + "mode": "0644", + "template": "files/mesh-kernel-initramfs.service" + }, + { + "id": "initramfs-apply", + "type": "service", + "unit": "mesh-kernel-initramfs.service", + "state": "running", + "boot": "enabled", + "restart-on": [ + "initramfs-unit", + "initramfs", + "microcode-hook" + ], + "health": { + "kind": "unit" + } } ], "build": { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/keycloak/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/keycloak/module.json.captured index 847d5f4f2..cfad61b60 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/keycloak/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/keycloak/module.json.captured @@ -1,6 +1,7 @@ { "module": "keycloak", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, "upgrade": { "policy": "record", @@ -9,6 +10,7 @@ "provides": [ { "name": "oidc-client", + "credential": {"form": "pair"}, "scope": "mesh", "identity": { "max": 255, @@ -240,6 +242,7 @@ "bound" ], "reads": [ - "mesh-controller.assignments" + "mesh-provisioner.plans", + "mesh-provisioner.provisions" ] } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/forge.gitconfig b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/forge.gitconfig new file mode 100644 index 000000000..d61dc5377 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/forge.gitconfig @@ -0,0 +1,5 @@ +[url "ssh://${bound:forge-account:ssh_alias}/"] + insteadOf = ${bound:forge-account:https_base} + insteadOf = ${config:forge}/ +[core] + sshCommand = ssh -F ${dir:state}/forge.ssh diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/forge.known_hosts b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/forge.known_hosts new file mode 100644 index 000000000..e0df6d811 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/forge.known_hosts @@ -0,0 +1 @@ +${bound:forge-account:ssh_alias} ${bound:forge-account:host_key} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/forge.ssh b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/forge.ssh new file mode 100644 index 000000000..8723cbf2e --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/forge.ssh @@ -0,0 +1,10 @@ +Host ${bound:forge-account:ssh_alias} + HostName ${bound:forge-account:ssh_host} + Port ${bound:forge-account:ssh_port} + HostKeyAlias ${bound:forge-account:ssh_alias} + User git + IdentityFile ~/.ssh/mesh_ed25519 + IdentitiesOnly yes + UserKnownHostsFile ${dir:state}/forge.known_hosts + StrictHostKeyChecking yes + BatchMode yes diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/lab.env b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/lab.env index 35aa1a293..6b0a8e771 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/lab.env +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/files/lab.env @@ -1,3 +1,3 @@ MESH_LAB_FORGE=${config:forge} MESH_LAB_FORGE_BINDING=${dir:state}/package-registry.json -MESH_LAB_FORGE_SECRET=${dir:state}/package-registry.secret +MESH_LAB_FORGE_GIT=${dir:state}/forge.gitconfig diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/module.json.captured index ef82b87c4..0d2f574e2 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lab/module.json.captured @@ -1,26 +1,21 @@ { "module": "lab", - "version": "1", + "version": "0.1", + "class": "leaf", + "moved": true, "capabilities": [ "container-runtime", "virtualisation" ], "requires": [ "npm-package-registry", + "forge-account", "go-toolchain", "node-toolchain" ], - "contributes": { - "npm-package-registry": { - "access": "read" - } - }, "binds": { "npm-package-registry": "${dir:state}/package-registry.json" }, - "secrets": { - "npm-package-registry": "${dir:state}/package-registry.secret" - }, "data": { "own": [ { @@ -61,11 +56,37 @@ "mode": "0600", "template": "files/lab.env" }, + { + "id": "forge-git", + "type": "file", + "path": "${dir:state}/forge.gitconfig", + "mode": "0600", + "template": "files/forge.gitconfig" + }, + { + "id": "forge-ssh", + "type": "file", + "path": "${dir:state}/forge.ssh", + "mode": "0600", + "template": "files/forge.ssh" + }, + { + "id": "forge-known-hosts", + "type": "file", + "path": "${dir:state}/forge.known_hosts", + "mode": "0644", + "template": "files/forge.known_hosts" + }, { "id": "git", "type": "package", "package": "git" }, + { + "id": "openssh", + "type": "package", + "package": "openssh" + }, { "id": "make", "type": "package", @@ -108,7 +129,7 @@ "MESH_LAB_WORK": "${dir:work}", "MESH_LAB_ENV_FILE": "${dir:state}/lab.env", "MESH_LAB_FORGE_BINDING": "${dir:state}/package-registry.json", - "MESH_LAB_FORGE_SECRET": "${dir:state}/package-registry.secret" + "MESH_LAB_FORGE_GIT": "${dir:state}/forge.gitconfig" } }, { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lemurs/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lemurs/module.json.captured index 702a9596b..8c143702d 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lemurs/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/lemurs/module.json.captured @@ -1,6 +1,7 @@ { "module": "lemurs", - "version": "1", + "version": "0.1", + "class": "core", "capabilities": [ "package-manager", "service-manager", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/letta/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/letta/module.json.captured index de7baf643..fffb0e5ce 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/letta/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/letta/module.json.captured @@ -1,6 +1,7 @@ { "module": "letta", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "container-runtime" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/local-model-consumer/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/local-model-consumer/module.json.captured index 730020920..cb35bdcad 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/local-model-consumer/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/local-model-consumer/module.json.captured @@ -1,6 +1,7 @@ { "module": "local-model-consumer", - "version": "1", + "version": "0.1", + "class": "leaf", "slug": "local", "requires": [ "model-access" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/localization/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/localization/module.json.captured index 0974ed382..dad52ffbf 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/localization/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/localization/module.json.captured @@ -1,6 +1,7 @@ { "module": "localization", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "service-manager" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/logrotate/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/logrotate/module.json.captured index 8318451b7..4ec39c136 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/logrotate/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/logrotate/module.json.captured @@ -1,6 +1,7 @@ { "module": "logrotate", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager", "service-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mailu/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mailu/module.json.captured index 568be1459..f88907ddd 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mailu/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mailu/module.json.captured @@ -1,6 +1,7 @@ { "module": "mailu", - "version": "1", + "version": "0.1", + "class": "leaf", "upgrade": { "policy": "record", "why": "people's mail: any change to how its containers are declared recreates them together in one send, and the mail is down for everyone until they are up again — a person chooses the moment (hq ADR 0242, issue 295)" @@ -215,12 +216,6 @@ "class": "rebuildable", "why": "certificates, issued again" }, - { - "id": "automx", - "path": "${dir:data-automx}", - "class": "rebuildable", - "why": "client autoconfiguration, written again" - }, { "id": "fetchmail", "path": "${dir:data-fetchmail}", @@ -307,12 +302,6 @@ "mode": "0700", "unknown": "program" }, - { - "id": "data-automx", - "type": "directory", - "mode": "0700", - "unknown": "program" - }, { "id": "config-env", "type": "file", @@ -677,14 +666,35 @@ "path": "${dir:mesh-state}/config.json", "mode": "0600", "template": "files/config.json", - "takes-config": ["domain", "proxy-address", "sitename", "website", "url", "container"], + "takes-config": [ + "domain", + "proxy-address", + "sitename", + "website", + "url", + "container" + ], "merge": "json" }, + { + "id": "program-automx", + "type": "archive", + "path": "${dir:state}/automx", + "artifact": "automx", + "unknown": "program" + }, { "id": "automx", "type": "container", "name": "mailu-automx", - "artifact": "automx", + "artifact": "alpine", + "health": { + "kind": "http", + "endpoint": "autoconfig", + "path": "/", + "status": 200, + "body": "Show Thunderbird-style" + }, "network": "mailu", "env-file": [ "${dir:state}/mailu.env" @@ -693,17 +703,18 @@ "4243" ], "volumes": [ - "${dir:data-automx}:/data" + "${dir:state}/automx:/opt/mesh:ro" + ], + "args": [ + "/opt/mesh/automx" + ], + "restart-on": [ + "program-automx", + "config-env" ] } ], "build": { - "on": [ - { - "arg": "PYTHON_BASE", - "image": "python@sha256:25f3cfeaceca14921366af4d1240b56457ef46273bdb508c7b0e8f469f6fd228" - } - ], "artifacts": [ { "name": "code", @@ -730,8 +741,16 @@ }, { "name": "automx", - "kind": "image", - "from": "automx/Dockerfile" + "kind": "bundle", + "language": "go", + "system": "alpine", + "from": "cmd/automx", + "binary": "automx" + }, + { + "name": "alpine", + "kind": "upstream", + "from": "alpine@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b" }, { "name": "files", @@ -747,6 +766,9 @@ "identity": { "max": 64, "in": "a mailbox's local part" + }, + "credential": { + "form": "pair" } } ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/marrytts/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/marrytts/module.json.captured index ed242aa32..916c106f2 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/marrytts/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/marrytts/module.json.captured @@ -1,6 +1,7 @@ { "module": "marrytts", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "container-runtime" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/matrix/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/matrix/module.json.captured index 170719ccd..38ff40b06 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/matrix/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/matrix/module.json.captured @@ -1,6 +1,7 @@ { "module": "matrix", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "container-runtime" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/memory-pressure/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/memory-pressure/module.json.captured index 1af96e30a..c4fc5ffec 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/memory-pressure/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/memory-pressure/module.json.captured @@ -1,6 +1,7 @@ { "module": "memory-pressure", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager", "service-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-go/files/settings.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-go/files/settings.json new file mode 100644 index 000000000..3b65dd1cb --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-go/files/settings.json @@ -0,0 +1,5 @@ +{ + "capacity": 0, + "cores-per-step": 6, + "build-hours": "" +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-go/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-go/module.json.captured index 9f0fd7fd0..2de4a290b 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-go/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-go/module.json.captured @@ -1,38 +1,197 @@ { "module": "mesh-build-go", - "version": "1", + "version": "0.1", + "class": "core", + "packages": { + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds": "0.1", + "git.novox.be/novox/mesh-catalog/modules/ssh-client/sshkeys": "0.1" + }, "moved": true, "runs-as": "mesh-build-go", "capabilities": [ "package-manager", + "seat-settle-delay", "user-namespaces" ], "state": [ - "toolchains", - "keys", - "steps" + { + "name": "toolchains", + "max-mib": 8 + }, + { + "name": "keys", + "max-mib": 8 + }, + { + "name": "pauses", + "max-mib": 8 + } ], + "claims": [ + { + "name": "node-build-go", + "scope": "node", + "serves": [ + "current", + "drop", + "pause", + "resume", + "steps", + "kept-artifact", + "output", + "answer" + ] + } + ], + "consumes": [ + "mesh-conditions.findings-asked", + "mesh-catalog.seat-definition-changed", + "mesh-catalog.seat-definition-removed" + ], + "invokes": [ + "seat:mesh-hand-acts.hand-act", + "seat:oci-artifact-registry.publish", + "seat:oci-artifact-registry.publish-part", + "seat:go-package-registry.publish", + "seat:go-package-registry.publish-part", + "seat:mesh-catalog.input", + "seat:mesh-wants.input", + "seat:mesh-catalog.module", + "seat:mesh-catalog.seat-definitions", + "seat:mesh-catalog.entry" + ], + "config": { + "capacity": { + "type": "number", + "description": "How many asks of the Go build seat this module runs at once on this node (novox/hq ADR 0525 §5); 0 pulls nothing. It is set per node in the mesh's configuration; a node with no value builds nothing.", + "minimum": 0, + "default": 0 + }, + "build-hours": { + "type": "string", + "description": "When this node may take this module's build asks: one window HH:MM-HH:MM in the node's local time (an end before its start crosses midnight, 18:00-06:00). Outside it the node takes no new step and finishes the ones it runs; an empty value builds at any hour. It is set per node in the mesh's configuration.", + "pattern": "|([01][0-9]|2[0-3]):[0-5][0-9]-([01][0-9]|2[0-3]):[0-5][0-9]", + "default": "" + }, + "cores-per-step": { + "type": "number", + "description": "How many processors one Go step of this module needs (a full check of a large repository takes what it is given: three at about 4 cores each ran past the 30-minute step bound on 2026-10-26). The capacity above is an upper bound: on each node the module runs at most floor(the cores of its build slice's CPU quota / this) steps at once, the quota read live from its cgroup (issue 1806), so a lowered build CPU share never starves its steps. Above 0.", + "minimum": 0.1, + "default": 6 + }, + "again-delays": { + "type": "string", + "description": "The delays a step ask whose fetch or publish met its holder away is given again after: after its first run, then after its second, as durations such as 15s,60s (design 47 H2 §799); a third run met so ends the step failed with why fetch: or publish:.", + "trusted": false, + "runtime": true, + "default": "15s,60s" + }, + "prune-mark": { + "type": "number", + "description": "The fill of mesh-build-go's state detected-steps, in percent of its cap, past which the module prunes it at its own write, oldest first (design 47 H2 §812): below the bus module's raise mark of 75 %.", + "trusted": false, + "runtime": true, + "minimum": 1, + "maximum": 100, + "default": 70 + }, + "prune-target": { + "type": "number", + "description": "The fill, in percent of the cap, a prune of mesh-build-go's state detected-steps takes it down to (design 47 H2 §812); below prune-mark.", + "trusted": false, + "runtime": true, + "minimum": 1, + "maximum": 100, + "default": 50 + } + }, "tools": [ "build_go_fetch", "build_go_test", "build_go_digest", "build_go_build", + "build_go_imports", + "build_go_release", + "build_go_kept", + "build_go_kept_drop", "build_go_step", "build_go_steps", + "build_go_step_end", "build_go_toolchains", "build_go_status", - "build_go_health" - ], - "streams": [ - { - "name": "toolchains-go", - "events": ["toolchain.**"] - } + "build_go_health", + "mesh-build-go_state_keep", + "mesh-build-go_state_prune_now" ], "requires": [ + { + "name": "steps", + "storage": "key-value", + "template": "state", + "options": { + "ttl-seconds": 172800, + "objects-max-mib": 256, + "max-mib": 128 + } + }, + { + "name": "detected-steps", + "storage": "key-value", + "template": "state", + "options": { + "history": 1, + "max-mib": 8 + } + }, + { + "name": "outputs", + "storage": "object-store", + "template": "objects", + "options": { + "max-mib": 1024, + "max-age-days": 7 + } + }, + { + "name": "kept-builds", + "storage": "object-store", + "template": "objects", + "options": { + "max-mib": 1024 + } + }, + "artifact-store", "forge-account", - "go-toolchain" + "go-toolchain", + "go-package-registry", + "node-tools", + { + "name": "findings", + "storage": "key-value", + "template": "state", + "options": { + "max-mib": 8 + } + }, + { + "name": "finding-events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } + } ], + "binds": { + "artifact-store": "${dir:state}/artifact-store.json", + "go-package-registry": "${dir:state}/go-package-registry.json" + }, "own-secrets": { "broker": "${dir:state}/broker" }, @@ -77,6 +236,21 @@ "owner": "mesh-build-go", "unknown": "program" }, + { + "id": "settings", + "trusted": false, + "type": "file", + "path": "${dir:state}/settings.json", + "mode": "0600", + "owner": "mesh-build-go", + "takes-config": [ + "capacity", + "cores-per-step", + "build-hours" + ], + "merge": "json", + "template": "files/settings.json" + }, { "id": "ssh-dir", "type": "directory", @@ -119,6 +293,11 @@ "type": "package", "package": "openssh" }, + { + "id": "bubblewrap", + "type": "package", + "package": "bubblewrap" + }, { "id": "postgresql", "type": "package", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/forge b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/forge new file mode 100644 index 000000000..6bbf4e20e --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/forge @@ -0,0 +1,7 @@ +Host ${bound:forge-account:ssh_alias} + HostName ${bound:forge-account:ssh_host} + Port ${bound:forge-account:ssh_port} + HostKeyAlias ${bound:forge-account:ssh_alias} + User git + IdentityFile ~/.ssh/mesh_ed25519 + IdentitiesOnly yes diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/gitconfig b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/gitconfig new file mode 100644 index 000000000..052523021 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/gitconfig @@ -0,0 +1,2 @@ +[url "ssh://${bound:forge-account:ssh_alias}/"] + insteadOf = ${bound:forge-account:https_base} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/known_hosts b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/known_hosts new file mode 100644 index 000000000..e0df6d811 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/known_hosts @@ -0,0 +1 @@ +${bound:forge-account:ssh_alias} ${bound:forge-account:host_key} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/settings.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/settings.json new file mode 100644 index 000000000..4a445c342 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/files/settings.json @@ -0,0 +1,5 @@ +{ + "capacity": 0, + "cores-per-step": 2, + "build-hours": "" +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/module.json.captured new file mode 100644 index 000000000..4ef6ba7b6 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-image/module.json.captured @@ -0,0 +1,206 @@ +{ + "module": "mesh-build-image", + "version": "0.1", + "class": "core", + "packages": { + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds": "0.1", + "git.novox.be/novox/mesh-catalog/modules/ssh-client/sshkeys": "0.1" + }, + "moved": true, + "runs-as": "mesh-build-image", + "capabilities": [ + "package-manager", + "seat-settle-delay", + "user-namespaces" + ], + "state": [ + {"name": "keys", "max-mib": 8}, + {"name": "pauses", "max-mib": 8}, + {"name": "mirror-waits", "ttl-seconds": 172800, "max-mib": 8} + ], + "claims": [ + { + "name": "node-build-image", + "scope": "node", + "serves": ["current", "drop", "pause", "resume", "steps", "kept-artifact", "output", "answer"] + } + ], + "config": { + "capacity": { + "type": "number", + "description": "How many asks of the image build seat this module runs at once on this node (novox/hq ADR 0525 §5); 0 pulls nothing. It is set per node in the mesh's configuration; a node with no value builds nothing.", + "minimum": 0, + "default": 0 + }, + "build-hours": { + "type": "string", + "description": "When this node may take this module's build asks: one window HH:MM-HH:MM in the node's local time (an end before its start crosses midnight, 18:00-06:00). Outside it the node takes no new step and finishes the ones it runs; an empty value builds at any hour. It is set per node in the mesh's configuration.", + "pattern": "|([01][0-9]|2[0-3]):[0-5][0-9]-([01][0-9]|2[0-3]):[0-5][0-9]", + "default": "" + }, + "cores-per-step": { + "type": "number", + "description": "How many processors one image step of this module needs (buildah, whose RUN lines are mostly fetches). The capacity above is an upper bound: on each node the module runs at most floor(the cores of its build slice's CPU quota / this) steps at once, the quota read live from its cgroup (issue 1806), so a lowered build CPU share never starves its steps. Above 0.", + "minimum": 0.1, + "default": 2 + }, + "again-delays": { + "type": "string", + "description": "The delays a step ask whose fetch or publish met its holder away is given again after: after its first run, then after its second, as durations such as 15s,60s (design 47 H2 §799); a third run met so ends the step failed with why fetch: or publish:.", + "trusted": false, + "runtime": true, + "default": "15s,60s" + } + }, + "tools": [ + "build_image_fetch", + "build_image_build", + "build_image_copy", + "build_image_mirror_waits", + "build_image_release", + "build_image_step", + "build_image_steps", + "build_image_step_end", + "build_image_status", + "build_image_health" + ], + "requires": [ + {"name": "steps", "storage": "key-value", "template": "state", "options": {"ttl-seconds": 172800, "objects-max-mib": 256, "max-mib": 8}}, + {"name": "outputs", "storage": "object-store", "template": "objects", "options": {"max-mib": 1024, "max-age-days": 7}}, + "forge-account", + "rootless-image-build", + "node-tools" + ], + "invokes": [ + "seat:mesh-hand-acts.hand-act", + "seat:container-image-registry.publish", + "seat:container-image-registry.publish-part", + "seat:container-image-registry.mirror", + "seat:mesh-catalog.module", + "seat:mesh-catalog.seat-definitions" + ], + "consumes": [ + "container-image-registry.published", + "container-image-registry.refused", + "mesh-catalog.seat-definition-changed", + "mesh-catalog.seat-definition-removed" + ], + "own-secrets": { + "broker": "${dir:state}/broker" + }, + "secrets-owner": "mesh-build-image", + "runtime-health": { + "kind": "tool", + "tool": "build_image_health", + "interval": "60s", + "timeout": "10s", + "looks": 2, + "grace": "60s" + }, + "resources": [ + { + "id": "account", + "type": "user", + "name": "mesh-build-image", + "shell": "/usr/bin/nologin", + "home": "/var/lib/mesh-build-image" + }, + { + "id": "state", + "type": "directory", + "mode": "0700", + "owner": "mesh-build-image", + "place": ".", + "unknown": "program" + }, + { + "id": "settings", + "trusted": false, + "type": "file", + "path": "${dir:state}/settings.json", + "mode": "0600", + "owner": "mesh-build-image", + "takes-config": ["capacity", "cores-per-step", "build-hours"], + "merge": "json", + "template": "files/settings.json" + }, + { + "id": "work", + "type": "directory", + "path": "/var/lib/mesh-build-image-work", + "mode": "0700", + "owner": "mesh-build-image", + "unknown": "program" + }, + { + "id": "store", + "type": "directory", + "path": "/var/lib/mesh-build-image-store", + "mode": "0700", + "owner": "mesh-build-image", + "unknown": "program" + }, + { + "id": "ssh-dir", + "type": "directory", + "path": "${dir:state}/.ssh", + "mode": "0700", + "owner": "mesh-build-image", + "unknown": "program" + }, + { + "id": "ssh-config", + "type": "file", + "path": "${dir:ssh-dir}/config", + "owner": "mesh-build-image", + "mode": "0600", + "template": "files/forge" + }, + { + "id": "known-hosts", + "type": "file", + "path": "${dir:ssh-dir}/known_hosts", + "owner": "mesh-build-image", + "mode": "0644", + "template": "files/known_hosts" + }, + { + "id": "git-config", + "type": "file", + "path": "${dir:state}/.config/git/config", + "owner": "mesh-build-image", + "mode": "0644", + "template": "files/gitconfig" + }, + { + "id": "git", + "type": "package", + "package": "git" + }, + { + "id": "openssh", + "type": "package", + "package": "openssh" + } + ], + "build": { + "artifacts": [ + { + "name": "tools", + "kind": "bundle", + "language": "go", + "system": "arch", + "from": "cmd/mesh-build-image", + "binary": "mesh-build-image", + "loads": [ + "mesh-build-image" + ] + }, + { + "name": "files", + "kind": "archive", + "from": "files" + } + ] + } +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-node/files/settings.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-node/files/settings.json new file mode 100644 index 000000000..4a445c342 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-node/files/settings.json @@ -0,0 +1,5 @@ +{ + "capacity": 0, + "cores-per-step": 2, + "build-hours": "" +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-node/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-node/module.json.captured index b92212aa7..d3b769eb2 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-node/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-build-node/module.json.captured @@ -1,51 +1,116 @@ { "module": "mesh-build-node", - "version": "1", + "version": "0.1", + "class": "core", + "packages": { + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds": "0.1", + "git.novox.be/novox/mesh-catalog/modules/ssh-client/sshkeys": "0.1" + }, "moved": true, "runs-as": "mesh-build-node", "capabilities": [ "package-manager", + "seat-settle-delay", "user-namespaces" ], "state": [ - "toolchains", - "keys", - "steps" + {"name": "toolchains", "max-mib": 8}, + {"name": "keys", "max-mib": 8}, + {"name": "pauses", "max-mib": 8} ], + "claims": [ + { + "name": "node-build-node", + "scope": "node", + "serves": ["current", "drop", "pause", "resume", "steps", "kept-artifact", "output", "answer"] + } + ], + "consumes": [ + "mesh-catalog.seat-definition-changed", + "mesh-catalog.seat-definition-removed" + ], + "config": { + "capacity": { + "type": "number", + "description": "How many asks of the Node build seat this module runs at once on this node (novox/hq ADR 0525 §5); 0 pulls nothing. It is set per node in the mesh's configuration; a node with no value builds nothing.", + "minimum": 0, + "default": 0 + }, + "build-hours": { + "type": "string", + "description": "When this node may take this module's build asks: one window HH:MM-HH:MM in the node's local time (an end before its start crosses midnight, 18:00-06:00). Outside it the node takes no new step and finishes the ones it runs; an empty value builds at any hour. It is set per node in the mesh's configuration.", + "pattern": "|([01][0-9]|2[0-3]):[0-5][0-9]-([01][0-9]|2[0-3]):[0-5][0-9]", + "default": "" + }, + "cores-per-step": { + "type": "number", + "description": "How many processors one Node step of this module needs (tsc, esbuild and a test runner; a median step takes 15 s). The capacity above is an upper bound: on each node the module runs at most floor(the cores of its build slice's CPU quota / this) steps at once, the quota read live from its cgroup (issue 1806), so a lowered build CPU share never starves its steps. Above 0.", + "minimum": 0.1, + "default": 2 + }, + "again-delays": { + "type": "string", + "description": "The delays a step ask whose fetch or publish met its holder away is given again after: after its first run, then after its second, as durations such as 15s,60s (design 47 H2 §799); a third run met so ends the step failed with why fetch: or publish:.", + "trusted": false, + "runtime": true, + "default": "15s,60s" + }, + "prune-mark": { + "type": "number", + "description": "The fill of mesh-build-node's state detected-steps, in percent of its cap, past which the module prunes it at its own write, oldest first (design 47 H2 §812): below the bus module's raise mark of 75 %.", + "trusted": false, + "runtime": true, + "minimum": 1, + "maximum": 100, + "default": 70 + }, + "prune-target": { + "type": "number", + "description": "The fill, in percent of the cap, a prune of mesh-build-node's state detected-steps takes it down to (design 47 H2 §812); below prune-mark.", + "trusted": false, + "runtime": true, + "minimum": 1, + "maximum": 100, + "default": 50 + } + }, "tools": [ "build_node_fetch", "build_node_test", "build_node_build", + "build_node_release", "build_node_step", "build_node_steps", + "build_node_step_end", "build_node_toolchains", "build_node_status", - "build_node_health" - ], - "streams": [ - { - "name": "toolchains-node", - "events": [ - "toolchain.**" - ] - } + "build_node_health", + "mesh-build-node_state_keep", + "mesh-build-node_state_prune_now" ], "requires": [ + {"name": "steps", "storage": "key-value", "template": "state", "options": {"ttl-seconds": 172800, "objects-max-mib": 256, "max-mib": 16}}, + {"name": "detected-steps", "storage": "key-value", "template": "state", "options": {"history": 1, "max-mib": 8}}, + {"name": "outputs", "storage": "object-store", "template": "objects", "options": {"max-mib": 1024, "max-age-days": 7}}, + "artifact-store", "forge-account", "npm-package-registry", - "node-toolchain" + "node-toolchain", + "node-tools" ], - "contributes": { - "npm-package-registry": { - "access": "read" - } - }, "binds": { + "artifact-store": "${dir:state}/artifact-store.json", "npm-package-registry": "${dir:state}/package-registry.json" }, - "secrets": { - "npm-package-registry": "${dir:state}/package-registry.secret" - }, + "invokes": [ + "seat:mesh-hand-acts.hand-act", + "seat:oci-artifact-registry.publish", + "seat:oci-artifact-registry.publish-part", + "seat:npm-package-registry.publish", + "seat:npm-package-registry.publish-part", + "seat:mesh-catalog.module", + "seat:mesh-catalog.seat-definitions" + ], "own-secrets": { "broker": "${dir:state}/broker" }, @@ -74,6 +139,17 @@ "place": ".", "unknown": "program" }, + { + "id": "settings", + "trusted": false, + "type": "file", + "path": "${dir:state}/settings.json", + "mode": "0600", + "owner": "mesh-build-node", + "takes-config": ["capacity", "cores-per-step", "build-hours"], + "merge": "json", + "template": "files/settings.json" + }, { "id": "work", "type": "directory", @@ -86,7 +162,7 @@ "id": "cache", "type": "directory", "path": "/var/lib/mesh-build-node-cache", - "mode": "0700", + "mode": "0711", "owner": "mesh-build-node", "unknown": "program" }, @@ -139,6 +215,11 @@ "id": "openssh", "type": "package", "package": "openssh" + }, + { + "id": "bubblewrap", + "type": "package", + "package": "bubblewrap" } ], "build": { @@ -152,6 +233,9 @@ "binary": "mesh-build-node", "loads": [ "mesh-build-node" + ], + "check-needs": [ + "node-build-node" ] }, { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-catalog/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-catalog/module.json.captured index 8d8c6599c..421804df1 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-catalog/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-catalog/module.json.captured @@ -1,16 +1,11 @@ { "module": "mesh-catalog", "slug": "catalog", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "container-runtime" ], - "claims": [ - { - "name": "mesh-catalog", - "scope": "mesh" - } - ], "requires": [ "postgres-database" ], @@ -25,11 +20,7 @@ "secrets": { "postgres-database": "${dir:state}/database.secret" }, - "consumes": [ - "node-build-agent.built", - "mesh-build-machine.built", - "mesh-controller.built-before" - ], + "consumes": [], "emits": [ "registered", "upgraded", @@ -94,5 +85,11 @@ "from": "files" } ] - } + }, + "invokes": [ + "mesh-delivery-builder.builder_builds_since" + ], + "reads": [ + "mesh-delivery-builder.builds" + ] } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-cli/files/console b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-cli/files/console new file mode 100644 index 000000000..198dbd469 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-cli/files/console @@ -0,0 +1 @@ +http://127.0.0.1:${bound:mcp-endpoint:port}/mcp diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-cli/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-cli/module.json.captured index 681a3e55e..86325ec23 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-cli/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-cli/module.json.captured @@ -1,7 +1,11 @@ { "module": "mesh-cli", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, + "requires": [ + "mcp-endpoint" + ], "resources": [ { "id": "program", @@ -9,6 +13,20 @@ "artifact": "program", "path": "/usr/local/bin", "unknown": "program" + }, + { + "id": "console-dir", + "type": "directory", + "path": "/etc/mesh-cli", + "mode": "0755", + "unknown": "program" + }, + { + "id": "console", + "type": "file", + "path": "/etc/mesh-cli/console", + "mode": "0644", + "template": "files/console" } ], "items": [ diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-conditions/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-conditions/module.json.captured new file mode 100644 index 000000000..4bfcc3fe1 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-conditions/module.json.captured @@ -0,0 +1,116 @@ +{ + "module": "mesh-conditions", + "version": "0.1", + "class": "core", + "runs-as": "mesh-conditions", + "claims": [ + { + "name": "mesh-conditions", + "scope": "mesh", + "serves": [ + "conditions", + "silence", + "resync" + ] + } + ], + "invokes": [ + "mesh-delivery-assigner.assigner_read_wants", + "mesh-delivery-assigner.assigner_read_assignments", + "seat:mesh-hand-acts.hand-act", + "seat:mesh-wants.revision", + "seat:mesh-catalog.registrations", + "seat:mesh-catalog.revision", + "seat:mesh-broker.list" + ], + "consumes": [ + "mesh-delivery-assigner.views.wants", + "mesh-delivery-assigner.views.assignments", + "*.finding-written", + "*.finding-cleared", + "*.findings-stated", + "mesh-watchdogs.machine-away", + "mesh-watchdogs.machine-back", + "mesh-wants.assignment-revision", + "mesh-catalog.registration-changed", + "mesh-catalog.catalog-revision", + "mesh-broker.created", + "node-engine.running", + "node-engine.composed", + "node-engine.wait-held", + "node-engine.wait-ended", + "mesh-healers.attempt-changed" + ], + "state": [ + "conditions", + { + "name": "history", + "ttl-seconds": 7776000 + }, + "held", + "findings-views", + { + "name": "bounds", + "key-ttl": true + } + ], + "config": { + "ask-bound-seconds": { + "type": "number", + "description": "How long an observer has to state its findings after an ask, in seconds, before the keeper raises findings-unstated for it: 300 is five minutes.", + "minimum": 1, + "default": 300, + "runtime": true + }, + "owner-handover-seconds": { + "type": "number", + "description": "How long a failed head stays its commit's author's, in seconds, before the keeper hands its condition to the operator: 7200 is two hours.", + "minimum": 1, + "default": 7200, + "runtime": true + }, + "view-waits-seconds": { + "type": "number", + "description": "How long a first view may stay unanswered, in seconds, before the keeper raises view-waits for it: 300 is five minutes.", + "minimum": 1, + "default": 300, + "runtime": true + } + }, + "own-secrets": { + "broker": "${dir:state}/broker" + }, + "secrets-owner": "mesh-conditions", + "resources": [ + { + "id": "account", + "type": "user", + "name": "mesh-conditions", + "shell": "/usr/bin/nologin", + "home": "/var/lib/mesh-conditions" + }, + { + "id": "state", + "type": "directory", + "mode": "0700", + "owner": "mesh-conditions", + "place": ".", + "unknown": "program" + } + ], + "build": { + "artifacts": [ + { + "name": "tools", + "kind": "bundle", + "language": "go", + "system": "arch", + "from": "cmd/mesh-conditions", + "binary": "mesh-conditions", + "loads": [ + "mesh-conditions" + ] + } + ] + } +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-config/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-config/module.json.captured index e03e891bf..e6ac9ed63 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-config/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-config/module.json.captured @@ -1,13 +1,15 @@ { "module": "mesh-config", - "version": "1", + "version": "0.1", + "class": "core", "runs-as": "mesh-config", "claims": [ { "name": "mesh-config", "scope": "mesh", "serves": [ - "config" + "config", + "renames" ] } ], @@ -17,20 +19,52 @@ "uses": [ "operator-channel" ], - "invokes": [ - "seat:mesh-controller.hand-act", - "seat:mesh-controller.warranted" + "consumes": [ + "mesh-delivery-view.delivered", + "node-engine.manifest-reads-changed", + "mesh-delivery-indexer.views.predefined", + "mesh-delivery-assigner.views.assignments", + "mesh-delivery-assigner.views.wants", + "mesh-catalog.catalog-revision", + "mesh-catalog.registration-changed", + "mesh-delivery.source-moved", + "mesh-conditions.findings-asked" ], - "reads": [ - "mesh-controller.assignments", - "mesh-controller.declared-config", - "mesh-controller.predefined" + "invokes": [ + "seat:mesh-hand-acts.hand-act", + "seat:mesh-hand-acts.warranted", + "mesh-delivery-view.node_haves", + "seat:node-engine.manifest-reads", + "mesh-delivery-indexer.indexer_config_readers", + "seat:mesh-vault.retire", + "mesh-delivery-indexer.indexer_read_predefined", + "mesh-delivery-assigner.assigner_read_assignments", + "mesh-delivery-assigner.assigner_read_wants", + "seat:mesh-catalog.revision", + "seat:mesh-catalog.registrations", + "seat:mesh-catalog.entry", + "seat:mesh-delivery.source" + ], + "tools": [ + "config_declared", + "config_resync", + "config_renames", + "config_rename_again", + "config_rename_close", + "config_retiring", + "config_first_views", + "config_first_view_again", + "config_entry_again" ], "state": [ "values", "resolved", "predefined", - "proposals" + "proposals", + "declared", + "renames", + "retiring", + "findings" ], "logs": [ "history" @@ -70,5 +104,37 @@ ] } ] + }, + "streams": [ + { + "name": "config-events", + "events": [ + "renamed", + "retiring", + "retired" + ], + "retention": "history" + }, + { + "name": "mesh-config-findings", + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 16 + } + ], + "config": { + "deadline-floor-seconds": { + "type": "number", + "description": "the least wait, in seconds, of mesh-config's one deadline timer: it is set for the earliest real deadline it holds (a waiting proposal's end, an unanswered retirement's second ask, a rename window's seven-day held finding) and never sooner than this after a look, so a deadline passed and not settled is tried again, not spun on (lead answer A-490l, ADR 0681).", + "minimum": 1, + "maximum": 3600, + "trusted": false, + "default": 60, + "runtime": true + } } } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-delivery-gate/files/settings.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-delivery-gate/files/settings.json new file mode 100644 index 000000000..63414735c --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-delivery-gate/files/settings.json @@ -0,0 +1,4 @@ +{ + "record-retention": 90, + "untaken-bound": 10 +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-delivery-gate/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-delivery-gate/module.json.captured index ec8385219..37f784c26 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-delivery-gate/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-delivery-gate/module.json.captured @@ -1,6 +1,7 @@ { "module": "mesh-delivery-gate", - "version": "1", + "version": "0.1", + "class": "core", "slug": "gate", "claims": [ { @@ -8,81 +9,483 @@ "scope": "mesh", "serves": [ "deliveries", - "times", "show", - "groups", - "what-if", - "checks", - "table", - "stalled", - "recheck", - "release", - "stop", - "close", - "retire-history" + "source", + "recovery", + "stalled" ] } ], "consumes": [ - "gitea.pull.updated", - "gitea.pull.merged", - "gitea.pull.closed", - "gitea.forge.status", - "gitea.forge.pull-request.edited", - "gitea.forge.pull-request.closed", - "mesh-controller.checked", - "mesh-controller.plan-moved", - "mesh-delivery-forge-bridge.forge.**" + "mesh-delivery-forge-bridge.owed.ended", + "git.merge-called.*", + "mesh-delivery-forge-bridge.forge.*.*.*.head-moved", + "mesh-delivery-indexer.take-in.taken", + "mesh-pipeline-runner.pipeline-started.*.*", + "mesh-pipeline-runner.pipeline-ended.*.*", + "mesh-pipeline-runner.wait-held.*.*", + "mesh-pipeline-runner.wait-ended.*.*", + "mesh-wants.wanted.*.*", + "mesh-wants.pipeline-wanted.*.*", + "node-engine.running.*.*", + "mesh-catalog.registration-changed", + "mesh-conditions.findings-asked" ], - "emits": [ - "transition", - "group", - "merged" - ], - "invokes": [ - "seat:mesh-controller.deliver", - "seat:mesh-controller.delivery-stop", - "seat:mesh-controller.delivery-backups-again", - "seat:mesh-controller.delivery-walks", - "seat:mesh-controller.delivery-check", - "seat:mesh-controller.forget-checks", - "seat:mesh-controller.plans", - "gitea.gitea_commit_statuses", - "gitea.gitea_contains", - "gitea.gitea_open_pulls" - ], - "state": [ - "deliveries", - "groups", - "pulls", + "requires": [ { - "name": "asks", - "history": 5 + "name": "records", + "storage": "ledger", + "template": "ledger", + "options": { + "max-mib": 1024 + }, + "types": [ + { + "name": "record", + "schema": { + "milestone": { + "type": "string" + }, + "source": { + "type": "integer" + }, + "call": { + "type": "string" + }, + "heads": { + "type": "object" + }, + "opened": { + "type": "string" + }, + "form": { + "type": "integer" + }, + "group": { + "type": "object" + }, + "trace": { + "type": "object" + }, + "key": { + "type": "string" + }, + "module": { + "type": "string" + }, + "fingerprint": { + "type": "string" + }, + "node": { + "type": "string" + }, + "step": { + "type": "string" + }, + "outcome": { + "type": "string" + }, + "why": { + "type": "string" + }, + "at": { + "type": "string" + }, + "event": { + "type": "string" + }, + "since": { + "type": "string" + }, + "branch": { + "type": "string" + }, + "ended": { + "type": "object" + }, + "id": { + "type": "string" + }, + "act": { + "type": "string" + }, + "repository": { + "type": "string" + }, + "number": { + "type": "integer" + }, + "head": { + "type": "string" + }, + "words": { + "type": "string" + }, + "recovery": { + "type": "object" + }, + "owed": { + "type": "object" + }, + "movers": { + "type": "integer" + }, + "merge-called": { + "type": "string" + }, + "delivery-time": { + "type": "string" + }, + "class": { + "type": "string" + }, + "phases": { + "type": "object" + } + }, + "operations": [ + { + "name": "open", + "effect": "set-fields", + "fields": [ + "milestone", + "branch", + "source", + "call", + "heads", + "opened", + "form", + "merge-called" + ], + "sequence": true + }, + { + "name": "group", + "effect": "set-fields", + "fields": [ + "group" + ], + "sequence": true + }, + { + "name": "trace", + "effect": "set-fields", + "fields": [ + "trace", + "recovery" + ], + "sequence": true + }, + { + "name": "movers", + "effect": "set-fields", + "fields": [ + "movers" + ], + "sequence": true + }, + { + "name": "phases", + "effect": "set-fields", + "fields": [ + "phases" + ], + "sequence": true + }, + { + "name": "away", + "effect": "set-entry", + "fields": [ + "node", + "since" + ], + "into": "away", + "key": "node" + }, + { + "name": "back", + "effect": "remove", + "into": "away", + "key": "node" + }, + { + "name": "act", + "effect": "set-entry", + "fields": [ + "id", + "act", + "repository", + "number", + "head", + "outcome", + "words", + "at", + "owed" + ], + "into": "acts", + "key": "id", + "sequence": true + }, + { + "name": "end", + "effect": "set-fields", + "fields": [ + "ended", + "delivery-time", + "class" + ], + "sequence": true + } + ] + }, + { + "name": "mover", + "schema": { + "record": { + "type": "string" + }, + "module": { + "type": "string" + }, + "pipeline": { + "type": "string" + }, + "version": { + "type": "string" + }, + "key": { + "type": "string" + }, + "fingerprint": { + "type": "string" + }, + "node": { + "type": "string" + }, + "step": { + "type": "string" + }, + "outcome": { + "type": "string" + }, + "why": { + "type": "string" + }, + "at": { + "type": "string" + }, + "event": { + "type": "string" + }, + "class": { + "type": "string" + } + }, + "operations": [ + { + "name": "mover", + "effect": "set-fields", + "fields": [ + "record", + "module", + "class", + "pipeline", + "version" + ], + "sequence": true + }, + { + "name": "entry", + "effect": "set-entry", + "fields": [ + "key", + "module", + "fingerprint", + "node" + ], + "into": "entries", + "key": "key", + "sequence": true + }, + { + "name": "outcome", + "effect": "set-entry", + "fields": [ + "key", + "module", + "fingerprint", + "node", + "step", + "outcome", + "why", + "at", + "event" + ], + "into": "outcomes", + "key": "key", + "sequence": true + } + ], + "indexes": [ + { + "name": "movers", + "on": [ + "record" + ] + } + ] + }, + { + "name": "held", + "schema": { + "instance": { + "type": "string" + }, + "opened": { + "type": "string" + } + }, + "operations": [ + { + "name": "hold", + "effect": "set-entry", + "fields": [ + "instance", + "opened" + ], + "into": "records", + "key": "instance" + }, + { + "name": "drop", + "effect": "remove", + "into": "records", + "key": "instance" + } + ] + } + ] }, { - "name": "merges", - "history": 10 + "name": "heads", + "storage": "key-value", + "template": "state", + "options": { + "max-mib": 8 + } }, { - "name": "owed", - "history": 5 + "name": "findings", + "storage": "key-value", + "template": "state", + "options": { + "max-mib": 8 + } }, { - "name": "source", - "history": 64 + "name": "finding-events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } } ], - "reads": [ - "mesh-delivery.deliveries", - "mesh-delivery.groups", - "mesh-delivery.pulls", - "mesh-delivery-teller.answers", - "mesh-controller.assignments", - "node-engine.have" + "packages": { + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-assigner/asks": "0.3", + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg": "0.1" + }, + "invokes": [ + "seat:git.branch", + "seat:mesh-catalog.entry", + "seat:mesh-catalog.registrations", + "seat:mesh-hand-acts.hand-act", + "seat:mesh-wants.entry", + "seat:node-engine.composition" + ], + "state": [ + { + "name": "source", + "history": 64, + "max-mib": 8 + } + ], + "capabilities": [ + "ledger-calls", + "ledger-upkeep-calls" ], "tools": [ - "delivery_status" + "delivery_status", + "gate_consumer", + "gate_head_take", + "gate_heads", + "gate_record", + "gate_record_end", + "gate_record_repair", + "gate_records", + "gate_source", + "gate_source_again", + "gate_source_seed", + "gate_source_start", + "gate_times", + "mesh-delivery-gate_state_keep", + "mesh-delivery-gate_state_prune_now" ], + "config": { + "record-retention": { + "type": "number", + "description": "days a delivery record is kept from when it opened (design 47 *The delivery record*): ninety covers every trace asked of a past delivery so far; when a record is removed at its retention, the gate says freed for each graph revision it pinned. Nothing else is removed to make room.", + "minimum": 1, + "maximum": 3650, + "trusted": false, + "default": 90 + }, + "untaken-bound": { + "type": "number", + "description": "minutes a watched branch's head may stand that no merge call delivered before the gate raises head-untaken (design 47 H §740); the gate keeps one deadline timer for the earliest.", + "minimum": 1, + "trusted": false, + "default": 10 + }, + "budget-core": { + "type": "string", + "description": "The budget of a delivery that moves a core module, from merge-called to the last running of its movers, as a duration such as 10m (ADR 0282; design 47 H2 §810): gate_times names every delivery over it, and the self-check raises over-budget for it.", + "trusted": false, + "runtime": true, + "default": "10m" + }, + "budget-leaf": { + "type": "string", + "description": "The budget of a delivery that moves only leaf modules, as a duration such as 3m (ADR 0304; design 47 H2 §810).", + "trusted": false, + "runtime": true, + "default": "3m" + }, + "prune-mark": { + "type": "number", + "description": "The fill of the gate's state heads, in percent of its cap, past which the gate prunes it at its own write, oldest first (design 47 H2 §812): below the bus module's raise mark of 75 %.", + "trusted": false, + "runtime": true, + "minimum": 1, + "maximum": 100, + "default": 70 + }, + "prune-target": { + "type": "number", + "description": "The fill, in percent of the cap, a prune of the gate's state heads takes it down to (design 47 H2 §812); below prune-mark.", + "trusted": false, + "runtime": true, + "minimum": 1, + "maximum": 100, + "default": 50 + } + }, "resources": [ { "id": "state", @@ -90,6 +493,18 @@ "mode": "0700", "place": ".", "unknown": "program" + }, + { + "id": "settings", + "type": "file", + "path": "${dir:state}/settings.json", + "mode": "0600", + "takes-config": [ + "record-retention", + "untaken-bound" + ], + "merge": "json", + "template": "files/settings.json" } ], "build": { @@ -103,7 +518,15 @@ "binary": "mesh-delivery-gate", "loads": [ "mesh-delivery-gate" - ] + ], + "env": { + "MESH_DELIVERY_GATE_SETTINGS": "${dir:state}/settings.json" + } + }, + { + "name": "files", + "kind": "archive", + "from": "files" } ] } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-files/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-files/module.json.captured index cc1df1622..4b75b5f33 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-files/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-files/module.json.captured @@ -1,6 +1,7 @@ { "module": "mesh-files", - "version": "1", + "version": "0.1", + "class": "core", "claims": [ { "name": "node-files", @@ -20,12 +21,15 @@ "chmod", "chown", "trash", - "restore" + "restore", + "upload", + "download" ] } ], "invokes": [ - "seat:operator-channel.tell" + "seat:operator-channel.tell", + "seat:object-store.link" ], "resources": [ { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-hand-acts/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-hand-acts/module.json.captured new file mode 100644 index 000000000..6131b4e2e --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-hand-acts/module.json.captured @@ -0,0 +1,66 @@ +{ + "module": "mesh-hand-acts", + "version": "0.1", + "class": "core", + "runs-as": "mesh-hand-acts", + "claims": [ + { + "name": "mesh-hand-acts", + "scope": "mesh", + "serves": [ + "hand-act", + "hand-acts", + "warranted" + ] + } + ], + "reads": [ + "messenger.asks" + ], + "logs": [ + { + "name": "acts", + "max-age-days": 400 + } + ], + "state": [ + "warrants", + "copied" + ], + "own-secrets": { + "broker": "${dir:state}/broker" + }, + "secrets-owner": "mesh-hand-acts", + "resources": [ + { + "id": "account", + "type": "user", + "name": "mesh-hand-acts", + "shell": "/usr/bin/nologin", + "home": "/var/lib/mesh-hand-acts" + }, + { + "id": "state", + "type": "directory", + "mode": "0700", + "owner": "mesh-hand-acts", + "place": ".", + "unknown": "program" + } + ], + "build": { + "artifacts": [ + { + "name": "tools", + "kind": "bundle", + "language": "go", + "system": "arch", + "from": "cmd/mesh-hand-acts", + "binary": "mesh-hand-acts", + "loads": [ + "mesh-hand-acts" + ] + } + ] + } +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-healers/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-healers/module.json.captured new file mode 100644 index 000000000..930c16ec9 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-healers/module.json.captured @@ -0,0 +1,101 @@ +{ + "module": "mesh-healers", + "version": "0.1", + "class": "core", + "runs-as": "mesh-healers", + "claims": [ + { + "name": "mesh-healers", + "scope": "mesh", + "serves": [ + "healers", + "heal", + "drill" + ] + } + ], + "consumes": [ + "mesh-conditions.condition-raised", + "mesh-conditions.condition-changed", + "mesh-hand-acts.act-recorded", + "mesh-conditions.findings-asked" + ], + "invokes": [ + "seat:mesh-hand-acts.hand-act", + "seat:mesh-hand-acts.hand-acts" + ], + "reads": [ + "mesh-conditions.conditions" + ], + "state": [ + { + "name": "attempts", + "key-ttl": true + }, + { + "name": "would", + "key-ttl": true + }, + { + "name": "wakes", + "key-ttl": true + } + ], + "own-secrets": { + "broker": "${dir:state}/broker" + }, + "secrets-owner": "mesh-healers", + "resources": [ + { + "id": "account", + "type": "user", + "name": "mesh-healers", + "shell": "/usr/bin/nologin", + "home": "/var/lib/mesh-healers" + }, + { + "id": "state", + "type": "directory", + "mode": "0700", + "owner": "mesh-healers", + "place": ".", + "unknown": "program" + } + ], + "build": { + "artifacts": [ + { + "name": "tools", + "kind": "bundle", + "language": "go", + "system": "arch", + "from": "cmd/mesh-healers", + "binary": "mesh-healers", + "loads": [ + "mesh-healers" + ] + } + ] + }, + "requires": [ + { + "name": "findings", + "storage": "key-value", + "template": "state" + }, + { + "name": "finding-events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } + } + ] +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-issues/files/settings.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-issues/files/settings.json index 66abd38f7..8c2f04378 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-issues/files/settings.json +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-issues/files/settings.json @@ -9,9 +9,9 @@ "mesh-catalog modules/audit-logger", "mesh-catalog modules/avahi", "mesh-catalog modules/baserow", - "mesh-catalog modules/betterbird", "mesh-catalog modules/blueman", "mesh-catalog modules/bluetooth", + "mesh-catalog modules/brother", "mesh-catalog modules/ca-trust", "mesh-catalog modules/claude-code", "mesh-catalog modules/claude-licence-manager", @@ -45,6 +45,7 @@ "mesh-catalog modules/influxdb", "mesh-catalog modules/invoicing", "mesh-catalog modules/jira", + "mesh-catalog modules/kernel", "mesh-catalog modules/keycloak", "mesh-catalog modules/lab", "mesh-catalog modules/lemurs", @@ -56,11 +57,29 @@ "mesh-catalog modules/marrytts", "mesh-catalog modules/matrix", "mesh-catalog modules/memory-pressure", + "mesh-catalog modules/mesh-build-go", + "mesh-catalog modules/mesh-build-image", + "mesh-catalog modules/mesh-build-node", "mesh-catalog modules/mesh-catalog", "mesh-catalog modules/mesh-cli", + "mesh-catalog modules/mesh-conditions", + "mesh-catalog modules/mesh-config", "mesh-catalog modules/mesh-delivery", "mesh-catalog modules/mesh-delivery-gate", + "mesh-catalog modules/mesh-files", + "mesh-catalog modules/mesh-hand-acts", + "mesh-catalog modules/mesh-healers", "mesh-catalog modules/mesh-issues", + "mesh-catalog modules/mesh-knowledge", + "mesh-catalog modules/mesh-mail", + "mesh-catalog modules/mesh-mail-notifier", + "mesh-catalog modules/mesh-mail-reader", + "mesh-catalog modules/mesh-mail-web", + "mesh-catalog modules/mesh-provisioner", + "mesh-catalog modules/mesh-provisioner-client", + "mesh-catalog modules/mesh-reads", + "mesh-catalog modules/mesh-recovery", + "mesh-catalog modules/mesh-self-check", "mesh-catalog modules/mesh-vault", "mesh-catalog modules/mesh-watcher", "mesh-catalog modules/messenger", @@ -126,15 +145,19 @@ "mesh-catalog modules/zsh", "mesh-catalog modules/zsh-autosuggestions", "mesh-catalog modules/zsh-syntax-highlighting", - "mesh-controller", - "mesh-controller modules/build-agent", - "mesh-controller modules/route-proxy", "mesh-delivery", + "mesh-delivery modules/mesh-delivery-builder", + "mesh-delivery modules/mesh-delivery-forge-bridge", + "mesh-delivery modules/mesh-delivery-indexer", + "mesh-delivery modules/mesh-delivery-teller", + "mesh-delivery modules/mesh-delivery-view", + "mesh-delivery modules/mesh-delivery-watchman", "mesh-host", "mesh-lab", "mesh-media-catalog", "mesh-sdk", - "mesh-tools" + "mesh-tools", + "okioki" ], "duplicate-check": "on", "judge-model": "sonnet", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-issues/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-issues/module.json.captured index dcfc71c36..ec6bdc8f8 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-issues/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-issues/module.json.captured @@ -1,6 +1,7 @@ { "module": "mesh-issues", - "version": "1", + "version": "0.1", + "class": "core", "slug": "issues", "seats": [ { @@ -13,12 +14,17 @@ "move", "note", "link", + "milestones", + "milestone-set", + "milestone-move", "import", "groom", "set", "tracking", "reserve", - "fix-times" + "fix-times", + "learn-fixes", + "changes" ] } ], @@ -33,12 +39,17 @@ "move", "note", "link", + "milestones", + "milestone-set", + "milestone-move", "import", "groom", "set", "tracking", "reserve", - "fix-times" + "fix-times", + "learn-fixes", + "changes" ] } ], @@ -52,18 +63,23 @@ "triaged", "ready", "ready-to-verify", - "reserved" + "reserved", + "milestone-set", + "milestone-moved" ], "consumes": [ "mesh-issues.opened", "mesh-issues.moved", - "mesh-delivery-gate.transition" + "mesh-delivery-gate.transition", + "mesh-delivery-view.delivered" ], "invokes": [ "claude-code.claude_code_judge", - "seat:mesh-delivery.checks", "seat:operator-channel.notify", - "gitea.gitea_pull_reviews", + "seat:git.pull", + "seat:git.contains", + "seat:mesh-pipeline-runner.list", + "seat:mesh-pipeline-runner.show", "records.records_status", "records.records_list", "records.records_read", @@ -79,7 +95,11 @@ }, "counters", "grooming", - "reservations" + "reservations", + { + "name": "milestones", + "history": 5 + } ], "config": { "first-number": { @@ -102,9 +122,9 @@ "mesh-catalog modules/audit-logger", "mesh-catalog modules/avahi", "mesh-catalog modules/baserow", - "mesh-catalog modules/betterbird", "mesh-catalog modules/blueman", "mesh-catalog modules/bluetooth", + "mesh-catalog modules/brother", "mesh-catalog modules/ca-trust", "mesh-catalog modules/claude-code", "mesh-catalog modules/claude-licence-manager", @@ -138,6 +158,7 @@ "mesh-catalog modules/influxdb", "mesh-catalog modules/invoicing", "mesh-catalog modules/jira", + "mesh-catalog modules/kernel", "mesh-catalog modules/keycloak", "mesh-catalog modules/lab", "mesh-catalog modules/lemurs", @@ -149,11 +170,29 @@ "mesh-catalog modules/marrytts", "mesh-catalog modules/matrix", "mesh-catalog modules/memory-pressure", + "mesh-catalog modules/mesh-build-go", + "mesh-catalog modules/mesh-build-image", + "mesh-catalog modules/mesh-build-node", "mesh-catalog modules/mesh-catalog", "mesh-catalog modules/mesh-cli", + "mesh-catalog modules/mesh-conditions", + "mesh-catalog modules/mesh-config", "mesh-catalog modules/mesh-delivery", "mesh-catalog modules/mesh-delivery-gate", + "mesh-catalog modules/mesh-files", + "mesh-catalog modules/mesh-hand-acts", + "mesh-catalog modules/mesh-healers", "mesh-catalog modules/mesh-issues", + "mesh-catalog modules/mesh-knowledge", + "mesh-catalog modules/mesh-mail", + "mesh-catalog modules/mesh-mail-notifier", + "mesh-catalog modules/mesh-mail-reader", + "mesh-catalog modules/mesh-mail-web", + "mesh-catalog modules/mesh-provisioner", + "mesh-catalog modules/mesh-provisioner-client", + "mesh-catalog modules/mesh-reads", + "mesh-catalog modules/mesh-recovery", + "mesh-catalog modules/mesh-self-check", "mesh-catalog modules/mesh-vault", "mesh-catalog modules/mesh-watcher", "mesh-catalog modules/messenger", @@ -219,15 +258,19 @@ "mesh-catalog modules/zsh", "mesh-catalog modules/zsh-autosuggestions", "mesh-catalog modules/zsh-syntax-highlighting", - "mesh-controller", - "mesh-controller modules/build-agent", - "mesh-controller modules/route-proxy", "mesh-delivery", + "mesh-delivery modules/mesh-delivery-builder", + "mesh-delivery modules/mesh-delivery-forge-bridge", + "mesh-delivery modules/mesh-delivery-indexer", + "mesh-delivery modules/mesh-delivery-teller", + "mesh-delivery modules/mesh-delivery-view", + "mesh-delivery modules/mesh-delivery-watchman", "mesh-host", "mesh-lab", "mesh-media-catalog", "mesh-sdk", - "mesh-tools" + "mesh-tools", + "okioki" ] }, "duplicate-check": { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-knowledge/files/readers.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-knowledge/files/readers.json new file mode 100644 index 000000000..aea1d275d --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-knowledge/files/readers.json @@ -0,0 +1,3 @@ +{ + "readers": {} +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-knowledge/files/settings.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-knowledge/files/settings.json index 6f682fed6..55571eb24 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-knowledge/files/settings.json +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-knowledge/files/settings.json @@ -1,5 +1,6 @@ { "judge-model": "sonnet", "drafting": "on", - "reserved-for": "168h" + "reserved-for": "168h", + "research-active-at-most": 3 } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-knowledge/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-knowledge/module.json.captured index 92b15f2db..43fbf81f2 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-knowledge/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-knowledge/module.json.captured @@ -1,18 +1,112 @@ { "module": "mesh-knowledge", - "version": "1", + "version": "0.1", + "class": "core", "slug": "knowledge", "requires": [ - "postgres-database" + "postgres-database", + "route", + { + "name": "records", "storage": "ledger", "template": "ledger", "options": {"max-mib": 1024}, + "types": [ + { + "name": "decision", + "schema": { + "kind": {"type": "string"}, + "number": {"type": "integer"}, + "entry": {"type": "object"}, + "version": {"type": "object"}, + "pending-sections": {"type": "object"}, + "title": {"type": "string"}, + "text": {"type": "text"}, + "digest": {"type": "string", "digest-of": "text"}, + "why": {"type": "string"}, + "reason": {"type": "string"} + }, + "operations": [ + {"name": "reserve", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "propose", "effect": "set-fields", "fields": ["kind", "number", "entry", "pending-sections"], "sequence": true, "author": true}, + {"name": "write-section", "effect": "set-entry", "into": "pending-sections", "key": "title", "fields": ["title", "digest"], "sequence": true, "author": true}, + {"name": "submit", "effect": "set-fields", "fields": ["kind", "number", "entry", "pending-sections"], "sequence": true, "author": true}, + {"name": "drop", "effect": "set-fields", "fields": ["kind", "number", "entry", "pending-sections"], "sequence": true, "author": true}, + {"name": "import", "effect": "set-fields", "fields": ["kind", "number", "entry", "pending-sections"], "sequence": true, "author": true}, + {"name": "form", "effect": "set-fields", "fields": ["kind", "number", "entry", "pending-sections"], "sequence": true, "author": true}, + {"name": "take-over", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "review", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "ask", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "warrant", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "accept", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "withdraw", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "retract", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "draft", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true} + ] + }, + { + "name": "research", + "schema": { + "kind": {"type": "string"}, + "number": {"type": "integer"}, + "entry": {"type": "object"}, + "version": {"type": "object"}, + "pending-sections": {"type": "object"}, + "title": {"type": "string"}, + "text": {"type": "text"}, + "digest": {"type": "string", "digest-of": "text"}, + "why": {"type": "string"}, + "reason": {"type": "string"} + }, + "operations": [ + {"name": "reserve", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "propose", "effect": "set-fields", "fields": ["kind", "number", "entry", "pending-sections"], "sequence": true, "author": true}, + {"name": "write-section", "effect": "set-entry", "into": "pending-sections", "key": "title", "fields": ["title", "digest"], "sequence": true, "author": true}, + {"name": "submit", "effect": "set-fields", "fields": ["kind", "number", "entry", "pending-sections"], "sequence": true, "author": true}, + {"name": "drop", "effect": "set-fields", "fields": ["kind", "number", "entry", "pending-sections"], "sequence": true, "author": true}, + {"name": "import", "effect": "set-fields", "fields": ["kind", "number", "entry", "pending-sections"], "sequence": true, "author": true}, + {"name": "form", "effect": "set-fields", "fields": ["kind", "number", "entry", "pending-sections"], "sequence": true, "author": true}, + {"name": "take-over", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "review", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "ask", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "warrant", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "accept", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "withdraw", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "retract", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true}, + {"name": "draft", "effect": "set-fields", "fields": ["kind", "number", "entry"], "sequence": true, "author": true} + ] + } + ] + }, + {"name": "drafts", "storage": "key-value", "template": "state", "options": {"key-ttl": true}}, + {"name": "asked", "storage": "key-value", "template": "state"}, + {"name": "findings", "storage": "key-value", "template": "state"}, + {"name": "sent", "storage": "key-value", "template": "state"}, + {"name": "reviews", "storage": "stream", "configuration": {"when-full": "refuse", "max-mib": 512, "max-age-days": "none", "grant": "readers", "events": ["part-reviewed"]}}, + { + "name": "finding-events", "storage": "stream", "template": "events", + "options": {"events": ["finding-written.*", "finding-cleared.*", "findings-stated.*"], "max-age-days": 7, "max-mib": 8} + } ], "contributes": { "postgres-database": { "name": "knowledge" + }, + "route": { + "label": "knowledge", + "endpoint": "overview" } }, "binds": { - "postgres-database": "${dir:state}/database.json" + "postgres-database": "${dir:state}/database.json", + "route": "${dir:state}/route.json" }, + "listens": [ + { + "name": "overview", + "port": 8480, + "protocol": "tcp", + "from": "machine", + "why": "the overview page, read-only: only a process on this machine reaches it, and the operator through the route proxy (novox/hq ADR 0616 §4)" + } + ], "secrets": { "postgres-database": "${dir:state}/database.secret" }, @@ -30,9 +124,19 @@ "history", "reserve", "propose", + "open", + "write", + "remove", + "order", + "submit", + "drop", + "take-over", "import", "return", - "withdraw" + "withdraw", + "close", + "retract", + "progress" ] } ], @@ -50,15 +154,41 @@ "history", "reserve", "propose", + "open", + "write", + "remove", + "order", + "submit", + "drop", + "take-over", "import", "return", - "withdraw" + "withdraw", + "close", + "retract", + "progress" ] } ], "tools": [ "knowledge_health", - "knowledge_highest" + "knowledge_highest", + "knowledge_marks", + "knowledge_head", + "knowledge_operations", + "knowledge_section", + "knowledge_draft", + "knowledge_parts", + "knowledge_asked", + "knowledge_fill", + "knowledge_rebuild_index", + "knowledge_review_again", + "knowledge_integrity", + "knowledge_form_only", + "knowledge_move", + "knowledge_move_check", + "knowledge_overview", + "knowledge_overview_reread" ], "emits": [ "reserved", @@ -69,7 +199,28 @@ "imported", "drafted", "confirmed", - "returned" + "returned", + "opened", + "written", + "removed", + "ordered", + "submitted", + "dropped", + "taken-over", + "part-reviewed", + "moved", + "checked", + "formed" + ], + "consumes": [ + "claude-code.judged", + "mesh-issues.opened", + "mesh-issues.moved", + "mesh-issues.milestone-set", + "mesh-issues.milestone-moved", + "messenger.offered", + "messenger.closed", + "mesh-conditions.findings-asked" ], "uses": [ "operator-channel" @@ -77,13 +228,26 @@ "invokes": [ "seat:issue-tracker.reserve", "claude-code.claude_code_judge", - "claude-code.claude_code_judged", "records.records_status", "records.records_list", "records.records_read", - "seat:operator-channel.notify" + "seat:operator-channel.notify", + "seat:issue-tracker.list", + "seat:issue-tracker.get", + "seat:issue-tracker.milestones", + "seat:issue-tracker.changes", + "seat:mesh-delivery.deliveries", + "seat:mesh-delivery.show", + "seat:operator-channel.asks", + "seat:mesh-hand-acts.hand-act" ], "config": { + "readers": { + "type": "object", + "trusted": true, + "description": "The modules heard on the reviews of records (the stream of each part's verdict), by name, each with why; empty grants none. Set only at the controller's terminal or on the operator's Approve.", + "default": {} + }, "judge-model": { "type": "string", "description": "The model the knowledge base's drafting and confirming judgements ask, by the agent's name for it, such as sonnet; empty is sonnet.", @@ -99,6 +263,12 @@ "description": "How long a reserved number waits for its proposal before it is withdrawn, as a duration such as 168h; empty is the knowledge base's own default.", "pattern": "|[0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h)([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))*", "default": "168h" + }, + "research-active-at-most": { + "type": "number", + "description": "The most research efforts that may be active at once; propose refuses a further one, which is parked as an idea instead. 0 or empty is 3.", + "minimum": 0, + "default": 3 } }, "resources": [ @@ -122,10 +292,19 @@ "type": "file", "path": "${dir:state}/settings.json", "mode": "0600", - "takes-config": ["judge-model", "drafting", "reserved-for"], + "takes-config": ["judge-model", "drafting", "reserved-for", "research-active-at-most"], "merge": "json", "template": "files/settings.json" }, + { + "id": "readers", + "type": "file", + "path": "${dir:state}/readers.json", + "mode": "0600", + "takes-config": ["readers"], + "merge": "json", + "template": "files/readers.json" + }, { "id": "prepare", "type": "process", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-notifier/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-notifier/module.json.captured index 9afba4661..290b2b2c2 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-notifier/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-notifier/module.json.captured @@ -1,6 +1,7 @@ { "module": "mesh-mail-notifier", - "version": "1", + "version": "0.1", + "class": "core", "runs-as": "mesh-mail-notifier", "claims": [ { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-reader/files/callers.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-reader/files/callers.json deleted file mode 100644 index 84dd80034..000000000 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-reader/files/callers.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "callers": ["mesh-mail-web"] -} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-reader/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-reader/module.json.captured index b83e8bb40..211b6dbe5 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-reader/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-reader/module.json.captured @@ -1,6 +1,7 @@ { "module": "mesh-mail-reader", - "version": "1", + "version": "0.1", + "class": "core", "runs-as": "mesh-mail-reader", "claims": [ { @@ -32,14 +33,6 @@ "secrets": { "postgres-database": "${dir:state}/database.secret" }, - "config": { - "callers": { - "type": "list", - "description": "Who may call one of mail-reading's six verbs (entries, groups, correct, lessons, undo, status): a module's name (on every machine), ., or person. (novox/hq ADR 0459 §2). mesh-mail-web alone by default.", - "trusted": true, - "default": ["mesh-mail-web"] - } - }, "tools": [ "mail-reading.entries", "mail-reading.groups", @@ -77,17 +70,6 @@ "place": ".", "unknown": "program" }, - { - "id": "callers", - "trusted": true, - "type": "file", - "path": "${dir:state}/callers.json", - "mode": "0600", - "owner": "mesh-mail-reader", - "merge": "json", - "template": "files/callers.json", - "takes-config": ["callers"] - }, { "id": "database-url", "type": "file", @@ -127,8 +109,7 @@ "mesh-mail-reader" ], "env": { - "DATABASE_URL_FILE": "${dir:state}/database.url", - "MESH_MAIL_READER_CALLERS": "${dir:state}/callers.json" + "DATABASE_URL_FILE": "${dir:state}/database.url" } }, { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-web/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-web/module.json.captured index c6c0d3de5..f9192aac6 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-web/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail-web/module.json.captured @@ -1,6 +1,7 @@ { "module": "mesh-mail-web", - "version": "1", + "version": "0.1", + "class": "core", "slug": "mail-web", "runs-as": "mesh-mail-web", "claims": [ diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail/module.json.captured index 735fbc54f..42ad7e902 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-mail/module.json.captured @@ -1,6 +1,7 @@ { "module": "mesh-mail", - "version": "1", + "version": "0.1", + "class": "core", "slug": "mail", "seats": [ { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-provisioner-client/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-provisioner-client/module.json.captured index 095128a87..c086a9afc 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-provisioner-client/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-provisioner-client/module.json.captured @@ -1,12 +1,14 @@ { "module": "mesh-provisioner-client", - "version": "1", + "version": "0.1", + "class": "core", "claims": [ { "name": "node-provisioner", "scope": "node" } ], + "core-credentials": true, "own-secrets": { "provisioner-broker": "${dir:state}/broker" }, diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-provisioner/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-provisioner/module.json.captured index 650425b3d..dd980a5c0 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-provisioner/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-provisioner/module.json.captured @@ -1,6 +1,7 @@ { "module": "mesh-provisioner", - "version": "1", + "version": "0.1", + "class": "core", "runs-as": "mesh-provisioner", "claims": [ { @@ -11,16 +12,69 @@ ] } ], + "uses": [ + "operator-channel" + ], + "reads": [ + "node-engine.have", + "mesh-host.composed", + "gitea.bound", + "keycloak.bound", + "postgres.bound", + "route-adapter.bound", + "route-proxy.bound", + "node-tools.bound", + "mesh-vault.bound" + ], + "invokes": [ + "mesh-delivery-assigner.assigner_read_assignments", + "mesh-delivery-assigner.assigner_read_wants", + "seat:mesh-catalog.revision", + "seat:mesh-catalog.registrations", + "seat:mesh-catalog.entry", + "seat:mesh-delivery.source", + "seat:mesh-hand-acts.hand-act" + ], + "consumes": [ + "mesh-delivery-assigner.views.assignments", + "mesh-delivery-assigner.views.wants", + "mesh-catalog.catalog-revision", + "mesh-catalog.registration-changed", + "mesh-delivery.source-moved", + "mesh-conditions.findings-asked" + ], + "tools": [ + "provisioner_provisions", + "provisioner_plans", + "provisioner_compose", + "provisioner_decide", + "provisioner_health", + "provisioner_first_views", + "provisioner_first_view_again", + "provisioner_entry_again" + ], "state": [ "registry", "needs", "applied", - "collect" + "collect", + "provisions", + "plans", + "refused" ], + "core-credentials": true, "own-secrets": { "broker": "${dir:state}/broker" }, "secrets-owner": "mesh-provisioner", + "runtime-health": { + "kind": "tool", + "tool": "provisioner_health", + "interval": "60s", + "timeout": "10s", + "looks": 2, + "grace": "60s" + }, "resources": [ { "id": "account", @@ -52,5 +106,26 @@ ] } ] - } + }, + "requires": [ + { + "name": "finding-events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } + }, + { + "name": "findings", + "storage": "key-value", + "template": "state" + } + ] } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-reads/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-reads/module.json.captured index 18062752f..1067ef63e 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-reads/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-reads/module.json.captured @@ -1,6 +1,7 @@ { "module": "mesh-reads", - "version": "1", + "version": "0.1", + "class": "core", "runs-as": "mesh-reads", "claims": [ { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/dump-wait-minutes b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/dump-wait-minutes new file mode 100644 index 000000000..bcb00821f --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/dump-wait-minutes @@ -0,0 +1 @@ +${config:dump-wait-minutes} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/expire-every-hours b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/expire-every-hours new file mode 100644 index 000000000..68cafde19 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/expire-every-hours @@ -0,0 +1 @@ +${config:expire-every-hours} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/point-keep-days b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/point-keep-days new file mode 100644 index 000000000..02af64917 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/point-keep-days @@ -0,0 +1 @@ +${config:point-keep-days} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/points-cap b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/points-cap new file mode 100644 index 000000000..cbe82190d --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/points-cap @@ -0,0 +1 @@ +${config:points-cap} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/points-filling-mark b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/points-filling-mark new file mode 100644 index 000000000..da03c7e78 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/points-filling-mark @@ -0,0 +1 @@ +${config:points-filling-mark} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/snapshot-restore-wait-minutes b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/snapshot-restore-wait-minutes new file mode 100644 index 000000000..89cd4bdf5 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/files/snapshot-restore-wait-minutes @@ -0,0 +1 @@ +${config:snapshot-restore-wait-minutes} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/module.json.captured new file mode 100644 index 000000000..2719831e7 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-recovery/module.json.captured @@ -0,0 +1,322 @@ +{ + "module": "mesh-recovery", + "version": "0.1", + "class": "core", + "runs-as": "mesh-recovery", + "claims": [ + { + "name": "mesh-recovery", + "scope": "mesh", + "serves": [ + "snapshot-kept", + "restore-kept", + "kept-points", + "restore-aside", + "cancel", + "take", + "restore", + "retry", + "aside", + "discard-aside", + "expire-points" + ] + } + ], + "tools": [ + "recovery_kept_points", + "recovery_take", + "recovery_restore", + "recovery_retry", + "recovery_aside", + "recovery_discard_aside", + "recovery_restore_aside", + "recovery_cancel", + "recovery_expire_points" + ], + "consumes": [ + "node-backup.item-started", + "node-backup.item-ended", + "node-engine.running", + "mesh-broker.snapshot-restored", + "mesh-broker.recreated", + "mesh-broker.dropped", + "mesh-conditions.findings-asked", + "mesh-catalog.seat-definition-changed", + "mesh-catalog.seat-definition-removed" + ], + "invokes": [ + "seat:mesh-catalog.seat-definitions", + "seat:mesh-catalog.entry", + "seat:mesh-module-assigner.assignments", + "seat:mesh-hand-acts.hand-act", + "seat:mesh-broker.show", + "seat:mesh-broker.snapshot-get", + "seat:mesh-broker.snapshot-restore", + "seat:mesh-broker.snapshot-restore-cancel", + "seat:node-backup.restore", + "seat:mesh-recovery.kept-points", + "seat:mesh-recovery.restore-aside", + "seat:mesh-recovery.cancel", + "seat:mesh-recovery.take", + "seat:mesh-recovery.restore", + "seat:mesh-recovery.retry", + "seat:mesh-recovery.aside", + "seat:mesh-recovery.discard-aside", + "seat:mesh-recovery.expire-points" + ], + "requires": [ + { + "name": "digests", + "storage": "key-value", + "template": "state" + }, + { + "name": "findings", + "storage": "key-value", + "template": "state" + }, + { + "name": "bounds", + "storage": "key-value", + "template": "state", + "options": { + "key-ttl": true + } + }, + { + "name": "finding-events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } + } + ], + "config": { + "points-cap": { + "type": "number", + "description": "bytes the points directory may hold; an act that would pass it ends failed, naming it, before it removes anything (design 47 G section 564).", + "minimum": 1, + "trusted": false, + "default": 10737418240 + }, + "points-filling-mark": { + "type": "number", + "description": "percent of the cap past which the finding points-filling is written (design 47 G section 564).", + "minimum": 1, + "maximum": 100, + "trusted": false, + "default": 80 + }, + "point-keep-days": { + "type": "number", + "description": "days after which a restore point is removed, the newest of its kept data never (design 47 G sections 551, 557).", + "minimum": 0.01, + "maximum": 3650, + "trusted": false, + "default": 90 + }, + "dump-wait-minutes": { + "type": "number", + "description": "minutes an act waits on the dump of the bus's item before recovery-waits is written (design 47 G sections 561, 557).", + "minimum": 0.01, + "maximum": 10080, + "trusted": false, + "default": 60 + }, + "snapshot-restore-wait-minutes": { + "type": "number", + "description": "minutes a restore in place of a protected keeper's snapshot is waited on, and once more after its cancel (design 47 G section 681, A-138, A-140).", + "minimum": 0.01, + "maximum": 10080, + "trusted": false, + "default": 90 + }, + "expire-every-hours": { + "type": "number", + "description": "hours between two removals of the points past their keep days, beside the one at the start and at each snapshot-kept; timed by a bound key of the state bounds (design 47 G sections 551, 557, A-138).", + "minimum": 0.01, + "maximum": 8760, + "trusted": false, + "default": 24 + } + }, + "data": { + "own": [ + { + "id": "points", + "path": "${dir:points}", + "class": "valuable", + "why": "the restore points taken of modules' kept data before a form change, and the asides of live data set aside before a restore (design 47 G sections 516, 554)" + } + ] + }, + "own-secrets": { + "broker": "${dir:state}/broker" + }, + "secrets-owner": "mesh-recovery", + "resources": [ + { + "id": "account", + "type": "user", + "name": "mesh-recovery", + "shell": "/usr/bin/nologin", + "home": "/var/lib/mesh-recovery" + }, + { + "id": "state", + "type": "directory", + "mode": "0700", + "owner": "mesh-recovery", + "place": ".", + "unknown": "program" + }, + { + "id": "points", + "type": "directory", + "path": "/var/lib/mesh-recovery/points", + "mode": "0700", + "owner": "mesh-recovery", + "unknown": "program" + }, + { + "id": "cap", + "type": "file", + "path": "${dir:state}/points-cap", + "owner": "mesh-recovery", + "mode": "0600", + "template": "files/points-cap" + }, + { + "id": "mark", + "type": "file", + "path": "${dir:state}/points-filling-mark", + "owner": "mesh-recovery", + "mode": "0600", + "template": "files/points-filling-mark" + }, + { + "id": "keep-days", + "type": "file", + "path": "${dir:state}/point-keep-days", + "owner": "mesh-recovery", + "mode": "0600", + "template": "files/point-keep-days" + }, + { + "id": "dump-wait", + "type": "file", + "path": "${dir:state}/dump-wait-minutes", + "owner": "mesh-recovery", + "mode": "0600", + "template": "files/dump-wait-minutes" + }, + { + "id": "restore-wait", + "type": "file", + "path": "${dir:state}/snapshot-restore-wait-minutes", + "owner": "mesh-recovery", + "mode": "0600", + "template": "files/snapshot-restore-wait-minutes" + }, + { + "id": "expire-every", + "type": "file", + "path": "${dir:state}/expire-every-hours", + "owner": "mesh-recovery", + "mode": "0600", + "template": "files/expire-every-hours" + }, + { + "id": "recovery", + "type": "process", + "name": "mesh-recovery", + "artifact": "program", + "run": [ + "./mesh-recovery" + ], + "env": { + "MESH_BROKER_FILE": "${dir:state}/broker", + "MESH_RECOVERY_POINTS": "${dir:points}", + "MESH_RECOVERY_POINTS_CAP_FILE": "${dir:state}/points-cap", + "MESH_RECOVERY_FILLING_MARK_FILE": "${dir:state}/points-filling-mark", + "MESH_RECOVERY_KEEP_DAYS_FILE": "${dir:state}/point-keep-days", + "MESH_RECOVERY_DUMP_WAIT_FILE": "${dir:state}/dump-wait-minutes", + "MESH_RECOVERY_RESTORE_WAIT_FILE": "${dir:state}/snapshot-restore-wait-minutes", + "MESH_RECOVERY_EXPIRE_EVERY_FILE": "${dir:state}/expire-every-hours" + }, + "user": "mesh-recovery", + "serves": [ + "seat:mesh-recovery.snapshot-kept", + "seat:mesh-recovery.restore-kept", + "seat:mesh-recovery.kept-points", + "seat:mesh-recovery.restore-aside", + "seat:mesh-recovery.cancel", + "seat:mesh-recovery.take", + "seat:mesh-recovery.restore", + "seat:mesh-recovery.retry", + "seat:mesh-recovery.aside", + "seat:mesh-recovery.discard-aside", + "seat:mesh-recovery.expire-points" + ], + "bus": { + "invokes": [ + "seat:mesh-catalog.seat-definitions", + "seat:mesh-catalog.entry", + "seat:mesh-module-assigner.assignments", + "seat:mesh-hand-acts.hand-act", + "seat:mesh-broker.show", + "seat:mesh-broker.snapshot-get", + "seat:mesh-broker.snapshot-restore", + "seat:mesh-broker.snapshot-restore-cancel", + "seat:node-backup.restore" + ] + }, + "health": { + "kind": "unit" + } + } + ], + "runtime-health": { + "kind": "tool", + "tool": "recovery_kept_points", + "interval": "60s", + "timeout": "10s", + "looks": 2, + "grace": "180s" + }, + "build": { + "artifacts": [ + { + "name": "program", + "kind": "bundle", + "language": "go", + "system": "arch", + "from": "cmd/mesh-recovery", + "binary": "mesh-recovery" + }, + { + "name": "tools", + "kind": "bundle", + "language": "go", + "system": "arch", + "from": "cmd/mesh-recovery-tools", + "binary": "mesh-recovery-tools", + "loads": [ + "mesh-recovery-tools" + ] + }, + { + "name": "files", + "kind": "archive", + "from": "files" + } + ] + } +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-self-check/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-self-check/module.json.captured new file mode 100644 index 000000000..ec9dfb550 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-self-check/module.json.captured @@ -0,0 +1,123 @@ +{ + "module": "mesh-self-check", + "version": "0.1", + "class": "core", + "packages": { + "git.novox.be/novox/mesh-catalog/modules/restic/backupgood": "0.1", + "git.novox.be/novox/mesh-catalog/modules/disk-load/diskreadings": "0.1" + }, + "runs-as": "mesh-self-check", + "claims": [ + { + "name": "mesh-self-check", + "scope": "mesh", + "serves": [ + "doctor", + "probes" + ] + } + ], + "invokes": [ + "nats.nats_streams", + "nats.nats_closed_connections", + "seat:mesh-watchdogs.signals", + "seat:node-intrusion-prevention.banned", + "mesh-delivery-assigner.assigner_read_assignments", + "mesh-delivery-assigner.assigner_read_seat_holders", + "seat:mesh-catalog.revision", + "seat:mesh-catalog.registrations", + "seat:mesh-delivery.source", + "seat:mesh-hand-acts.hand-act", + "mesh-delivery-gate.gate_times" + ], + "reads": [ + "mesh-delivery-watchman.presence", + "mesh-host.health", + "disk-load.readings", + "restic.good" + ], + "consumes": [ + "mesh-delivery-assigner.views.assignments", + "mesh-delivery-assigner.views.seat-holders", + "mesh-catalog.catalog-revision", + "mesh-catalog.registration-changed", + "mesh-delivery.source-moved", + "mesh-conditions.findings-asked" + ], + "state": [ + "verdict", + { + "name": "verdicts", + "ttl-seconds": 604800 + } + ], + "own-secrets": { + "broker": "${dir:state}/broker" + }, + "secrets-owner": "mesh-self-check", + "resources": [ + { + "id": "account", + "type": "user", + "name": "mesh-self-check", + "shell": "/usr/bin/nologin", + "home": "/var/lib/mesh-self-check" + }, + { + "id": "state", + "type": "directory", + "mode": "0700", + "owner": "mesh-self-check", + "place": ".", + "unknown": "program" + } + ], + "build": { + "artifacts": [ + { + "name": "tools", + "kind": "bundle", + "language": "go", + "system": "arch", + "from": "cmd/mesh-self-check", + "binary": "mesh-self-check", + "loads": [ + "mesh-self-check" + ] + } + ] + }, + "config": { + "probes": { + "type": "list", + "description": "The ids of the probes that run, each judging one thing of the mesh (mesh-self-check.probes lists them with what each asserts). A probe not listed runs nothing and raises nothing, and what it raised before is cleared. D8 and DA are in the code and off by default.", + "trusted": true, + "default": [ + "D13", + "D-fill" + ], + "runtime": true + } + }, + "requires": [ + { + "name": "findings", + "storage": "key-value", + "template": "state" + }, + { + "name": "finding-events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } + } + ] +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-vault/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-vault/module.json.captured index 44944c952..1e9300a8e 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-vault/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-vault/module.json.captured @@ -1,10 +1,17 @@ { "module": "mesh-vault", - "version": "1", + "version": "0.1", + "class": "core", + "packages": { + "git.novox.be/novox/mesh-delivery/modules/mesh-grants/grantsstate": "0.1" + }, "runs-as": "mesh-vault", "provides": [ { "name": "secret", + "credential": { + "form": "pair" + }, "scope": "mesh", "identity": { "in": "a vault entry" @@ -14,10 +21,37 @@ "emits": [ "provisioned", "rotated", - "secret-changed" + "secret-changed", + "account-hashed", + "own-replaced", + "account-issued", + "signed", + "rotation-begun", + "node-account-ready", + "rotation-done", + "own-retired" + ], + "invokes": [ + "seat:mesh-hand-acts.hand-acts", + "mesh-delivery-assigner.assigner_read_assignments", + "seat:anthropic-licence-manager.bindings" ], "reads": [ - "mesh-controller.assignments" + "node-engine.have", + "mesh-grants.accounts", + "mesh-provisioner.plans", + "mesh-provisioner.provisions" + ], + "state": [ + { + "name": "bus-accounts", + "history": 2 + }, + "signers", + "bound", + "node-logins", + "findings", + "licence-bindings" ], "receives": { "secret": "${dir:grants}/mesh.json" @@ -118,6 +152,18 @@ "unknown": "program" } ], + "streams": [ + { + "name": "mesh-vault-findings", + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 16 + } + ], "build": { "artifacts": [ { @@ -135,7 +181,8 @@ "MESH_VAULT_LEDGER": "${dir:ledger}", "MESH_VAULT_ROOT": "${dir:root}", "MESH_VAULT_STORE": "${dir:store}", - "MESH_VAULT_STATE": "${dir:state}" + "MESH_VAULT_STATE": "${dir:state}", + "MESH_VAULT_ENROLMENT_CALLERS": "mesh-enrolment" } } ] @@ -145,6 +192,11 @@ "secret_holders", "secret_verify", "secret_handed", + "own_handed", + "secret_own", + "account_hash", + "account_adopt", + "account_retire", "secret_asks", "secret_vault_export", "provisioner_retirement", @@ -152,7 +204,15 @@ "provisioner_retire_reject", "provisioner_delete", "vault_status", - "vault_health" + "vault_health", + "own_drift", + "own_take_switch", + "vault_signers", + "vault_signed", + "signers_reassert", + "node_logins", + "vault_first_views", + "vault_first_view_again" ], "claims": [ { @@ -160,14 +220,28 @@ "scope": "mesh", "serves": [ "get", - "accept", "secret-ask", "issued", "rotate", "move-in", "node-key", - "move-asks" + "own", + "issue-account", + "sign", + "enrolment-token", + "node-account", + "rotate-node", + "node-account-confirm", + "abandon", + "retire", + "licence-put", + "own-put" ] } + ], + "consumes": [ + "mesh-delivery-assigner.views.assignments", + "mesh-conditions.findings-asked", + "claude-licence-manager.binding.changed.*" ] } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-watcher/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-watcher/module.json.captured index e9543a5d3..23877ef24 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-watcher/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mesh-watcher/module.json.captured @@ -1,13 +1,17 @@ { "module": "mesh-watcher", - "version": "1", + "version": "0.1", + "class": "leaf", "slug": "watch", "consumes": [ - "mesh-controller.doctor-heartbeat" + "mesh-self-check.checked", + "mesh-delivery-assigner.views.seat-holders", + "mesh-conditions.findings-asked" ], "invokes": [ + "mesh-delivery-assigner.assigner_read_seat_holders", "mesh-watcher.watcher_ping", - "seat:mesh-controller.seats" + "seat:mesh-hand-acts.hand-act" ], "own-secrets": { "telegram-token": "${dir:state}/telegram-token" @@ -16,7 +20,9 @@ "watcher_status", "watcher_last_heard", "watcher_test", - "watcher_ping" + "watcher_ping", + "watcher_first_views", + "watcher_first_view_again" ], "config": { "telegram-chat-id": { @@ -39,7 +45,9 @@ "type": "file", "path": "${dir:state}/settings.json", "mode": "0600", - "takes-config": ["telegram-chat-id"], + "takes-config": [ + "telegram-chat-id" + ], "merge": "json", "template": "files/settings.json" } @@ -67,5 +75,26 @@ "from": "files" } ] - } + }, + "requires": [ + { + "name": "findings", + "storage": "key-value", + "template": "state" + }, + { + "name": "finding-events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } + } + ] } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/messenger/files/settings.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/messenger/files/settings.json index 6d22854ac..7eaa42a2d 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/messenger/files/settings.json +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/messenger/files/settings.json @@ -1,5 +1,8 @@ { "time-zone": "", "only-what-needs-me": [], - "messages-per-hour": 100 + "messages-per-hour": 100, + "settle-seconds": 120, + "refused-kept": 20, + "readers": {"offered": ["mesh-knowledge"], "closed": ["mesh-knowledge"]} } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/messenger/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/messenger/module.json.captured index 604519581..4f89a31b8 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/messenger/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/messenger/module.json.captured @@ -1,6 +1,7 @@ { "module": "messenger", - "version": "1", + "version": "0.1", + "class": "core", "slug": "msgr", "runs-as": "messenger", "seats": [ @@ -74,10 +75,12 @@ "channel" ], "consumes": [ - "mesh-controller.condition-raised", - "mesh-controller.condition-changed", - "mesh-controller.condition-cleared", - "mesh-controller.plan-moved", + "mesh-conditions.condition-raised", + "mesh-conditions.condition-changed", + "mesh-conditions.condition-cleared", + "mesh-delivery-view.moving", + "mesh-delivery-view.settled", + "mesh-delivery-view.stuck", "intake.choice", "intake.link", "intake.failed", @@ -86,9 +89,22 @@ "emits": [ "refused" ], + "requires": [ + { + "name": "ask-events", + "storage": "stream", + "template": "events", + "options": { + "events": ["offered", "closed"], + "max-age-days": 7, + "max-mib": 64, + "grant": "readers" + } + } + ], "invokes": [ - "seat:mesh-controller.conditions", - "seat:mesh-controller.root-free", + "seat:mesh-conditions.conditions", + "seat:node-engine.root-free", "seat:issue-tracker.tracking" ], "state": [ @@ -115,6 +131,12 @@ "messenger_unlink" ], "config": { + "readers": { + "type": "object", + "description": "Who may hear an ask offered or closed (the stream of the asks, kept seven days), per event: offered and closed, each a list of module names, on every machine. The knowledge base alone by default, for its overview page; an asker's own answers (decided) are never on it (ADR 0616 §7).", + "trusted": true, + "default": {"offered": ["mesh-knowledge"], "closed": ["mesh-knowledge"]} + }, "time-zone": { "type": "string", "description": "The time zone every time a message says is said in, an IANA name such as Europe/Brussels; empty is this machine's own zone.", @@ -140,6 +162,22 @@ "maximum": 1000, "trusted": false, "default": 100 + }, + "refused-kept": { + "type": "number", + "description": "how many refused asks of one asker the router keeps as closed records, a whole number from 1 to 1000: the twenty-first refusal of an asker removes its oldest (design 47 G section 570).", + "minimum": 1, + "maximum": 1000, + "trusted": false, + "default": 20 + }, + "settle-seconds": { + "type": "number", + "description": "seconds a delivery that ended well still holds the messages about what it changed, so a problem that passes as the delivery settles is not sent (ADR 0505 §3); 0 holds nothing after the end.", + "minimum": 0, + "maximum": 3600, + "trusted": false, + "default": 120 } }, "resources": [ @@ -163,7 +201,7 @@ "type": "file", "path": "${dir:state}/settings.json", "mode": "0600", - "takes-config": ["time-zone", "desktop-machines", "only-what-needs-me", "messages-per-hour"], + "takes-config": ["time-zone", "desktop-machines", "only-what-needs-me", "messages-per-hour", "settle-seconds", "refused-kept", "readers"], "merge": "json", "template": "files/settings.json", "owner": "messenger" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/minio/files/object-store.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/minio/files/object-store.json new file mode 100644 index 000000000..d2970bcc8 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/minio/files/object-store.json @@ -0,0 +1,6 @@ +{ + "scheme": "http", + "at": "${machine:at}", + "port": "${port:9000}", + "region": "eu-west" +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/minio/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/minio/module.json.captured index 85b825308..956a69fb6 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/minio/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/minio/module.json.captured @@ -1,6 +1,7 @@ { "module": "minio", - "version": "1", + "version": "0.1", + "class": "core", "upgrade": { "policy": "record", "why": "holds the photos themselves (irreplaceable, kept by photos) for its consumers: a person takes each build, after a backup (hq ADR 0236)" @@ -12,11 +13,59 @@ "identity": { "max": 20, "in": "an S3 access key" + }, + "credential": { + "form": "pair" } } ], "requires": [ - "route" + "route", + { + "name": "findings", + "storage": "key-value", + "template": "state" + }, + { + "name": "finding-events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } + } + ], + "seats": [ + { + "name": "object-store", + "scope": "mesh", + "serves": [ + "link" + ] + } + ], + "claims": [ + { + "name": "object-store", + "scope": "mesh", + "serves": [ + "link" + ] + } + ], + "invokes": [ + "mesh-delivery-assigner.assigner_read_seat_holders", + "seat:mesh-hand-acts.hand-act" + ], + "consumes": [ + "mesh-delivery-assigner.views.seat-holders", + "mesh-conditions.findings-asked" ], "contributes": { "route": { @@ -108,6 +157,13 @@ "mode": "0600", "template": "files/root.env" }, + { + "id": "object-store", + "type": "file", + "path": "${dir:state}/object-store.json", + "mode": "0600", + "template": "files/object-store.json" + }, { "id": "data", "type": "directory", @@ -173,11 +229,28 @@ "MESH_MINIO_ROOT_USER": "meshroot", "MESH_MINIO_ROOT_PASSWORD_FILE": "${dir:state}/root.secret", "MESH_MINIO_REGION": "eu-west", + "MESH_MINIO_LINKS": "${dir:state}/links", "MESH_MINIO_MC_BIN": "mcli", "MESH_MINIO_MC_CONFIG": "${dir:state}/mc", "MESH_RECEIVES": "${dir:grants}/mesh.json" } }, + { + "name": "tools-go", + "kind": "bundle", + "language": "go", + "system": "arch", + "from": "cmd/object-store", + "binary": "object-store", + "loads": [ + "object-store" + ], + "env": { + "OBJECT_STORE_CONFIG": "${dir:state}/object-store.json", + "MESH_MINIO_LINKS": "${dir:state}/links", + "MESH_RECEIVES": "${dir:grants}/mesh.json" + } + }, { "name": "files", "kind": "archive", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/model-usage/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/model-usage/module.json.captured index 50743a3cd..86ef6f202 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/model-usage/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/model-usage/module.json.captured @@ -1,6 +1,7 @@ { "module": "model-usage", - "version": "1", + "version": "0.1", + "class": "leaf", "slug": "usage", "capabilities": [ "container-runtime" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mongodb/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mongodb/module.json.captured index cbb12681d..27ab92027 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mongodb/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mongodb/module.json.captured @@ -1,6 +1,7 @@ { "module": "mongodb", - "version": "1", + "version": "0.1", + "class": "leaf", "upgrade": { "policy": "record", "why": "a provider whose restart drops every consumer on its machine, and which holds the photos' albums (irreplaceable, kept by photos): a person takes each build, after a backup (hq ADR 0236)" @@ -12,6 +13,9 @@ "identity": { "max": 63, "in": "a MongoDB database name" + }, + "credential": { + "form": "pair" } } ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mosquitto/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mosquitto/module.json.captured index 21058e0ac..a8bb15153 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mosquitto/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mosquitto/module.json.captured @@ -1,6 +1,7 @@ { "module": "mosquitto", - "version": "1", + "version": "0.1", + "class": "leaf", "slug": "mosq", "provides": [ { @@ -8,6 +9,9 @@ "scope": "mesh", "identity": { "in": "a Mosquitto client and topic prefix" + }, + "credential": { + "form": "pair" } } ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mounts/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mounts/module.json.captured index 488ebb976..2da577468 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mounts/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mounts/module.json.captured @@ -1,15 +1,17 @@ { "module": "mounts", - "version": "1", + "version": "0.1", + "class": "core", + "packages": { + "git.novox.be/novox/mesh-catalog/modules/disk-load/diskreadings": "0.1" + }, "requires": [ "nfs-share" ], "reads": [ + "disk-load.readings", "nfs-server.exports" ], - "invokes": [ - "seat:mesh-controller.data" - ], "capabilities": [ "package-manager", "service-manager" @@ -38,20 +40,20 @@ "per-machine": true } ], - "config": { - "shares": { - "type": "string", - "description": "The shares of another machine this machine mounts: space-separated name=mountpoint, each optionally :ro, or none (novox/hq ADR 0263 rule 5).", - "trusted": true, - "default": "none" - }, - "sources": { - "type": "string", - "description": "The occasional sources this machine mounts: space-separated name=smb://[@]/@ or name=disk:@, each optionally :ro, or none (novox/hq ADR 0263 rule 6); an SMB source's username is in its entry, its password the secret smb-password- (novox/hq ADR 0283).", - "trusted": true, - "default": "none" - } + "config": { + "shares": { + "type": "string", + "description": "The shares of another machine this machine mounts: space-separated name=mountpoint, each optionally :ro, or none (novox/hq ADR 0263 rule 5).", + "trusted": true, + "default": "none" }, + "sources": { + "type": "string", + "description": "The occasional sources this machine mounts: space-separated name=smb://[@]/@ or name=disk:@, each optionally :ro, or none (novox/hq ADR 0263 rule 6); an SMB source's username is in its entry, its password the secret smb-password- (novox/hq ADR 0283).", + "trusted": true, + "default": "none" + } + }, "own-secrets": { "smb-password-*": { "path": "${dir:state}/smb-password-*.secret", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mssql/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mssql/module.json.captured index ed4e44887..52f62daa9 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mssql/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/mssql/module.json.captured @@ -1,6 +1,7 @@ { "module": "mssql", - "version": "1", + "version": "0.1", + "class": "leaf", "upgrade": { "policy": "record", "why": "a provider whose restart drops every consumer on its machine, and whose new version may upgrade its databases in place: a person takes each build, after a backup (hq ADR 0236)" @@ -12,6 +13,9 @@ "identity": { "max": 128, "in": "a SQL Server login and database name" + }, + "credential": { + "form": "pair" } } ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/n8n/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/n8n/module.json.captured index 975247faa..d67bc7a60 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/n8n/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/n8n/module.json.captured @@ -1,6 +1,7 @@ { "module": "n8n", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "container-runtime" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nats/files/settings.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nats/files/settings.json new file mode 100644 index 000000000..f973289e0 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nats/files/settings.json @@ -0,0 +1,4 @@ +{ + "snapshots-cap": 21474836480, + "snapshot-keep-days": 90 +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nats/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nats/module.json.captured index 3ad66bc38..bcc65be90 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nats/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nats/module.json.captured @@ -1,38 +1,160 @@ { "module": "nats", - "version": "1", + "version": "0.1", + "class": "core", + "packages": { + "git.novox.be/novox/mesh-delivery/modules/mesh-grants/busgrants": "0.1" + }, "upgrade": { "policy": "record", - "why": "the bus: replaced only as a planned step a person starts (`bus upgrade`), its streams snapshotted first and checked after (hq ADR 0236); the controller holds this whatever is said here" + "why": "the bus keeps the streams of the whole mesh: each move waits for a person's yes, which the operator's Approve of the release that carries its build gives, and its node backs its streams up before it applies (hq ADR 0236, ADR 0601)" }, "provides": [ { "name": "mesh-bus", - "scope": "mesh" + "scope": "mesh", + "credential": { + "form": "none" + } + }, + { + "name": "bus-state", + "scope": "mesh", + "credential": { + "form": "none" + } } ], "claims": [ { "name": "mesh-broker", - "scope": "mesh" + "scope": "mesh", + "serves": [ + "list", + "show", + "check", + "orphans", + "snapshot-get", + "snapshot-restore", + "snapshot-restore-cancel", + "snapshot-remove" + ] } ], "bus-users": "/var/lib/nats-module/conf/accounts.conf", + "core-credentials": true, "own-secrets": { - "broker": "${dir:mesh-state}/broker" + "broker": "${dir:mesh-state}/broker", + "broker-nats-tools": "${dir:tools-secret}/broker-nats-tools", + "broker-keeper": { + "path": "${dir:keeper-state}/broker-keeper", + "owner": "nats-keeper" + } }, "capabilities": [ "container-runtime" ], - "emits": [], - "consumes": [], + "emits": [ + "consumer-removed", + "bucket-keys-removed", + "stream-removed", + "stream-purged", + "bucket-expiry-set", + "snapshot-restored" + ], + "invokes": [ + "seat:mesh-hand-acts.hand-act", + "seat:mesh-catalog.revision", + "seat:mesh-catalog.registrations", + "seat:mesh-delivery.source", + "seat:mesh-catalog.seat-definitions" + ], + "consumes": [ + "mesh-catalog.catalog-revision", + "mesh-catalog.registration-changed", + "mesh-delivery.source-moved", + "mesh-catalog.seat-definition-changed", + "mesh-catalog.seat-definition-removed", + "mesh-conditions.findings-asked" + ], + "uses": [ + "operator-channel" + ], + "config": { + "snapshots-cap": { + "type": "number", + "description": "How many bytes the keeper's snapshots directory may hold (design 47 G §681): past 80 % of it the keeper tells a finding, and it never takes a snapshot past it. The keeper reads it at its start from its settings file.", + "minimum": 1, + "default": 21474836480 + }, + "snapshot-keep-days": { + "type": "number", + "description": "How many days a snapshot the keeper took before a drop or recreate, and its record, are kept (design 47 G §681, A-112). The keeper reads it at its start from its settings file; the tool nats_snapshots reads it as its configuration.", + "minimum": 1, + "default": 90 + } + }, + "streams": [ + { + "name": "broker-events", + "events": [ + "created", + "refused", + "drifted", + "drift-cleared", + "full", + "full-cleared", + "orphaned", + "recreated", + "dropped" + ], + "retention": "history", + "max-mib": 256 + }, + { + "name": "nats-findings", + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 16 + } + ], + "state": [ + { + "name": "asked", + "history": 5 + }, + { + "name": "requests", + "history": 5, + "ttl-seconds": 7862400 + }, + { + "name": "spent", + "history": 1, + "ttl-seconds": 86400, + "read-only": true + }, + { + "name": "plans", + "history": 1, + "read-only": true + }, + { + "name": "findings", + "history": 1 + } + ], "listens": [ { "name": "bus", "port": 4222, "protocol": "tcp", "from": "mesh", - "why": "the mesh bus — every link the mesh has, over TLS, reached across the overlay" + "why": "the mesh bus \u2014 every link the mesh has, over TLS, reached across the overlay" } ], "tools": [ @@ -42,9 +164,28 @@ "nats_subscriptions", "nats_streams", "nats_backlog", + "nats_consumer", + "nats_consumers", + "nats_stream_messages", "nats_buckets", "nats_users", - "nats_user_can" + "nats_user_can", + "nats_snapshot_verify", + "nats_consumer_remove", + "nats_bucket_remove", + "nats_stream_remove", + "nats_stream_purge", + "nats_bucket_expiry", + "nats_history", + "nats_create", + "nats_apply", + "nats_recreate", + "nats_drop", + "nats_keeper_health", + "nats_first_view_again", + "nats_requests", + "nats_snapshots", + "nats_plans" ], "guards": [ 8222 @@ -57,7 +198,7 @@ "class": "valuable", "active": "1d", "backup": { - "dump": "docker exec -i mesh-broker-nats mesh-nats-snapshot snapshot < ${dir:mesh-state}/broker > ${dir:snapshots}/bus.tar.partial && mv ${dir:snapshots}/bus.tar.partial ${dir:snapshots}/bus.tar || { rm -f ${dir:snapshots}/bus.tar.partial; exit 1; }", + "dump": "p=${dir:snapshots}/bus.tar.partial; s=0; docker exec -i mesh-broker-nats /opt/mesh/mesh-nats-snapshot snapshot < ${dir:mesh-state}/broker > \"$p\" || s=$?; if [ $s -ne 0 ]; then echo \"mesh-nats-snapshot snapshot exited $s$([ $s -eq 137 -o $s -eq 143 ] && echo ' (killed by a signal)')\" >&2; docker inspect -f 'container {{.State.Status}} since {{.State.StartedAt}}' mesh-broker-nats >&2; rm -f \"$p\"; exit $s; fi; mv \"$p\" ${dir:snapshots}/bus.tar || exit 1", "into": "snapshots" }, "why": "the bus's streams and key-value buckets: the hand-act log, conditions, every module's state; written all the time, so copied by the server's own snapshot of each stream (novox/hq ADR 0235), never as live files" @@ -71,6 +212,13 @@ ] }, "resources": [ + { + "id": "keeper-account", + "type": "user", + "name": "nats-keeper", + "shell": "/usr/bin/nologin", + "home": "/var/lib/nats-keeper" + }, { "id": "jetstream-data", "type": "directory", @@ -85,6 +233,21 @@ "mode": "0700", "unknown": "program" }, + { + "id": "tools-secret", + "type": "directory", + "path": "/var/lib/mesh/nats-tools", + "mode": "0711", + "unknown": "program" + }, + { + "id": "keeper-state", + "type": "directory", + "path": "/var/lib/nats-keeper", + "mode": "0700", + "owner": "nats-keeper", + "unknown": "program" + }, { "id": "snapshots", "type": "directory", @@ -98,6 +261,20 @@ "place": "mesh", "unknown": "program" }, + { + "id": "keeper-settings", + "trusted": false, + "type": "file", + "path": "${dir:keeper-state}/settings.json", + "mode": "0600", + "owner": "nats-keeper", + "takes-config": [ + "snapshots-cap", + "snapshot-keep-days" + ], + "merge": "json", + "template": "files/settings.json" + }, { "id": "server-conf", "type": "file", @@ -105,6 +282,76 @@ "template": "files/nats.conf", "mode": "0644" }, + { + "id": "state", + "type": "directory", + "mode": "0700", + "place": ".", + "unknown": "program" + }, + { + "id": "program-snapshot", + "type": "archive", + "path": "${dir:state}/snapshot", + "artifact": "snapshot", + "unknown": "program" + }, + { + "id": "program-entrypoint", + "type": "archive", + "path": "${dir:state}/entrypoint", + "artifact": "entrypoint", + "unknown": "program" + }, + { + "id": "keeper", + "type": "process", + "name": "nats-keeper", + "artifact": "tools", + "run": [ + "./nats-tools", + "keep" + ], + "user": "nats-keeper", + "env": { + "MESH_BROKER_FILE": "${dir:keeper-state}/broker-keeper", + "MESH_NATS_FULL_RAISE": "75", + "MESH_NATS_FULL_CLEAR": "70", + "MESH_NATS_SNAPSHOTS_DIR": "${dir:keeper-state}" + }, + "serves": [ + "seat:mesh-broker.snapshot-get", + "seat:mesh-broker.snapshot-restore", + "seat:mesh-broker.snapshot-restore-cancel", + "seat:mesh-broker.snapshot-remove" + ], + "bus": { + "state": [ + "asked", + "requests", + "spent", + "plans", + "findings" + ], + "asks": true, + "keeps": true, + "invokes": [ + "seat:mesh-catalog.revision", + "seat:mesh-catalog.registrations", + "seat:mesh-delivery.source", + "seat:mesh-catalog.seat-definitions", + "seat:mesh-hand-acts.hand-act" + ] + }, + "health": { + "kind": "tool", + "tool": "nats_keeper_health", + "interval": "60s", + "timeout": "10s", + "looks": 2, + "grace": "180s" + } + }, { "id": "server", "type": "container", @@ -116,9 +363,23 @@ "volumes": [ "/var/lib/mesh-broker-nats:/data", "/var/lib/nats-module/conf:/etc/nats:ro", - "${access:tls}:/tls:ro" + "${access:tls}:/tls:ro", + "${dir:state}/snapshot:/opt/mesh:ro", + "${dir:state}/entrypoint:/opt/mesh-entrypoint:ro" ], - "artifact": "server" + "args": [ + "sh", + "/opt/mesh-entrypoint/entrypoint.sh" + ], + "artifact": "server", + "restart-on": [ + "program-snapshot", + "program-entrypoint" + ], + "health": { + "kind": "tcp", + "endpoint": "bus" + } } ], "accesses": [ @@ -129,21 +390,24 @@ } ], "build": { - "on": [ - { - "arg": "NATS_BASE", - "image": "nats@sha256:e4bf19f15fd3218814a4e3c9e0064e1334bd8aa20d5984b9f1a0afd084f8cc00" - }, - { - "arg": "GO_BASE", - "image": "golang@sha256:8ac98ca534ac3f51e1f420a1dd2c15e74c75cfa0f23f3ad27eb5d7236c349a0c" - } - ], "artifacts": [ { "name": "server", - "kind": "image", - "from": "Dockerfile" + "kind": "upstream", + "from": "nats:2.11.17-alpine@sha256:e4bf19f15fd3218814a4e3c9e0064e1334bd8aa20d5984b9f1a0afd084f8cc00" + }, + { + "name": "snapshot", + "kind": "bundle", + "language": "go", + "system": "alpine", + "from": "cmd/mesh-nats-snapshot", + "binary": "mesh-nats-snapshot" + }, + { + "name": "entrypoint", + "kind": "archive", + "from": "program" }, { "name": "tools", @@ -155,10 +419,17 @@ "loads": [ "nats-tools" ], + "bus": { + "removes": [ + "controller-leftovers" + ] + }, "env": { "MESH_NATS_MONITOR": "http://127.0.0.1:8222", "MESH_NATS_CONTAINER": "mesh-broker-nats", - "MESH_NATS_USERS_FILE": "/etc/nats/accounts.conf" + "MESH_NATS_USERS_FILE": "/etc/nats/accounts.conf", + "MESH_NATS_SNAPSHOTS_DIR": "${dir:snapshots}", + "NATS_TOOLS_CREDENTIAL": "${dir:tools-secret}/broker-nats-tools" } }, { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/netcheck/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/netcheck/module.json.captured index ec01003a8..ba762203c 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/netcheck/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/netcheck/module.json.captured @@ -1,6 +1,7 @@ { "module": "netcheck", - "version": "1", + "version": "0.1", + "class": "leaf", "emits": [ "tunnel.endpoint-changed", "tunnel.handshake-stale", @@ -11,6 +12,7 @@ "netcheck_tcp", "netcheck_dns", "netcheck_http", + "netcheck_request", "netcheck_listening" ], "replaces": { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/networkmanager/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/networkmanager/module.json.captured index 68ace345e..3433f40ba 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/networkmanager/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/networkmanager/module.json.captured @@ -1,6 +1,7 @@ { "module": "networkmanager", - "version": "1", + "version": "0.1", + "class": "core", "upgrade": { "policy": "record", "why": "the machine's network: a build that breaks it can cut the machine off from the bus, and then neither the gate's rollback nor a push reaches it (hq ADR 0236)" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nextcloud-client/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nextcloud-client/module.json.captured index af71acbbb..5b603e465 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nextcloud-client/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nextcloud-client/module.json.captured @@ -1,6 +1,7 @@ { "module": "nextcloud-client", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nextcloud/files/config.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nextcloud/files/config.json index 0967ef424..fe0323434 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nextcloud/files/config.json +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nextcloud/files/config.json @@ -1 +1,6 @@ -{} +{ + "onlyofficeUrl": "${bound:document-server:public-root}", + "onlyofficeInternalUrl": "http://${bound:document-server:at}:${bound:document-server:port}/", + "onlyofficeStorageUrl": "https://${bound:route:name}/", + "onlyofficeSecret": "${secret:document-server}" +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nextcloud/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nextcloud/module.json.captured index 2854a160c..c4efbe8a4 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nextcloud/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nextcloud/module.json.captured @@ -1,11 +1,13 @@ { "module": "nextcloud", - "version": "1", + "version": "0.1", + "class": "leaf", "slug": "ncloud", "requires": [ "postgres-database", "s3-bucket", - "route" + "route", + "document-server" ], "contributes": { "postgres-database": { @@ -19,11 +21,13 @@ "binds": { "postgres-database": "${dir:state}/database.json", "s3-bucket": "${dir:state}/store.json", - "route": "${dir:state}/route.json" + "route": "${dir:state}/route.json", + "document-server": "${dir:state}/document-server.json" }, "secrets": { "postgres-database": "${dir:state}/database.secret", - "s3-bucket": "${dir:state}/store.secret" + "s3-bucket": "${dir:state}/store.secret", + "document-server": "${dir:state}/document-server.secret" }, "emits": [ "user.created", @@ -69,7 +73,7 @@ }, "user": { "type": "string", - "description": "The Nextcloud account the module's tools act as; empty is admin.", + "description": "The Nextcloud account the module's tools act as; empty is mesh-admin, the account the module makes and keeps for itself. Any other account is used as given and never repaired.", "trusted": true, "default": "" } @@ -134,6 +138,7 @@ "mode": "0600", "template": "files/config.json", "takes-config": ["container", "url", "user"], + "protected": ["onlyofficeSecret"], "merge": "json" } ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nfs-server/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nfs-server/module.json.captured index f9994d16f..b3f027d18 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nfs-server/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nfs-server/module.json.captured @@ -1,6 +1,10 @@ { "module": "nfs-server", - "version": "1", + "version": "0.1", + "class": "core", + "packages": { + "git.novox.be/novox/mesh-catalog/modules/disk-load/diskreadings": "0.1" + }, "upgrade": { "policy": "record", "why": "the folders other machines mount: a build that breaks the exports leaves every client's mount hanging or refused, and the gate on this one machine does not see the clients (hq ADR 0236, ADR 0263)" @@ -13,7 +17,10 @@ { "name": "nfs-share", "scope": "mesh", - "identity": false + "identity": false, + "credential": { + "form": "none" + } } ], "data": { @@ -45,26 +52,23 @@ } ], "reads": [ + "disk-load.readings", "mounts.shares" ], - "invokes": [ - "seat:mesh-controller.seats", - "seat:mesh-controller.data" - ], - "config": { - "shares": { - "type": "string", - "description": "The folders this machine exports, as space-separated name=path; the operator's, with no default (novox/hq ADR 0263).", - "trusted": true, - "required": true - }, - "grants": { - "type": "string", - "description": "Which nodes may mount which share, and how: share=node:rw|ro[,node:rw|ro], entries separated by spaces, or none to export to no node whatever a node wants (novox/hq ADR 0263).", - "trusted": true, - "default": "none" - } + "config": { + "shares": { + "type": "string", + "description": "The folders this machine exports, as space-separated name=path; the operator's, with no default (novox/hq ADR 0263).", + "trusted": true, + "required": true }, + "grants": { + "type": "string", + "description": "Which nodes may mount which share, and how: share=node:rw|ro[,node:rw|ro], entries separated by spaces, or none to export to no node whatever a node wants (novox/hq ADR 0263).", + "trusted": true, + "default": "none" + } + }, "facts": { "machines": { "path": "/etc/nfs-server/machines", @@ -187,5 +191,34 @@ "from": "files" } ] - } + }, + "invokes": [ + "mesh-delivery-assigner.assigner_read_seat_holders", + "seat:mesh-hand-acts.hand-act" + ], + "consumes": [ + "mesh-delivery-assigner.views.seat-holders", + "mesh-conditions.findings-asked" + ], + "requires": [ + { + "name": "findings", + "storage": "key-value", + "template": "state" + }, + { + "name": "finding-events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } + } + ] } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nftables/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nftables/module.json.captured index b7b0c83fe..f4b31b727 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nftables/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nftables/module.json.captured @@ -1,6 +1,7 @@ { "module": "nftables", - "version": "1", + "version": "0.1", + "class": "core", "upgrade": { "policy": "record", "why": "the machine's packet filter: a build that breaks it can cut the machine off from the bus, and then neither the gate's rollback nor a push reaches it (hq ADR 0236)" @@ -15,10 +16,28 @@ "serves": [ "rules", "reload", - "remove" + "remove", + "allow", + "disallow", + "allowed" ] } ], + "requires": [ + { + "name": "allowances", + "storage": "key-value", + "template": "state", + "options": { + "history": 1, + "per-machine": true + } + } + ], + "invokes": [ + "seat:node-engine.converged", + "seat:mesh-hand-acts.hand-act" + ], "filtering": { "into": "/etc/nftables.conf" }, @@ -71,6 +90,15 @@ "tools": [ "firewall_rules" ], + "config": { + "allowances-max": { + "type": "number", + "description": "The most allowances this machine keeps, which allow refuses past (design 33 control-verbs §3): it keeps the rendered chain readable and allowed in one answer.", + "trusted": false, + "runtime": true, + "default": 100 + } + }, "build": { "artifacts": [ { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nm-applet/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nm-applet/module.json.captured index 1c6764ef0..22f916059 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nm-applet/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nm-applet/module.json.captured @@ -1,6 +1,7 @@ { "module": "nm-applet", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/node-env/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/node-env/module.json.captured index 85fd7e57c..db48bb5f4 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/node-env/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/node-env/module.json.captured @@ -1,6 +1,7 @@ { "module": "node-env", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "claims": [ { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nodejs/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nodejs/module.json.captured index c3573444a..0762ab3ac 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nodejs/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nodejs/module.json.captured @@ -1,13 +1,17 @@ { "module": "nodejs", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager" ], "provides": [ { "name": "node-toolchain", - "reach": "machine" + "reach": "machine", + "credential": { + "form": "none" + } } ], "resources": [ diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nodered/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nodered/module.json.captured index f8068dd1c..672625046 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nodered/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/nodered/module.json.captured @@ -1,6 +1,7 @@ { "module": "nodered", - "version": "1", + "version": "0.1", + "class": "leaf", "emits": [ "flows.deployed" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/ollama/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/ollama/module.json.captured index 2d5fb48c3..690f62adc 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/ollama/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/ollama/module.json.captured @@ -1,13 +1,17 @@ { "module": "ollama", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "container-runtime" ], "provides": [ { "name": "model-access", - "scope": "node" + "scope": "node", + "credential": { + "form": "none" + } } ], "listens": [ diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/only-office/files/server.env b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/only-office/files/server.env index 19fab119b..a92e1c8fe 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/only-office/files/server.env +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/only-office/files/server.env @@ -2,4 +2,5 @@ JWT_ENABLED=true JWT_SECRET=${secret:jwt} JWT_HEADER=Authorization JWT_IN_BODY=true +SECURE_LINK_SECRET=${secret:secure-link} ALLOW_PRIVATE_IP_ADDRESS=true diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/only-office/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/only-office/module.json.captured index 4af651f4d..98f530cf5 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/only-office/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/only-office/module.json.captured @@ -1,7 +1,24 @@ { "module": "only-office", - "version": "1", + "version": "0.1", + "class": "core", "slug": "office", + "provides": [ + { + "name": "document-server", + "scope": "mesh", + "credential": { + "own": "jwt" + } + } + ], + "serves": { + "document-server": { + "scheme": "http", + "port": 9070, + "public-root": "https://${bound:route:name}/" + } + }, "capabilities": [ "container-runtime" ], @@ -14,11 +31,60 @@ "endpoint": "web" } }, + "seats": [ + { + "name": "document-converter", + "scope": "mesh", + "serves": [ + "convert" + ] + } + ], + "claims": [ + { + "name": "document-converter", + "scope": "mesh", + "serves": [ + "convert" + ] + } + ], + "streams": [ + { + "name": "convert-asks", + "events": [ + "convert.asked" + ], + "max-age-days": 1, + "max-mib": 8, + "retention": "work-queue", + "max-deliveries": 3, + "duplicates": 24 + } + ], + "state": [ + { + "name": "convert-answers", + "ttl-seconds": 600 + } + ], "binds": { "route": "${dir:state}/route.json" }, "own-secrets": { - "jwt": "${dir:state}/jwt.secret" + "jwt": { + "path": "${dir:state}/jwt.secret", + "owner": "only-office-converter", + "taken": "at-start" + }, + "secure-link": { + "path": "${dir:state}/secure-link.secret", + "taken": "at-start" + }, + "broker-converter": { + "path": "${dir:state}/broker-converter.secret", + "owner": "only-office-converter" + } }, "listens": [ { @@ -39,7 +105,7 @@ }, { "id": "lib", - "path": "${dir:lib}", + "path": "${dir:server-lib}", "class": "rebuildable", "why": "the document server's working files" }, @@ -79,10 +145,16 @@ { "id": "state", "type": "directory", - "mode": "0700", + "mode": "0711", "place": ".", "unknown": "program" }, + { + "id": "converter-account", + "type": "user", + "name": "only-office-converter", + "shell": "/usr/bin/nologin" + }, { "id": "server-env", "type": "file", @@ -90,45 +162,58 @@ "mode": "0600", "template": "files/server.env" }, + { + "id": "box", + "type": "directory", + "mode": "0700", + "unknown": "program" + }, { "id": "logs", "type": "directory", + "path": "${dir:box}/logs", "mode": "0700", "unknown": "program" }, { "id": "data", "type": "directory", + "path": "${dir:box}/data", "mode": "0700", "unknown": "program" }, { - "id": "lib", + "id": "server-lib", "type": "directory", - "mode": "0700", + "path": "${dir:box}/lib", + "mode": "0711", "unknown": "program" }, { "id": "db", "type": "directory", + "path": "${dir:box}/db", "mode": "0700", "unknown": "program" }, { "id": "rabbitmq", "type": "directory", + "path": "${dir:box}/rabbitmq", "mode": "0700", "unknown": "program" }, { "id": "redis", "type": "directory", + "path": "${dir:box}/redis", "mode": "0700", "unknown": "program" }, { "id": "fonts", "type": "directory", + "path": "${dir:box}/fonts", "mode": "0700", "unknown": "program" }, @@ -152,17 +237,55 @@ "volumes": [ "${dir:logs}:/var/log/onlyoffice", "${dir:data}:/var/www/onlyoffice/Data", - "${dir:lib}:/var/lib/onlyoffice", + "${dir:server-lib}:/var/lib/onlyoffice", "${dir:db}:/var/lib/postgresql", "${dir:rabbitmq}:/var/lib/rabbitmq", "${dir:redis}:/var/lib/redis", "${dir:fonts}:/usr/share/fonts/truetype/custom" ], - "secrets-in-environment": "run-document-server.sh regenerates JWT_SECRET from the environment on every start and overwrites local.json; not convertible" + "secrets-in-environment": "run-document-server.sh regenerates JWT_SECRET and SECURE_LINK_SECRET from the environment on every start and overwrites local.json and nginx's ds.conf; not convertible" + }, + { + "id": "converter", + "type": "process", + "name": "only-office-converter", + "artifact": "tools", + "run": [ + "./only-office", + "converter" + ], + "user": "only-office-converter", + "env": { + "ONLY_OFFICE_BROKER": "${dir:state}/broker-converter.secret", + "ONLY_OFFICE_JWT": "${dir:state}/jwt.secret", + "ONLY_OFFICE_SERVER": "http://127.0.0.1:9070" + }, + "bus": { + "queues": [ + "convert-asks" + ], + "state": [ + "convert-answers" + ] + }, + "health": { + "kind": "unit" + } } ], "build": { "artifacts": [ + { + "name": "tools", + "kind": "bundle", + "language": "go", + "system": "arch", + "from": "cmd/only-office", + "binary": "only-office", + "loads": [ + "only-office" + ] + }, { "name": "files", "kind": "archive", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/openai-consumer/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/openai-consumer/module.json.captured index 2e98414ef..20d633cfa 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/openai-consumer/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/openai-consumer/module.json.captured @@ -1,6 +1,7 @@ { "module": "openai-consumer", - "version": "1", + "version": "0.1", + "class": "leaf", "slug": "openai", "capabilities": [ "container-runtime" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/openrazer/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/openrazer/module.json.captured index faa34f870..6e30f9513 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/openrazer/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/openrazer/module.json.captured @@ -1,6 +1,7 @@ { "module": "openrazer", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/keeper.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/keeper.json new file mode 100644 index 000000000..8e340a943 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/keeper.json @@ -0,0 +1,5 @@ +{ + "upgrade-order": [], + "record-days": 180, + "round-start-minutes": 120 +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/mesh-pacman-weekly-upgrade.service b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/mesh-pacman-weekly-upgrade.service deleted file mode 100644 index 69741dd7a..000000000 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/mesh-pacman-weekly-upgrade.service +++ /dev/null @@ -1,12 +0,0 @@ -# Generated by the mesh. Do not edit — module pacman writes this file and replaces it at every push. -[Unit] -Description=Weekly full upgrade (the mesh's pacman module, ADR 0477) -Wants=network-online.target -After=network-online.target - -[Service] -# The upgrade pacman_upgrade runs (pacman -Syu --noconfirm), as a oneshot whose result is the module's health -# (pacman_upgrade_health). The mesh restarts no machine for an upgrade: a new kernel waits for the next restart. -Type=oneshot -Nice=10 -ExecStart=/usr/bin/pacman -Syu --noconfirm diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/mesh-pacman-weekly-upgrade.timer b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/mesh-pacman-weekly-upgrade.timer deleted file mode 100644 index a8a9b4d9d..000000000 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/mesh-pacman-weekly-upgrade.timer +++ /dev/null @@ -1,11 +0,0 @@ -# Generated by the mesh. Do not edit — module pacman writes this file and replaces it at every push. -[Unit] -Description=Weekly full upgrade, Saturday 04:00 local time on every node (the mesh's pacman module, ADR 0477) - -[Timer] -# The same moment on every node: no random delay. A node that was off or asleep then upgrades at its next start. -OnCalendar=Sat *-*-* 04:00:00 -Persistent=true - -[Install] -WantedBy=timers.target diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/reflector.conf b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/reflector.conf index eb9e731b7..91bad4c7c 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/reflector.conf +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/files/reflector.conf @@ -1,7 +1,7 @@ -# The mesh's (module pacman, novox/hq to-be 42): how reflector refreshes the mirror list, weekly, -# through reflector.timer. Written whole at every push. Before the module, every machine's list was -# generated once and never again. ---save /etc/pacman.d/mirrorlist +# The mesh's (module pacman, novox/hq ADR 0585): the options reflector ranks the mesh's one mirror list with. +# The keeper of the node that opens a week's upgrade round runs reflector with them (and --info) and keeps only the +# mirrors as fresh as the newest; every node writes /etc/pacman.d/mirrorlist from that list. reflector's own timer +# stays disabled, and nothing here saves a list. Written whole at every push. --protocol https --country Belgium,Netherlands,Luxembourg,Germany,France --latest 20 diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/module.json.captured index ca1a81a30..580aaaa54 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/pacman/module.json.captured @@ -1,6 +1,7 @@ { "module": "pacman", - "version": "1", + "version": "0.1", + "class": "core", "capabilities": [ "package-manager", "service-manager" @@ -11,15 +12,74 @@ "scope": "node" } ], + "reads": [ + "mesh-host.packages" + ], + "uses": [ + "operator-channel" + ], + "config": { + "upgrade-order": { + "type": "list", + "description": "The nodes in the order they upgrade, each by its name: the first opens each week's round on Saturday at 04:00 local time, and each node upgrades after the one before it passed its after-upgrade check (novox/hq ADR 0508 §5). Empty: no round starts, and every node's health says why. Falls back to the mesh-level key of the same name.", + "trusted": true, + "predefined": "upgrade-order", + "default": [] + }, + "record-days": { + "type": "number", + "description": "How many days a package record taken before an upgrade is kept on the bus before it is deleted (novox/hq ADR 0508 §2); a rollback can return only to a record still kept.", + "minimum": 1, + "trusted": false, + "default": 180 + }, + "round-start-minutes": { + "type": "number", + "description": "How many minutes a node whose turn in the round came may take to start its upgrade before the round is said to stand still, in that node's and the waiting nodes' health (novox/hq ADR 0508 §6).", + "minimum": 1, + "trusted": false, + "default": 120 + } + }, + "own-secrets": { + "broker-keeper": { + "path": "${dir:state}/broker-keeper.secret", + "owner": "pacman-keeper" + } + }, + "state": [ + "installed", + "updates", + "runs", + "records", + "rounds", + "asks", + "mirrors" + ], + "emits": [ + "package.changed", + "upgrade.recorded", + "upgrade.kernel-held", + "upgrade.started", + "upgrade.finished", + "upgrade.failed", + "upgrade.checked", + "rollback.started", + "rollback.finished" + ], "tools": [ "pacman_search", "pacman_info", "pacman_installed", + "pacman_packages", "pacman_owns", "pacman_files", "pacman_updates", "pacman_upgrade", "pacman_upgrade_health", + "pacman_upgrades", + "pacman_rollback", + "pacman_round", "pacman_orphans", "pacman_remove_orphans", "pacman_cache", @@ -30,11 +90,6 @@ "pacman_config" ], "resources": [ - { - "id": "package", - "type": "package", - "package": "pacman" - }, { "id": "config", "type": "file", @@ -42,6 +97,11 @@ "mode": "0644", "template": "files/pacman.conf" }, + { + "id": "package", + "type": "package", + "package": "pacman" + }, { "id": "contrib", "type": "package", @@ -63,11 +123,8 @@ "id": "mirror-refresh", "type": "service", "unit": "reflector.timer", - "state": "running", - "boot": "enabled", - "health": { - "kind": "unit" - } + "state": "stopped", + "boot": "disabled" }, { "id": "cache-cleaning", @@ -80,29 +137,90 @@ } }, { - "id": "upgrade-service", - "type": "file", - "path": "/etc/systemd/system/mesh-pacman-weekly-upgrade.service", - "mode": "0644", - "template": "files/mesh-pacman-weekly-upgrade.service" + "id": "keeper-account", + "type": "user", + "name": "pacman-keeper", + "shell": "/usr/bin/nologin" }, { - "id": "upgrade-timer", - "type": "file", - "path": "/etc/systemd/system/mesh-pacman-weekly-upgrade.timer", - "mode": "0644", - "template": "files/mesh-pacman-weekly-upgrade.timer" + "id": "state", + "type": "directory", + "mode": "0711", + "place": "mesh", + "unknown": "program" }, { - "id": "weekly-upgrade", - "type": "service", - "unit": "mesh-pacman-weekly-upgrade.timer", - "state": "running", - "boot": "enabled", - "restart-on": [ - "upgrade-service", - "upgrade-timer" + "id": "keeper-config", + "type": "file", + "path": "${dir:state}/keeper.json", + "mode": "0644", + "takes-config": [ + "upgrade-order", + "record-days", + "round-start-minutes" ], + "merge": "json", + "template": "files/keeper.json", + "trusted": true + }, + { + "id": "root-helper", + "type": "process", + "name": "pacman-root", + "artifact": "tools", + "run": [ + "./pacman-tools", + "root" + ], + "env": { + "PACMAN_ROOT_SOCKET": "${dir:state}/root/helper.sock", + "PACMAN_ROOT_PEER": "pacman-keeper" + }, + "health": { + "kind": "unit" + } + }, + { + "id": "keeper", + "type": "process", + "name": "pacman-keeper", + "artifact": "tools", + "run": [ + "./pacman-tools", + "keeper" + ], + "user": "pacman-keeper", + "env": { + "PACMAN_KEEPER_BROKER": "${dir:state}/broker-keeper.secret", + "PACMAN_KEEPER_CONFIG": "${dir:state}/keeper.json", + "PACMAN_ROOT_SOCKET": "${dir:state}/root/helper.sock" + }, + "restart-on": [ + "keeper-config" + ], + "bus": { + "state": [ + "installed", + "updates", + "runs", + "records", + "rounds", + "asks", + "mirrors" + ], + "emits": [ + "package.changed", + "upgrade.recorded", + "upgrade.kernel-held", + "upgrade.started", + "upgrade.finished", + "upgrade.failed", + "upgrade.checked", + "rollback.started", + "rollback.finished" + ], + "asks": true + }, "health": { "kind": "tool", "tool": "pacman_upgrade_health", @@ -124,7 +242,10 @@ "binary": "pacman-tools", "loads": [ "pacman-tools" - ] + ], + "env": { + "PACMAN_KEEPER_CONFIG": "${dir:state}/keeper.json" + } }, { "name": "files", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/photos-eef/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/photos-eef/module.json.captured index 101bdc27a..6f9989e33 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/photos-eef/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/photos-eef/module.json.captured @@ -1,6 +1,7 @@ { "module": "photos-eef", - "version": "1", + "version": "0.1", + "class": "leaf", "slug": "eef", "capabilities": [ "container-runtime" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/photos-filip/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/photos-filip/module.json.captured index 9c1c83fac..c526f3818 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/photos-filip/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/photos-filip/module.json.captured @@ -1,6 +1,7 @@ { "module": "photos-filip", - "version": "1", + "version": "0.1", + "class": "leaf", "slug": "filip", "capabilities": [ "container-runtime" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/picom/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/picom/module.json.captured index cfdc39702..bc61080d1 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/picom/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/picom/module.json.captured @@ -1,6 +1,7 @@ { "module": "picom", - "version": "1", + "version": "0.1", + "class": "core", "capabilities": [ "package-manager" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/polychromatic/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/polychromatic/module.json.captured index 4d6ba4b33..8930b1469 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/polychromatic/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/polychromatic/module.json.captured @@ -1,6 +1,7 @@ { "module": "polychromatic", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, "requires": [ "x11-display" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/postgres/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/postgres/module.json.captured index 919df4216..e41fab60c 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/postgres/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/postgres/module.json.captured @@ -1,6 +1,7 @@ { "module": "postgres", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "upgrade": { "policy": "record", @@ -9,6 +10,7 @@ "provides": [ { "name": "postgres-database", + "credential": {"form": "pair"}, "scope": "mesh", "identity": { "max": 63, @@ -61,8 +63,8 @@ "postgres-database": "${dir:grants}" }, "own-secrets": { - "superuser": "${dir:state}/superuser.secret", - "reader": "${dir:state}/reader.secret" + "superuser": "${dir:data}/superuser.secret", + "reader": "${dir:data}/reader.secret" }, "data": { "own": [ @@ -93,22 +95,31 @@ }, "resources": [ { - "id": "state", + "id": "data", "type": "directory", "mode": "0700", - "place": ".", + "place": "mesh", + "unknown": "program" + }, + { + "id": "state", + "type": "directory", + "path": "/var/lib/postgres", + "owner": "postgres", + "mode": "0700", "unknown": "program" }, { "id": "grants", "type": "directory", + "path": "${dir:data}/grants", "mode": "0700", "unknown": "program" }, { "id": "consumers", "type": "file", - "path": "${dir:state}/consumers.json", + "path": "${dir:data}/consumers.json", "mode": "0600", "template": "files/consumers.json" }, @@ -146,7 +157,7 @@ ], "volumes": [ "/var/lib/mesh-store:/var/lib/postgresql/data", - "${dir:state}/superuser.secret:/run/secrets/superuser:ro" + "${dir:data}/superuser.secret:/run/secrets/superuser:ro" ] }, { @@ -169,10 +180,10 @@ ], "env": { "MESH_PROVISION_POSTGRES": "postgres://postgres@127.0.0.1:${port:5432}/postgres?sslmode=disable", - "MESH_PROVISION_PASSWORD_FILE": "${dir:state}/superuser.secret", + "MESH_PROVISION_PASSWORD_FILE": "${dir:data}/superuser.secret", "MESH_RECEIVES": "${dir:grants}/mesh.json", - "MESH_POSTGRES_READER_PASSWORD_FILE": "${dir:state}/reader.secret", - "MESH_CONSUMERS_FILE": "${dir:state}/consumers.json" + "MESH_POSTGRES_READER_PASSWORD_FILE": "${dir:data}/reader.secret", + "MESH_CONSUMERS_FILE": "${dir:data}/consumers.json" } }, { @@ -186,6 +197,7 @@ "bound" ], "reads": [ - "mesh-controller.assignments" + "mesh-provisioner.plans", + "mesh-provisioner.provisions" ] } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/module.json.captured index a110d4109..e4b54f8f4 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/module.json.captured @@ -1,6 +1,7 @@ { "module": "power", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "templates": "templates", "capabilities": [ @@ -314,6 +315,48 @@ "mode": "0644", "template": "templates/systemd/system/suspend-then-hibernate.target.d/mesh-power.conf" }, + { + "id": "reboot-drop-ins", + "type": "directory", + "path": "/etc/systemd/system/reboot.target.d", + "mode": "0755", + "unknown": "program" + }, + { + "id": "reboot-bound", + "type": "file", + "path": "/etc/systemd/system/reboot.target.d/mesh-power.conf", + "mode": "0644", + "template": "templates/systemd/system/reboot.target.d/mesh-power.conf" + }, + { + "id": "poweroff-drop-ins", + "type": "directory", + "path": "/etc/systemd/system/poweroff.target.d", + "mode": "0755", + "unknown": "program" + }, + { + "id": "poweroff-bound", + "type": "file", + "path": "/etc/systemd/system/poweroff.target.d/mesh-power.conf", + "mode": "0644", + "template": "templates/systemd/system/poweroff.target.d/mesh-power.conf" + }, + { + "id": "halt-drop-ins", + "type": "directory", + "path": "/etc/systemd/system/halt.target.d", + "mode": "0755", + "unknown": "program" + }, + { + "id": "halt-bound", + "type": "file", + "path": "/etc/systemd/system/halt.target.d/mesh-power.conf", + "mode": "0644", + "template": "templates/systemd/system/halt.target.d/mesh-power.conf" + }, { "id": "udev-rule", "type": "file", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/templates/systemd/system/halt.target.d/mesh-power.conf b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/templates/systemd/system/halt.target.d/mesh-power.conf new file mode 100644 index 000000000..569d7fd97 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/templates/systemd/system/halt.target.d/mesh-power.conf @@ -0,0 +1,8 @@ +# Written by the mesh (module power, novox/hq ADR 0211; issue 1126). Replaced on every push. +# +# A shutdown is bounded at ten minutes, not systemd's thirty. A unit started again during the shutdown +# (on ace, 2026-10-28, the bus and the authorization manager) is never stopped a second time, and the +# shutdown then waits on this job's timeout with nothing on the console. The target keeps its own +# forcing action: the last phase still ends every process, unmounts and syncs. +[Unit] +JobTimeoutSec=10min diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/templates/systemd/system/poweroff.target.d/mesh-power.conf b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/templates/systemd/system/poweroff.target.d/mesh-power.conf new file mode 100644 index 000000000..569d7fd97 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/templates/systemd/system/poweroff.target.d/mesh-power.conf @@ -0,0 +1,8 @@ +# Written by the mesh (module power, novox/hq ADR 0211; issue 1126). Replaced on every push. +# +# A shutdown is bounded at ten minutes, not systemd's thirty. A unit started again during the shutdown +# (on ace, 2026-10-28, the bus and the authorization manager) is never stopped a second time, and the +# shutdown then waits on this job's timeout with nothing on the console. The target keeps its own +# forcing action: the last phase still ends every process, unmounts and syncs. +[Unit] +JobTimeoutSec=10min diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/templates/systemd/system/reboot.target.d/mesh-power.conf b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/templates/systemd/system/reboot.target.d/mesh-power.conf new file mode 100644 index 000000000..569d7fd97 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/power/templates/systemd/system/reboot.target.d/mesh-power.conf @@ -0,0 +1,8 @@ +# Written by the mesh (module power, novox/hq ADR 0211; issue 1126). Replaced on every push. +# +# A shutdown is bounded at ten minutes, not systemd's thirty. A unit started again during the shutdown +# (on ace, 2026-10-28, the bus and the authorization manager) is never stopped a second time, and the +# shutdown then waits on this job's timeout with nothing on the console. The target keeps its own +# forcing action: the last phase still ends every process, unmounts and syncs. +[Unit] +JobTimeoutSec=10min diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/powerlevel10k/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/powerlevel10k/module.json.captured index da1bd4dfe..d719efb31 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/powerlevel10k/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/powerlevel10k/module.json.captured @@ -1,6 +1,7 @@ { "module": "powerlevel10k", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, "resources": [ { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/records/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/records/module.json.captured index db6f7e5a9..a41fe6961 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/records/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/records/module.json.captured @@ -1,6 +1,7 @@ { "module": "records", - "version": "1", + "version": "0.1", + "class": "leaf", "slug": "records", "requires": [ "git" @@ -9,7 +10,7 @@ "git": "${dir:mesh-state}/git.json" }, "consumes": [ - "gitea.pull.merged" + "git.pull-merged" ], "tools": [ "records_search", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/redis/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/redis/module.json.captured index 58e11064b..357accec8 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/redis/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/redis/module.json.captured @@ -1,12 +1,16 @@ { "module": "redis", - "version": "1", + "version": "0.1", + "class": "leaf", "provides": [ { "name": "redis-cache", "scope": "mesh", "identity": { "in": "a Redis ACL user and key prefix" + }, + "credential": { + "form": "pair" } } ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/restic/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/restic/module.json.captured index 313d3e7de..1a006be0e 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/restic/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/restic/module.json.captured @@ -1,6 +1,7 @@ { "module": "restic", "version": "0.1", + "class": "core", "packages": { "git.novox.be/novox/mesh-catalog/modules/disk-load/diskreadings": "0.1" }, @@ -261,7 +262,7 @@ "findings-stated.*" ], "max-age-days": 7, - "max-mib": 16 + "max-mib": 8 } } ] diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/rofi/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/rofi/module.json.captured index fbd061d01..1bba3a54f 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/rofi/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/rofi/module.json.captured @@ -1,6 +1,7 @@ { "module": "rofi", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/route-adapter/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/route-adapter/module.json.captured index 5234c78bb..ee7e27f74 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/route-adapter/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/route-adapter/module.json.captured @@ -1,6 +1,7 @@ { "module": "route-adapter", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, "slug": "radapt", "capabilities": [ @@ -9,6 +10,7 @@ "provides": [ { "name": "route", + "credential": {"form": "none"}, "scope": "mesh", "identity": false } @@ -129,6 +131,7 @@ "bound" ], "reads": [ - "mesh-controller.assignments" + "mesh-provisioner.plans", + "mesh-provisioner.provisions" ] } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/screen-lock/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/screen-lock/module.json.captured index 1791c7986..5f184f289 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/screen-lock/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/screen-lock/module.json.captured @@ -1,6 +1,7 @@ { "module": "screen-lock", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/searxng/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/searxng/module.json.captured index cee18e4ef..14add9c82 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/searxng/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/searxng/module.json.captured @@ -1,6 +1,7 @@ { "module": "searxng", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "container-runtime" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/sensors/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/sensors/module.json.captured index 3df678384..79a476d6f 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/sensors/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/sensors/module.json.captured @@ -1,6 +1,7 @@ { "module": "sensors", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager", "service-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/showcase/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/showcase/module.json.captured index e657e2ab0..06fea3efc 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/showcase/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/showcase/module.json.captured @@ -1,6 +1,7 @@ { "module": "showcase", - "version": "1", + "version": "0.1", + "class": "core", "templates": "templates", "slug": "show", "capabilities": [ @@ -9,7 +10,10 @@ "provides": [ { "name": "greeting", - "scope": "mesh" + "scope": "mesh", + "credential": { + "form": "none" + } } ], "serves": { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/slack/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/slack/module.json.captured index 9feeedb31..f791e2451 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/slack/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/slack/module.json.captured @@ -1,6 +1,7 @@ { "module": "slack", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, "requires": [ "x11-display" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/snapd/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/snapd/module.json.captured index 93ad73073..cd5ecd1d3 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/snapd/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/snapd/module.json.captured @@ -1,6 +1,7 @@ { "module": "snapd", - "version": "1", + "version": "0.1", + "class": "leaf", "tools": [ "snapd_status", "snapd_list", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/ssh-client/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/ssh-client/module.json.captured index a6965445a..c4f8c3a91 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/ssh-client/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/ssh-client/module.json.captured @@ -1,6 +1,7 @@ { "module": "ssh-client", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, "tools": [ "ssh_client_hosts", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/sshd/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/sshd/module.json.captured index 066e058d2..b799d5a87 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/sshd/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/sshd/module.json.captured @@ -1,6 +1,7 @@ { "module": "sshd", - "version": "1", + "version": "0.1", + "class": "leaf", "upgrade": { "policy": "record", "why": "the operator's way into the machine when the mesh cannot reach it: a build that breaks it is found only when that way is needed, which no gate sees (hq ADR 0236)" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/step-ca/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/step-ca/module.json.captured index b11d2b990..887945e1f 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/step-ca/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/step-ca/module.json.captured @@ -1,13 +1,17 @@ { "module": "step-ca", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "container-runtime" ], "provides": [ { "name": "internal-acme-ca", - "scope": "mesh" + "scope": "mesh", + "credential": { + "form": "none" + } } ], "serves": { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/sudo/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/sudo/module.json.captured index 364ce5fc9..019d9f992 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/sudo/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/sudo/module.json.captured @@ -1,6 +1,7 @@ { "module": "sudo", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/supabase/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/supabase/module.json.captured index 14ddbcd56..e67fad8e2 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/supabase/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/supabase/module.json.captured @@ -1,6 +1,7 @@ { "module": "supabase", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "container-runtime" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/systemd-networkd/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/systemd-networkd/module.json.captured index 0c4c109d7..5c0e60f68 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/systemd-networkd/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/systemd-networkd/module.json.captured @@ -1,6 +1,7 @@ { "module": "systemd-networkd", - "version": "1", + "version": "0.1", + "class": "core", "upgrade": { "policy": "record", "why": "the machine's network: a build that breaks it can cut the machine off from the bus, and then neither the gate's rollback nor a push reaches it (hq ADR 0236)" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/systemd-resolved/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/systemd-resolved/module.json.captured index b850afcfe..c62dbd7b4 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/systemd-resolved/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/systemd-resolved/module.json.captured @@ -1,6 +1,7 @@ { "module": "systemd-resolved", - "version": "1", + "version": "0.1", + "class": "core", "upgrade": { "policy": "record", "why": "the machine's names: a build that breaks this resolver stops every name resolving on a machine a person works on, the bus's included, and then neither the gate's rollback nor a push reaches it (hq ADR 0236, ADR 0247)" @@ -8,7 +9,10 @@ "provides": [ { "name": "split-dns", - "reach": "machine" + "reach": "machine", + "credential": { + "form": "none" + } } ], "requires": [ @@ -49,7 +53,7 @@ "facts": { "kept": { "path": "/etc/node-resolver/resolv.conf", - "template": "# Managed by the mesh, and written by the module holding this machine's own resolver\n# (module systemd-resolved, novox/hq ADR 0247). On every other machine the module holding\n# the uplink writes this file, listing the mesh's resolvers (ADR 0223); here something\n# requires names routed by domain - a VPN client's domains to its own servers - so the file\n# names this machine's own resolver alone, which sends those domains over the VPN's link and\n# every other name to the mesh's resolvers. One server listed, so one answer per name.\n#\n# Its address on the private network, not loopback: a container copies this file, and\n# this address is one it can reach. Another program writing this file is put back by the\n# module's guard, which keeps what it wrote for whoever handles it on this machine.\n# Replaced on every push; edit nothing here.\n{{$own := \"\"}}{{range .Machines}}{{if eq .Name $.Node}}{{$own = .Address}}{{end}}{{end}}nameserver {{if $own}}{{$own}}{{else}}127.0.0.53{{end}}\noptions timeout:1 attempts:2 edns0\n" + "template": "# Managed by the mesh, and written by the module holding this machine's own resolver\n# (module systemd-resolved, novox/hq ADR 0247). On every other machine the module holding\n# the uplink writes this file, listing the mesh's resolvers (ADR 0223); here something\n# requires names routed by domain - a VPN client's domains to its own servers - so the file\n# names this machine's own resolver alone, which sends those domains over the VPN's link and\n# every other name to the mesh's resolvers. One server listed, so one answer per name.\n#\n# Its address on the private network, not loopback: a container copies this file, and\n# this address is one it can reach. Another program writing this file is put back by the\n# module's guard, which keeps what it wrote for whoever handles it on this machine.\n# Replaced on every push; edit nothing here.\n{{$own := \"\"}}{{range .Machines}}{{if eq .Name $.Node}}{{$own = .Address}}{{end}}{{end}}nameserver {{if $own}}{{$own}}{{else}}127.0.0.53{{end}}\noptions timeout:3 attempts:2 edns0\n" }, "resolved": { "path": "/etc/systemd/resolved.conf.d/50-mesh.conf", @@ -57,7 +61,7 @@ }, "resolvers": { "path": "/etc/resolv.conf", - "template": "# Managed by the mesh, and written by the module holding this machine's own resolver\n# (module systemd-resolved, novox/hq ADR 0247). On every other machine the module holding\n# the uplink writes this file, listing the mesh's resolvers (ADR 0223); here something\n# requires names routed by domain - a VPN client's domains to its own servers - so the file\n# names this machine's own resolver alone, which sends those domains over the VPN's link and\n# every other name to the mesh's resolvers. One server listed, so one answer per name.\n#\n# Its address on the private network, not loopback: a container copies this file, and\n# this address is one it can reach. Another program writing this file is put back by the\n# module's guard, which keeps what it wrote for whoever handles it on this machine.\n# Replaced on every push; edit nothing here.\n{{$own := \"\"}}{{range .Machines}}{{if eq .Name $.Node}}{{$own = .Address}}{{end}}{{end}}nameserver {{if $own}}{{$own}}{{else}}127.0.0.53{{end}}\noptions timeout:1 attempts:2 edns0\n" + "template": "# Managed by the mesh, and written by the module holding this machine's own resolver\n# (module systemd-resolved, novox/hq ADR 0247). On every other machine the module holding\n# the uplink writes this file, listing the mesh's resolvers (ADR 0223); here something\n# requires names routed by domain - a VPN client's domains to its own servers - so the file\n# names this machine's own resolver alone, which sends those domains over the VPN's link and\n# every other name to the mesh's resolvers. One server listed, so one answer per name.\n#\n# Its address on the private network, not loopback: a container copies this file, and\n# this address is one it can reach. Another program writing this file is put back by the\n# module's guard, which keeps what it wrote for whoever handles it on this machine.\n# Replaced on every push; edit nothing here.\n{{$own := \"\"}}{{range .Machines}}{{if eq .Name $.Node}}{{$own = .Address}}{{end}}{{end}}nameserver {{if $own}}{{$own}}{{else}}127.0.0.53{{end}}\noptions timeout:3 attempts:2 edns0\n" }, "suffix": { "path": "/etc/node-resolver/suffix", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/systemd/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/systemd/module.json.captured index 984ccf3aa..2f3cff730 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/systemd/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/systemd/module.json.captured @@ -1,6 +1,7 @@ { "module": "systemd", - "version": "1", + "version": "0.1", + "class": "core", "capabilities": [ "service-manager", "package-manager" @@ -18,6 +19,7 @@ "enable", "disable", "journal", + "kernel-log", "failed", "reset-failed", "wanted-by", @@ -41,7 +43,7 @@ "systemd-tools" ], "env": { - "MESH_SYSTEMD_STATE": "${dir:state}" + "MESH_SYSTEMD_STATE": "${dir:data}" } } ] @@ -53,10 +55,18 @@ "package": "systemd" }, { - "id": "state", + "id": "data", "type": "directory", "mode": "0700", - "place": ".", + "place": "mesh", + "unknown": "program" + }, + { + "id": "state", + "type": "directory", + "path": "/var/lib/systemd", + "owner": "root", + "mode": "0755", "unknown": "program" } ] diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/telegram/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/telegram/module.json.captured index 95ae6f1b2..22304d74c 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/telegram/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/telegram/module.json.captured @@ -1,6 +1,7 @@ { "module": "telegram", - "version": "1", + "version": "0.1", + "class": "core", "slug": "tgrm", "runs-as": "telegram", "claims": [ diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/time-sync/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/time-sync/module.json.captured index c3d9b0c52..de09c9e59 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/time-sync/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/time-sync/module.json.captured @@ -1,6 +1,7 @@ { "module": "time-sync", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager", "service-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/triggerhappy/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/triggerhappy/module.json.captured index 18faaf4b9..babb95e7b 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/triggerhappy/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/triggerhappy/module.json.captured @@ -1,6 +1,7 @@ { "module": "triggerhappy", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "service-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/umami/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/umami/module.json.captured index 22ead4197..d1c618a88 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/umami/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/umami/module.json.captured @@ -1,6 +1,7 @@ { "module": "umami", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "container-runtime" ], @@ -32,7 +33,10 @@ "provides": [ { "name": "analytics", - "scope": "mesh" + "scope": "mesh", + "credential": { + "form": "none" + } } ], "serves": { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/unifi/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/unifi/module.json.captured index 2ee5cf49f..c9f09c7e5 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/unifi/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/unifi/module.json.captured @@ -1,6 +1,7 @@ { "module": "unifi", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "container-runtime" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/website/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/website/module.json.captured index 481cfc665..07970c19e 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/website/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/website/module.json.captured @@ -1,6 +1,7 @@ { "module": "website", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "container-runtime" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xclip/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xclip/module.json.captured index bf06f6fa3..a094b45ed 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xclip/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xclip/module.json.captured @@ -1,6 +1,7 @@ { "module": "xclip", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xdg/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xdg/module.json.captured index c3d191ac3..72b0650a2 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xdg/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xdg/module.json.captured @@ -1,6 +1,7 @@ { "module": "xdg", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ "package-manager" ], diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xorg/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xorg/module.json.captured index 7b0b6b1e7..26550fec3 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xorg/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xorg/module.json.captured @@ -1,6 +1,7 @@ { "module": "xorg", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "package-manager", @@ -9,7 +10,10 @@ "provides": [ { "name": "x11-display", - "reach": "machine" + "reach": "machine", + "credential": { + "form": "none" + } } ], "claims": [ diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xterm/files/xresources-normal b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xterm/files/xresources-normal index d95ee3b9a..8867c3139 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xterm/files/xresources-normal +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xterm/files/xresources-normal @@ -1,31 +1,31 @@ ! xterm: the face, the palette and the clipboard keys. Scoped to the XTerm class, so they ! outrank any `*name` resource of yours and touch no other X program. -XTerm*termName: xterm-256color -XTerm*saveLines: 10000 -XTerm*renderFont: true -XTerm*faceName: JetBrainsMono Nerd Font -XTerm*faceSize: 12 -XTerm*boldMode: false -XTerm*alwaysBoldMode: false -XTerm*allowBoldFonts: true -XTerm*background: #000000 -XTerm*foreground: #a8a8a8 -XTerm*color0: #000000 -XTerm*color8: #666666 -XTerm*color1: #9e1828 -XTerm*color9: #bc5766 -XTerm*color2: #008800 -XTerm*color10: #61a171 -XTerm*color3: #d2bb4b -XTerm*color11: #e7db52 -XTerm*color4: #414171 -XTerm*color12: #5085af -XTerm*color5: #963c59 -XTerm*color13: #a97a99 -XTerm*color6: #418179 -XTerm*color14: #6ba4a4 -XTerm*color7: #bebebe -XTerm*color15: #ffffff +XTerm*termName: ${config:term-name} +XTerm*saveLines: ${config:save-lines} +XTerm*renderFont: ${config:render-font} +XTerm*faceName: ${config:face} +XTerm*faceSize: ${config:size} +XTerm*boldMode: ${config:bold-mode} +XTerm*alwaysBoldMode: ${config:always-bold-mode} +XTerm*allowBoldFonts: ${config:allow-bold-fonts} +XTerm*background: ${config:background} +XTerm*foreground: ${config:foreground} +XTerm*color0: ${config:color0} +XTerm*color8: ${config:color8} +XTerm*color1: ${config:color1} +XTerm*color9: ${config:color9} +XTerm*color2: ${config:color2} +XTerm*color10: ${config:color10} +XTerm*color3: ${config:color3} +XTerm*color11: ${config:color11} +XTerm*color4: ${config:color4} +XTerm*color12: ${config:color12} +XTerm*color5: ${config:color5} +XTerm*color13: ${config:color13} +XTerm*color6: ${config:color6} +XTerm*color14: ${config:color14} +XTerm*color7: ${config:color7} +XTerm*color15: ${config:color15} XTerm*VT100.Translations: #override \n\ - Ctrl Shift ~Alt C: copy-selection(CLIPBOARD) \n\ - Ctrl Shift ~Alt V: insert-selection(CLIPBOARD) + ${config:copy-binding}: copy-selection(CLIPBOARD) \n\ + ${config:paste-binding}: insert-selection(CLIPBOARD) diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xterm/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xterm/module.json.captured index e6a565ac8..195510057 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xterm/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/xterm/module.json.captured @@ -1,6 +1,7 @@ { "module": "xterm", - "version": "1", + "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "package-manager" @@ -21,6 +22,175 @@ "xterm_font", "xterm_colours" ], + "config": { + "face": { + "type": "string", + "description": "The font family xterm draws with, as fc-list names it: JetBrainsMono Nerd Font, because research 026/04 chose it for its glyphs the prompt uses. A family the machine does not have falls back to the nearest installed face (xterm_font says which).", + "pattern": "[A-Za-z0-9 ._-]{1,64}", + "default": "JetBrainsMono Nerd Font" + }, + "size": { + "type": "number", + "description": "The size of xterm's text, in points: 12 reads well on a screen of about 100 DPI, and a denser screen needs a larger size.", + "minimum": 6, + "maximum": 72, + "predefined": "font-size", + "default": 12 + }, + "save-lines": { + "type": "number", + "description": "How many lines of scrollback xterm keeps per terminal: 10000 holds a long build log, and each line costs memory in every open terminal.", + "minimum": 0, + "maximum": 1000000, + "default": 10000 + }, + "term-name": { + "type": "string", + "description": "The TERM value xterm sets for the programs it runs: xterm-256color, because the palette has 256 colours and every program knows the name.", + "pattern": "[A-Za-z0-9._-]{1,64}", + "default": "xterm-256color" + }, + "render-font": { + "type": "boolean", + "description": "Whether xterm draws with fontconfig faces (true) or the old X core fonts (false): true, because the face is a fontconfig family and core fonts cannot show it.", + "default": true + }, + "bold-mode": { + "type": "boolean", + "description": "Whether xterm draws bold text by overstriking the normal face (true): false, because the face has a real bold style and overstriking blurs it.", + "default": false + }, + "always-bold-mode": { + "type": "boolean", + "description": "Whether xterm overstrikes bold even where the face has a bold style (true): false, for the same reason as bold-mode.", + "default": false + }, + "allow-bold-fonts": { + "type": "boolean", + "description": "Whether xterm may use the face's bold style for bold text (true): true, so bold text is drawn with the real bold weight.", + "default": true + }, + "background": { + "type": "string", + "description": "The terminal's background colour, as #rrggbb: black, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#000000" + }, + "foreground": { + "type": "string", + "description": "The terminal's text colour, as #rrggbb: a light grey, easier on the eyes than white on black.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#a8a8a8" + }, + "color0": { + "type": "string", + "description": "Palette entry 0, the normal black, as #rrggbb: #000000, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#000000" + }, + "color1": { + "type": "string", + "description": "Palette entry 1, the normal red, as #rrggbb: #9e1828, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#9e1828" + }, + "color2": { + "type": "string", + "description": "Palette entry 2, the normal green, as #rrggbb: #008800, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#008800" + }, + "color3": { + "type": "string", + "description": "Palette entry 3, the normal yellow, as #rrggbb: #d2bb4b, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#d2bb4b" + }, + "color4": { + "type": "string", + "description": "Palette entry 4, the normal blue, as #rrggbb: #414171, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#414171" + }, + "color5": { + "type": "string", + "description": "Palette entry 5, the normal magenta, as #rrggbb: #963c59, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#963c59" + }, + "color6": { + "type": "string", + "description": "Palette entry 6, the normal cyan, as #rrggbb: #418179, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#418179" + }, + "color7": { + "type": "string", + "description": "Palette entry 7, the normal white, as #rrggbb: #bebebe, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#bebebe" + }, + "color8": { + "type": "string", + "description": "Palette entry 8, the bright black, as #rrggbb: #666666, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#666666" + }, + "color9": { + "type": "string", + "description": "Palette entry 9, the bright red, as #rrggbb: #bc5766, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#bc5766" + }, + "color10": { + "type": "string", + "description": "Palette entry 10, the bright green, as #rrggbb: #61a171, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#61a171" + }, + "color11": { + "type": "string", + "description": "Palette entry 11, the bright yellow, as #rrggbb: #e7db52, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#e7db52" + }, + "color12": { + "type": "string", + "description": "Palette entry 12, the bright blue, as #rrggbb: #5085af, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#5085af" + }, + "color13": { + "type": "string", + "description": "Palette entry 13, the bright magenta, as #rrggbb: #a97a99, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#a97a99" + }, + "color14": { + "type": "string", + "description": "Palette entry 14, the bright cyan, as #rrggbb: #6ba4a4, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#6ba4a4" + }, + "color15": { + "type": "string", + "description": "Palette entry 15, the bright white, as #rrggbb: #ffffff, as both workstations ran it.", + "pattern": "#[0-9a-fA-F]{6}", + "default": "#ffffff" + }, + "copy-binding": { + "type": "string", + "description": "The key combination that copies the selection to the clipboard, in X translation syntax: Ctrl Shift ~Alt C, so a plain Ctrl+C still interrupts the program. It holds no colon, backslash or line break, which would end the resource.", + "pattern": "[^:\\\\\\n]+", + "default": "Ctrl Shift ~Alt C" + }, + "paste-binding": { + "type": "string", + "description": "The key combination that pastes the clipboard, in X translation syntax: Ctrl Shift ~Alt V, the pair of copy-binding. It holds no colon, backslash or line break, which would end the resource.", + "pattern": "[^:\\\\\\n]+", + "default": "Ctrl Shift ~Alt V" + } + }, "items": [ { "collection": "environment", diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/all-syslog.sh b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/all-syslog.sh new file mode 100644 index 000000000..5f601144a --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/all-syslog.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# shellcheck disable=SC2154 +# +# Copyright (C) 2013-2014 Lawrence Livermore National Security, LLC. +# Copyright (c) 2020 by Delphix. All rights reserved. +# + +# +# Log the zevent via syslog. +# + +[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc" +. "${ZED_ZEDLET_DIR}/zed-functions.sh" + +zed_exit_if_ignoring_this_event + +# build a string of name=value pairs for this event +msg="eid=${ZEVENT_EID} class=${ZEVENT_SUBCLASS}" + +if [ "${ZED_SYSLOG_DISPLAY_GUIDS}" = "1" ]; then + [ -n "${ZEVENT_POOL_GUID}" ] && msg="${msg} pool_guid=${ZEVENT_POOL_GUID}" + [ -n "${ZEVENT_VDEV_GUID}" ] && msg="${msg} vdev_guid=${ZEVENT_VDEV_GUID}" +else + [ -n "${ZEVENT_POOL}" ] && msg="${msg} pool='${ZEVENT_POOL}'" + [ -n "${ZEVENT_VDEV_PATH}" ] && msg="${msg} vdev=${ZEVENT_VDEV_PATH##*/}" +fi + +# log pool state if state is anything other than 'ACTIVE' +[ -n "${ZEVENT_POOL_STATE_STR}" ] && [ "$ZEVENT_POOL_STATE" -ne 0 ] && \ + msg="${msg} pool_state=${ZEVENT_POOL_STATE_STR}" + +# Log the following payload nvpairs if they are present +[ -n "${ZEVENT_VDEV_STATE_STR}" ] && msg="${msg} vdev_state=${ZEVENT_VDEV_STATE_STR}" +[ -n "${ZEVENT_CKSUM_ALGORITHM}" ] && msg="${msg} algorithm=${ZEVENT_CKSUM_ALGORITHM}" +[ -n "${ZEVENT_ZIO_SIZE}" ] && msg="${msg} size=${ZEVENT_ZIO_SIZE}" +[ -n "${ZEVENT_ZIO_OFFSET}" ] && msg="${msg} offset=${ZEVENT_ZIO_OFFSET}" +[ -n "${ZEVENT_ZIO_PRIORITY}" ] && msg="${msg} priority=${ZEVENT_ZIO_PRIORITY}" +[ -n "${ZEVENT_ZIO_ERR}" ] && msg="${msg} err=${ZEVENT_ZIO_ERR}" +[ -n "${ZEVENT_ZIO_FLAGS}" ] && msg="${msg} flags=$(printf '0x%x' "${ZEVENT_ZIO_FLAGS}")" + +# log delays that are >= 10 milisec +[ -n "${ZEVENT_ZIO_DELAY}" ] && [ "$ZEVENT_ZIO_DELAY" -gt 10000000 ] && \ + msg="${msg} delay=$((ZEVENT_ZIO_DELAY / 1000000))ms" + +# list the bookmark data together +# shellcheck disable=SC2153 +[ -n "${ZEVENT_ZIO_OBJSET}" ] && \ + msg="${msg} bookmark=${ZEVENT_ZIO_OBJSET}:${ZEVENT_ZIO_OBJECT}:${ZEVENT_ZIO_LEVEL}:${ZEVENT_ZIO_BLKID}" + +zed_log_msg "${msg}" + +exit 0 diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/config.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/config.json new file mode 100644 index 000000000..0984e89a2 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/config.json @@ -0,0 +1 @@ +${config-json} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/resilver_finish-start-scrub.sh b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/resilver_finish-start-scrub.sh new file mode 100644 index 000000000..cafce6fde --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/resilver_finish-start-scrub.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# shellcheck disable=SC2154 +# resilver_finish-start-scrub.sh +# Run a scrub after a resilver +# +# Exit codes: +# 1: Internal error +# 2: Script wasn't enabled in zed.rc +# 3: Scrubs are automatically started for sequential resilvers +[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc" +. "${ZED_ZEDLET_DIR}/zed-functions.sh" + +[ "${ZED_SCRUB_AFTER_RESILVER}" = "1" ] || exit 2 +[ "${ZEVENT_RESILVER_TYPE}" != "sequential" ] || exit 3 +[ -n "${ZEVENT_POOL}" ] || exit 1 +[ -n "${ZEVENT_SUBCLASS}" ] || exit 1 +zed_check_cmd "${ZPOOL}" || exit 1 + +zed_log_msg "Starting scrub after resilver on ${ZEVENT_POOL}" +"${ZPOOL}" scrub "${ZEVENT_POOL}" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/scrub.conf b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/scrub.conf deleted file mode 100644 index daccbd93f..000000000 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/scrub.conf +++ /dev/null @@ -1,6 +0,0 @@ -# Written by the mesh (module zfs) from this machine's assignment. Replaced on every push; change the -# settings scrub-pool, scrub-cadence, scrub-day and scrub-time, never this file. The module's tools read it. -pool=${config:scrub-pool} -cadence=${config:scrub-cadence} -day=${config:scrub-day} -time=${config:scrub-time} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zed-functions.sh b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zed-functions.sh new file mode 100644 index 000000000..78d8f658d --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zed-functions.sh @@ -0,0 +1,825 @@ +#!/bin/sh +# shellcheck disable=SC2154,SC3043 +# zed-functions.sh +# +# ZED helper functions for use in ZEDLETs + + +# Variable Defaults +# +: "${ZED_LOCKDIR:="/var/lock"}" +: "${ZED_NOTIFY_INTERVAL_SECS:=3600}" +: "${ZED_NOTIFY_VERBOSE:=0}" +: "${ZED_RUNDIR:="/var/run"}" +: "${ZED_SYSLOG_PRIORITY:="daemon.notice"}" +: "${ZED_SYSLOG_TAG:="zed"}" + +ZED_FLOCK_FD=8 + + +# zed_check_cmd (cmd, ...) +# +# For each argument given, search PATH for the executable command [cmd]. +# Log a message if [cmd] is not found. +# +# Arguments +# cmd: name of executable command for which to search +# +# Return +# 0 if all commands are found in PATH and are executable +# n for a count of the command executables that are not found +# +zed_check_cmd() +{ + local cmd + local rv=0 + + for cmd; do + if ! command -v "${cmd}" >/dev/null 2>&1; then + zed_log_err "\"${cmd}\" not installed" + rv=$((rv + 1)) + fi + done + return "${rv}" +} + + +# zed_log_msg (msg, ...) +# +# Write all argument strings to the system log. +# +# Globals +# ZED_SYSLOG_PRIORITY +# ZED_SYSLOG_TAG +# +# Return +# nothing +# +zed_log_msg() +{ + logger -p "${ZED_SYSLOG_PRIORITY}" -t "${ZED_SYSLOG_TAG}" -- "$@" +} + + +# zed_log_err (msg, ...) +# +# Write an error message to the system log. This message will contain the +# script name, EID, and all argument strings. +# +# Globals +# ZED_SYSLOG_PRIORITY +# ZED_SYSLOG_TAG +# ZEVENT_EID +# +# Return +# nothing +# +zed_log_err() +{ + zed_log_msg "error: ${0##*/}:""${ZEVENT_EID:+" eid=${ZEVENT_EID}:"}" "$@" +} + + +# zed_lock (lockfile, [fd]) +# +# Obtain an exclusive (write) lock on [lockfile]. If the lock cannot be +# immediately acquired, wait until it becomes available. +# +# Every zed_lock() must be paired with a corresponding zed_unlock(). +# +# By default, flock-style locks associate the lockfile with file descriptor 8. +# The bash manpage warns that file descriptors >9 should be used with care as +# they may conflict with file descriptors used internally by the shell. File +# descriptor 9 is reserved for zed_rate_limit(). If concurrent locks are held +# within the same process, they must use different file descriptors (preferably +# decrementing from 8); otherwise, obtaining a new lock with a given file +# descriptor will release the previous lock associated with that descriptor. +# +# Arguments +# lockfile: pathname of the lock file; the lock will be stored in +# ZED_LOCKDIR unless the pathname contains a "/". +# fd: integer for the file descriptor used by flock (OPTIONAL unless holding +# concurrent locks) +# +# Globals +# ZED_FLOCK_FD +# ZED_LOCKDIR +# +# Return +# nothing +# +zed_lock() +{ + local lockfile="$1" + local fd="${2:-${ZED_FLOCK_FD}}" + local umask_bak + local err + + [ -n "${lockfile}" ] || return + if ! expr "${lockfile}" : '.*/' >/dev/null 2>&1; then + lockfile="${ZED_LOCKDIR}/${lockfile}" + fi + + umask_bak="$(umask)" + umask 077 + + # Obtain a lock on the file bound to the given file descriptor. + # + eval "exec ${fd}>> '${lockfile}'" + if ! err="$(flock --exclusive "${fd}" 2>&1)"; then + zed_log_err "failed to lock \"${lockfile}\": ${err}" + fi + + umask "${umask_bak}" +} + + +# zed_unlock (lockfile, [fd]) +# +# Release the lock on [lockfile]. +# +# Arguments +# lockfile: pathname of the lock file +# fd: integer for the file descriptor used by flock (must match the file +# descriptor passed to the zed_lock function call) +# +# Globals +# ZED_FLOCK_FD +# ZED_LOCKDIR +# +# Return +# nothing +# +zed_unlock() +{ + local lockfile="$1" + local fd="${2:-${ZED_FLOCK_FD}}" + local err + + [ -n "${lockfile}" ] || return + if ! expr "${lockfile}" : '.*/' >/dev/null 2>&1; then + lockfile="${ZED_LOCKDIR}/${lockfile}" + fi + + # Release the lock and close the file descriptor. + if ! err="$(flock --unlock "${fd}" 2>&1)"; then + zed_log_err "failed to unlock \"${lockfile}\": ${err}" + fi + eval "exec ${fd}>&-" +} + + +# zed_notify (subject, pathname) +# +# Send a notification via all available methods. +# +# Arguments +# subject: notification subject +# pathname: pathname containing the notification message (OPTIONAL) +# +# Return +# 0: notification succeeded via at least one method +# 1: notification failed +# 2: no notification methods configured +# +zed_notify() +{ + local subject="$1" + local pathname="$2" + local num_success=0 + local num_failure=0 + + zed_notify_email "${subject}" "${pathname}"; rv=$? + [ "${rv}" -eq 0 ] && num_success=$((num_success + 1)) + [ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1)) + + zed_notify_pushbullet "${subject}" "${pathname}"; rv=$? + [ "${rv}" -eq 0 ] && num_success=$((num_success + 1)) + [ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1)) + + zed_notify_slack_webhook "${subject}" "${pathname}"; rv=$? + [ "${rv}" -eq 0 ] && num_success=$((num_success + 1)) + [ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1)) + + zed_notify_pushover "${subject}" "${pathname}"; rv=$? + [ "${rv}" -eq 0 ] && num_success=$((num_success + 1)) + [ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1)) + + zed_notify_ntfy "${subject}" "${pathname}"; rv=$? + [ "${rv}" -eq 0 ] && num_success=$((num_success + 1)) + [ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1)) + + zed_notify_gotify "${subject}" "${pathname}"; rv=$? + [ "${rv}" -eq 0 ] && num_success=$((num_success + 1)) + [ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1)) + + [ "${num_success}" -gt 0 ] && return 0 + [ "${num_failure}" -gt 0 ] && return 1 + return 2 +} + + +# zed_notify_email (subject, pathname) +# +# Send a notification via email to the address specified by ZED_EMAIL_ADDR. +# +# Requires the mail executable to be installed in the standard PATH, or +# ZED_EMAIL_PROG to be defined with the pathname of an executable capable of +# reading a message body from stdin. +# +# Command-line options to the mail executable can be specified in +# ZED_EMAIL_OPTS. This undergoes the following keyword substitutions: +# - @ADDRESS@ is replaced with the space-delimited recipient email address(es) +# - @SUBJECT@ is replaced with the notification subject +# If @SUBJECT@ was omited here, a "Subject: ..." header will be added to notification +# +# +# Arguments +# subject: notification subject +# pathname: pathname containing the notification message (OPTIONAL) +# +# Globals +# ZED_EMAIL_PROG +# ZED_EMAIL_OPTS +# ZED_EMAIL_ADDR +# +# Return +# 0: notification sent +# 1: notification failed +# 2: not configured +# +zed_notify_email() +{ + local subject="${1:-"ZED notification"}" + local pathname="${2:-"/dev/null"}" + + : "${ZED_EMAIL_PROG:="mail"}" + : "${ZED_EMAIL_OPTS:="-s '@SUBJECT@' @ADDRESS@"}" + + # For backward compatibility with ZED_EMAIL. + if [ -n "${ZED_EMAIL}" ] && [ -z "${ZED_EMAIL_ADDR}" ]; then + ZED_EMAIL_ADDR="${ZED_EMAIL}" + fi + [ -n "${ZED_EMAIL_ADDR}" ] || return 2 + + zed_check_cmd "${ZED_EMAIL_PROG}" || return 1 + + [ -n "${subject}" ] || return 1 + if [ ! -r "${pathname}" ]; then + zed_log_err \ + "${ZED_EMAIL_PROG##*/} cannot read \"${pathname}\"" + return 1 + fi + + # construct cmdline options + ZED_EMAIL_OPTS_PARSED="$(echo "${ZED_EMAIL_OPTS}" \ + | sed -e "s/@ADDRESS@/${ZED_EMAIL_ADDR}/g" \ + -e "s/@SUBJECT@/${subject}/g")" + + # pipe message to email prog + # shellcheck disable=SC2086,SC2248 + { + # no subject passed as option? + if [ "${ZED_EMAIL_OPTS%@SUBJECT@*}" = "${ZED_EMAIL_OPTS}" ] ; then + # inject subject header + printf "Subject: %s\n" "${subject}" + # The following empty line is needed to separate the header from the + # body of the message. Otherwise programs like sendmail will skip + # everything up to the first empty line (or wont send an email at + # all) and will still exit with exit code 0 + printf "\n" + fi + # output message + cat "${pathname}" + } | + eval ${ZED_EMAIL_PROG} ${ZED_EMAIL_OPTS_PARSED} >/dev/null 2>&1 + rv=$? + if [ "${rv}" -ne 0 ]; then + zed_log_err "${ZED_EMAIL_PROG##*/} exit=${rv}" + return 1 + fi + return 0 +} + + +# zed_notify_pushbullet (subject, pathname) +# +# Send a notification via Pushbullet . +# The access token (ZED_PUSHBULLET_ACCESS_TOKEN) identifies this client to the +# Pushbullet server. The optional channel tag (ZED_PUSHBULLET_CHANNEL_TAG) is +# for pushing to notification feeds that can be subscribed to; if a channel is +# not defined, push notifications will instead be sent to all devices +# associated with the account specified by the access token. +# +# Requires awk, curl, and sed executables to be installed in the standard PATH. +# +# References +# https://docs.pushbullet.com/ +# https://www.pushbullet.com/security +# +# Arguments +# subject: notification subject +# pathname: pathname containing the notification message (OPTIONAL) +# +# Globals +# ZED_PUSHBULLET_ACCESS_TOKEN +# ZED_PUSHBULLET_CHANNEL_TAG +# +# Return +# 0: notification sent +# 1: notification failed +# 2: not configured +# +zed_notify_pushbullet() +{ + local subject="$1" + local pathname="${2:-"/dev/null"}" + local msg_body + local msg_tag + local msg_json + local msg_out + local msg_err + local url="https://api.pushbullet.com/v2/pushes" + + [ -n "${ZED_PUSHBULLET_ACCESS_TOKEN}" ] || return 2 + + [ -n "${subject}" ] || return 1 + if [ ! -r "${pathname}" ]; then + zed_log_err "pushbullet cannot read \"${pathname}\"" + return 1 + fi + + zed_check_cmd "awk" "curl" "sed" || return 1 + + # Escape the following characters in the message body for JSON: + # newline, backslash, double quote, horizontal tab, vertical tab, + # and carriage return. + # + msg_body="$(awk '{ ORS="\\n" } { gsub(/\\/, "\\\\"); gsub(/"/, "\\\""); + gsub(/\t/, "\\t"); gsub(/\f/, "\\f"); gsub(/\r/, "\\r"); print }' \ + "${pathname}")" + + # Push to a channel if one is configured. + # + [ -n "${ZED_PUSHBULLET_CHANNEL_TAG}" ] && msg_tag="$(printf \ + '"channel_tag": "%s", ' "${ZED_PUSHBULLET_CHANNEL_TAG}")" + + # Construct the JSON message for pushing a note. + # + msg_json="$(printf '{%s"type": "note", "title": "%s", "body": "%s"}' \ + "${msg_tag}" "${subject}" "${msg_body}")" + + # Send the POST request and check for errors. + # + msg_out="$(curl -u "${ZED_PUSHBULLET_ACCESS_TOKEN}:" -X POST "${url}" \ + --header "Content-Type: application/json" --data-binary "${msg_json}" \ + 2>/dev/null)"; rv=$? + if [ "${rv}" -ne 0 ]; then + zed_log_err "curl exit=${rv}" + return 1 + fi + msg_err="$(echo "${msg_out}" \ + | sed -n -e 's/.*"error" *:.*"message" *: *"\([^"]*\)".*/\1/p')" + if [ -n "${msg_err}" ]; then + zed_log_err "pushbullet \"${msg_err}"\" + return 1 + fi + return 0 +} + + +# zed_notify_slack_webhook (subject, pathname) +# +# Notification via Slack Webhook . +# The Webhook URL (ZED_SLACK_WEBHOOK_URL) identifies this client to the +# Slack channel. +# +# Requires awk, curl, and sed executables to be installed in the standard PATH. +# +# References +# https://api.slack.com/incoming-webhooks +# +# Arguments +# subject: notification subject +# pathname: pathname containing the notification message (OPTIONAL) +# +# Globals +# ZED_SLACK_WEBHOOK_URL +# +# Return +# 0: notification sent +# 1: notification failed +# 2: not configured +# +zed_notify_slack_webhook() +{ + [ -n "${ZED_SLACK_WEBHOOK_URL}" ] || return 2 + + local subject="$1" + local pathname="${2:-"/dev/null"}" + local msg_body + local msg_tag + local msg_json + local msg_out + local msg_err + local url="${ZED_SLACK_WEBHOOK_URL}" + + [ -n "${subject}" ] || return 1 + if [ ! -r "${pathname}" ]; then + zed_log_err "slack webhook cannot read \"${pathname}\"" + return 1 + fi + + zed_check_cmd "awk" "curl" "sed" || return 1 + + # Escape the following characters in the message body for JSON: + # newline, backslash, double quote, horizontal tab, vertical tab, + # and carriage return. + # + msg_body="$(awk '{ ORS="\\n" } { gsub(/\\/, "\\\\"); gsub(/"/, "\\\""); + gsub(/\t/, "\\t"); gsub(/\f/, "\\f"); gsub(/\r/, "\\r"); print }' \ + "${pathname}")" + + # Construct the JSON message for posting. + # shellcheck disable=SC2016 + # + msg_json="$(printf '{"text": "*%s*\\n```%s```"}' "${subject}" "${msg_body}" )" + + # Send the POST request and check for errors. + # + msg_out="$(curl -X POST "${url}" \ + --header "Content-Type: application/json" --data-binary "${msg_json}" \ + 2>/dev/null)"; rv=$? + if [ "${rv}" -ne 0 ]; then + zed_log_err "curl exit=${rv}" + return 1 + fi + msg_err="$(echo "${msg_out}" \ + | sed -n -e 's/.*"error" *:.*"message" *: *"\([^"]*\)".*/\1/p')" + if [ -n "${msg_err}" ]; then + zed_log_err "slack webhook \"${msg_err}"\" + return 1 + fi + return 0 +} + +# zed_notify_pushover (subject, pathname) +# +# Send a notification via Pushover . +# The access token (ZED_PUSHOVER_TOKEN) identifies this client to the +# Pushover server. The user token (ZED_PUSHOVER_USER) defines the user or +# group to which the notification will be sent. +# +# Requires curl and sed executables to be installed in the standard PATH. +# +# References +# https://pushover.net/api +# +# Arguments +# subject: notification subject +# pathname: pathname containing the notification message (OPTIONAL) +# +# Globals +# ZED_PUSHOVER_TOKEN +# ZED_PUSHOVER_USER +# +# Return +# 0: notification sent +# 1: notification failed +# 2: not configured +# +zed_notify_pushover() +{ + local subject="$1" + local pathname="${2:-"/dev/null"}" + local msg_body + local msg_out + local msg_err + local url="https://api.pushover.net/1/messages.json" + + [ -n "${ZED_PUSHOVER_TOKEN}" ] && [ -n "${ZED_PUSHOVER_USER}" ] || return 2 + + if [ ! -r "${pathname}" ]; then + zed_log_err "pushover cannot read \"${pathname}\"" + return 1 + fi + + zed_check_cmd "curl" "sed" || return 1 + + # Read the message body in. + # + msg_body="$(cat "${pathname}")" + + if [ -z "${msg_body}" ] + then + msg_body=$subject + subject="" + fi + + # Send the POST request and check for errors. + # + msg_out="$( \ + curl \ + --form-string "token=${ZED_PUSHOVER_TOKEN}" \ + --form-string "user=${ZED_PUSHOVER_USER}" \ + --form-string "message=${msg_body}" \ + --form-string "title=${subject}" \ + "${url}" \ + 2>/dev/null \ + )"; rv=$? + if [ "${rv}" -ne 0 ]; then + zed_log_err "curl exit=${rv}" + return 1 + fi + msg_err="$(echo "${msg_out}" \ + | sed -n -e 's/.*"errors" *:.*\[\(.*\)\].*/\1/p')" + if [ -n "${msg_err}" ]; then + zed_log_err "pushover \"${msg_err}"\" + return 1 + fi + return 0 +} + + +# zed_notify_ntfy (subject, pathname) +# +# Send a notification via Ntfy.sh . +# The ntfy topic (ZED_NTFY_TOPIC) identifies the topic that the notification +# will be sent to Ntfy.sh server. The ntfy url (ZED_NTFY_URL) defines the +# self-hosted or provided hosted ntfy service location. The ntfy access token +# (ZED_NTFY_ACCESS_TOKEN) reprsents an +# access token that could be used if a topic is read/write protected. If a +# topic can be written to publicaly, a ZED_NTFY_ACCESS_TOKEN is not required. +# +# Requires curl and sed executables to be installed in the standard PATH. +# +# References +# https://docs.ntfy.sh +# +# Arguments +# subject: notification subject +# pathname: pathname containing the notification message (OPTIONAL) +# +# Globals +# ZED_NTFY_TOPIC +# ZED_NTFY_ACCESS_TOKEN (OPTIONAL) +# ZED_NTFY_URL +# +# Return +# 0: notification sent +# 1: notification failed +# 2: not configured +# +zed_notify_ntfy() +{ + local subject="$1" + local pathname="${2:-"/dev/null"}" + local msg_body + local msg_out + local msg_err + + [ -n "${ZED_NTFY_TOPIC}" ] || return 2 + local url="${ZED_NTFY_URL:-"https://ntfy.sh"}/${ZED_NTFY_TOPIC}" + + if [ ! -r "${pathname}" ]; then + zed_log_err "ntfy cannot read \"${pathname}\"" + return 1 + fi + + zed_check_cmd "curl" "sed" || return 1 + + # Read the message body in. + # + msg_body="$(cat "${pathname}")" + + if [ -z "${msg_body}" ] + then + msg_body=$subject + subject="" + fi + + # Send the POST request and check for errors. + # + if [ -n "${ZED_NTFY_ACCESS_TOKEN}" ]; then + msg_out="$( \ + curl \ + -u ":${ZED_NTFY_ACCESS_TOKEN}" \ + -H "Title: ${subject}" \ + -d "${msg_body}" \ + -H "Priority: high" \ + "${url}" \ + 2>/dev/null \ + )"; rv=$? + else + msg_out="$( \ + curl \ + -H "Title: ${subject}" \ + -d "${msg_body}" \ + -H "Priority: high" \ + "${url}" \ + 2>/dev/null \ + )"; rv=$? + fi + if [ "${rv}" -ne 0 ]; then + zed_log_err "curl exit=${rv}" + return 1 + fi + msg_err="$(echo "${msg_out}" \ + | sed -n -e 's/.*"errors" *:.*\[\(.*\)\].*/\1/p')" + if [ -n "${msg_err}" ]; then + zed_log_err "ntfy \"${msg_err}"\" + return 1 + fi + return 0 +} + + +# zed_notify_gotify (subject, pathname) +# +# Send a notification via Gotify . +# The Gotify URL (ZED_GOTIFY_URL) defines a self-hosted Gotify location. +# The Gotify application token (ZED_GOTIFY_APPTOKEN) defines a +# Gotify application token which is associated with a message. +# The optional Gotify priority value (ZED_GOTIFY_PRIORITY) overrides the +# default or configured priority at the Gotify server for the application. +# +# Requires curl and sed executables to be installed in the standard PATH. +# +# References +# https://gotify.net/docs/index +# +# Arguments +# subject: notification subject +# pathname: pathname containing the notification message (OPTIONAL) +# +# Globals +# ZED_GOTIFY_URL +# ZED_GOTIFY_APPTOKEN +# ZED_GOTIFY_PRIORITY +# +# Return +# 0: notification sent +# 1: notification failed +# 2: not configured +# +zed_notify_gotify() +{ + local subject="$1" + local pathname="${2:-"/dev/null"}" + local msg_body + local msg_out + local msg_err + + [ -n "${ZED_GOTIFY_URL}" ] && [ -n "${ZED_GOTIFY_APPTOKEN}" ] || return 2 + local url="${ZED_GOTIFY_URL}/message?token=${ZED_GOTIFY_APPTOKEN}" + + if [ ! -r "${pathname}" ]; then + zed_log_err "gotify cannot read \"${pathname}\"" + return 1 + fi + + zed_check_cmd "curl" "sed" || return 1 + + # Read the message body in. + # + msg_body="$(cat "${pathname}")" + + if [ -z "${msg_body}" ] + then + msg_body=$subject + subject="" + fi + + # Send the POST request and check for errors. + # + if [ -n "${ZED_GOTIFY_PRIORITY}" ]; then + msg_out="$( \ + curl \ + --form-string "title=${subject}" \ + --form-string "message=${msg_body}" \ + --form-string "priority=${ZED_GOTIFY_PRIORITY}" \ + "${url}" \ + 2>/dev/null \ + )"; rv=$? + else + msg_out="$( \ + curl \ + --form-string "title=${subject}" \ + --form-string "message=${msg_body}" \ + "${url}" \ + 2>/dev/null \ + )"; rv=$? + fi + + if [ "${rv}" -ne 0 ]; then + zed_log_err "curl exit=${rv}" + return 1 + fi + msg_err="$(echo "${msg_out}" \ + | sed -n -e 's/.*"errors" *:.*\[\(.*\)\].*/\1/p')" + if [ -n "${msg_err}" ]; then + zed_log_err "gotify \"${msg_err}"\" + return 1 + fi + return 0 +} + + + +# zed_rate_limit (tag, [interval]) +# +# Check whether an event of a given type [tag] has already occurred within the +# last [interval] seconds. +# +# This function obtains a lock on the statefile using file descriptor 9. +# +# Arguments +# tag: arbitrary string for grouping related events to rate-limit +# interval: time interval in seconds (OPTIONAL) +# +# Globals +# ZED_NOTIFY_INTERVAL_SECS +# ZED_RUNDIR +# +# Return +# 0 if the event should be processed +# 1 if the event should be dropped +# +# State File Format +# time;tag +# +zed_rate_limit() +{ + local tag="$1" + local interval="${2:-${ZED_NOTIFY_INTERVAL_SECS}}" + local lockfile="zed.zedlet.state.lock" + local lockfile_fd=9 + local statefile="${ZED_RUNDIR}/zed.zedlet.state" + local time_now + local time_prev + local umask_bak + local rv=0 + + [ -n "${tag}" ] || return 0 + + zed_lock "${lockfile}" "${lockfile_fd}" + time_now="$(date +%s)" + time_prev="$(grep -E "^[0-9]+;${tag}\$" "${statefile}" 2>/dev/null \ + | tail -1 | cut -d\; -f1)" + + if [ -n "${time_prev}" ] \ + && [ "$((time_now - time_prev))" -lt "${interval}" ]; then + rv=1 + else + umask_bak="$(umask)" + umask 077 + grep -E -v "^[0-9]+;${tag}\$" "${statefile}" 2>/dev/null \ + > "${statefile}.$$" + echo "${time_now};${tag}" >> "${statefile}.$$" + mv -f "${statefile}.$$" "${statefile}" + umask "${umask_bak}" + fi + + zed_unlock "${lockfile}" "${lockfile_fd}" + return "${rv}" +} + + +# zed_guid_to_pool (guid) +# +# Convert a pool GUID into its pool name (like "tank") +# Arguments +# guid: pool GUID (decimal or hex) +# +# Return +# Pool name +# +zed_guid_to_pool() +{ + if [ -z "$1" ] ; then + return + fi + + guid="$(printf "%u" "$1")" + $ZPOOL get -H -ovalue,name guid | awk '$1 == '"$guid"' {print $2; exit}' +} + +# zed_exit_if_ignoring_this_event +# +# Exit the script if we should ignore this event, as determined by +# $ZED_SYSLOG_SUBCLASS_INCLUDE and $ZED_SYSLOG_SUBCLASS_EXCLUDE in zed.rc. +# This function assumes you've imported the normal zed variables. +zed_exit_if_ignoring_this_event() +{ + if [ -n "${ZED_SYSLOG_SUBCLASS_INCLUDE}" ]; then + eval "case ${ZEVENT_SUBCLASS} in + ${ZED_SYSLOG_SUBCLASS_INCLUDE});; + *) exit 0;; + esac" + elif [ -n "${ZED_SYSLOG_SUBCLASS_EXCLUDE}" ]; then + eval "case ${ZEVENT_SUBCLASS} in + ${ZED_SYSLOG_SUBCLASS_EXCLUDE}) exit 0;; + *);; + esac" + fi +} diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zed-mesh.conf b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zed-mesh.conf new file mode 100644 index 000000000..196be4669 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zed-mesh.conf @@ -0,0 +1,4 @@ +# Written by the mesh (module zfs). ZED runs from the module's own folder, which holds no link. +[Service] +ExecStart= +ExecStart=/usr/bin/zed -F -d /etc/zfs/mesh-zed.d diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zed.rc b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zed.rc new file mode 100644 index 000000000..562b9f594 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zed.rc @@ -0,0 +1,7 @@ +# Written by the mesh (module zfs). Replaced on every push; change the settings zed and zed-handlers, never this file. +# It holds the package's own variables but its notification and mail lines: a pool's fault reaches the operator once, +# from the event follower's finding, never from a ZED handler. +ZED_USE_ENCLOSURE_LEDS=1 +ZED_SYSLOG_SUBCLASS_EXCLUDE="history_event" +# Read only by the scrub-after-resilver handler, which is placed only while zed-handlers names it. +ZED_SCRUB_AFTER_RESILVER=1 diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zfs.conf b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zfs.conf new file mode 100644 index 000000000..edc788e72 --- /dev/null +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/files/zfs.conf @@ -0,0 +1,5 @@ +# Written by the mesh (module zfs) from this machine's assignment. Replaced on every push; change the +# settings arc-max, arc-min and module-options, never this file. ZFS reads it when its kernel module loads. +${config-lines:arc-max:options zfs zfs_arc_max=:mib-bytes} +${config-lines:arc-min:options zfs zfs_arc_min=:mib-bytes} +${config-lines:module-options:options zfs } diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/module.json.captured index c109320a6..9e41b0586 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zfs/module.json.captured @@ -1,53 +1,266 @@ { "module": "zfs", - "version": "1", + "version": "0.1", + "class": "leaf", "capabilities": [ - "service-manager" + "bus-state-calls", + "ledger-calls", + "package-manager", + "service-manager", + "stream-publish" ], - "emits": [ - "snapshot.taken", - "scrub.requested" + "invokes": [ + "seat:node-service-manager.start" ], - "config": { - "scrub-pool": { - "type": "string", - "description": "The name of the ZFS pool the module scrubs; the operator's, with no default.", - "trusted": true, - "required": true - }, - "scrub-cadence": { - "type": "string", - "description": "How often the pool named by scrub-pool is scrubbed: weekly, or monthly on the first scrub-day of each month. Weekly is what the distribution's timer did on the home server before the module, so taking it over moves nothing until the operator chooses.", - "enum": [ - "weekly", - "monthly" + "consumes": [ + "mesh-conditions.findings-asked" + ], + "own-secrets": { + "broker-keeper": { + "path": "${dir:keeper-state}/broker-keeper.secret", + "owner": "zfs-keeper" + } + }, + "requires": [ + { + "name": "events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "config.applied", + "config.refused", + "config.waiting", + "snapshot.taken.person", + "snapshot.taken.schedule", + "snapshot.removed.person", + "snapshot.removed.schedule", + "snapshot.skipped.person", + "snapshot.skipped.schedule", + "run.skipped", + "scrub.requested" ], - "trusted": true, - "default": "weekly" - }, - "scrub-day": { - "type": "string", - "description": "The weekday the scrub starts, Mon to Sun; for a monthly scrub, the first such day of the month. Checked by the scheduled run, which refuses any other value and runs nothing; Monday is when the distribution's weekly timer fired.", - "enum": [ - "Mon", - "Tue", - "Wed", - "Thu", - "Fri", - "Sat", - "Sun" - ], - "trusted": true, - "default": "Mon" - }, - "scrub-time": { - "type": "string", - "description": "The time the scrub starts, HH:MM from 00:00 to 23:59 in the machine's time zone; the scheduled run checks it every quarter of an hour, so the scrub starts within 15 minutes of it. Midnight is when the distribution's weekly timer fired.", - "pattern": "([01][0-9]|2[0-3]):[0-5][0-9]", - "trusted": true, - "default": "00:00" + "max-age-days": 30 } }, + { + "name": "applied", + "storage": "key-value", + "template": "state" + }, + { + "name": "schedule", + "storage": "key-value", + "template": "state" + }, + { + "name": "snapshots", + "storage": "ledger", + "template": "ledger", + "options": { + "max-mib": 64 + }, + "types": [ + { + "name": "snapshot", + "schema": { + "dataset": { + "type": "string" + }, + "name": { + "type": "string" + }, + "kind": { + "type": "string" + }, + "at": { + "type": "string" + }, + "taken": { + "type": "object" + } + }, + "operations": [ + { + "name": "taken", + "effect": "set-entry", + "into": "taken", + "key": "name", + "fields": [ + "dataset", + "name", + "kind", + "at" + ] + }, + { + "name": "removed", + "effect": "remove", + "into": "taken", + "key": "name" + } + ] + } + ] + }, + { + "name": "findings", + "storage": "key-value", + "template": "state" + }, + { + "name": "finding-events", + "storage": "stream", + "template": "events", + "options": { + "events": [ + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "max-age-days": 7, + "max-mib": 8 + } + } + ], + "config": { + "pool": { + "type": "string", + "description": "The name of the ZFS pool the module owns: scrubs, trims, takes scheduled ZFS snapshots of and converges; the operator's, with no default.", + "trusted": true, + "required": true, + "renamed-from": "scrub-pool" + }, + "scrub-cadence": { + "type": "string", + "description": "How often the pool named by pool is scrubbed: weekly, or monthly on the first scrub-day of each month. Weekly is what the distribution's timer did on the home server before the module, so taking it over moves nothing until the operator chooses.", + "enum": [ + "weekly", + "monthly" + ], + "trusted": true, + "default": "weekly" + }, + "scrub-day": { + "type": "string", + "description": "The weekday the scrub starts, Mon to Sun; for a monthly scrub, the first such day of the month. Checked by the scheduled run, which refuses any other value and runs nothing; Monday is when the distribution's weekly timer fired.", + "enum": [ + "Mon", + "Tue", + "Wed", + "Thu", + "Fri", + "Sat", + "Sun" + ], + "trusted": true, + "default": "Mon" + }, + "scrub-time": { + "type": "string", + "description": "The time the scrub starts, HH:MM from 00:00 to 23:59 in the machine's time zone; the scheduled run checks it every quarter of an hour, so the scrub starts within 15 minutes of it. Midnight is when the distribution's weekly timer fired.", + "pattern": "([01][0-9]|2[0-3]):[0-5][0-9]", + "trusted": true, + "default": "00:00" + }, + "arc-max": { + "type": "number", + "description": "The most ZFS's read cache in memory (the ARC) may hold, in whole MiB: at least 64 and below the node's memory. Written live and into the options file. Not managed until set.", + "minimum": 64, + "trusted": false + }, + "arc-min": { + "type": "number", + "description": "The least the ARC keeps, in whole MiB, not above arc-max. Written live and into the options file. Not managed until set.", + "minimum": 0, + "trusted": false + }, + "module-options": { + "type": "list", + "description": "Kernel module parameters, each name=digits, from l2arc_write_max, l2arc_write_boost, l2arc_headroom, l2arc_noprefetch, l2arc_rebuild_enabled, zfs_txg_timeout, zfs_dirty_data_max, zfs_scan_vdev_limit, zfs_scrub_min_time_ms, zfs_resilver_min_time_ms and zfs_arc_sys_free (arc-max and arc-min hold the ARC's). Written into the options file; a live one is also written live, the others take effect at the next load of the kernel module. An empty list is not managed.", + "trusted": true + }, + "hostid": { + "type": "string", + "description": "The node's ZFS id: eight hexadecimal digits, not all zero, written to /etc/hostid with ZFS's own writer only when the pool's label holds 0 or this value. Changing it needs a check of the pool's import at the next boot; the module never reboots. Not managed until set.", + "pattern": "^[0-9a-fA-F]{8}$", + "trusted": true + }, + "zed": { + "type": "string", + "description": "Whether the ZFS event daemon runs from the module's own folder: on or off. Not managed until set.", + "enum": [ + "on", + "off" + ], + "trusted": false + }, + "zed-handlers": { + "type": "list", + "description": "The event handlers placed in the module's folder: all-syslog (the journal handler) and resilver_finish-start-scrub (a scrub after a resilver). Empty is not managed.", + "trusted": true + }, + "trim-schedule": { + "type": "string", + "description": "How often the pool is trimmed by the scheduled run: none, weekly, or monthly on the first trim-day of each month. Any set value holds the distribution's trim timers stopped. Needs trim-day and trim-time for weekly and monthly. Not managed until set.", + "enum": [ + "none", + "weekly", + "monthly" + ], + "trusted": false + }, + "trim-day": { + "type": "string", + "description": "The weekday the trim starts, Mon to Sun; for monthly, the first such day of the month. Not managed until set.", + "enum": [ + "Mon", + "Tue", + "Wed", + "Thu", + "Fri", + "Sat", + "Sun" + ], + "trusted": false + }, + "trim-time": { + "type": "string", + "description": "The time the trim starts, HH:MM in the machine's time zone, within 15 minutes. Not managed until set.", + "pattern": "([01][0-9]|2[0-3]):[0-5][0-9]", + "trusted": false + }, + "cache-devices": { + "type": "list", + "description": "The pool's cache devices, by their names under /dev/disk/by-id: letters, digits, -, _, . and : only. A kernel-named member is re-added by its stable name; an empty list removes nothing and is not managed.", + "trusted": true + }, + "log-devices": { + "type": "list", + "description": "The pool's log devices, by their names under /dev/disk/by-id. An empty list removes nothing and is not managed.", + "trusted": true + }, + "log-mirror": { + "type": "boolean", + "description": "Whether log-devices are one mirror: true needs exactly two names, added as one mirror; otherwise each is a log device of its own. Not managed until set.", + "trusted": true + }, + "pool-properties": { + "type": "object", + "description": "The pool's properties: autotrim, autoexpand, autoreplace (on, off or default) and failmode (wait, continue, panic or default). Not managed until set.", + "trusted": true + }, + "dataset-properties": { + "type": "object", + "description": "Per dataset of the pool, its properties: compression, atime, relatime, recordsize, primarycache, secondarycache, sync, logbias, quota and reservation, each in its own form; never sharenfs or sharesmb. Not managed until set.", + "trusted": true + }, + "snapshots": { + "type": "object", + "description": "The scheduled ZFS snapshots of every filesystem of the pool: {\"none\": true}, or keep counts hourly, daily, weekly and monthly, each a whole number from 0 to 168; a count of 0 takes none of that kind and removes none. Only snapshots the module took, named mesh-- and recorded in its ledger, are ever removed. Not managed until set.", + "trusted": true + } + }, "tools": [ "zfs_datasets", "zfs_snapshots", @@ -59,6 +272,17 @@ "zfs_scrub_start", "zfs_scrub_pause", "zfs_scrub_stop", + "zfs_snapshots_run_now", + "zfs_snapshots_prune_now", + "zfs_config_apply", + "zfs_snapshots_pause", + "zfs_snapshots_resume", + "zfs_snapshots_record", + "zfs_config", + "zfs_snapshots_schedule", + "zfs_module_events", + "zfs_snapshots_check", + "zfs_findings", "zfs_io", "zfs_arc", "zfs_events", @@ -118,6 +342,310 @@ ] }, "resources": [ + { + "id": "utils", + "type": "package", + "package": "zfs-utils" + }, + { + "id": "dkms", + "type": "package", + "package": "zfs-dkms" + }, + { + "id": "state-dir", + "type": "directory", + "path": "/var/lib/zfs-tools", + "mode": "0755", + "owner": "${machine:account}", + "unknown": "program" + }, + { + "id": "cursor-dir", + "type": "directory", + "path": "/run/zfs-events", + "mode": "0700", + "unknown": "program" + }, + { + "id": "run-dir", + "type": "directory", + "path": "/run/zfs-tools", + "mode": "0755", + "unknown": "program" + }, + { + "id": "keeper-account", + "type": "user", + "name": "zfs-keeper", + "shell": "/usr/bin/nologin" + }, + { + "id": "keeper-state", + "type": "directory", + "mode": "0711", + "owner": "zfs-keeper", + "place": "mesh", + "unknown": "program" + }, + { + "id": "config-dir", + "type": "directory", + "path": "/etc/zfs-tools", + "mode": "0755", + "unknown": "program" + }, + { + "id": "scrub-state-dir", + "type": "directory", + "path": "/var/lib/zfs-scrub", + "mode": "0700", + "unknown": "program" + }, + { + "id": "config", + "type": "file", + "path": "/etc/zfs-tools/config.json", + "mode": "0644", + "template": "files/config.json", + "trusted": false + }, + { + "id": "options", + "type": "file", + "path": "/etc/modprobe.d/zfs.conf", + "mode": "0644", + "template": "files/zfs.conf", + "if-config": [ + "arc-max", + "arc-min", + "module-options" + ] + }, + { + "id": "zed-dir", + "type": "directory", + "path": "/etc/zfs/mesh-zed.d", + "mode": "0755", + "unknown": "module", + "if-config": [ + "zed=on" + ] + }, + { + "id": "zed-rc", + "type": "file", + "path": "/etc/zfs/mesh-zed.d/zed.rc", + "mode": "0644", + "template": "files/zed.rc", + "if-config": [ + "zed=on" + ] + }, + { + "id": "zed-functions", + "type": "file", + "path": "/etc/zfs/mesh-zed.d/zed-functions.sh", + "mode": "0644", + "template": "files/zed-functions.sh", + "if-config": [ + "zed=on" + ], + "names-on-purpose": { + "api.pushbullet.com": "the distribution's own zed-functions.sh, kept as the package ships it (A-2): its notifier functions name the notification services' sites in their comments and urls, and none is used unless the operator's zed.rc enables it", + "api.pushover.net": "the distribution's own zed-functions.sh, kept as the package ships it (A-2): its notifier functions name the notification services' sites in their comments and urls, and none is used unless the operator's zed.rc enables it", + "api.slack.com": "the distribution's own zed-functions.sh, kept as the package ships it (A-2): its notifier functions name the notification services' sites in their comments and urls, and none is used unless the operator's zed.rc enables it", + "docs.pushbullet.com": "the distribution's own zed-functions.sh, kept as the package ships it (A-2): its notifier functions name the notification services' sites in their comments and urls, and none is used unless the operator's zed.rc enables it", + "gotify.net": "the distribution's own zed-functions.sh, kept as the package ships it (A-2): its notifier functions name the notification services' sites in their comments and urls, and none is used unless the operator's zed.rc enables it", + "pushover.net": "the distribution's own zed-functions.sh, kept as the package ships it (A-2): its notifier functions name the notification services' sites in their comments and urls, and none is used unless the operator's zed.rc enables it", + "www.pushbullet.com": "the distribution's own zed-functions.sh, kept as the package ships it (A-2): its notifier functions name the notification services' sites in their comments and urls, and none is used unless the operator's zed.rc enables it" + } + }, + { + "id": "zed-handler-all-syslog", + "type": "file", + "path": "/etc/zfs/mesh-zed.d/all-syslog.sh", + "mode": "0755", + "template": "files/all-syslog.sh", + "if-config": [ + "zed-handlers=all-syslog" + ] + }, + { + "id": "zed-handler-scrub-after-resilver", + "type": "file", + "path": "/etc/zfs/mesh-zed.d/resilver_finish-start-scrub.sh", + "mode": "0755", + "template": "files/resilver_finish-start-scrub.sh", + "if-config": [ + "zed-handlers=resilver_finish-start-scrub" + ] + }, + { + "id": "zed-drop-ins", + "type": "directory", + "path": "/etc/systemd/system/zfs-zed.service.d", + "mode": "0755", + "unknown": "program", + "if-config": [ + "zed=on" + ] + }, + { + "id": "zed-drop-in", + "type": "file", + "path": "/etc/systemd/system/zfs-zed.service.d/mesh.conf", + "mode": "0644", + "template": "files/zed-mesh.conf", + "if-config": [ + "zed=on" + ] + }, + { + "id": "import-cache", + "type": "service", + "unit": "zfs-import-cache.service", + "state": "running", + "boot": "enabled", + "health": { + "kind": "unit" + } + }, + { + "id": "mount", + "type": "service", + "unit": "zfs-mount.service", + "state": "running", + "boot": "enabled", + "health": { + "kind": "unit" + } + }, + { + "id": "target", + "type": "service", + "unit": "zfs.target", + "state": "running", + "boot": "enabled", + "health": { + "kind": "unit" + } + }, + { + "id": "import-scan", + "type": "service", + "unit": "zfs-import-scan.service" + }, + { + "id": "share", + "type": "service", + "unit": "zfs-share.service" + }, + { + "id": "volume-wait", + "type": "service", + "unit": "zfs-volume-wait.service" + }, + { + "id": "import-target", + "type": "service", + "unit": "zfs-import.target" + }, + { + "id": "zed-on", + "type": "service", + "unit": "zfs-zed.service", + "state": "running", + "boot": "enabled", + "if-config": [ + "zed=on" + ], + "restart-on": [ + "zed-rc", + "zed-functions", + "zed-handler-all-syslog", + "zed-handler-scrub-after-resilver", + "zed-drop-in" + ], + "health": { + "kind": "unit" + } + }, + { + "id": "zed-off", + "type": "service", + "unit": "zfs-zed.service", + "state": "stopped", + "boot": "disabled", + "if-config": [ + "zed=off" + ] + }, + { + "id": "keeper", + "type": "process", + "name": "zfs-keeper", + "artifact": "tools", + "run": [ + "./zfs-tools", + "keeper" + ], + "user": "zfs-keeper", + "env": { + "MESH_BROKER_FILE": "${dir:keeper-state}/broker-keeper.secret", + "ZFS_KEEPER_SOCKET": "${dir:keeper-state}/keeper.sock" + }, + "bus": { + "state": [ + "applied", + "schedule", + "findings" + ], + "emits": [ + "config.applied", + "config.refused", + "config.waiting", + "snapshot.taken.person", + "snapshot.taken.schedule", + "snapshot.removed.person", + "snapshot.removed.schedule", + "snapshot.skipped.person", + "snapshot.skipped.schedule", + "run.skipped", + "finding-written.*", + "finding-cleared.*", + "findings-stated.*" + ], + "consumes": [ + "mesh-conditions.findings-asked" + ], + "invokes": [ + "zfs.zfs_snapshots_record", + "zfs.zfs_snapshots_schedule", + "seat:node-service-manager.start" + ] + }, + "health": { + "kind": "unit" + } + }, + { + "id": "apply", + "type": "process", + "name": "zfs-config-apply", + "artifact": "tools", + "run": [ + "./zfs-tools", + "apply" + ], + "run-once": true, + "restart-on": [ + "config" + ], + "env": { + "ZFS_KEEPER_SOCKET": "${dir:keeper-state}/keeper.sock" + } + }, { "id": "watch", "type": "process", @@ -137,21 +665,6 @@ "grace": "60s" } }, - { - "id": "state-dir", - "type": "directory", - "path": "/var/lib/zfs-tools", - "mode": "0755", - "owner": "${machine:account}", - "unknown": "program" - }, - { - "id": "cursor-dir", - "type": "directory", - "path": "/run/zfs-events", - "mode": "0700", - "unknown": "program" - }, { "id": "events", "type": "process", @@ -163,53 +676,62 @@ ], "health": { "kind": "unit" + }, + "env": { + "ZFS_KEEPER_SOCKET": "${dir:keeper-state}/keeper.sock" } }, { - "id": "config-dir", - "type": "directory", - "path": "/etc/zfs-tools", - "mode": "0755", - "unknown": "program" - }, - { - "id": "scrub-config", - "type": "file", - "path": "/etc/zfs-tools/scrub.conf", - "mode": "0644", - "template": "files/scrub.conf" - }, - { - "id": "scrub-state-dir", - "type": "directory", - "path": "/var/lib/zfs-scrub", - "mode": "0700", - "unknown": "program" - }, - { - "id": "scrub-run", + "id": "run", "type": "process", - "name": "zfs-mesh-scrub", + "name": "zfs-mesh-run", "artifact": "tools", "run": [ "./zfs-tools", - "scrub-run" + "run" ], - "schedule": "*/15 * * * *" + "schedule": "0,15,30,45 * * * *", + "env": { + "ZFS_KEEPER_SOCKET": "${dir:keeper-state}/keeper.sock" + } }, { "id": "distribution-weekly", "type": "service", - "unit": "zfs-scrub-weekly@${config:scrub-pool}.timer", + "unit": "zfs-scrub-weekly@${config:pool}.timer", "state": "stopped", "boot": "disabled" }, { "id": "distribution-monthly", "type": "service", - "unit": "zfs-scrub-monthly@${config:scrub-pool}.timer", + "unit": "zfs-scrub-monthly@${config:pool}.timer", "state": "stopped", "boot": "disabled" + }, + { + "id": "distribution-trim-weekly", + "type": "service", + "unit": "zfs-trim-weekly@${config:pool}.timer", + "state": "stopped", + "boot": "disabled", + "if-config": [ + "trim-schedule=none", + "trim-schedule=weekly", + "trim-schedule=monthly" + ] + }, + { + "id": "distribution-trim-monthly", + "type": "service", + "unit": "zfs-trim-monthly@${config:pool}.timer", + "state": "stopped", + "boot": "disabled", + "if-config": [ + "trim-schedule=none", + "trim-schedule=weekly", + "trim-schedule=monthly" + ] } ], "build": { diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zsh-autosuggestions/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zsh-autosuggestions/module.json.captured index e8839210f..16415c596 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zsh-autosuggestions/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zsh-autosuggestions/module.json.captured @@ -1,6 +1,7 @@ { "module": "zsh-autosuggestions", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zsh-syntax-highlighting/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zsh-syntax-highlighting/module.json.captured index b9c81a90c..8fa4c1cb4 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zsh-syntax-highlighting/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zsh-syntax-highlighting/module.json.captured @@ -1,6 +1,7 @@ { "module": "zsh-syntax-highlighting", - "version": "1", + "version": "0.1", + "class": "leaf", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zsh/module.json.captured b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zsh/module.json.captured index 028f2213d..c4bbfb570 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zsh/module.json.captured +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/modules/zsh/module.json.captured @@ -1,6 +1,7 @@ { "module": "zsh", "version": "0.1", + "class": "core", "moved": true, "capabilities": [ "package-manager" diff --git a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/predefined.json b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/predefined.json index 9e536767b..56ba37d0c 100644 --- a/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/predefined.json +++ b/modules/mesh-delivery-indexer/testdata/beside/mesh-catalog/predefined.json @@ -9,5 +9,10 @@ "description": "The size a desktop program shows its text in, in points.", "minimum": 6, "maximum": 72 + }, + "upgrade-order": { + "type": "list", + "description": "The nodes in the order they upgrade, each by its name: the first opens each week's round of upgrades, and each node upgrades only after the one before it passed its after-upgrade check. Empty or unset: no round starts.", + "trusted": true } }