From 5f4eb03fcf1dca79ccde18b7110aa95e05cab3af Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 05:04:11 +0100 Subject: [PATCH] Join: the assigner's composition-run test reads no case verdicts The assigner branch was built before SDK-C took Case.Verdicts out of the composer's request; its test still read the field, so the joined line did not compile. Builds: design 47 H H-A-112 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../meshdeliverycheckerclient/client.go | 341 ----------- .../meshdeliverycheckerclient/client_test.go | 269 --------- .../meshdeliverycheckerclient/codec.go | 150 ----- .../clients/meshdeliverycheckerclient/go.mod | 8 - .../meshdeliverycheckerclient/input.go | 53 -- .../go/seats/meshdeliverychecker/contract.go | 490 --------------- .../meshdeliverychecker/contract_test.go | 82 --- contracts/go/seats/meshdeliverychecker/go.mod | 3 - .../compositionrun_test.go | 4 +- .../meshdeliverycheckerclient/client.go | 341 ----------- .../meshdeliverycheckerclient/client_test.go | 269 --------- .../meshdeliverycheckerclient/codec.go | 150 ----- .../clients/meshdeliverycheckerclient/go.mod | 8 - .../meshdeliverycheckerclient/input.go | 53 -- .../go/seats/meshdeliverychecker/contract.go | 566 ------------------ .../meshdeliverychecker/contract_test.go | 86 --- .../go/seats/meshdeliverychecker/go.mod | 3 - .../ts/seats/meshdeliverychecker/index.d.ts | 371 ------------ .../ts/seats/meshdeliverychecker/index.js | 138 ----- .../meshdeliverychecker/package-lock.json | 12 - .../ts/seats/meshdeliverychecker/package.json | 18 - 21 files changed, 2 insertions(+), 3413 deletions(-) delete mode 100644 contracts/go/clients/meshdeliverycheckerclient/client.go delete mode 100644 contracts/go/clients/meshdeliverycheckerclient/client_test.go delete mode 100644 contracts/go/clients/meshdeliverycheckerclient/codec.go delete mode 100644 contracts/go/clients/meshdeliverycheckerclient/go.mod delete mode 100644 contracts/go/clients/meshdeliverycheckerclient/input.go delete mode 100644 contracts/go/seats/meshdeliverychecker/contract.go delete mode 100644 contracts/go/seats/meshdeliverychecker/contract_test.go delete mode 100644 contracts/go/seats/meshdeliverychecker/go.mod delete mode 100644 modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/client.go delete mode 100644 modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/client_test.go delete mode 100644 modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/codec.go delete mode 100644 modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/go.mod delete mode 100644 modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/input.go delete mode 100644 modules/mesh-delivery-contracts/go/seats/meshdeliverychecker/contract.go delete mode 100644 modules/mesh-delivery-contracts/go/seats/meshdeliverychecker/contract_test.go delete mode 100644 modules/mesh-delivery-contracts/go/seats/meshdeliverychecker/go.mod delete mode 100644 modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/index.d.ts delete mode 100644 modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/index.js delete mode 100644 modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/package-lock.json delete mode 100644 modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/package.json diff --git a/contracts/go/clients/meshdeliverycheckerclient/client.go b/contracts/go/clients/meshdeliverycheckerclient/client.go deleted file mode 100644 index 7e2acbf3..00000000 --- a/contracts/go/clients/meshdeliverycheckerclient/client.go +++ /dev/null @@ -1,341 +0,0 @@ -// Package meshdeliverycheckerclient holds the logic the holders and callers of the seat mesh-delivery-checker share over its -// contract (novox/hq ADR 0625 §4, ADR 0634 §2): the rules a verdict and a kept verdict must keep to be written or read. The -// checker writes them, and the view, the gate and the indexer read them; the contract's decoding is strict by schema only, so -// these rules are written once here and no caller copies them. -package meshdeliverycheckerclient - -import ( - "fmt" - pathpkg "path" - "strings" - - checker "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-sdk/go/keys" -) - -// The states of a verdict, the levels of a check and the compositions' states. -const ( - VerdictRunning = "running" - VerdictPass = "pass" - VerdictFail = "fail" - - LevelUnit = "unit" - LevelIntegration = "integration" - - CompositionNotRun = "not-run" - CompositionPass = "pass" - CompositionFail = "fail" -) - -// MaxFailures is the most failures a verdict names; it names the count of the rest beside them. -const MaxFailures = 50 - -func checkLevel(level string) error { - if level != LevelUnit && level != LevelIntegration { - return fmt.Errorf("meshdeliverycheckerclient: the level %q is not %s or %s", level, LevelUnit, LevelIntegration) - } - return nil -} - -func isHex12(s string) bool { return len(s) == 12 && strings.Trim(s, "0123456789abcdef") == "" } - -// CheckRepository refuses a repository that is not / with exactly one slash, each part a key part. -func CheckRepository(repository string) error { - owner, name, ok := strings.Cut(repository, "/") - if !ok || strings.Contains(name, "/") { - return fmt.Errorf("meshdeliverycheckerclient: the repository %q is not /, with exactly one slash", repository) - } - if err := keys.CheckName("repository owner", owner); err != nil { - return fmt.Errorf("meshdeliverycheckerclient: the repository %q: %w", repository, err) - } - if err := keys.CheckName("repository name", name); err != nil { - return fmt.Errorf("meshdeliverycheckerclient: the repository %q: %w", repository, err) - } - return nil -} - -func checkComposition(c *checker.VerdictsByGroupHeadsValueComposition) error { - if c == nil { - return nil - } - switch c.State { - case CompositionNotRun: - if c.Sdk != "" || len(c.Machines) > 0 { - return fmt.Errorf("meshdeliverycheckerclient: the verdict's composition is not run and names no mesh-sdk commit or machines") - } - case CompositionPass: - if c.Sdk == "" { - return fmt.Errorf("meshdeliverycheckerclient: the verdict's composition passed and names no mesh-sdk commit") - } - case CompositionFail: - if c.Words == "" { - return fmt.Errorf("meshdeliverycheckerclient: the verdict's composition failed and gives no words") - } - default: - return fmt.Errorf("meshdeliverycheckerclient: the verdict's composition state %q is not %s, %s or %s", c.State, CompositionNotRun, CompositionPass, CompositionFail) - } - return nil -} - -// checkJudgedBy refuses a checking program named at no repository, full commit and package, kept under no program key, -// or over no head or a head at no full commit (novox/hq ADR 0644, ADR 0656; issue 1921). -func checkJudgedBy(j *checker.VerdictsByGroupHeadsValueJudgedBy) error { - const who = "meshdeliverycheckerclient: " - if j == nil { - return nil - } - if CheckRepository(j.Program.Repository) != nil || !isCommit(j.Program.Commit) || j.Program.Package == "" { - return fmt.Errorf(who+"the verdict is judged by a checking program built at no repository, full commit and package (%+v)", j.Program) - } - if !strings.HasPrefix(j.Key, "program-") { - return fmt.Errorf(who+"the verdict's checking program is kept under %q, which is no program key", j.Key) - } - if len(j.Heads) == 0 { - return fmt.Errorf(who + "the verdict's checking program read no head") - } - for _, h := range j.Heads { - if CheckRepository(h.Repository) != nil || !isCommit(h.Commit) { - return fmt.Errorf(who+"the verdict's checking program read %s at %q, which is no full commit", h.Repository, h.Commit) - } - } - return nil -} - -func isCommit(s string) bool { return len(s) == 40 && strings.Trim(s, "0123456789abcdef") == "" } - -// CheckVerdict refuses a verdict a reader could not place: no group, heads that are not 12 lowercase hex digits, a repository -// both merged and read beside, a carried-from that carries nothing, a series change from a series to itself or named twice, a -// level that is neither unit nor integration or counts a negative number, a time below zero, a pass that says nothing of a -// level, a fail that names neither a test nor a machine, and failures on a verdict that did not fail. -func CheckVerdict(v checker.VerdictsByGroupHeadsValue) error { - const who = "meshdeliverycheckerclient: " - if v.Group == "" { - return fmt.Errorf(who + "a verdict names no group") - } - if !isHex12(v.Heads) { - return fmt.Errorf(who+"the verdict's heads hash %q is not 12 lowercase hex digits", v.Heads) - } - for repository, head := range v.Trunk { - if head == "" { - return fmt.Errorf(who+"the verdict's trunk head of %s is empty", repository) - } - } - for repository, commit := range v.Beside { - if commit == "" { - return fmt.Errorf(who+"the verdict's sibling commit of %s is empty", repository) - } - if _, ok := v.Trunk[repository]; ok { - return fmt.Errorf(who+"the verdict names %s as a trunk it merged and as a sibling it read", repository) - } - } - if len(v.CarriedFrom) > 0 { - if v.State == VerdictRunning { - return fmt.Errorf(who + "a running verdict is carried from nothing: carried-from is written with its end") - } - moved := false - for repository, commit := range v.CarriedFrom { - now, inTrunk := v.Trunk[repository] - if !inTrunk { - now = v.Beside[repository] - } - if commit == "" || now == "" { - return fmt.Errorf(who+"the verdict's carried-from names %s, which it judged on no commit of", repository) - } - moved = moved || commit != now - } - if !moved { - return fmt.Errorf(who + "the verdict's carried-from names the commits it is judged on: nothing moved, so nothing was carried") - } - } - changed := map[string]bool{} - for _, c := range v.Series { - if c.Module == "" || c.Artifact == "" || c.From == "" || c.To == "" { - return fmt.Errorf(who+"the verdict's series change %+v names no module, artifact, from or to", c) - } - if c.From == c.To { - return fmt.Errorf(who+"the verdict's series change of %s/%s is from %s to the same series", c.Module, c.Artifact, c.From) - } - if changed[c.Module+"/"+c.Artifact] { - return fmt.Errorf(who+"the verdict names the series change of %s/%s twice", c.Module, c.Artifact) - } - changed[c.Module+"/"+c.Artifact] = true - } - for level, r := range v.Levels { - if err := checkLevel(level); err != nil { - return err - } - if r.Run < 0 || r.Kept < 0 || r.Skipped < 0 { - return fmt.Errorf(who+"the verdict's %s level counts a negative number of tests", level) - } - } - if err := checkComposition(v.Composition); err != nil { - return err - } - if err := checkJudgedBy(v.JudgedBy); err != nil { - return err - } - seen := map[string]bool{} - for _, level := range v.OverBound { - if err := checkLevel(level); err != nil { - return fmt.Errorf(who+"the verdict's over-bound names: %w", err) - } - if seen[level] { - return fmt.Errorf(who+"the verdict's over-bound names the level %s twice", level) - } - seen[level] = true - } - if t := v.Took; t != nil { - for part, ms := range map[string]int64{"queue": t.Queue, "clone": t.Clone, "unit": t.Unit, "lint": t.Lint, - "integration-setup": t.IntegrationSetup, "integration-run": t.IntegrationRun, "composition": t.Composition} { - if ms < 0 { - return fmt.Errorf(who+"the verdict's time of the part %s is negative", part) - } - } - } - named := v.Failed != nil && (v.Failed.Test != "" || v.Failed.Machine != "") - if len(v.Failures) > 0 && v.State != VerdictFail { - return fmt.Errorf(who+"a %s verdict names no failures", v.State) - } - if len(v.Failures) > MaxFailures+1 { - return fmt.Errorf(who+"the verdict names %d failures, more than %d and the count of the rest", len(v.Failures), MaxFailures) - } - switch v.State { - case VerdictRunning: - if v.Failed != nil && *v.Failed != (checker.VerdictsByGroupHeadsValueFailed{}) { - return fmt.Errorf(who + "a running verdict names no failure") - } - case VerdictPass: - if v.Failed != nil && *v.Failed != (checker.VerdictsByGroupHeadsValueFailed{}) { - return fmt.Errorf(who + "a pass names no failure") - } - for _, level := range []string{LevelUnit, LevelIntegration} { - if _, ok := v.Levels[level]; !ok { - return fmt.Errorf(who+"a pass says nothing of the %s level", level) - } - } - case VerdictFail: - if !named { - return fmt.Errorf(who + "a fail names neither a test nor a machine") - } - default: - return fmt.Errorf(who+"the verdict state %q is not running, pass or fail", v.State) - } - return nil -} - -// CheckKept refuses a kept verdict that is not a pass of a repository's package at a level, with its toolchain and its time: -// a failure is never kept. -func CheckKept(k checker.KeptByLevelDigestValue) error { - const who = "meshdeliverycheckerclient: " - if k.State != VerdictPass { - return fmt.Errorf(who+"a kept verdict is a pass, never %q: a failure is never kept", k.State) - } - if err := CheckRepository(k.Repository); err != nil { - return err - } - if k.Package == "" { - return fmt.Errorf(who + "a kept verdict names no package") - } - if err := checkLevel(k.Level); err != nil { - return err - } - if k.Tests < 0 || k.Took < 0 { - return fmt.Errorf(who + "a kept verdict counts a negative number of tests or a negative time") - } - if k.Toolchain == "" { - return fmt.Errorf(who + "a kept verdict names no toolchain version") - } - if k.At == "" { - return fmt.Errorf(who + "a kept verdict says no time") - } - return nil -} - -// CheckPreview refuses a preview a reader could not place (the checker writes it, the indexer reads it for the candidates' -// fingerprints): a repository, head or trunk commit that does not key, a head in conflict that names no file or has a merge -// commit or modules, a head that merged and names no merge commit, and a module with no directory, no tree, a manifest -// digest that is not 64 lowercase hex digits, a lock without path or hash, or a named path that is not clean and inside the -// module's directory or names no git object. -func CheckPreview(p checker.PreviewsByRepositoryHeadTrunkValue) error { - const who = "meshdeliverycheckerclient: " - if err := CheckRepository(p.Repository); err != nil { - return err - } - if err := keys.CheckName("head", p.Head); err != nil { - return fmt.Errorf(who+"the preview: %w", err) - } - if err := keys.CheckName("trunk commit", p.Trunk); err != nil { - return fmt.Errorf(who+"the preview: %w", err) - } - for _, f := range p.Conflicts { - if f == "" { - return fmt.Errorf(who + "a preview names a conflicting file with an empty path") - } - } - if len(p.Conflicts) > 0 { - if p.Merge != "" || len(p.Modules) > 0 { - return fmt.Errorf(who + "a preview of a head in conflict has no merge commit and no modules") - } - return nil - } - if p.Merge == "" { - return fmt.Errorf(who + "a preview names no merge commit") - } - for dir, m := range p.Modules { - if dir == "" { - return fmt.Errorf(who + "a preview names a module with an empty directory") - } - if m.Tree == "" { - return fmt.Errorf(who+"the preview's module %q has no tree", dir) - } - if !keys.IsHex64(m.Manifest) { - return fmt.Errorf(who+"the preview's module %q: %q is not a manifest digest, 64 lowercase hex digits", dir, m.Manifest) - } - for path, hash := range m.Locks { - if path == "" || hash == "" { - return fmt.Errorf(who+"the lock %q of the preview's module %q has an empty path or hash", path, dir) - } - } - for p, object := range m.Paths { - if p == "" || p != pathpkg.Clean(p) || strings.HasPrefix(p, "/") || p == ".." || strings.HasPrefix(p, "../") { - return fmt.Errorf(who+"the preview's module %q: the named path %q is not a clean path inside the module's directory", dir, p) - } - if object == "" { - return fmt.Errorf(who+"the preview's module %q: the named path %q names no git object", dir, p) - } - } - } - return nil -} - -// VerdictKey is the key, in the state verdicts, of a group's check at its heads: `.`, the -// group escaped so a branch such as `fix/1.2` keys, the heads hash as the mesh-delivery client's HeadsHash gives it -// (12 lowercase hex digits). -func VerdictKey(group, headsHash string) (string, error) { - if group == "" { - return "", fmt.Errorf("meshdeliverycheckerclient: the group name is empty") - } - if !isHex12(headsHash) { - return "", fmt.Errorf("meshdeliverycheckerclient: %q is not a heads hash, 12 lowercase hex digits", headsHash) - } - return keys.EscapeName(group) + "." + headsHash, nil -} - -// ParseVerdictKey is the inverse of VerdictKey. -func ParseVerdictKey(key string) (group, headsHash string, err error) { - i := strings.LastIndex(key, ".") - if i < 0 { - return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a verdict key, .", key) - } - part, headsHash := key[:i], key[i+1:] - if !isHex12(headsHash) { - return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a verdict key: %q is not a heads hash, 12 lowercase hex digits", key, headsHash) - } - if part == "" || strings.Contains(part, ".") { - return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a verdict key: the group part is empty or holds a dot", key) - } - if group, err = keys.UnescapeName(part); err != nil { - return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a verdict key: %w", key, err) - } - return group, headsHash, nil -} diff --git a/contracts/go/clients/meshdeliverycheckerclient/client_test.go b/contracts/go/clients/meshdeliverycheckerclient/client_test.go deleted file mode 100644 index 38c651c0..00000000 --- a/contracts/go/clients/meshdeliverycheckerclient/client_test.go +++ /dev/null @@ -1,269 +0,0 @@ -package meshdeliverycheckerclient - -import ( - "encoding/json" - "strings" - "testing" - - checker "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdeliverychecker" -) - -type verdict = checker.VerdictsByGroupHeadsValue - -func passing() verdict { - return verdict{Group: "g", Heads: "0123456789ab", State: VerdictPass, Trunk: map[string]string{"novox/a": "c1"}, - Levels: map[string]checker.VerdictsByGroupHeadsValueLevelsValue{LevelUnit: {Run: 3}, LevelIntegration: {Run: 1}}} -} - -// The rules a verdict keeps to be written or read: each case edits a passing verdict and names what the refusal says. -func TestAVerdictIsRefusedForWhatAReaderCouldNotPlace(t *testing.T) { - if err := CheckVerdict(passing()); err != nil { - t.Fatalf("a passing verdict is refused: %v", err) - } - for name, c := range map[string]struct { - edit func(*verdict) - says string - }{ - "no group": {func(v *verdict) { v.Group = "" }, "no group"}, - "heads of 11 digits": {func(v *verdict) { v.Heads = "0123456789a" }, "12 lowercase hex"}, - "an empty trunk head": {func(v *verdict) { v.Trunk["novox/a"] = "" }, "trunk head"}, - "merged and read": {func(v *verdict) { v.Beside = map[string]string{"novox/a": "c2"} }, "trunk it merged and as a sibling"}, - "nothing carried": {func(v *verdict) { v.CarriedFrom = map[string]string{"novox/a": "c1"} }, "nothing moved"}, - "a running carry": {func(v *verdict) { v.State, v.CarriedFrom = VerdictRunning, map[string]string{"novox/a": "c0"} }, "carried from nothing"}, - "a series to itself": {func(v *verdict) { - v.Series = []checker.VerdictsByGroupHeadsValueSeriesItem{{Module: "m", Artifact: "a", From: "0.1", To: "0.1"}} - }, "same series"}, - "an unknown level": {func(v *verdict) { v.Levels["smoke"] = checker.VerdictsByGroupHeadsValueLevelsValue{} }, "smoke"}, - "a negative count": {func(v *verdict) { v.Levels[LevelUnit] = checker.VerdictsByGroupHeadsValueLevelsValue{Run: -1} }, "negative"}, - "a negative time": {func(v *verdict) { v.Took = &checker.VerdictsByGroupHeadsValueTook{Unit: -1} }, "negative"}, - "a pass without a level": {func(v *verdict) { delete(v.Levels, LevelIntegration) }, "integration level"}, - "a pass that failed": {func(v *verdict) { v.Failed = &checker.VerdictsByGroupHeadsValueFailed{Test: "T"} }, "names no failure"}, - "failures of a pass": {func(v *verdict) { v.Failures = []checker.VerdictsByGroupHeadsValueFailuresItem{{Test: "T"}} }, "names no failures"}, - "a fail naming nothing": {func(v *verdict) { v.State = VerdictFail }, "neither a test nor a machine"}, - "an unknown state": {func(v *verdict) { v.State = "maybe" }, "maybe"}, - "a composition passed without a commit": {func(v *verdict) { - v.Composition = &checker.VerdictsByGroupHeadsValueComposition{State: CompositionPass} - }, "mesh-sdk commit"}, - "the same level over bound twice": {func(v *verdict) { v.OverBound = []string{LevelUnit, LevelUnit} }, "twice"}, - // 1921 (B0, G): the checking program that judged it. - "judged at no full commit": {func(v *verdict) { j := judgedBy(); j.Program.Commit = "0123456"; v.JudgedBy = &j }, "checking program built at no repository, full commit"}, - "judged under no key": {func(v *verdict) { j := judgedBy(); j.Key = "composer-1"; v.JudgedBy = &j }, "composer-1"}, - "judged over no head": {func(v *verdict) { j := judgedBy(); j.Heads = nil; v.JudgedBy = &j }, "no head"}, - "judged over a branch": {func(v *verdict) { j := judgedBy(); j.Heads[0].Commit = "main"; v.JudgedBy = &j }, "novox/mesh-delivery"}, - } { - v := passing() - c.edit(&v) - if err := CheckVerdict(v); err == nil || !strings.Contains(err.Error(), c.says) { - t.Errorf("%s: %v, want a refusal saying %q", name, err, c.says) - } - } - judged := passing() - j := judgedBy() - judged.JudgedBy = &j - if err := CheckVerdict(judged); err != nil { - t.Errorf("a pass judged by a checking program is refused: %v", err) - } - failed := passing() - failed.State, failed.Failed = VerdictFail, &checker.VerdictsByGroupHeadsValueFailed{Machine: "ace"} - if err := CheckVerdict(failed); err != nil { - t.Errorf("a fail naming a machine is refused: %v", err) - } -} - -func TestAKeptVerdictIsAPassOfAPackageAtALevel(t *testing.T) { - t.Run("a preview is refused for what a reader of candidates could not place", previewIsRefused) - ok := checker.KeptByLevelDigestValue{State: VerdictPass, Repository: "novox/mesh-sdk", Package: "./go/keys", Level: LevelUnit, Toolchain: "1.26.0", At: "2026-11-05T10:00:00Z"} - if err := CheckKept(ok); err != nil { - t.Fatalf("a kept pass is refused: %v", err) - } - for name, edit := range map[string]func(*checker.KeptByLevelDigestValue){ - "a fail": func(k *checker.KeptByLevelDigestValue) { k.State = VerdictFail }, - "no owner": func(k *checker.KeptByLevelDigestValue) { k.Repository = "mesh-sdk" }, - "no package": func(k *checker.KeptByLevelDigestValue) { k.Package = "" }, - "an unknown level": func(k *checker.KeptByLevelDigestValue) { k.Level = "smoke" }, - "negative tests": func(k *checker.KeptByLevelDigestValue) { k.Tests = -1 }, - "no toolchain": func(k *checker.KeptByLevelDigestValue) { k.Toolchain = "" }, - "no time": func(k *checker.KeptByLevelDigestValue) { k.At = "" }, - } { - k := ok - edit(&k) - if CheckKept(k) == nil { - t.Errorf("%s was taken", name) - } - } -} - -// A preview is refused for what a reader of candidates could not place. -func previewIsRefused(t *testing.T) { - good := func() checker.PreviewsByRepositoryHeadTrunkValue { - return checker.PreviewsByRepositoryHeadTrunkValue{Repository: "novox/a", Head: "h1", Trunk: "t1", Merge: "m1", - Modules: map[string]checker.PreviewsByRepositoryHeadTrunkValueModulesValue{"mod": {Tree: "tr", Manifest: strings.Repeat("a", 64), - Locks: map[string]string{"go.sum": "x"}, Paths: map[string]string{"src": "o1"}}}} - } - if err := CheckPreview(good()); err != nil { - t.Fatalf("a good preview is refused: %v", err) - } - for name, c := range map[string]struct { - edit func(*checker.PreviewsByRepositoryHeadTrunkValue) - says string - }{ - "a repository with no owner": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { p.Repository = "a" }, "/"}, - "a head with a dot": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { p.Head = "h.1" }, "head"}, - "a conflict with a merge": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { p.Conflicts = []string{"f"} }, "in conflict"}, - "no merge commit": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { p.Merge = "" }, "no merge commit"}, - "a module with no tree": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { - m := p.Modules["mod"] - m.Tree = "" - p.Modules["mod"] = m - }, "no tree"}, - "a short manifest digest": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { - m := p.Modules["mod"] - m.Manifest = "abc" - p.Modules["mod"] = m - }, "manifest digest"}, - "a path outside the module": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { - m := p.Modules["mod"] - m.Paths = map[string]string{"../x": "o"} - p.Modules["mod"] = m - }, "clean path"}, - } { - p := good() - c.edit(&p) - if err := CheckPreview(p); err == nil || !strings.Contains(err.Error(), c.says) { - t.Errorf("%s: CheckPreview = %v, want it to say %q", name, err, c.says) - } - } - if err := CheckPreview(checker.PreviewsByRepositoryHeadTrunkValue{Repository: "novox/a", Head: "h", Trunk: "t", Conflicts: []string{"f"}}); err != nil { - t.Errorf("a head in conflict is refused: %v", err) - } -} - -// A verdict's key as go/delivery's CheckerVerdictKey wrote it (golden): the group escaped, the heads hash after the -// last dot. -func TestVerdictKeyAsGoDeliveryWroteIt(t *testing.T) { - key, err := VerdictKey("fix/1.2", "0123456789ab") - if err != nil || key != "fix/1=2e2.0123456789ab" { - t.Fatalf("%q %v", key, err) - } - group, heads, err := ParseVerdictKey(key) - if err != nil || group != "fix/1.2" || heads != "0123456789ab" { - t.Fatalf("%q %q %v", group, heads, err) - } - for _, bad := range []string{"nodot", "g.XYZ", ".0123456789ab", "a.b.0123456789ab", "g=zz.0123456789ab"} { - if _, _, err := ParseVerdictKey(bad); err == nil { - t.Errorf("%q parses", bad) - } - } - if _, err := VerdictKey("", "0123456789ab"); err == nil { - t.Error("an empty group keys") - } - if _, err := VerdictKey("g", "0123"); err == nil { - t.Error("a short hash keys") - } -} - -// The codecs write a value at the kept values' version after its rules and read it back through them. -func TestTheCodecsWriteAtTheVersionAndReadBackThroughTheRules(t *testing.T) { - raw, err := EncodeVerdict(passing()) - if err != nil { - t.Fatal(err) - } - if got, err := DecodeVerdict(raw); err != nil || got.V == 0 || got.Group != "g" { - t.Errorf("verdict read back = %+v, %v", got, err) - } - bad := passing() - bad.Heads = "x" - if _, err := EncodeVerdict(bad); err == nil { - t.Error("a verdict whose heads are no hash is written") - } - if _, err := DecodeVerdict([]byte(`{"v":99,"group":"g","heads":"0123456789ab","state":"running"}`)); err == nil { - t.Error("a verdict of an unknown version is read") - } - k := checker.KeptByLevelDigestValue{State: VerdictPass, Repository: "novox/mesh-sdk", Package: "./go/keys", Level: LevelUnit, Toolchain: "1.26.0", At: "2026-11-05T10:00:00Z"} - raw, err = EncodeKept(k) - if err != nil { - t.Fatal(err) - } - if got, err := DecodeKept(raw); err != nil || got.Package != k.Package { - t.Errorf("kept read back = %+v, %v", got, err) - } - k.State = VerdictFail - if _, err := EncodeKept(k); err == nil { - t.Error("a failure is kept") - } - p := checker.PreviewsByRepositoryHeadTrunkValue{Repository: "novox/a", Head: "h1", Trunk: "t1", Conflicts: []string{"f.go"}} - raw, err = EncodePreview(p) - if err != nil { - t.Fatal(err) - } - if got, err := DecodePreview(raw); err != nil || got.Head != "h1" { - t.Errorf("preview read back = %+v, %v", got, err) - } - p.Conflicts = nil - if _, err := EncodePreview(p); err == nil { - t.Error("a preview with no merge commit and no conflict is written") - } - // 1921 (B0, G): a checking program's input is asked of the seat's verb input by its digest, and an answer for - // another digest, or bytes that are not the digest, is refused. - body := []byte(`{"v":1}`) - digest := DigestOf(body) - for name, c := range map[string]struct { - answer any - says string - }{ - "its own bytes": {InputAnswerOf(body), ""}, - "another digest": {checker.InputAnswer{Digest: DigestOf([]byte("x")), Input: InputAnswerOf(body).Input}, "answered the input"}, - "bytes that are not it": {checker.InputAnswer{Digest: digest, Input: InputAnswerOf([]byte(`{"v":2}`)).Input}, "whose digest is"}, - "bytes in no base64": {checker.InputAnswer{Digest: digest, Input: "%%"}, "no base64"}, - "no answer of the layout": {"nothing", "answered no input"}, - } { - got, err := ReadInput(func(key string, b any) (json.RawMessage, error) { - if key != "seat:mesh-delivery-checker.input" || b != (checker.InputInput{Digest: digest}) { - t.Errorf("%s: asked %s %+v", name, key, b) - } - return json.Marshal(c.answer) - }, digest) - switch { - case c.says == "" && (err != nil || string(got) != string(body)): - t.Errorf("%s: %q, %v", name, got, err) - case c.says != "" && (err == nil || !strings.Contains(err.Error(), c.says)): - t.Errorf("%s: %v, want a refusal saying %q", name, err, c.says) - } - } -} - -// The kept and preview keys: a key reads back to its parts, and a part that does not key is refused. -func TestKeptAndPreviewKeysReadBack(t *testing.T) { - digest := strings.Repeat("ab", 32) - key, err := KeptKey(LevelUnit, digest) - if err != nil || key != "unit."+digest { - t.Fatalf("kept key = %q, %v", key, err) - } - if level, d, err := ParseKeptKey(key); err != nil || level != LevelUnit || d != digest { - t.Errorf("kept key read back = %q %q, %v", level, d, err) - } - for _, bad := range []string{"fast." + digest, "unit.XY", "unit"} { - if _, _, err := ParseKeptKey(bad); err == nil { - t.Errorf("kept key %q is read", bad) - } - } - key, err = PreviewKey("novox/mesh-sdk", "h1", "t1") - if err != nil { - t.Fatal(err) - } - if repo, h, tr, err := ParsePreviewKey(key); err != nil || repo != "novox/mesh-sdk" || h != "h1" || tr != "t1" { - t.Errorf("preview key %q read back = %q %q %q, %v", key, repo, h, tr, err) - } - for _, bad := range []string{"novox.h1.t1", "a/b.h1", "a/b.h1.t1.x"} { - if _, _, _, err := ParsePreviewKey(bad); err == nil { - t.Errorf("preview key %q is read", bad) - } - } -} - -func judgedBy() checker.VerdictsByGroupHeadsValueJudgedBy { - const c = "0123456789abcdef0123456789abcdef01234567" - return checker.VerdictsByGroupHeadsValueJudgedBy{ - Program: checker.VerdictsByGroupHeadsValueJudgedByProgram{Repository: "novox/mesh-delivery", Commit: c, Dir: "modules/mesh-delivery-checker", Package: "p"}, - Key: "program-0123456789abcdef", Built: true, Heads: []checker.VerdictsByGroupHeadsValueJudgedByHeadsItem{{Repository: "novox/mesh-delivery", Commit: c}}} -} diff --git a/contracts/go/clients/meshdeliverycheckerclient/codec.go b/contracts/go/clients/meshdeliverycheckerclient/codec.go deleted file mode 100644 index c684e73d..00000000 --- a/contracts/go/clients/meshdeliverycheckerclient/codec.go +++ /dev/null @@ -1,150 +0,0 @@ -package meshdeliverycheckerclient - -import ( - "encoding/json" - "fmt" - "strings" - - checker "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-sdk/go/keys" -) - -// The codecs of the three states the checker writes and others read (the view and the gate read verdicts, the indexer reads -// previews, the checker and the tools read kept verdicts): a value is written at the version of the kept values after its rules -// (CheckVerdict, CheckKept, CheckPreview) and read back through the same rules. The checker's owed state is read by no other -// part and keeps its own codec. - -// EncodeVerdict is v as JSON at the kept values' version, refused by CheckVerdict's rules. -func EncodeVerdict(v checker.VerdictsByGroupHeadsValue) ([]byte, error) { - if err := CheckVerdict(v); err != nil { - return nil, err - } - v.V = keys.Version - return json.Marshal(v) -} - -// DecodeVerdict reads a `verdicts` value; it refuses an unknown version (keys.ErrUnknownVersion) and what EncodeVerdict refuses. -func DecodeVerdict(data []byte) (checker.VerdictsByGroupHeadsValue, error) { - var v checker.VerdictsByGroupHeadsValue - if err := decode(data, &v); err != nil { - return v, err - } - if err := CheckVerdict(v); err != nil { - return checker.VerdictsByGroupHeadsValue{}, err - } - return v, nil -} - -// EncodeKept is k as JSON at the kept values' version, refused by CheckKept's rules. -func EncodeKept(k checker.KeptByLevelDigestValue) ([]byte, error) { - if err := CheckKept(k); err != nil { - return nil, err - } - k.V = keys.Version - return json.Marshal(k) -} - -// DecodeKept reads a `kept` value; it refuses an unknown version and what EncodeKept refuses. -func DecodeKept(data []byte) (checker.KeptByLevelDigestValue, error) { - var k checker.KeptByLevelDigestValue - if err := decode(data, &k); err != nil { - return k, err - } - if err := CheckKept(k); err != nil { - return checker.KeptByLevelDigestValue{}, err - } - return k, nil -} - -// EncodePreview is p as JSON at the kept values' version, refused by CheckPreview's rules. -func EncodePreview(p checker.PreviewsByRepositoryHeadTrunkValue) ([]byte, error) { - if err := CheckPreview(p); err != nil { - return nil, err - } - p.V = keys.Version - return json.Marshal(p) -} - -// DecodePreview reads a `previews` value; it refuses an unknown version and what EncodePreview refuses. -func DecodePreview(data []byte) (checker.PreviewsByRepositoryHeadTrunkValue, error) { - var p checker.PreviewsByRepositoryHeadTrunkValue - if err := decode(data, &p); err != nil { - return p, err - } - if err := CheckPreview(p); err != nil { - return checker.PreviewsByRepositoryHeadTrunkValue{}, err - } - return p, nil -} - -func decode(data []byte, into any) error { - if err := keys.CheckVersion(data); err != nil { - return err - } - if err := json.Unmarshal(data, into); err != nil { - return fmt.Errorf("meshdeliverycheckerclient: value does not fit its shape: %w", err) - } - return nil -} - -// KeptKey is the key, in the state kept, of a kept verdict: `.`, the level unit or integration and the digest, -// lowercase hex, of everything that package's tests read at that level as the language's build module names it. -func KeptKey(level, digest string) (string, error) { - if err := checkLevel(level); err != nil { - return "", err - } - if digest == "" || strings.Trim(digest, "0123456789abcdef") != "" { - return "", fmt.Errorf("meshdeliverycheckerclient: %q is not a digest, lowercase hex", digest) - } - return checker.KeptByLevelDigestKey(level, digest), nil -} - -// ParseKeptKey is the inverse of KeptKey. -func ParseKeptKey(key string) (level, digest string, err error) { - level, digest, ok := checker.ParseKeptByLevelDigestKey(key) - if !ok { - return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a kept key, .", key) - } - if _, err = KeptKey(level, digest); err != nil { - return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a kept key: %w", key, err) - } - return level, digest, nil -} - -// PreviewKey is the key, in the state previews, of a head merged onto a trunk commit: `..`, the -// repository's owner and name each escaped (keys.EscapeName). -func PreviewKey(repository, head, trunk string) (string, error) { - if err := CheckRepository(repository); err != nil { - return "", err - } - if err := keys.CheckName("head", head); err != nil { - return "", err - } - if err := keys.CheckName("trunk commit", trunk); err != nil { - return "", err - } - owner, name, _ := strings.Cut(repository, "/") - return checker.PreviewsByRepositoryHeadTrunkKey(keys.EscapeName(owner)+"/"+keys.EscapeName(name), head, trunk), nil -} - -// ParsePreviewKey is the inverse of PreviewKey. -func ParsePreviewKey(key string) (repository, head, trunk string, err error) { - repo, head, trunk, ok := checker.ParsePreviewsByRepositoryHeadTrunkKey(key) - if !ok || strings.Contains(trunk, ".") { - return "", "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a preview key, ..", key) - } - owner, name, found := strings.Cut(repo, "/") - if !found { - return "", "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a preview key: the repository has no slash", key) - } - owner, err1 := keys.UnescapeName(owner) - name, err2 := keys.UnescapeName(name) - if err1 != nil || err2 != nil { - return "", "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a preview key: the repository does not unescape", key) - } - repository = owner + "/" + name - if _, err := PreviewKey(repository, head, trunk); err != nil { - return "", "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a preview key: %w", key, err) - } - return repository, head, trunk, nil -} diff --git a/contracts/go/clients/meshdeliverycheckerclient/go.mod b/contracts/go/clients/meshdeliverycheckerclient/go.mod deleted file mode 100644 index ba6062bf..00000000 --- a/contracts/go/clients/meshdeliverycheckerclient/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module git.novox.be/novox/mesh-delivery/contracts/go/clients/meshdeliverycheckerclient - -go 1.26.0 - -require ( - git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdeliverychecker v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000 -) diff --git a/contracts/go/clients/meshdeliverycheckerclient/input.go b/contracts/go/clients/meshdeliverycheckerclient/input.go deleted file mode 100644 index 1594df80..00000000 --- a/contracts/go/clients/meshdeliverycheckerclient/input.go +++ /dev/null @@ -1,53 +0,0 @@ -package meshdeliverycheckerclient - -import ( - "crypto/sha256" - "encoding/base64" - "encoding/hex" - "encoding/json" - "fmt" - - checker "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdeliverychecker" -) - -// InputVerb is the seat's verb input as a manifest's `invokes` names it and a run ask's input names it: asked of the -// seat, on no one machine (novox/hq ADR 0644, ADR 0656; issue 1921). A checking program's input is kept by the checker -// by the sha256 of its exact bytes, and asked of it by the build module that runs the program (ADR 0596 §2). -const InputVerb = "seat:" + checker.Seat + "." + checker.VerbInput - -// InputAnswerOf is the verb input's answer for body: its digest and its exact bytes, base64. -func InputAnswerOf(body []byte) checker.InputAnswer { - return checker.InputAnswer{Digest: DigestOf(body), Input: base64.StdEncoding.EncodeToString(body)} -} - -// DigestOf is the digest a checking program's input is kept and asked by: the sha256 of its bytes, 64 lowercase hex -// digits. -func DigestOf(body []byte) string { - sum := sha256.Sum256(body) - return hex.EncodeToString(sum[:]) -} - -// ReadInput asks the verb input, with ask (a tools bundle's stdio.Ask, a process's Conn.Call), for the input kept by -// digest and answers its bytes, refusing an answer for another digest and bytes whose sha256 is not the digest. -func ReadInput(ask func(key string, body any) (json.RawMessage, error), digest string) ([]byte, error) { - const who = "meshdeliverycheckerclient: " - raw, err := ask(InputVerb, checker.InputInput{Digest: digest}) - if err != nil { - return nil, fmt.Errorf(who+"asking %s for the input %s: %w", InputVerb, digest, err) - } - var a checker.InputAnswer - if err := json.Unmarshal(raw, &a); err != nil { - return nil, fmt.Errorf(who+"%s answered no input for %s: %w", InputVerb, digest, err) - } - if a.Digest != digest { - return nil, fmt.Errorf(who+"%s answered the input %q, asked %s", InputVerb, a.Digest, digest) - } - body, err := base64.StdEncoding.DecodeString(a.Input) - if err != nil { - return nil, fmt.Errorf(who+"%s answered the input %s in no base64: %w", InputVerb, digest, err) - } - if got := DigestOf(body); got != digest { - return nil, fmt.Errorf(who+"the input %s answered %d bytes whose digest is %s", digest, len(body), got) - } - return body, nil -} diff --git a/contracts/go/seats/meshdeliverychecker/contract.go b/contracts/go/seats/meshdeliverychecker/contract.go deleted file mode 100644 index 00a8c8d8..00000000 --- a/contracts/go/seats/meshdeliverychecker/contract.go +++ /dev/null @@ -1,490 +0,0 @@ -// Code generated by seatgen from the seat definitions; DO NOT EDIT. - -// Package meshdeliverychecker is the contract of the seat "mesh-delivery-checker", defined whole (seats/mesh-delivery-checker/seat.json): The merge check's tries: start one, read one, end one. The checker's own events stay under its own subjects (ADR 0620 §2). -package meshdeliverychecker - -import ( - "bytes" - "encoding/json" - "errors" - "strings" -) - -// Seat is the seat's name. -const Seat = "mesh-delivery-checker" - -const ( - VerbTry = "try" - VerbTryRead = "try-read" - VerbTryEnd = "try-end" - VerbInput = "input" -) - -// Verbs is every verb the seat serves, in its definition's order: a new copy each call. -func Verbs() []string { - return []string{VerbTry, VerbTryRead, VerbTryEnd, VerbInput} -} - -// The holder's own events, listed beside the seat and published under the holder's subjects (ADR 0620 §2). -const ( - HolderEventVerdict = "verdict" - HolderEventTagWanted = "tag-wanted" - HolderEventPreviewWritten = "preview.written" -) - -// HolderSubjectVerdict is where the holder publishes verdict, kept in checker.asks. -func HolderSubjectVerdict(holder string) string { return "mesh.stream." + holder + ".event.verdict" } - -// HolderSubjectTagWanted is where the holder publishes tag-wanted, kept in checker.asks. -func HolderSubjectTagWanted(holder string) string { - return "mesh.stream." + holder + ".event.tag-wanted" -} - -// HolderSubjectPreviewWritten is where the holder publishes preview.written, kept in checks. -func HolderSubjectPreviewWritten(holder string) string { - return "mesh.stream." + holder + ".event.preview.written" -} - -const ( - StateVerdicts = "verdicts" - StateKept = "kept" - StateOwed = "owed" - StatePreviews = "previews" -) - -// VerdictsByGroupHeadsKey is the key of one value of the state verdicts under the form ".". -func VerdictsByGroupHeadsKey(group, heads string) string { return group + "." + heads } - -// ParseVerdictsByGroupHeadsKey reads the parts of a key of the form ".", in the order of the form; the last result is false for a key of another form. -func ParseVerdictsByGroupHeadsKey(key string) (string, string, bool) { - rest := key - v0, after0, found0 := strings.Cut(rest, ".") - if !found0 || v0 == "" { - return "", "", false - } - rest = after0 - if rest == "" { - return "", "", false - } - v2 := rest - rest = "" - if rest != "" { - return "", "", false - } - return v0, v2, true -} - -// DecodeVerdictsByGroupHeadsValue reads one value of the state verdicts under the form ".", refusing a field VerdictsByGroupHeadsValue does not know and any text after the value. -func DecodeVerdictsByGroupHeadsValue(raw []byte) (VerdictsByGroupHeadsValue, error) { - var v VerdictsByGroupHeadsValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err - } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil -} - -// KeptByLevelDigestKey is the key of one value of the state kept under the form ".". -func KeptByLevelDigestKey(level, digest string) string { return level + "." + digest } - -// ParseKeptByLevelDigestKey reads the parts of a key of the form ".", in the order of the form; the last result is false for a key of another form. -func ParseKeptByLevelDigestKey(key string) (string, string, bool) { - rest := key - v0, after0, found0 := strings.Cut(rest, ".") - if !found0 || v0 == "" { - return "", "", false - } - rest = after0 - if rest == "" { - return "", "", false - } - v2 := rest - rest = "" - if rest != "" { - return "", "", false - } - return v0, v2, true -} - -// DecodeKeptByLevelDigestValue reads one value of the state kept under the form ".", refusing a field KeptByLevelDigestValue does not know and any text after the value. -func DecodeKeptByLevelDigestValue(raw []byte) (KeptByLevelDigestValue, error) { - var v KeptByLevelDigestValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err - } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil -} - -// OwedByRepositoryNumberHeadActKey is the key of one value of the state owed under the form "...". -func OwedByRepositoryNumberHeadActKey(repository, number, head, act string) string { - return repository + "." + number + "." + head + "." + act -} - -// ParseOwedByRepositoryNumberHeadActKey reads the parts of a key of the form "...", in the order of the form; the last result is false for a key of another form. -func ParseOwedByRepositoryNumberHeadActKey(key string) (string, string, string, string, bool) { - rest := key - v0, after0, found0 := strings.Cut(rest, ".") - if !found0 || v0 == "" { - return "", "", "", "", false - } - rest = after0 - v2, after2, found2 := strings.Cut(rest, ".") - if !found2 || v2 == "" { - return "", "", "", "", false - } - rest = after2 - v4, after4, found4 := strings.Cut(rest, ".") - if !found4 || v4 == "" { - return "", "", "", "", false - } - rest = after4 - if rest == "" { - return "", "", "", "", false - } - v6 := rest - rest = "" - if rest != "" { - return "", "", "", "", false - } - return v0, v2, v4, v6, true -} - -// DecodeOwedByRepositoryNumberHeadActValue reads one value of the state owed under the form "...", refusing a field OwedByRepositoryNumberHeadActValue does not know and any text after the value. -func DecodeOwedByRepositoryNumberHeadActValue(raw []byte) (OwedByRepositoryNumberHeadActValue, error) { - var v OwedByRepositoryNumberHeadActValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err - } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil -} - -// PreviewsByRepositoryHeadTrunkKey is the key of one value of the state previews under the form "..". -func PreviewsByRepositoryHeadTrunkKey(repository, head, trunk string) string { - return repository + "." + head + "." + trunk -} - -// ParsePreviewsByRepositoryHeadTrunkKey reads the parts of a key of the form "..", in the order of the form; the last result is false for a key of another form. -func ParsePreviewsByRepositoryHeadTrunkKey(key string) (string, string, string, bool) { - rest := key - v0, after0, found0 := strings.Cut(rest, ".") - if !found0 || v0 == "" { - return "", "", "", false - } - rest = after0 - v2, after2, found2 := strings.Cut(rest, ".") - if !found2 || v2 == "" { - return "", "", "", false - } - rest = after2 - if rest == "" { - return "", "", "", false - } - v4 := rest - rest = "" - if rest != "" { - return "", "", "", false - } - return v0, v2, v4, true -} - -// DecodePreviewsByRepositoryHeadTrunkValue reads one value of the state previews under the form "..", refusing a field PreviewsByRepositoryHeadTrunkValue does not know and any text after the value. -func DecodePreviewsByRepositoryHeadTrunkValue(raw []byte) (PreviewsByRepositoryHeadTrunkValue, error) { - var v PreviewsByRepositoryHeadTrunkValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err - } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil -} - -// TryInputMembersItem is a type of the contract. -type TryInputMembersItem struct { - // the full commit to try, 40 or 64 hex digits - Head string `json:"head"` - // / - Repository string `json:"repository"` - // the trunk commit to merge it onto, or the trunk's branch for its head now; the trunk's head when absent - Trunk string `json:"trunk,omitempty"` -} - -// TryInput is what try takes. -type TryInput struct { - // the full commit to try, 40 or 64 hex digits, for a try of one member (instead of members) - Head string `json:"head,omitempty"` - // unit or integration: only this level; both when absent - Level string `json:"level,omitempty"` - // the group: one repository at most once, each at the exact commit asked and the trunk commit it is merged onto; instead of repository and head - Members []TryInputMembersItem `json:"members,omitempty"` - // /, for a try of one member (instead of members) - Repository string `json:"repository,omitempty"` - // a go test -run pattern: only those tests run, and nothing is kept - Tests string `json:"tests,omitempty"` - // the trunk commit to merge it onto, or the trunk's branch for its head now; the trunk's head when absent - Trunk string `json:"trunk,omitempty"` -} - -// TryAnswer is what try answers. -type TryAnswer struct { - // the try's id - ID string `json:"id"` - // its state - State string `json:"state,omitempty"` -} - -// TryReadInput is what try-read takes. -type TryReadInput struct { - // the try's id, try- - ID string `json:"id"` -} - -// TryReadAnswer is what try-read answers. -type TryReadAnswer = map[string]any - -// TryEndInput is what try-end takes. -type TryEndInput struct { - // the try's id, try- - ID string `json:"id"` - // why it is ended, in words - Why string `json:"why"` -} - -// TryEndAnswer is what try-end answers. -type TryEndAnswer struct { - // it is ended - Ended bool `json:"ended"` - // the try - ID string `json:"id"` -} - -// InputInput is what input takes. -type InputInput struct { - // the input's sha256, 64 lowercase hex digits, as the run ask names it - Digest string `json:"digest"` -} - -// InputAnswer is what input answers. -type InputAnswer struct { - // the digest asked - Digest string `json:"digest"` - // the input's exact bytes, base64, so no encoding on the way changes a byte the digest covers - Input string `json:"input"` -} - -// VerdictHolderEventSeriesItem is a type of the contract. -type VerdictHolderEventSeriesItem struct { - // its artifact, or the package's ecosystem name as the module's packages name it - Artifact string `json:"artifact"` - // the series on trunk - From string `json:"from"` - // the module whose artifact's series changes - Module string `json:"module"` - // the series the checked head gives it - To string `json:"to"` -} - -// VerdictHolderEvent is the body of the holder's event verdict. -type VerdictHolderEvent struct { - // the commit checked - Head string `json:"head"` - // the generated files out of step with their seat definitions, each path (design 26) - OutOfStep []string `json:"out-of-step,omitempty"` - // the pull request's number, for a pull request's check - Pull int64 `json:"pull,omitempty"` - // owner/repo - Repository string `json:"repository"` - // each change of an artifact's series the checked head makes against trunk's manifests, once each (design 32); absent when it changes none - Series []VerdictHolderEventSeriesItem `json:"series,omitempty"` - // pass or fail - Verdict string `json:"verdict"` -} - -// TagWantedHolderEvent is the body of the holder's event tag-wanted. -type TagWantedHolderEvent struct { - // the pull request's branch: its tag is removed when the branch ends - Branch string `json:"branch"` - // its head - Head string `json:"head"` - // the group member - Module string `json:"module"` - // the package it declares - Package string `json:"package"` - // the pull request - Pull int64 `json:"pull,omitempty"` - // owner/repo - Repository string `json:"repository"` - // the tag wanted - Tag string `json:"tag,omitempty"` -} - -// VerdictsByGroupHeadsValueComposition is a type of the contract. -type VerdictsByGroupHeadsValueComposition struct { - Fpset string `json:"fpset,omitempty"` - Machines []string `json:"machines,omitempty"` - Sdk string `json:"sdk,omitempty"` - // not-run, pass or fail - State string `json:"state"` - Words string `json:"words,omitempty"` -} - -// VerdictsByGroupHeadsValueFailed is a type of the contract. -type VerdictsByGroupHeadsValueFailed struct { - Machine string `json:"machine,omitempty"` - Test string `json:"test,omitempty"` - Words string `json:"words,omitempty"` -} - -// VerdictsByGroupHeadsValueFailuresItem is a type of the contract. -type VerdictsByGroupHeadsValueFailuresItem struct { - Machine string `json:"machine,omitempty"` - Test string `json:"test,omitempty"` - Words string `json:"words,omitempty"` -} - -// VerdictsByGroupHeadsValueJudgedByHeadsItem is a type of the contract. -type VerdictsByGroupHeadsValueJudgedByHeadsItem struct { - Commit string `json:"commit"` - Repository string `json:"repository"` -} - -// VerdictsByGroupHeadsValueJudgedByProgram is a type of the contract. -type VerdictsByGroupHeadsValueJudgedByProgram struct { - Commit string `json:"commit"` - Dir string `json:"dir"` - Package string `json:"package"` - Repository string `json:"repository"` -} - -// VerdictsByGroupHeadsValueJudgedBy is the checking program that judged the check: where it was built, the key its build is kept under, whether this check's run built it, and the heads it read (ADR 0644, ADR 0656). Absent in a value written before it. -type VerdictsByGroupHeadsValueJudgedBy struct { - Built bool `json:"built,omitempty"` - Heads []VerdictsByGroupHeadsValueJudgedByHeadsItem `json:"heads"` - // program- and 16 hex digits - Key string `json:"key"` - Program VerdictsByGroupHeadsValueJudgedByProgram `json:"program"` -} - -// VerdictsByGroupHeadsValueLevelsValue is a type of the contract. -type VerdictsByGroupHeadsValueLevelsValue struct { - Kept int64 `json:"kept"` - Run int64 `json:"run"` - Skipped int64 `json:"skipped,omitempty"` -} - -// VerdictsByGroupHeadsValueSeriesItem is a type of the contract. -type VerdictsByGroupHeadsValueSeriesItem struct { - Artifact string `json:"artifact"` - From string `json:"from"` - Module string `json:"module"` - To string `json:"to"` -} - -// VerdictsByGroupHeadsValueTook is milliseconds. -type VerdictsByGroupHeadsValueTook struct { - Clone int64 `json:"clone,omitempty"` - Composition int64 `json:"composition,omitempty"` - IntegrationRun int64 `json:"integration-run,omitempty"` - IntegrationSetup int64 `json:"integration-setup,omitempty"` - Lint int64 `json:"lint,omitempty"` - Queue int64 `json:"queue,omitempty"` - Unit int64 `json:"unit,omitempty"` -} - -// VerdictsByGroupHeadsValue is one value of the state verdicts under the key .. -type VerdictsByGroupHeadsValue struct { - Beside map[string]string `json:"beside,omitempty"` - CarriedFrom map[string]string `json:"carried-from,omitempty"` - Composition *VerdictsByGroupHeadsValueComposition `json:"composition,omitempty"` - Failed *VerdictsByGroupHeadsValueFailed `json:"failed,omitempty"` - Failures []VerdictsByGroupHeadsValueFailuresItem `json:"failures,omitempty"` - Group string `json:"group"` - // 12 hex digits - Heads string `json:"heads"` - // the checking program that judged the check: where it was built, the key its build is kept under, whether this check's run built it, and the heads it read (ADR 0644, ADR 0656). Absent in a value written before it - JudgedBy *VerdictsByGroupHeadsValueJudgedBy `json:"judged-by,omitempty"` - // by level, unit or integration - Levels map[string]VerdictsByGroupHeadsValueLevelsValue `json:"levels,omitempty"` - Machines []string `json:"machines,omitempty"` - OverBound []string `json:"over-bound,omitempty"` - Sdk string `json:"sdk,omitempty"` - Series []VerdictsByGroupHeadsValueSeriesItem `json:"series,omitempty"` - // running, pass or fail - State string `json:"state"` - // milliseconds - Took *VerdictsByGroupHeadsValueTook `json:"took,omitempty"` - // repository to the trunk head merged onto - Trunk map[string]string `json:"trunk,omitempty"` - // the layout version - V int64 `json:"v,omitempty"` -} - -// KeptByLevelDigestValue is one value of the state kept under the key .. -type KeptByLevelDigestValue struct { - // when (RFC 3339 time) - At string `json:"at,omitempty"` - Level string `json:"level"` - Package string `json:"package"` - Repository string `json:"repository"` - // pass: a failure is never kept - State string `json:"state"` - Tests int64 `json:"tests,omitempty"` - Took int64 `json:"took,omitempty"` - Toolchain string `json:"toolchain,omitempty"` - // the layout version - V int64 `json:"v,omitempty"` -} - -// OwedByRepositoryNumberHeadActValue is one value of the state owed under the key .... -type OwedByRepositoryNumberHeadActValue struct { - // status=, view, note or comment. - Act string `json:"act"` - Context string `json:"context,omitempty"` - Ref string `json:"ref,omitempty"` - State string `json:"state,omitempty"` - Target string `json:"target,omitempty"` - Text string `json:"text,omitempty"` - // the layout version - V int64 `json:"v,omitempty"` -} - -// PreviewsByRepositoryHeadTrunkValueModulesValue is a type of the contract. -type PreviewsByRepositoryHeadTrunkValueModulesValue struct { - Locks map[string]string `json:"locks,omitempty"` - // manifest digest - Manifest string `json:"manifest"` - Packages []string `json:"packages,omitempty"` - Paths map[string]string `json:"paths,omitempty"` - Tree string `json:"tree"` -} - -// PreviewsByRepositoryHeadTrunkValue is one value of the state previews under the key ... -type PreviewsByRepositoryHeadTrunkValue struct { - // files in conflict - Conflicts []string `json:"conflicts,omitempty"` - Head string `json:"head"` - // the merge commit - Merge string `json:"merge,omitempty"` - // by directory - Modules map[string]PreviewsByRepositoryHeadTrunkValueModulesValue `json:"modules,omitempty"` - Repository string `json:"repository"` - Trunk string `json:"trunk"` - // the layout version - V int64 `json:"v,omitempty"` -} diff --git a/contracts/go/seats/meshdeliverychecker/contract_test.go b/contracts/go/seats/meshdeliverychecker/contract_test.go deleted file mode 100644 index 65d9e0c4..00000000 --- a/contracts/go/seats/meshdeliverychecker/contract_test.go +++ /dev/null @@ -1,82 +0,0 @@ -// Code generated by seatgen from the seat definitions; DO NOT EDIT. - -package meshdeliverychecker - -import ( - "encoding/json" - "reflect" - "regexp" - "testing" -) - -// TestFixtures reads every fixture of seats/mesh-delivery-checker/fixtures: each decodes into its type, a field the type does not -// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's. -func TestFixtures(t *testing.T) { - cases := []struct { - name, subject, given, wire string - decode func([]byte) (any, error) - subjectIs *regexp.Regexp - }{ - {name: "verdict on the checker's own family", subject: "mesh.stream.mesh-delivery-checker.event.verdict", given: "{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"out-of-step\":[\"go/seats/meshbroker/contract.go\"],\"pull\":3,\"repository\":\"novox/mesh-contracts\",\"series\":[{\"artifact\":\"go\",\"from\":\"0.1\",\"module\":\"mesh-contracts\",\"to\":\"0.2\"}],\"verdict\":\"fail\"}", wire: "{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"out-of-step\":[\"go/seats/meshbroker/contract.go\"],\"pull\":3,\"repository\":\"novox/mesh-contracts\",\"series\":[{\"artifact\":\"go\",\"from\":\"0.1\",\"module\":\"mesh-contracts\",\"to\":\"0.2\"}],\"verdict\":\"fail\"}", - decode: func(b []byte) (any, error) { var v VerdictHolderEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.stream\\.[a-z0-9-]+\\.event\\.verdict$")}, - {name: "tag-wanted on the checker's own family", subject: "mesh.stream.mesh-delivery-checker.event.tag-wanted", given: "{\"branch\":\"feat/registry\",\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"module\":\"mesh-sdk\",\"package\":\"go\",\"pull\":170,\"repository\":\"novox/mesh-sdk\",\"tag\":\"registry-1966\"}", wire: "{\"branch\":\"feat/registry\",\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"module\":\"mesh-sdk\",\"package\":\"go\",\"pull\":170,\"repository\":\"novox/mesh-sdk\",\"tag\":\"registry-1966\"}", - decode: func(b []byte) (any, error) { var v TagWantedHolderEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.stream\\.[a-z0-9-]+\\.event\\.tag-wanted$")}, - {name: "preview.written on the checker's stream", subject: "mesh.stream.mesh-delivery-checker.event.preview.written", given: "{}", wire: "{}", - decode: func(b []byte) (any, error) { var v map[string]any; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.stream\\.[a-z0-9-]+\\.event\\.preview\\.written$")}, - {name: "a running verdict", subject: "", given: "{\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"state\":\"running\",\"v\":1}", wire: "{\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"state\":\"running\",\"v\":1}", - decode: func(b []byte) (any, error) { - var v VerdictsByGroupHeadsValue - err := json.Unmarshal(b, &v) - return v, err - }, subjectIs: nil}, - {name: "a pass judged by the checking program built at a mesh-delivery head", subject: "", given: "{\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"judged-by\":{\"built\":true,\"heads\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-delivery\"}],\"key\":\"program-0123456789abcdef\",\"program\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"dir\":\"modules/mesh-delivery-checker\",\"package\":\"./cmd/mesh-checking-program\",\"repository\":\"novox/mesh-delivery\"}},\"levels\":{\"integration\":{\"kept\":0,\"run\":3},\"unit\":{\"kept\":0,\"run\":12}},\"state\":\"pass\",\"v\":1}", wire: "{\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"judged-by\":{\"built\":true,\"heads\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-delivery\"}],\"key\":\"program-0123456789abcdef\",\"program\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"dir\":\"modules/mesh-delivery-checker\",\"package\":\"./cmd/mesh-checking-program\",\"repository\":\"novox/mesh-delivery\"}},\"levels\":{\"integration\":{\"kept\":0,\"run\":3},\"unit\":{\"kept\":0,\"run\":12}},\"state\":\"pass\",\"v\":1}", - decode: func(b []byte) (any, error) { - var v VerdictsByGroupHeadsValue - err := json.Unmarshal(b, &v) - return v, err - }, subjectIs: nil}, - {name: "a kept pass", subject: "", given: "{\"at\":\"2026-11-05T10:00:00Z\",\"level\":\"unit\",\"package\":\"go/keys\",\"repository\":\"novox/mesh-sdk\",\"state\":\"pass\",\"tests\":4,\"took\":120,\"toolchain\":\"go1.26\",\"v\":1}", wire: "{\"at\":\"2026-11-05T10:00:00Z\",\"level\":\"unit\",\"package\":\"go/keys\",\"repository\":\"novox/mesh-sdk\",\"state\":\"pass\",\"tests\":4,\"took\":120,\"toolchain\":\"go1.26\",\"v\":1}", - decode: func(b []byte) (any, error) { var v KeptByLevelDigestValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "the status owed for a head", subject: "", given: "{\"act\":\"status=mesh/check\",\"context\":\"mesh/check\",\"state\":\"success\",\"v\":1}", wire: "{\"act\":\"status=mesh/check\",\"context\":\"mesh/check\",\"state\":\"success\",\"v\":1}", - decode: func(b []byte) (any, error) { - var v OwedByRepositoryNumberHeadActValue - err := json.Unmarshal(b, &v) - return v, err - }, subjectIs: nil}, - {name: "a preview", subject: "", given: "{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"merge\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"repository\":\"novox/mesh-sdk\",\"trunk\":\"dddddddddddddddddddddddddddddddddddddddd\",\"v\":1}", wire: "{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"merge\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"repository\":\"novox/mesh-sdk\",\"trunk\":\"dddddddddddddddddddddddddddddddddddddddd\",\"v\":1}", - decode: func(b []byte) (any, error) { - var v PreviewsByRepositoryHeadTrunkValue - err := json.Unmarshal(b, &v) - return v, err - }, subjectIs: nil}, - {name: "a checking program asks its input by its digest", subject: "", given: "{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"}", wire: "{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"}", - decode: func(b []byte) (any, error) { var v InputInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "the input answered as its exact bytes, base64", subject: "", given: "{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"input\":\"eyJ2IjoxfQ==\"}", wire: "{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"input\":\"eyJ2IjoxfQ==\"}", - decode: func(b []byte) (any, error) { var v InputAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - } - for _, c := range cases { - v, err := c.decode([]byte(c.given)) - if err != nil { - t.Errorf("%s: does not decode: %v", c.name, err) - continue - } - back, err := json.Marshal(v) - if err != nil { - t.Errorf("%s: does not encode: %v", c.name, err) - continue - } - var got, want any - if err := json.Unmarshal(back, &got); err != nil { - t.Fatal(err) - } - if err := json.Unmarshal([]byte(c.wire), &want); err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(got, want) { - t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire) - } - if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) { - t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs) - } - } -} diff --git a/contracts/go/seats/meshdeliverychecker/go.mod b/contracts/go/seats/meshdeliverychecker/go.mod deleted file mode 100644 index d50dcda1..00000000 --- a/contracts/go/seats/meshdeliverychecker/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdeliverychecker - -go 1.26.0 diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go index d1f3f260..ed48790f 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go @@ -185,8 +185,8 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) { t.Errorf("the request of ace %+v", req) } c := req.Cases[0] - if string(c.Manifests["m"].Raw) != `{"module":"m"}` || len(c.Manifests) != 4 || len(c.None) != 1 || c.None["lidarr"] != "builders disagree: node" || len(c.Verdicts) != 0 { - t.Errorf("the case %+v %s", c.Manifests, c.Verdicts) + if string(c.Manifests["m"].Raw) != `{"module":"m"}` || len(c.Manifests) != 4 || len(c.None) != 1 || c.None["lidarr"] != "builders disagree: node" { + t.Errorf("the case %+v", c.Manifests) } if strings.Join(s.entries, " ") == "" { t.Error("no node-engine entry is read through entry") diff --git a/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/client.go b/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/client.go deleted file mode 100644 index c9ccff63..00000000 --- a/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/client.go +++ /dev/null @@ -1,341 +0,0 @@ -// Package meshdeliverycheckerclient holds the logic the holders and callers of the seat mesh-delivery-checker share over its -// contract (novox/hq ADR 0625 §4, ADR 0634 §2): the rules a verdict and a kept verdict must keep to be written or read. The -// checker writes them, and the view, the gate and the indexer read them; the contract's decoding is strict by schema only, so -// these rules are written once here and no caller copies them. -package meshdeliverycheckerclient - -import ( - "fmt" - pathpkg "path" - "strings" - - checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-sdk/go/keys" -) - -// The states of a verdict, the levels of a check and the compositions' states. -const ( - VerdictRunning = "running" - VerdictPass = "pass" - VerdictFail = "fail" - - LevelUnit = "unit" - LevelIntegration = "integration" - - CompositionNotRun = "not-run" - CompositionPass = "pass" - CompositionFail = "fail" -) - -// MaxFailures is the most failures a verdict names; it names the count of the rest beside them. -const MaxFailures = 50 - -func checkLevel(level string) error { - if level != LevelUnit && level != LevelIntegration { - return fmt.Errorf("meshdeliverycheckerclient: the level %q is not %s or %s", level, LevelUnit, LevelIntegration) - } - return nil -} - -func isHex12(s string) bool { return len(s) == 12 && strings.Trim(s, "0123456789abcdef") == "" } - -// CheckRepository refuses a repository that is not / with exactly one slash, each part a key part. -func CheckRepository(repository string) error { - owner, name, ok := strings.Cut(repository, "/") - if !ok || strings.Contains(name, "/") { - return fmt.Errorf("meshdeliverycheckerclient: the repository %q is not /, with exactly one slash", repository) - } - if err := keys.CheckName("repository owner", owner); err != nil { - return fmt.Errorf("meshdeliverycheckerclient: the repository %q: %w", repository, err) - } - if err := keys.CheckName("repository name", name); err != nil { - return fmt.Errorf("meshdeliverycheckerclient: the repository %q: %w", repository, err) - } - return nil -} - -func checkComposition(c *checker.VerdictsByGroupHeadsValueComposition) error { - if c == nil { - return nil - } - switch c.State { - case CompositionNotRun: - if c.Sdk != "" || len(c.Machines) > 0 { - return fmt.Errorf("meshdeliverycheckerclient: the verdict's composition is not run and names no mesh-sdk commit or machines") - } - case CompositionPass: - if c.Sdk == "" { - return fmt.Errorf("meshdeliverycheckerclient: the verdict's composition passed and names no mesh-sdk commit") - } - case CompositionFail: - if c.Words == "" { - return fmt.Errorf("meshdeliverycheckerclient: the verdict's composition failed and gives no words") - } - default: - return fmt.Errorf("meshdeliverycheckerclient: the verdict's composition state %q is not %s, %s or %s", c.State, CompositionNotRun, CompositionPass, CompositionFail) - } - return nil -} - -// checkJudgedBy refuses a checking program named at no repository, full commit and package, kept under no program key, -// or over no head or a head at no full commit (novox/hq ADR 0644, ADR 0656; issue 1921). -func checkJudgedBy(j *checker.VerdictsByGroupHeadsValueJudgedBy) error { - const who = "meshdeliverycheckerclient: " - if j == nil { - return nil - } - if CheckRepository(j.Program.Repository) != nil || !isCommit(j.Program.Commit) || j.Program.Package == "" { - return fmt.Errorf(who+"the verdict is judged by a checking program built at no repository, full commit and package (%+v)", j.Program) - } - if !strings.HasPrefix(j.Key, "program-") { - return fmt.Errorf(who+"the verdict's checking program is kept under %q, which is no program key", j.Key) - } - if len(j.Heads) == 0 { - return fmt.Errorf(who + "the verdict's checking program read no head") - } - for _, h := range j.Heads { - if CheckRepository(h.Repository) != nil || !isCommit(h.Commit) { - return fmt.Errorf(who+"the verdict's checking program read %s at %q, which is no full commit", h.Repository, h.Commit) - } - } - return nil -} - -func isCommit(s string) bool { return len(s) == 40 && strings.Trim(s, "0123456789abcdef") == "" } - -// CheckVerdict refuses a verdict a reader could not place: no group, heads that are not 12 lowercase hex digits, a repository -// both merged and read beside, a carried-from that carries nothing, a series change from a series to itself or named twice, a -// level that is neither unit nor integration or counts a negative number, a time below zero, a pass that says nothing of a -// level, a fail that names neither a test nor a machine, and failures on a verdict that did not fail. -func CheckVerdict(v checker.VerdictsByGroupHeadsValue) error { - const who = "meshdeliverycheckerclient: " - if v.Group == "" { - return fmt.Errorf(who + "a verdict names no group") - } - if !isHex12(v.Heads) { - return fmt.Errorf(who+"the verdict's heads hash %q is not 12 lowercase hex digits", v.Heads) - } - for repository, head := range v.Trunk { - if head == "" { - return fmt.Errorf(who+"the verdict's trunk head of %s is empty", repository) - } - } - for repository, commit := range v.Beside { - if commit == "" { - return fmt.Errorf(who+"the verdict's sibling commit of %s is empty", repository) - } - if _, ok := v.Trunk[repository]; ok { - return fmt.Errorf(who+"the verdict names %s as a trunk it merged and as a sibling it read", repository) - } - } - if len(v.CarriedFrom) > 0 { - if v.State == VerdictRunning { - return fmt.Errorf(who + "a running verdict is carried from nothing: carried-from is written with its end") - } - moved := false - for repository, commit := range v.CarriedFrom { - now, inTrunk := v.Trunk[repository] - if !inTrunk { - now = v.Beside[repository] - } - if commit == "" || now == "" { - return fmt.Errorf(who+"the verdict's carried-from names %s, which it judged on no commit of", repository) - } - moved = moved || commit != now - } - if !moved { - return fmt.Errorf(who + "the verdict's carried-from names the commits it is judged on: nothing moved, so nothing was carried") - } - } - changed := map[string]bool{} - for _, c := range v.Series { - if c.Module == "" || c.Artifact == "" || c.From == "" || c.To == "" { - return fmt.Errorf(who+"the verdict's series change %+v names no module, artifact, from or to", c) - } - if c.From == c.To { - return fmt.Errorf(who+"the verdict's series change of %s/%s is from %s to the same series", c.Module, c.Artifact, c.From) - } - if changed[c.Module+"/"+c.Artifact] { - return fmt.Errorf(who+"the verdict names the series change of %s/%s twice", c.Module, c.Artifact) - } - changed[c.Module+"/"+c.Artifact] = true - } - for level, r := range v.Levels { - if err := checkLevel(level); err != nil { - return err - } - if r.Run < 0 || r.Kept < 0 || r.Skipped < 0 { - return fmt.Errorf(who+"the verdict's %s level counts a negative number of tests", level) - } - } - if err := checkComposition(v.Composition); err != nil { - return err - } - if err := checkJudgedBy(v.JudgedBy); err != nil { - return err - } - seen := map[string]bool{} - for _, level := range v.OverBound { - if err := checkLevel(level); err != nil { - return fmt.Errorf(who+"the verdict's over-bound names: %w", err) - } - if seen[level] { - return fmt.Errorf(who+"the verdict's over-bound names the level %s twice", level) - } - seen[level] = true - } - if t := v.Took; t != nil { - for part, ms := range map[string]int64{"queue": t.Queue, "clone": t.Clone, "unit": t.Unit, "lint": t.Lint, - "integration-setup": t.IntegrationSetup, "integration-run": t.IntegrationRun, "composition": t.Composition} { - if ms < 0 { - return fmt.Errorf(who+"the verdict's time of the part %s is negative", part) - } - } - } - named := v.Failed != nil && (v.Failed.Test != "" || v.Failed.Machine != "") - if len(v.Failures) > 0 && v.State != VerdictFail { - return fmt.Errorf(who+"a %s verdict names no failures", v.State) - } - if len(v.Failures) > MaxFailures+1 { - return fmt.Errorf(who+"the verdict names %d failures, more than %d and the count of the rest", len(v.Failures), MaxFailures) - } - switch v.State { - case VerdictRunning: - if v.Failed != nil && *v.Failed != (checker.VerdictsByGroupHeadsValueFailed{}) { - return fmt.Errorf(who + "a running verdict names no failure") - } - case VerdictPass: - if v.Failed != nil && *v.Failed != (checker.VerdictsByGroupHeadsValueFailed{}) { - return fmt.Errorf(who + "a pass names no failure") - } - for _, level := range []string{LevelUnit, LevelIntegration} { - if _, ok := v.Levels[level]; !ok { - return fmt.Errorf(who+"a pass says nothing of the %s level", level) - } - } - case VerdictFail: - if !named { - return fmt.Errorf(who + "a fail names neither a test nor a machine") - } - default: - return fmt.Errorf(who+"the verdict state %q is not running, pass or fail", v.State) - } - return nil -} - -// CheckKept refuses a kept verdict that is not a pass of a repository's package at a level, with its toolchain and its time: -// a failure is never kept. -func CheckKept(k checker.KeptByLevelDigestValue) error { - const who = "meshdeliverycheckerclient: " - if k.State != VerdictPass { - return fmt.Errorf(who+"a kept verdict is a pass, never %q: a failure is never kept", k.State) - } - if err := CheckRepository(k.Repository); err != nil { - return err - } - if k.Package == "" { - return fmt.Errorf(who + "a kept verdict names no package") - } - if err := checkLevel(k.Level); err != nil { - return err - } - if k.Tests < 0 || k.Took < 0 { - return fmt.Errorf(who + "a kept verdict counts a negative number of tests or a negative time") - } - if k.Toolchain == "" { - return fmt.Errorf(who + "a kept verdict names no toolchain version") - } - if k.At == "" { - return fmt.Errorf(who + "a kept verdict says no time") - } - return nil -} - -// CheckPreview refuses a preview a reader could not place (the checker writes it, the indexer reads it for the candidates' -// fingerprints): a repository, head or trunk commit that does not key, a head in conflict that names no file or has a merge -// commit or modules, a head that merged and names no merge commit, and a module with no directory, no tree, a manifest -// digest that is not 64 lowercase hex digits, a lock without path or hash, or a named path that is not clean and inside the -// module's directory or names no git object. -func CheckPreview(p checker.PreviewsByRepositoryHeadTrunkValue) error { - const who = "meshdeliverycheckerclient: " - if err := CheckRepository(p.Repository); err != nil { - return err - } - if err := keys.CheckName("head", p.Head); err != nil { - return fmt.Errorf(who+"the preview: %w", err) - } - if err := keys.CheckName("trunk commit", p.Trunk); err != nil { - return fmt.Errorf(who+"the preview: %w", err) - } - for _, f := range p.Conflicts { - if f == "" { - return fmt.Errorf(who + "a preview names a conflicting file with an empty path") - } - } - if len(p.Conflicts) > 0 { - if p.Merge != "" || len(p.Modules) > 0 { - return fmt.Errorf(who + "a preview of a head in conflict has no merge commit and no modules") - } - return nil - } - if p.Merge == "" { - return fmt.Errorf(who + "a preview names no merge commit") - } - for dir, m := range p.Modules { - if dir == "" { - return fmt.Errorf(who + "a preview names a module with an empty directory") - } - if m.Tree == "" { - return fmt.Errorf(who+"the preview's module %q has no tree", dir) - } - if !keys.IsHex64(m.Manifest) { - return fmt.Errorf(who+"the preview's module %q: %q is not a manifest digest, 64 lowercase hex digits", dir, m.Manifest) - } - for path, hash := range m.Locks { - if path == "" || hash == "" { - return fmt.Errorf(who+"the lock %q of the preview's module %q has an empty path or hash", path, dir) - } - } - for p, object := range m.Paths { - if p == "" || p != pathpkg.Clean(p) || strings.HasPrefix(p, "/") || p == ".." || strings.HasPrefix(p, "../") { - return fmt.Errorf(who+"the preview's module %q: the named path %q is not a clean path inside the module's directory", dir, p) - } - if object == "" { - return fmt.Errorf(who+"the preview's module %q: the named path %q names no git object", dir, p) - } - } - } - return nil -} - -// VerdictKey is the key, in the state verdicts, of a group's check at its heads: `.`, the -// group escaped so a branch such as `fix/1.2` keys, the heads hash as the mesh-delivery client's HeadsHash gives it -// (12 lowercase hex digits). -func VerdictKey(group, headsHash string) (string, error) { - if group == "" { - return "", fmt.Errorf("meshdeliverycheckerclient: the group name is empty") - } - if !isHex12(headsHash) { - return "", fmt.Errorf("meshdeliverycheckerclient: %q is not a heads hash, 12 lowercase hex digits", headsHash) - } - return keys.EscapeName(group) + "." + headsHash, nil -} - -// ParseVerdictKey is the inverse of VerdictKey. -func ParseVerdictKey(key string) (group, headsHash string, err error) { - i := strings.LastIndex(key, ".") - if i < 0 { - return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a verdict key, .", key) - } - part, headsHash := key[:i], key[i+1:] - if !isHex12(headsHash) { - return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a verdict key: %q is not a heads hash, 12 lowercase hex digits", key, headsHash) - } - if part == "" || strings.Contains(part, ".") { - return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a verdict key: the group part is empty or holds a dot", key) - } - if group, err = keys.UnescapeName(part); err != nil { - return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a verdict key: %w", key, err) - } - return group, headsHash, nil -} diff --git a/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/client_test.go b/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/client_test.go deleted file mode 100644 index ef3a12d0..00000000 --- a/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/client_test.go +++ /dev/null @@ -1,269 +0,0 @@ -package meshdeliverycheckerclient - -import ( - "encoding/json" - "strings" - "testing" - - checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" -) - -type verdict = checker.VerdictsByGroupHeadsValue - -func passing() verdict { - return verdict{Group: "g", Heads: "0123456789ab", State: VerdictPass, Trunk: map[string]string{"novox/a": "c1"}, - Levels: map[string]checker.VerdictsByGroupHeadsValueLevelsValue{LevelUnit: {Run: 3}, LevelIntegration: {Run: 1}}} -} - -// The rules a verdict keeps to be written or read: each case edits a passing verdict and names what the refusal says. -func TestAVerdictIsRefusedForWhatAReaderCouldNotPlace(t *testing.T) { - if err := CheckVerdict(passing()); err != nil { - t.Fatalf("a passing verdict is refused: %v", err) - } - for name, c := range map[string]struct { - edit func(*verdict) - says string - }{ - "no group": {func(v *verdict) { v.Group = "" }, "no group"}, - "heads of 11 digits": {func(v *verdict) { v.Heads = "0123456789a" }, "12 lowercase hex"}, - "an empty trunk head": {func(v *verdict) { v.Trunk["novox/a"] = "" }, "trunk head"}, - "merged and read": {func(v *verdict) { v.Beside = map[string]string{"novox/a": "c2"} }, "trunk it merged and as a sibling"}, - "nothing carried": {func(v *verdict) { v.CarriedFrom = map[string]string{"novox/a": "c1"} }, "nothing moved"}, - "a running carry": {func(v *verdict) { v.State, v.CarriedFrom = VerdictRunning, map[string]string{"novox/a": "c0"} }, "carried from nothing"}, - "a series to itself": {func(v *verdict) { - v.Series = []checker.VerdictsByGroupHeadsValueSeriesItem{{Module: "m", Artifact: "a", From: "0.1", To: "0.1"}} - }, "same series"}, - "an unknown level": {func(v *verdict) { v.Levels["smoke"] = checker.VerdictsByGroupHeadsValueLevelsValue{} }, "smoke"}, - "a negative count": {func(v *verdict) { v.Levels[LevelUnit] = checker.VerdictsByGroupHeadsValueLevelsValue{Run: -1} }, "negative"}, - "a negative time": {func(v *verdict) { v.Took = &checker.VerdictsByGroupHeadsValueTook{Unit: -1} }, "negative"}, - "a pass without a level": {func(v *verdict) { delete(v.Levels, LevelIntegration) }, "integration level"}, - "a pass that failed": {func(v *verdict) { v.Failed = &checker.VerdictsByGroupHeadsValueFailed{Test: "T"} }, "names no failure"}, - "failures of a pass": {func(v *verdict) { v.Failures = []checker.VerdictsByGroupHeadsValueFailuresItem{{Test: "T"}} }, "names no failures"}, - "a fail naming nothing": {func(v *verdict) { v.State = VerdictFail }, "neither a test nor a machine"}, - "an unknown state": {func(v *verdict) { v.State = "maybe" }, "maybe"}, - "a composition passed without a commit": {func(v *verdict) { - v.Composition = &checker.VerdictsByGroupHeadsValueComposition{State: CompositionPass} - }, "mesh-sdk commit"}, - "the same level over bound twice": {func(v *verdict) { v.OverBound = []string{LevelUnit, LevelUnit} }, "twice"}, - // 1921 (B0, G): the checking program that judged it. - "judged at no full commit": {func(v *verdict) { j := judgedBy(); j.Program.Commit = "0123456"; v.JudgedBy = &j }, "checking program built at no repository, full commit"}, - "judged under no key": {func(v *verdict) { j := judgedBy(); j.Key = "composer-1"; v.JudgedBy = &j }, "composer-1"}, - "judged over no head": {func(v *verdict) { j := judgedBy(); j.Heads = nil; v.JudgedBy = &j }, "no head"}, - "judged over a branch": {func(v *verdict) { j := judgedBy(); j.Heads[0].Commit = "main"; v.JudgedBy = &j }, "novox/mesh-delivery"}, - } { - v := passing() - c.edit(&v) - if err := CheckVerdict(v); err == nil || !strings.Contains(err.Error(), c.says) { - t.Errorf("%s: %v, want a refusal saying %q", name, err, c.says) - } - } - judged := passing() - j := judgedBy() - judged.JudgedBy = &j - if err := CheckVerdict(judged); err != nil { - t.Errorf("a pass judged by a checking program is refused: %v", err) - } - failed := passing() - failed.State, failed.Failed = VerdictFail, &checker.VerdictsByGroupHeadsValueFailed{Machine: "anchor"} - if err := CheckVerdict(failed); err != nil { - t.Errorf("a fail naming a machine is refused: %v", err) - } -} - -func TestAKeptVerdictIsAPassOfAPackageAtALevel(t *testing.T) { - t.Run("a preview is refused for what a reader of candidates could not place", previewIsRefused) - ok := checker.KeptByLevelDigestValue{State: VerdictPass, Repository: "novox/mesh-sdk", Package: "./go/keys", Level: LevelUnit, Toolchain: "1.26.0", At: "2026-11-05T10:00:00Z"} - if err := CheckKept(ok); err != nil { - t.Fatalf("a kept pass is refused: %v", err) - } - for name, edit := range map[string]func(*checker.KeptByLevelDigestValue){ - "a fail": func(k *checker.KeptByLevelDigestValue) { k.State = VerdictFail }, - "no owner": func(k *checker.KeptByLevelDigestValue) { k.Repository = "mesh-sdk" }, - "no package": func(k *checker.KeptByLevelDigestValue) { k.Package = "" }, - "an unknown level": func(k *checker.KeptByLevelDigestValue) { k.Level = "smoke" }, - "negative tests": func(k *checker.KeptByLevelDigestValue) { k.Tests = -1 }, - "no toolchain": func(k *checker.KeptByLevelDigestValue) { k.Toolchain = "" }, - "no time": func(k *checker.KeptByLevelDigestValue) { k.At = "" }, - } { - k := ok - edit(&k) - if CheckKept(k) == nil { - t.Errorf("%s was taken", name) - } - } -} - -// A preview is refused for what a reader of candidates could not place. -func previewIsRefused(t *testing.T) { - good := func() checker.PreviewsByRepositoryHeadTrunkValue { - return checker.PreviewsByRepositoryHeadTrunkValue{Repository: "novox/a", Head: "h1", Trunk: "t1", Merge: "m1", - Modules: map[string]checker.PreviewsByRepositoryHeadTrunkValueModulesValue{"mod": {Tree: "tr", Manifest: strings.Repeat("a", 64), - Locks: map[string]string{"go.sum": "x"}, Paths: map[string]string{"src": "o1"}}}} - } - if err := CheckPreview(good()); err != nil { - t.Fatalf("a good preview is refused: %v", err) - } - for name, c := range map[string]struct { - edit func(*checker.PreviewsByRepositoryHeadTrunkValue) - says string - }{ - "a repository with no owner": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { p.Repository = "a" }, "/"}, - "a head with a dot": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { p.Head = "h.1" }, "head"}, - "a conflict with a merge": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { p.Conflicts = []string{"f"} }, "in conflict"}, - "no merge commit": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { p.Merge = "" }, "no merge commit"}, - "a module with no tree": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { - m := p.Modules["mod"] - m.Tree = "" - p.Modules["mod"] = m - }, "no tree"}, - "a short manifest digest": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { - m := p.Modules["mod"] - m.Manifest = "abc" - p.Modules["mod"] = m - }, "manifest digest"}, - "a path outside the module": {func(p *checker.PreviewsByRepositoryHeadTrunkValue) { - m := p.Modules["mod"] - m.Paths = map[string]string{"../x": "o"} - p.Modules["mod"] = m - }, "clean path"}, - } { - p := good() - c.edit(&p) - if err := CheckPreview(p); err == nil || !strings.Contains(err.Error(), c.says) { - t.Errorf("%s: CheckPreview = %v, want it to say %q", name, err, c.says) - } - } - if err := CheckPreview(checker.PreviewsByRepositoryHeadTrunkValue{Repository: "novox/a", Head: "h", Trunk: "t", Conflicts: []string{"f"}}); err != nil { - t.Errorf("a head in conflict is refused: %v", err) - } -} - -// A verdict's key as go/delivery's CheckerVerdictKey wrote it (golden): the group escaped, the heads hash after the -// last dot. -func TestVerdictKeyAsGoDeliveryWroteIt(t *testing.T) { - key, err := VerdictKey("fix/1.2", "0123456789ab") - if err != nil || key != "fix/1=2e2.0123456789ab" { - t.Fatalf("%q %v", key, err) - } - group, heads, err := ParseVerdictKey(key) - if err != nil || group != "fix/1.2" || heads != "0123456789ab" { - t.Fatalf("%q %q %v", group, heads, err) - } - for _, bad := range []string{"nodot", "g.XYZ", ".0123456789ab", "a.b.0123456789ab", "g=zz.0123456789ab"} { - if _, _, err := ParseVerdictKey(bad); err == nil { - t.Errorf("%q parses", bad) - } - } - if _, err := VerdictKey("", "0123456789ab"); err == nil { - t.Error("an empty group keys") - } - if _, err := VerdictKey("g", "0123"); err == nil { - t.Error("a short hash keys") - } -} - -// The codecs write a value at the kept values' version after its rules and read it back through them. -func TestTheCodecsWriteAtTheVersionAndReadBackThroughTheRules(t *testing.T) { - raw, err := EncodeVerdict(passing()) - if err != nil { - t.Fatal(err) - } - if got, err := DecodeVerdict(raw); err != nil || got.V == 0 || got.Group != "g" { - t.Errorf("verdict read back = %+v, %v", got, err) - } - bad := passing() - bad.Heads = "x" - if _, err := EncodeVerdict(bad); err == nil { - t.Error("a verdict whose heads are no hash is written") - } - if _, err := DecodeVerdict([]byte(`{"v":99,"group":"g","heads":"0123456789ab","state":"running"}`)); err == nil { - t.Error("a verdict of an unknown version is read") - } - k := checker.KeptByLevelDigestValue{State: VerdictPass, Repository: "novox/mesh-sdk", Package: "./go/keys", Level: LevelUnit, Toolchain: "1.26.0", At: "2026-11-05T10:00:00Z"} - raw, err = EncodeKept(k) - if err != nil { - t.Fatal(err) - } - if got, err := DecodeKept(raw); err != nil || got.Package != k.Package { - t.Errorf("kept read back = %+v, %v", got, err) - } - k.State = VerdictFail - if _, err := EncodeKept(k); err == nil { - t.Error("a failure is kept") - } - p := checker.PreviewsByRepositoryHeadTrunkValue{Repository: "novox/a", Head: "h1", Trunk: "t1", Conflicts: []string{"f.go"}} - raw, err = EncodePreview(p) - if err != nil { - t.Fatal(err) - } - if got, err := DecodePreview(raw); err != nil || got.Head != "h1" { - t.Errorf("preview read back = %+v, %v", got, err) - } - p.Conflicts = nil - if _, err := EncodePreview(p); err == nil { - t.Error("a preview with no merge commit and no conflict is written") - } - // 1921 (B0, G): a checking program's input is asked of the seat's verb input by its digest, and an answer for - // another digest, or bytes that are not the digest, is refused. - body := []byte(`{"v":1}`) - digest := DigestOf(body) - for name, c := range map[string]struct { - answer any - says string - }{ - "its own bytes": {InputAnswerOf(body), ""}, - "another digest": {checker.InputAnswer{Digest: DigestOf([]byte("x")), Input: InputAnswerOf(body).Input}, "answered the input"}, - "bytes that are not it": {checker.InputAnswer{Digest: digest, Input: InputAnswerOf([]byte(`{"v":2}`)).Input}, "whose digest is"}, - "bytes in no base64": {checker.InputAnswer{Digest: digest, Input: "%%"}, "no base64"}, - "no answer of the layout": {"nothing", "answered no input"}, - } { - got, err := ReadInput(func(key string, b any) (json.RawMessage, error) { - if key != "seat:mesh-delivery-checker.input" || b != (checker.InputInput{Digest: digest}) { - t.Errorf("%s: asked %s %+v", name, key, b) - } - return json.Marshal(c.answer) - }, digest) - switch { - case c.says == "" && (err != nil || string(got) != string(body)): - t.Errorf("%s: %q, %v", name, got, err) - case c.says != "" && (err == nil || !strings.Contains(err.Error(), c.says)): - t.Errorf("%s: %v, want a refusal saying %q", name, err, c.says) - } - } -} - -// The kept and preview keys: a key reads back to its parts, and a part that does not key is refused. -func TestKeptAndPreviewKeysReadBack(t *testing.T) { - digest := strings.Repeat("ab", 32) - key, err := KeptKey(LevelUnit, digest) - if err != nil || key != "unit."+digest { - t.Fatalf("kept key = %q, %v", key, err) - } - if level, d, err := ParseKeptKey(key); err != nil || level != LevelUnit || d != digest { - t.Errorf("kept key read back = %q %q, %v", level, d, err) - } - for _, bad := range []string{"fast." + digest, "unit.XY", "unit"} { - if _, _, err := ParseKeptKey(bad); err == nil { - t.Errorf("kept key %q is read", bad) - } - } - key, err = PreviewKey("novox/mesh-sdk", "h1", "t1") - if err != nil { - t.Fatal(err) - } - if repo, h, tr, err := ParsePreviewKey(key); err != nil || repo != "novox/mesh-sdk" || h != "h1" || tr != "t1" { - t.Errorf("preview key %q read back = %q %q %q, %v", key, repo, h, tr, err) - } - for _, bad := range []string{"novox.h1.t1", "a/b.h1", "a/b.h1.t1.x"} { - if _, _, _, err := ParsePreviewKey(bad); err == nil { - t.Errorf("preview key %q is read", bad) - } - } -} - -func judgedBy() checker.VerdictsByGroupHeadsValueJudgedBy { - const c = "0123456789abcdef0123456789abcdef01234567" - return checker.VerdictsByGroupHeadsValueJudgedBy{ - Program: checker.VerdictsByGroupHeadsValueJudgedByProgram{Repository: "novox/mesh-delivery", Commit: c, Dir: "modules/mesh-delivery-checker", Package: "p"}, - Key: "program-0123456789abcdef", Built: true, Heads: []checker.VerdictsByGroupHeadsValueJudgedByHeadsItem{{Repository: "novox/mesh-delivery", Commit: c}}} -} diff --git a/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/codec.go b/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/codec.go deleted file mode 100644 index 59162b97..00000000 --- a/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/codec.go +++ /dev/null @@ -1,150 +0,0 @@ -package meshdeliverycheckerclient - -import ( - "encoding/json" - "fmt" - "strings" - - checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" - "git.novox.be/novox/mesh-sdk/go/keys" -) - -// The codecs of the three states the checker writes and others read (the view and the gate read verdicts, the indexer reads -// previews, the checker and the tools read kept verdicts): a value is written at the version of the kept values after its rules -// (CheckVerdict, CheckKept, CheckPreview) and read back through the same rules. The checker's owed state is read by no other -// part and keeps its own codec. - -// EncodeVerdict is v as JSON at the kept values' version, refused by CheckVerdict's rules. -func EncodeVerdict(v checker.VerdictsByGroupHeadsValue) ([]byte, error) { - if err := CheckVerdict(v); err != nil { - return nil, err - } - v.V = keys.Version - return json.Marshal(v) -} - -// DecodeVerdict reads a `verdicts` value; it refuses an unknown version (keys.ErrUnknownVersion) and what EncodeVerdict refuses. -func DecodeVerdict(data []byte) (checker.VerdictsByGroupHeadsValue, error) { - var v checker.VerdictsByGroupHeadsValue - if err := decode(data, &v); err != nil { - return v, err - } - if err := CheckVerdict(v); err != nil { - return checker.VerdictsByGroupHeadsValue{}, err - } - return v, nil -} - -// EncodeKept is k as JSON at the kept values' version, refused by CheckKept's rules. -func EncodeKept(k checker.KeptByLevelDigestValue) ([]byte, error) { - if err := CheckKept(k); err != nil { - return nil, err - } - k.V = keys.Version - return json.Marshal(k) -} - -// DecodeKept reads a `kept` value; it refuses an unknown version and what EncodeKept refuses. -func DecodeKept(data []byte) (checker.KeptByLevelDigestValue, error) { - var k checker.KeptByLevelDigestValue - if err := decode(data, &k); err != nil { - return k, err - } - if err := CheckKept(k); err != nil { - return checker.KeptByLevelDigestValue{}, err - } - return k, nil -} - -// EncodePreview is p as JSON at the kept values' version, refused by CheckPreview's rules. -func EncodePreview(p checker.PreviewsByRepositoryHeadTrunkValue) ([]byte, error) { - if err := CheckPreview(p); err != nil { - return nil, err - } - p.V = keys.Version - return json.Marshal(p) -} - -// DecodePreview reads a `previews` value; it refuses an unknown version and what EncodePreview refuses. -func DecodePreview(data []byte) (checker.PreviewsByRepositoryHeadTrunkValue, error) { - var p checker.PreviewsByRepositoryHeadTrunkValue - if err := decode(data, &p); err != nil { - return p, err - } - if err := CheckPreview(p); err != nil { - return checker.PreviewsByRepositoryHeadTrunkValue{}, err - } - return p, nil -} - -func decode(data []byte, into any) error { - if err := keys.CheckVersion(data); err != nil { - return err - } - if err := json.Unmarshal(data, into); err != nil { - return fmt.Errorf("meshdeliverycheckerclient: value does not fit its shape: %w", err) - } - return nil -} - -// KeptKey is the key, in the state kept, of a kept verdict: `.`, the level unit or integration and the digest, -// lowercase hex, of everything that package's tests read at that level as the language's build module names it. -func KeptKey(level, digest string) (string, error) { - if err := checkLevel(level); err != nil { - return "", err - } - if digest == "" || strings.Trim(digest, "0123456789abcdef") != "" { - return "", fmt.Errorf("meshdeliverycheckerclient: %q is not a digest, lowercase hex", digest) - } - return checker.KeptByLevelDigestKey(level, digest), nil -} - -// ParseKeptKey is the inverse of KeptKey. -func ParseKeptKey(key string) (level, digest string, err error) { - level, digest, ok := checker.ParseKeptByLevelDigestKey(key) - if !ok { - return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a kept key, .", key) - } - if _, err = KeptKey(level, digest); err != nil { - return "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a kept key: %w", key, err) - } - return level, digest, nil -} - -// PreviewKey is the key, in the state previews, of a head merged onto a trunk commit: `..`, the -// repository's owner and name each escaped (keys.EscapeName). -func PreviewKey(repository, head, trunk string) (string, error) { - if err := CheckRepository(repository); err != nil { - return "", err - } - if err := keys.CheckName("head", head); err != nil { - return "", err - } - if err := keys.CheckName("trunk commit", trunk); err != nil { - return "", err - } - owner, name, _ := strings.Cut(repository, "/") - return checker.PreviewsByRepositoryHeadTrunkKey(keys.EscapeName(owner)+"/"+keys.EscapeName(name), head, trunk), nil -} - -// ParsePreviewKey is the inverse of PreviewKey. -func ParsePreviewKey(key string) (repository, head, trunk string, err error) { - repo, head, trunk, ok := checker.ParsePreviewsByRepositoryHeadTrunkKey(key) - if !ok || strings.Contains(trunk, ".") { - return "", "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a preview key, ..", key) - } - owner, name, found := strings.Cut(repo, "/") - if !found { - return "", "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a preview key: the repository has no slash", key) - } - owner, err1 := keys.UnescapeName(owner) - name, err2 := keys.UnescapeName(name) - if err1 != nil || err2 != nil { - return "", "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a preview key: the repository does not unescape", key) - } - repository = owner + "/" + name - if _, err := PreviewKey(repository, head, trunk); err != nil { - return "", "", "", fmt.Errorf("meshdeliverycheckerclient: %q is not a preview key: %w", key, err) - } - return repository, head, trunk, nil -} diff --git a/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/go.mod b/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/go.mod deleted file mode 100644 index e8930ad4..00000000 --- a/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient - -go 1.26.0 - -require ( - git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker v0.0.0-00010101000000-000000000000 - git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000 -) diff --git a/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/input.go b/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/input.go deleted file mode 100644 index 106c908b..00000000 --- a/modules/mesh-delivery-contracts/go/clients/meshdeliverycheckerclient/input.go +++ /dev/null @@ -1,53 +0,0 @@ -package meshdeliverycheckerclient - -import ( - "crypto/sha256" - "encoding/base64" - "encoding/hex" - "encoding/json" - "fmt" - - checker "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker" -) - -// InputVerb is the seat's verb input as a manifest's `invokes` names it and a run ask's input names it: asked of the -// seat, on no one machine (novox/hq ADR 0644, ADR 0656; issue 1921). A checking program's input is kept by the checker -// by the sha256 of its exact bytes, and asked of it by the build module that runs the program (ADR 0596 §2). -const InputVerb = "seat:" + checker.Seat + "." + checker.VerbInput - -// InputAnswerOf is the verb input's answer for body: its digest and its exact bytes, base64. -func InputAnswerOf(body []byte) checker.InputAnswer { - return checker.InputAnswer{Digest: DigestOf(body), Input: base64.StdEncoding.EncodeToString(body)} -} - -// DigestOf is the digest a checking program's input is kept and asked by: the sha256 of its bytes, 64 lowercase hex -// digits. -func DigestOf(body []byte) string { - sum := sha256.Sum256(body) - return hex.EncodeToString(sum[:]) -} - -// ReadInput asks the verb input, with ask (a tools bundle's stdio.Ask, a process's Conn.Call), for the input kept by -// digest and answers its bytes, refusing an answer for another digest and bytes whose sha256 is not the digest. -func ReadInput(ask func(key string, body any) (json.RawMessage, error), digest string) ([]byte, error) { - const who = "meshdeliverycheckerclient: " - raw, err := ask(InputVerb, checker.InputInput{Digest: digest}) - if err != nil { - return nil, fmt.Errorf(who+"asking %s for the input %s: %w", InputVerb, digest, err) - } - var a checker.InputAnswer - if err := json.Unmarshal(raw, &a); err != nil { - return nil, fmt.Errorf(who+"%s answered no input for %s: %w", InputVerb, digest, err) - } - if a.Digest != digest { - return nil, fmt.Errorf(who+"%s answered the input %q, asked %s", InputVerb, a.Digest, digest) - } - body, err := base64.StdEncoding.DecodeString(a.Input) - if err != nil { - return nil, fmt.Errorf(who+"%s answered the input %s in no base64: %w", InputVerb, digest, err) - } - if got := DigestOf(body); got != digest { - return nil, fmt.Errorf(who+"the input %s answered %d bytes whose digest is %s", digest, len(body), got) - } - return body, nil -} diff --git a/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker/contract.go b/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker/contract.go deleted file mode 100644 index d3a20139..00000000 --- a/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker/contract.go +++ /dev/null @@ -1,566 +0,0 @@ -// Code generated by seatgen from the seat definitions; DO NOT EDIT. - -// Package meshdeliverychecker is the contract of the seat "mesh-delivery-checker", defined whole (seats/mesh-delivery-checker/seat.json): The merge check's tries: start one, read one, end one. The seat says each check's end as checked and what the checker owes the forge as owed; the checker's other events stay under its own subjects (ADR 0620 §2). -package meshdeliverychecker - -import ( - "bytes" - "encoding/json" - "errors" - "strings" - "time" -) - -// Seat is the seat's name. -const Seat = "mesh-delivery-checker" - -const ( - VerbTry = "try" - VerbTryRead = "try-read" - VerbTryEnd = "try-end" - VerbInput = "input" -) - -const ( - EventChecked = "checked" - EventOwed = "owed" -) - -// Verbs is every verb the seat serves, in its definition's order: a new copy each call. -func Verbs() []string { - return []string{VerbTry, VerbTryRead, VerbTryEnd, VerbInput} -} - -// Events is every event published on the seat's subject: a new copy each call. -func Events() []string { - return []string{EventChecked, EventOwed} -} - -// Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects. -const ( - Family = "mesh-delivery-checker.events" - FamilyMaxAgeDays = 7 -) - -// SubjectChecked is where checked is published. -const SubjectChecked = "mesh.seat.mesh-delivery-checker.event.checked" - -// StreamOwed is the stream owed is kept in. -const StreamOwed = "SEAT_mesh-delivery-checker_owed" - -// SubjectOwed is where owed is published, on mesh.seat.mesh-delivery-checker.event.owed... -func SubjectOwed(repository, number string) string { - return "mesh.seat.mesh-delivery-checker.event.owed." + repository + "." + number -} - -// SubjectOwedAll hears every owed. -const SubjectOwedAll = "mesh.seat.mesh-delivery-checker.event.owed.*.*" - -// The holder's own events, listed beside the seat and published under the holder's subjects (ADR 0620 §2). -const ( - HolderEventVerdict = "verdict" - HolderEventPreviewWritten = "preview.written" -) - -// HolderSubjectVerdict is where the holder publishes verdict, kept in checker.asks. -func HolderSubjectVerdict(holder string) string { return "mesh.stream." + holder + ".event.verdict" } - -// HolderSubjectPreviewWritten is where the holder publishes preview.written, kept in checks. -func HolderSubjectPreviewWritten(holder string) string { - return "mesh.stream." + holder + ".event.preview.written" -} - -const ( - StateVerdicts = "verdicts" - StateKept = "kept" - StateOwed = "owed" - StatePreviews = "previews" -) - -// VerdictsByGroupHeadsKey is the key of one value of the state verdicts under the form ".". -func VerdictsByGroupHeadsKey(group, heads string) string { return group + "." + heads } - -// ParseVerdictsByGroupHeadsKey reads the parts of a key of the form ".", in the order of the form; the last result is false for a key of another form. -func ParseVerdictsByGroupHeadsKey(key string) (string, string, bool) { - rest := key - v0, after0, found0 := strings.Cut(rest, ".") - if !found0 || v0 == "" { - return "", "", false - } - rest = after0 - if rest == "" { - return "", "", false - } - v2 := rest - rest = "" - if rest != "" { - return "", "", false - } - return v0, v2, true -} - -// DecodeVerdictsByGroupHeadsValue reads one value of the state verdicts under the form ".", refusing a field VerdictsByGroupHeadsValue does not know and any text after the value. -func DecodeVerdictsByGroupHeadsValue(raw []byte) (VerdictsByGroupHeadsValue, error) { - var v VerdictsByGroupHeadsValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err - } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil -} - -// KeptByLevelDigestKey is the key of one value of the state kept under the form ".". -func KeptByLevelDigestKey(level, digest string) string { return level + "." + digest } - -// ParseKeptByLevelDigestKey reads the parts of a key of the form ".", in the order of the form; the last result is false for a key of another form. -func ParseKeptByLevelDigestKey(key string) (string, string, bool) { - rest := key - v0, after0, found0 := strings.Cut(rest, ".") - if !found0 || v0 == "" { - return "", "", false - } - rest = after0 - if rest == "" { - return "", "", false - } - v2 := rest - rest = "" - if rest != "" { - return "", "", false - } - return v0, v2, true -} - -// DecodeKeptByLevelDigestValue reads one value of the state kept under the form ".", refusing a field KeptByLevelDigestValue does not know and any text after the value. -func DecodeKeptByLevelDigestValue(raw []byte) (KeptByLevelDigestValue, error) { - var v KeptByLevelDigestValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err - } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil -} - -// OwedByRepositoryNumberHeadActKey is the key of one value of the state owed under the form "...". -func OwedByRepositoryNumberHeadActKey(repository, number, head, act string) string { - return repository + "." + number + "." + head + "." + act -} - -// ParseOwedByRepositoryNumberHeadActKey reads the parts of a key of the form "...", in the order of the form; the last result is false for a key of another form. -func ParseOwedByRepositoryNumberHeadActKey(key string) (string, string, string, string, bool) { - rest := key - v0, after0, found0 := strings.Cut(rest, ".") - if !found0 || v0 == "" { - return "", "", "", "", false - } - rest = after0 - v2, after2, found2 := strings.Cut(rest, ".") - if !found2 || v2 == "" { - return "", "", "", "", false - } - rest = after2 - v4, after4, found4 := strings.Cut(rest, ".") - if !found4 || v4 == "" { - return "", "", "", "", false - } - rest = after4 - if rest == "" { - return "", "", "", "", false - } - v6 := rest - rest = "" - if rest != "" { - return "", "", "", "", false - } - return v0, v2, v4, v6, true -} - -// DecodeOwedByRepositoryNumberHeadActValue reads one value of the state owed under the form "...", refusing a field OwedByRepositoryNumberHeadActValue does not know and any text after the value. -func DecodeOwedByRepositoryNumberHeadActValue(raw []byte) (OwedByRepositoryNumberHeadActValue, error) { - var v OwedByRepositoryNumberHeadActValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err - } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil -} - -// PreviewsByRepositoryHeadTrunkKey is the key of one value of the state previews under the form "..". -func PreviewsByRepositoryHeadTrunkKey(repository, head, trunk string) string { - return repository + "." + head + "." + trunk -} - -// ParsePreviewsByRepositoryHeadTrunkKey reads the parts of a key of the form "..", in the order of the form; the last result is false for a key of another form. -func ParsePreviewsByRepositoryHeadTrunkKey(key string) (string, string, string, bool) { - rest := key - v0, after0, found0 := strings.Cut(rest, ".") - if !found0 || v0 == "" { - return "", "", "", false - } - rest = after0 - v2, after2, found2 := strings.Cut(rest, ".") - if !found2 || v2 == "" { - return "", "", "", false - } - rest = after2 - if rest == "" { - return "", "", "", false - } - v4 := rest - rest = "" - if rest != "" { - return "", "", "", false - } - return v0, v2, v4, true -} - -// DecodePreviewsByRepositoryHeadTrunkValue reads one value of the state previews under the form "..", refusing a field PreviewsByRepositoryHeadTrunkValue does not know and any text after the value. -func DecodePreviewsByRepositoryHeadTrunkValue(raw []byte) (PreviewsByRepositoryHeadTrunkValue, error) { - var v PreviewsByRepositoryHeadTrunkValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err - } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil -} - -// CheckedEntry is one entry of the candidate checked: a module at its fingerprint. -type CheckedEntry struct { - // the entry's fingerprint - Fp string `json:"fp"` - // the module - Module string `json:"module"` - // the node it was composed for, when the check composed it on one - Node string `json:"node,omitempty"` -} - -// Owed is the status the checker owes the forge for a head, said under its id and safe to repeat (a status replaces what stands); the forge bridge performs it through the seat git's verb status (design 47 *What the gate owes the forge*). -type Owed struct { - // the act: always status - Act string `json:"act"` - // its context, mesh/check - Context string `json:"context"` - // what it says - Description string `json:"description,omitempty"` - // the pull request's head the status is on - Head string `json:"head"` - // the act's id, the same each time it is said again - ID string `json:"id"` - // the pull request's number - Number int64 `json:"number"` - // the repository, / - Repository string `json:"repository"` - // when the checker first said it - Said *time.Time `json:"said,omitempty"` - // pending, success, failure or error - State string `json:"state"` - // the page it links to - Target string `json:"target,omitempty"` -} - -// The values of Owed's act. -const ( - OwedActStatus = "status" -) - -// TryInputMembersItem is a type of the contract. -type TryInputMembersItem struct { - // the full commit to try, 40 or 64 hex digits - Head string `json:"head"` - // / - Repository string `json:"repository"` - // the trunk commit to merge it onto, or the trunk's branch for its head now; the trunk's head when absent - Trunk string `json:"trunk,omitempty"` -} - -// TryInput is what try takes. -type TryInput struct { - // the full commit to try, 40 or 64 hex digits, for a try of one member (instead of members) - Head string `json:"head,omitempty"` - // unit or integration: only this level; both when absent - Level string `json:"level,omitempty"` - // the group: one repository at most once, each at the exact commit asked and the trunk commit it is merged onto; instead of repository and head - Members []TryInputMembersItem `json:"members,omitempty"` - // /, for a try of one member (instead of members) - Repository string `json:"repository,omitempty"` - // a go test -run pattern: only those tests run, and nothing is kept - Tests string `json:"tests,omitempty"` - // the trunk commit to merge it onto, or the trunk's branch for its head now; the trunk's head when absent - Trunk string `json:"trunk,omitempty"` -} - -// TryAnswer is what try answers. -type TryAnswer struct { - // the try's id - ID string `json:"id"` - // its state - State string `json:"state,omitempty"` -} - -// TryReadInput is what try-read takes. -type TryReadInput struct { - // the try's id, try- - ID string `json:"id"` -} - -// TryReadAnswer is what try-read answers. -type TryReadAnswer = map[string]any - -// TryEndInput is what try-end takes. -type TryEndInput struct { - // the try's id, try- - ID string `json:"id"` - // why it is ended, in words - Why string `json:"why"` -} - -// TryEndAnswer is what try-end answers. -type TryEndAnswer struct { - // it is ended - Ended bool `json:"ended"` - // the try - ID string `json:"id"` -} - -// InputInput is what input takes. -type InputInput struct { - // the input's sha256, 64 lowercase hex digits, as the run ask names it - Digest string `json:"digest"` -} - -// InputAnswer is what input answers. -type InputAnswer struct { - // the digest asked - Digest string `json:"digest"` - // the input's exact bytes, base64, so no encoding on the way changes a byte the digest covers - Input string `json:"input"` -} - -// CheckedEvent is the body of the event checked. -type CheckedEvent struct { - // when - At *time.Time `json:"at,omitempty"` - // the candidate's catalog graph revision judged, by its number on the seat mesh-catalog - Catalog int64 `json:"catalog,omitempty"` - // the entries checked - Entries []CheckedEntry `json:"entries,omitempty"` - // the group, its branch - Group string `json:"group"` - // the heads checked, 12 hex digits, as the candidate's revisions are keyed - Heads string `json:"heads"` - // the source revision the heads are merged onto - Source int64 `json:"source,omitempty"` - // pass, fail, or could not run when a part the check needs did not answer - Verdict string `json:"verdict"` - // what failed first, or the part not heard - Words string `json:"words,omitempty"` -} - -// The values of CheckedEvent's verdict. -const ( - CheckedEventVerdictPass = "pass" - CheckedEventVerdictFail = "fail" - CheckedEventVerdictCouldNotRun = "could not run" -) - -// OwedEvent is the body of the event owed. -type OwedEvent = Owed - -// VerdictHolderEventSeriesItem is a type of the contract. -type VerdictHolderEventSeriesItem struct { - // its artifact, or the package's ecosystem name as the module's packages name it - Artifact string `json:"artifact"` - // the series on trunk - From string `json:"from"` - // the module whose artifact's series changes - Module string `json:"module"` - // the series the checked head gives it - To string `json:"to"` -} - -// VerdictHolderEvent is the body of the holder's event verdict. -type VerdictHolderEvent struct { - // the commit checked - Head string `json:"head"` - // the generated files out of step with their seat definitions, each path (design 26) - OutOfStep []string `json:"out-of-step,omitempty"` - // the pull request's number, for a pull request's check - Pull int64 `json:"pull,omitempty"` - // owner/repo - Repository string `json:"repository"` - // each change of an artifact's series the checked head makes against trunk's manifests, once each (design 32); absent when it changes none - Series []VerdictHolderEventSeriesItem `json:"series,omitempty"` - // pass or fail - Verdict string `json:"verdict"` -} - -// VerdictsByGroupHeadsValueComposition is a type of the contract. -type VerdictsByGroupHeadsValueComposition struct { - Fpset string `json:"fpset,omitempty"` - Machines []string `json:"machines,omitempty"` - Sdk string `json:"sdk,omitempty"` - // not-run, pass or fail - State string `json:"state"` - Words string `json:"words,omitempty"` -} - -// VerdictsByGroupHeadsValueFailed is a type of the contract. -type VerdictsByGroupHeadsValueFailed struct { - Machine string `json:"machine,omitempty"` - Test string `json:"test,omitempty"` - Words string `json:"words,omitempty"` -} - -// VerdictsByGroupHeadsValueFailuresItem is a type of the contract. -type VerdictsByGroupHeadsValueFailuresItem struct { - Machine string `json:"machine,omitempty"` - Test string `json:"test,omitempty"` - Words string `json:"words,omitempty"` -} - -// VerdictsByGroupHeadsValueJudgedByHeadsItem is a type of the contract. -type VerdictsByGroupHeadsValueJudgedByHeadsItem struct { - Commit string `json:"commit"` - Repository string `json:"repository"` -} - -// VerdictsByGroupHeadsValueJudgedByProgram is a type of the contract. -type VerdictsByGroupHeadsValueJudgedByProgram struct { - Commit string `json:"commit"` - Dir string `json:"dir"` - Package string `json:"package"` - Repository string `json:"repository"` -} - -// VerdictsByGroupHeadsValueJudgedBy is the checking program that judged the check: where it was built, the key its build is kept under, whether this check's run built it, and the heads it read (ADR 0644, ADR 0656). Absent in a value written before it. -type VerdictsByGroupHeadsValueJudgedBy struct { - Built bool `json:"built,omitempty"` - Heads []VerdictsByGroupHeadsValueJudgedByHeadsItem `json:"heads"` - // program- and 16 hex digits - Key string `json:"key"` - Program VerdictsByGroupHeadsValueJudgedByProgram `json:"program"` -} - -// VerdictsByGroupHeadsValueLevelsValue is a type of the contract. -type VerdictsByGroupHeadsValueLevelsValue struct { - Kept int64 `json:"kept"` - Run int64 `json:"run"` - Skipped int64 `json:"skipped,omitempty"` -} - -// VerdictsByGroupHeadsValueSeriesItem is a type of the contract. -type VerdictsByGroupHeadsValueSeriesItem struct { - Artifact string `json:"artifact"` - From string `json:"from"` - Module string `json:"module"` - To string `json:"to"` -} - -// VerdictsByGroupHeadsValueTook is milliseconds. -type VerdictsByGroupHeadsValueTook struct { - Clone int64 `json:"clone,omitempty"` - Composition int64 `json:"composition,omitempty"` - IntegrationRun int64 `json:"integration-run,omitempty"` - IntegrationSetup int64 `json:"integration-setup,omitempty"` - Lint int64 `json:"lint,omitempty"` - Queue int64 `json:"queue,omitempty"` - Unit int64 `json:"unit,omitempty"` -} - -// VerdictsByGroupHeadsValue is one value of the state verdicts under the key .. -type VerdictsByGroupHeadsValue struct { - Beside map[string]string `json:"beside,omitempty"` - CarriedFrom map[string]string `json:"carried-from,omitempty"` - Composition *VerdictsByGroupHeadsValueComposition `json:"composition,omitempty"` - Failed *VerdictsByGroupHeadsValueFailed `json:"failed,omitempty"` - Failures []VerdictsByGroupHeadsValueFailuresItem `json:"failures,omitempty"` - Group string `json:"group"` - // 12 hex digits - Heads string `json:"heads"` - // the checking program that judged the check: where it was built, the key its build is kept under, whether this check's run built it, and the heads it read (ADR 0644, ADR 0656). Absent in a value written before it - JudgedBy *VerdictsByGroupHeadsValueJudgedBy `json:"judged-by,omitempty"` - // by level, unit or integration - Levels map[string]VerdictsByGroupHeadsValueLevelsValue `json:"levels,omitempty"` - Machines []string `json:"machines,omitempty"` - OverBound []string `json:"over-bound,omitempty"` - Sdk string `json:"sdk,omitempty"` - Series []VerdictsByGroupHeadsValueSeriesItem `json:"series,omitempty"` - // running, pass or fail - State string `json:"state"` - // milliseconds - Took *VerdictsByGroupHeadsValueTook `json:"took,omitempty"` - // repository to the trunk head merged onto - Trunk map[string]string `json:"trunk,omitempty"` - // the layout version - V int64 `json:"v,omitempty"` -} - -// KeptByLevelDigestValue is one value of the state kept under the key .. -type KeptByLevelDigestValue struct { - // when (RFC 3339 time) - At string `json:"at,omitempty"` - Level string `json:"level"` - Package string `json:"package"` - Repository string `json:"repository"` - // pass: a failure is never kept - State string `json:"state"` - Tests int64 `json:"tests,omitempty"` - Took int64 `json:"took,omitempty"` - Toolchain string `json:"toolchain,omitempty"` - // the layout version - V int64 `json:"v,omitempty"` -} - -// OwedByRepositoryNumberHeadActValue is one value of the state owed under the key .... -type OwedByRepositoryNumberHeadActValue struct { - // status=, view, note or comment. - Act string `json:"act"` - Context string `json:"context,omitempty"` - Ref string `json:"ref,omitempty"` - State string `json:"state,omitempty"` - Target string `json:"target,omitempty"` - Text string `json:"text,omitempty"` - // the layout version - V int64 `json:"v,omitempty"` -} - -// PreviewsByRepositoryHeadTrunkValueModulesValue is a type of the contract. -type PreviewsByRepositoryHeadTrunkValueModulesValue struct { - Locks map[string]string `json:"locks,omitempty"` - // manifest digest - Manifest string `json:"manifest"` - Packages []string `json:"packages,omitempty"` - Paths map[string]string `json:"paths,omitempty"` - Tree string `json:"tree"` -} - -// PreviewsByRepositoryHeadTrunkValue is one value of the state previews under the key ... -type PreviewsByRepositoryHeadTrunkValue struct { - // files in conflict - Conflicts []string `json:"conflicts,omitempty"` - Head string `json:"head"` - // the merge commit - Merge string `json:"merge,omitempty"` - // by directory - Modules map[string]PreviewsByRepositoryHeadTrunkValueModulesValue `json:"modules,omitempty"` - Repository string `json:"repository"` - Trunk string `json:"trunk"` - // the layout version - V int64 `json:"v,omitempty"` -} diff --git a/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker/contract_test.go deleted file mode 100644 index d88df869..00000000 --- a/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker/contract_test.go +++ /dev/null @@ -1,86 +0,0 @@ -// Code generated by seatgen from the seat definitions; DO NOT EDIT. - -package meshdeliverychecker - -import ( - "encoding/json" - "reflect" - "regexp" - "testing" -) - -// TestFixtures reads every fixture of seats/mesh-delivery-checker/fixtures: each decodes into its type, a field the type does not -// know is dropped (ADR 0608 §6), and it reads back as its wire says; each subject named is the contract's. -func TestFixtures(t *testing.T) { - cases := []struct { - name, subject, given, wire string - decode func([]byte) (any, error) - subjectIs *regexp.Regexp - }{ - {name: "verdict on the checker's own family", subject: "mesh.stream.mesh-delivery-checker.event.verdict", given: "{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"out-of-step\":[\"go/seats/meshbroker/contract.go\"],\"pull\":3,\"repository\":\"novox/mesh-contracts\",\"series\":[{\"artifact\":\"go\",\"from\":\"0.1\",\"module\":\"mesh-contracts\",\"to\":\"0.2\"}],\"verdict\":\"fail\"}", wire: "{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"out-of-step\":[\"go/seats/meshbroker/contract.go\"],\"pull\":3,\"repository\":\"novox/mesh-contracts\",\"series\":[{\"artifact\":\"go\",\"from\":\"0.1\",\"module\":\"mesh-contracts\",\"to\":\"0.2\"}],\"verdict\":\"fail\"}", - decode: func(b []byte) (any, error) { var v VerdictHolderEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.stream\\.[a-z0-9-]+\\.event\\.verdict$")}, - {name: "preview.written on the checker's stream", subject: "mesh.stream.mesh-delivery-checker.event.preview.written", given: "{}", wire: "{}", - decode: func(b []byte) (any, error) { var v map[string]any; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.stream\\.[a-z0-9-]+\\.event\\.preview\\.written$")}, - {name: "checked is said", subject: "mesh.seat.mesh-delivery-checker.event.checked", given: "{\"at\":\"2026-11-09T20:30:00Z\",\"catalog\":3612,\"entries\":[{\"fp\":\"src2:1480985e\",\"module\":\"mesh-delivery-gate\"}],\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"source\":3611,\"verdict\":\"pass\"}", wire: "{\"at\":\"2026-11-09T20:30:00Z\",\"catalog\":3612,\"entries\":[{\"fp\":\"src2:1480985e\",\"module\":\"mesh-delivery-gate\"}],\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"source\":3611,\"verdict\":\"pass\"}", - decode: func(b []byte) (any, error) { var v CheckedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery-checker\\.event\\.checked$")}, - {name: "checked is said when it could not run", subject: "mesh.seat.mesh-delivery-checker.event.checked", given: "{\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"verdict\":\"could not run\",\"words\":\"the seat git's holder did not answer\"}", wire: "{\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"verdict\":\"could not run\",\"words\":\"the seat git's holder did not answer\"}", - decode: func(b []byte) (any, error) { var v CheckedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery-checker\\.event\\.checked$")}, - {name: "owed is said", subject: "mesh.seat.mesh-delivery-checker.event.owed.novox/mesh-sdk.178", given: "{\"act\":\"status\",\"context\":\"mesh/check\",\"description\":\"passed\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/check\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"said\":\"2026-11-09T20:30:00Z\",\"state\":\"success\",\"target\":\"https://forge.test/x\"}", wire: "{\"act\":\"status\",\"context\":\"mesh/check\",\"description\":\"passed\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"id\":\"status.novox/mesh-sdk#178.aaaaaaaaaaaa.mesh/check\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"said\":\"2026-11-09T20:30:00Z\",\"state\":\"success\",\"target\":\"https://forge.test/x\"}", - decode: func(b []byte) (any, error) { var v OwedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery-checker\\.event\\.owed\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "a running verdict", subject: "", given: "{\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"state\":\"running\",\"v\":1}", wire: "{\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"state\":\"running\",\"v\":1}", - decode: func(b []byte) (any, error) { - var v VerdictsByGroupHeadsValue - err := json.Unmarshal(b, &v) - return v, err - }, subjectIs: nil}, - {name: "a pass judged by the checking program built at a mesh-delivery head", subject: "", given: "{\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"judged-by\":{\"built\":true,\"heads\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-delivery\"}],\"key\":\"program-0123456789abcdef\",\"program\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"dir\":\"modules/mesh-delivery-checker\",\"package\":\"./cmd/mesh-checking-program\",\"repository\":\"novox/mesh-delivery\"}},\"levels\":{\"integration\":{\"kept\":0,\"run\":3},\"unit\":{\"kept\":0,\"run\":12}},\"state\":\"pass\",\"v\":1}", wire: "{\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"judged-by\":{\"built\":true,\"heads\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"repository\":\"novox/mesh-delivery\"}],\"key\":\"program-0123456789abcdef\",\"program\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"dir\":\"modules/mesh-delivery-checker\",\"package\":\"./cmd/mesh-checking-program\",\"repository\":\"novox/mesh-delivery\"}},\"levels\":{\"integration\":{\"kept\":0,\"run\":3},\"unit\":{\"kept\":0,\"run\":12}},\"state\":\"pass\",\"v\":1}", - decode: func(b []byte) (any, error) { - var v VerdictsByGroupHeadsValue - err := json.Unmarshal(b, &v) - return v, err - }, subjectIs: nil}, - {name: "a kept pass", subject: "", given: "{\"at\":\"2026-11-05T10:00:00Z\",\"level\":\"unit\",\"package\":\"go/keys\",\"repository\":\"novox/mesh-sdk\",\"state\":\"pass\",\"tests\":4,\"took\":120,\"toolchain\":\"go1.26\",\"v\":1}", wire: "{\"at\":\"2026-11-05T10:00:00Z\",\"level\":\"unit\",\"package\":\"go/keys\",\"repository\":\"novox/mesh-sdk\",\"state\":\"pass\",\"tests\":4,\"took\":120,\"toolchain\":\"go1.26\",\"v\":1}", - decode: func(b []byte) (any, error) { var v KeptByLevelDigestValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "the status owed for a head", subject: "", given: "{\"act\":\"status=mesh/check\",\"context\":\"mesh/check\",\"state\":\"success\",\"v\":1}", wire: "{\"act\":\"status=mesh/check\",\"context\":\"mesh/check\",\"state\":\"success\",\"v\":1}", - decode: func(b []byte) (any, error) { - var v OwedByRepositoryNumberHeadActValue - err := json.Unmarshal(b, &v) - return v, err - }, subjectIs: nil}, - {name: "a preview", subject: "", given: "{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"merge\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"repository\":\"novox/mesh-sdk\",\"trunk\":\"dddddddddddddddddddddddddddddddddddddddd\",\"v\":1}", wire: "{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"merge\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"repository\":\"novox/mesh-sdk\",\"trunk\":\"dddddddddddddddddddddddddddddddddddddddd\",\"v\":1}", - decode: func(b []byte) (any, error) { - var v PreviewsByRepositoryHeadTrunkValue - err := json.Unmarshal(b, &v) - return v, err - }, subjectIs: nil}, - {name: "a checking program asks its input by its digest", subject: "", given: "{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"}", wire: "{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"}", - decode: func(b []byte) (any, error) { var v InputInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "the input answered as its exact bytes, base64", subject: "", given: "{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"input\":\"eyJ2IjoxfQ==\"}", wire: "{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"input\":\"eyJ2IjoxfQ==\"}", - decode: func(b []byte) (any, error) { var v InputAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - } - for _, c := range cases { - v, err := c.decode([]byte(c.given)) - if err != nil { - t.Errorf("%s: does not decode: %v", c.name, err) - continue - } - back, err := json.Marshal(v) - if err != nil { - t.Errorf("%s: does not encode: %v", c.name, err) - continue - } - var got, want any - if err := json.Unmarshal(back, &got); err != nil { - t.Fatal(err) - } - if err := json.Unmarshal([]byte(c.wire), &want); err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(got, want) { - t.Errorf("%s: reads back as %s, want %s", c.name, back, c.wire) - } - if c.subjectIs != nil && !c.subjectIs.MatchString(c.subject) { - t.Errorf("%s: subject %q is not the contract's %s", c.name, c.subject, c.subjectIs) - } - } -} diff --git a/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker/go.mod b/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker/go.mod deleted file mode 100644 index 50d16d24..00000000 --- a/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdeliverychecker - -go 1.26.0 diff --git a/modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/index.d.ts deleted file mode 100644 index 33710ac4..00000000 --- a/modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/index.d.ts +++ /dev/null @@ -1,371 +0,0 @@ -// Code generated by seatgen from the seat definitions; DO NOT EDIT. - -// The contract of the seat "mesh-delivery-checker", defined whole (seats/mesh-delivery-checker/seat.json): The merge check's tries: start one, read one, end one. The seat says each check's end as checked and what the checker owes the forge as owed; the checker's other events stay under its own subjects (ADR 0620 §2). - -export declare const seat: "mesh-delivery-checker"; - -export declare const verbs: { - readonly try: "try"; - readonly tryRead: "try-read"; - readonly tryEnd: "try-end"; - readonly input: "input"; -}; - -export declare const events: { - readonly checked: "checked"; - readonly owed: "owed"; -}; - -export declare const family: { readonly name: "mesh-delivery-checker.events"; readonly maxAgeDays: 7 }; - -export declare const checkedSubject: "mesh.seat.mesh-delivery-checker.event.checked"; - -export declare const owedStream: "SEAT_mesh-delivery-checker_owed"; - -export declare function owedSubject(repository: string, number: string): string; - -export declare const owedSubjectAll: "mesh.seat.mesh-delivery-checker.event.owed.*.*"; - -export declare const holderEvents: { - readonly verdict: "verdict"; - readonly previewWritten: "preview.written"; -}; - -export declare function verdictHolderSubject(holder: string): string; - -export declare function previewWrittenHolderSubject(holder: string): string; - -export declare const states: { - readonly verdicts: "verdicts"; - readonly kept: "kept"; - readonly owed: "owed"; - readonly previews: "previews"; -}; - -/** The key of one value of the state verdicts under the form ".". */ -export declare function verdictsByGroupHeadsKey(group: string, heads: string): string; - -/** The parts of a key of the form ".", or undefined for a key of another form. */ -export declare function parseVerdictsByGroupHeadsKey(_key: string): { group: string; heads: string } | undefined; - -/** The key of one value of the state kept under the form ".". */ -export declare function keptByLevelDigestKey(level: string, digest: string): string; - -/** The parts of a key of the form ".", or undefined for a key of another form. */ -export declare function parseKeptByLevelDigestKey(_key: string): { level: string; digest: string } | undefined; - -/** The key of one value of the state owed under the form "...". */ -export declare function owedByRepositoryNumberHeadActKey(repository: string, number: string, head: string, act: string): string; - -/** The parts of a key of the form "...", or undefined for a key of another form. */ -export declare function parseOwedByRepositoryNumberHeadActKey(_key: string): { repository: string; number: string; head: string; act: string } | undefined; - -/** The key of one value of the state previews under the form "..". */ -export declare function previewsByRepositoryHeadTrunkKey(repository: string, head: string, trunk: string): string; - -/** The parts of a key of the form "..", or undefined for a key of another form. */ -export declare function parsePreviewsByRepositoryHeadTrunkKey(_key: string): { repository: string; head: string; trunk: string } | undefined; - -/** one entry of the candidate checked: a module at its fingerprint */ -export interface CheckedEntry { - /** the entry's fingerprint */ - "fp": string; - /** the module */ - "module": string; - /** the node it was composed for, when the check composed it on one */ - "node"?: string; -} - -/** the status the checker owes the forge for a head, said under its id and safe to repeat (a status replaces what stands); the forge bridge performs it through the seat git's verb status (design 47 *What the gate owes the forge*) */ -export interface Owed { - /** the act: always status */ - "act": "status"; - /** its context, mesh/check */ - "context": string; - /** what it says */ - "description"?: string; - /** the pull request's head the status is on */ - "head": string; - /** the act's id, the same each time it is said again */ - "id": string; - /** the pull request's number */ - "number": number; - /** the repository, / */ - "repository": string; - /** when the checker first said it */ - "said"?: string; - /** pending, success, failure or error */ - "state": string; - /** the page it links to */ - "target"?: string; -} - -export interface TryInputMembersItem { - /** the full commit to try, 40 or 64 hex digits */ - "head": string; - /** / */ - "repository": string; - /** the trunk commit to merge it onto, or the trunk's branch for its head now; the trunk's head when absent */ - "trunk"?: string; -} - -/** is what try takes. */ -export interface TryInput { - /** the full commit to try, 40 or 64 hex digits, for a try of one member (instead of members) */ - "head"?: string; - /** unit or integration: only this level; both when absent */ - "level"?: string; - /** the group: one repository at most once, each at the exact commit asked and the trunk commit it is merged onto; instead of repository and head */ - "members"?: TryInputMembersItem[]; - /** /, for a try of one member (instead of members) */ - "repository"?: string; - /** a go test -run pattern: only those tests run, and nothing is kept */ - "tests"?: string; - /** the trunk commit to merge it onto, or the trunk's branch for its head now; the trunk's head when absent */ - "trunk"?: string; -} - -/** is what try answers. */ -export interface TryAnswer { - /** the try's id */ - "id": string; - /** its state */ - "state"?: string; -} - -/** is what try-read takes. */ -export interface TryReadInput { - /** the try's id, try- */ - "id": string; -} - -/** is what try-read answers. */ -export type TryReadAnswer = Record; - -/** is what try-end takes. */ -export interface TryEndInput { - /** the try's id, try- */ - "id": string; - /** why it is ended, in words */ - "why": string; -} - -/** is what try-end answers. */ -export interface TryEndAnswer { - /** it is ended */ - "ended": boolean; - /** the try */ - "id": string; -} - -/** is what input takes. */ -export interface InputInput { - /** the input's sha256, 64 lowercase hex digits, as the run ask names it */ - "digest": string; -} - -/** is what input answers. */ -export interface InputAnswer { - /** the digest asked */ - "digest": string; - /** the input's exact bytes, base64, so no encoding on the way changes a byte the digest covers */ - "input": string; -} - -/** is the body of the event checked. */ -export interface CheckedEvent { - /** when */ - "at"?: string; - /** the candidate's catalog graph revision judged, by its number on the seat mesh-catalog */ - "catalog"?: number; - /** the entries checked */ - "entries"?: CheckedEntry[]; - /** the group, its branch */ - "group": string; - /** the heads checked, 12 hex digits, as the candidate's revisions are keyed */ - "heads": string; - /** the source revision the heads are merged onto */ - "source"?: number; - /** pass, fail, or could not run when a part the check needs did not answer */ - "verdict": "pass" | "fail" | "could not run"; - /** what failed first, or the part not heard */ - "words"?: string; -} - -/** is the body of the event owed. */ -export type OwedEvent = Owed; - -export interface VerdictHolderEventSeriesItem { - /** its artifact, or the package's ecosystem name as the module's packages name it */ - "artifact": string; - /** the series on trunk */ - "from": string; - /** the module whose artifact's series changes */ - "module": string; - /** the series the checked head gives it */ - "to": string; -} - -/** is the body of the holder's event verdict. */ -export interface VerdictHolderEvent { - /** the commit checked */ - "head": string; - /** the generated files out of step with their seat definitions, each path (design 26) */ - "out-of-step"?: string[]; - /** the pull request's number, for a pull request's check */ - "pull"?: number; - /** owner/repo */ - "repository": string; - /** each change of an artifact's series the checked head makes against trunk's manifests, once each (design 32); absent when it changes none */ - "series"?: VerdictHolderEventSeriesItem[]; - /** pass or fail */ - "verdict": string; -} - -export interface VerdictsByGroupHeadsValueComposition { - "fpset"?: string; - "machines"?: string[]; - "sdk"?: string; - /** not-run, pass or fail */ - "state": string; - "words"?: string; -} - -export interface VerdictsByGroupHeadsValueFailed { - "machine"?: string; - "test"?: string; - "words"?: string; -} - -export interface VerdictsByGroupHeadsValueFailuresItem { - "machine"?: string; - "test"?: string; - "words"?: string; -} - -export interface VerdictsByGroupHeadsValueJudgedByHeadsItem { - "commit": string; - "repository": string; -} - -export interface VerdictsByGroupHeadsValueJudgedByProgram { - "commit": string; - "dir": string; - "package": string; - "repository": string; -} - -/** the checking program that judged the check: where it was built, the key its build is kept under, whether this check's run built it, and the heads it read (ADR 0644, ADR 0656). Absent in a value written before it */ -export interface VerdictsByGroupHeadsValueJudgedBy { - "built"?: boolean; - "heads": VerdictsByGroupHeadsValueJudgedByHeadsItem[]; - /** program- and 16 hex digits */ - "key": string; - "program": VerdictsByGroupHeadsValueJudgedByProgram; -} - -export interface VerdictsByGroupHeadsValueLevelsValue { - "kept": number; - "run": number; - "skipped"?: number; -} - -export interface VerdictsByGroupHeadsValueSeriesItem { - "artifact": string; - "from": string; - "module": string; - "to": string; -} - -/** milliseconds */ -export interface VerdictsByGroupHeadsValueTook { - "clone"?: number; - "composition"?: number; - "integration-run"?: number; - "integration-setup"?: number; - "lint"?: number; - "queue"?: number; - "unit"?: number; -} - -/** is one value of the state verdicts under the key .. */ -export interface VerdictsByGroupHeadsValue { - "beside"?: Record; - "carried-from"?: Record; - "composition"?: VerdictsByGroupHeadsValueComposition; - "failed"?: VerdictsByGroupHeadsValueFailed; - "failures"?: VerdictsByGroupHeadsValueFailuresItem[]; - "group": string; - /** 12 hex digits */ - "heads": string; - /** the checking program that judged the check: where it was built, the key its build is kept under, whether this check's run built it, and the heads it read (ADR 0644, ADR 0656). Absent in a value written before it */ - "judged-by"?: VerdictsByGroupHeadsValueJudgedBy; - /** by level, unit or integration */ - "levels"?: Record; - "machines"?: string[]; - "over-bound"?: string[]; - "sdk"?: string; - "series"?: VerdictsByGroupHeadsValueSeriesItem[]; - /** running, pass or fail */ - "state": string; - /** milliseconds */ - "took"?: VerdictsByGroupHeadsValueTook; - /** repository to the trunk head merged onto */ - "trunk"?: Record; - /** the layout version */ - "v"?: number; -} - -/** is one value of the state kept under the key .. */ -export interface KeptByLevelDigestValue { - /** when (RFC 3339 time) */ - "at"?: string; - "level": string; - "package": string; - "repository": string; - /** pass: a failure is never kept */ - "state": string; - "tests"?: number; - "took"?: number; - "toolchain"?: string; - /** the layout version */ - "v"?: number; -} - -/** is one value of the state owed under the key .... */ -export interface OwedByRepositoryNumberHeadActValue { - /** status=, view, note or comment. */ - "act": string; - "context"?: string; - "ref"?: string; - "state"?: string; - "target"?: string; - "text"?: string; - /** the layout version */ - "v"?: number; -} - -export interface PreviewsByRepositoryHeadTrunkValueModulesValue { - "locks"?: Record; - /** manifest digest */ - "manifest": string; - "packages"?: string[]; - "paths"?: Record; - "tree": string; -} - -/** is one value of the state previews under the key ... */ -export interface PreviewsByRepositoryHeadTrunkValue { - /** files in conflict */ - "conflicts"?: string[]; - "head": string; - /** the merge commit */ - "merge"?: string; - /** by directory */ - "modules"?: Record; - "repository": string; - "trunk": string; - /** the layout version */ - "v"?: number; -} - diff --git a/modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/index.js b/modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/index.js deleted file mode 100644 index f5d59fc9..00000000 --- a/modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/index.js +++ /dev/null @@ -1,138 +0,0 @@ -// Code generated by seatgen from the seat definitions; DO NOT EDIT. - -// The contract of the seat "mesh-delivery-checker", defined whole (seats/mesh-delivery-checker/seat.json): The merge check's tries: start one, read one, end one. The seat says each check's end as checked and what the checker owes the forge as owed; the checker's other events stay under its own subjects (ADR 0620 §2). - -export const seat = "mesh-delivery-checker"; - -export const verbs = { - try: "try", - tryRead: "try-read", - tryEnd: "try-end", - input: "input", -}; - -export const events = { - checked: "checked", - owed: "owed", -}; - -export const family = { name: "mesh-delivery-checker.events", maxAgeDays: 7 }; - -export const checkedSubject = "mesh.seat.mesh-delivery-checker.event.checked"; - -export const owedStream = "SEAT_mesh-delivery-checker_owed"; - -export function owedSubject(repository, number) { - return "mesh.seat.mesh-delivery-checker.event.owed." + repository + "." + number; -} - -export const owedSubjectAll = "mesh.seat.mesh-delivery-checker.event.owed.*.*"; - -export const holderEvents = { - verdict: "verdict", - previewWritten: "preview.written", -}; - -export function verdictHolderSubject(holder) { - return "mesh.stream." + holder + ".event.verdict"; -} - -export function previewWrittenHolderSubject(holder) { - return "mesh.stream." + holder + ".event.preview.written"; -} - -export const states = { - verdicts: "verdicts", - kept: "kept", - owed: "owed", - previews: "previews", -}; - -/** The key of one value of the state verdicts under the form ".". */ -export function verdictsByGroupHeadsKey(group, heads) { - return group + "." + heads; -} - -/** The parts of a key of the form ".", or undefined for a key of another form. */ -export function parseVerdictsByGroupHeadsKey(_key) { - let _rest = _key; - const _at0 = _rest.indexOf("."); - if (_at0 <= 0) return undefined; - const group = _rest.slice(0, _at0); - _rest = _rest.slice(_at0 + 1); - if (_rest === "") return undefined; - const heads = _rest; - _rest = ""; - if (_rest !== "") return undefined; - return { group, heads }; -} - -/** The key of one value of the state kept under the form ".". */ -export function keptByLevelDigestKey(level, digest) { - return level + "." + digest; -} - -/** The parts of a key of the form ".", or undefined for a key of another form. */ -export function parseKeptByLevelDigestKey(_key) { - let _rest = _key; - const _at0 = _rest.indexOf("."); - if (_at0 <= 0) return undefined; - const level = _rest.slice(0, _at0); - _rest = _rest.slice(_at0 + 1); - if (_rest === "") return undefined; - const digest = _rest; - _rest = ""; - if (_rest !== "") return undefined; - return { level, digest }; -} - -/** The key of one value of the state owed under the form "...". */ -export function owedByRepositoryNumberHeadActKey(repository, number, head, act) { - return repository + "." + number + "." + head + "." + act; -} - -/** The parts of a key of the form "...", or undefined for a key of another form. */ -export function parseOwedByRepositoryNumberHeadActKey(_key) { - let _rest = _key; - const _at0 = _rest.indexOf("."); - if (_at0 <= 0) return undefined; - const repository = _rest.slice(0, _at0); - _rest = _rest.slice(_at0 + 1); - const _at2 = _rest.indexOf("."); - if (_at2 <= 0) return undefined; - const number = _rest.slice(0, _at2); - _rest = _rest.slice(_at2 + 1); - const _at4 = _rest.indexOf("."); - if (_at4 <= 0) return undefined; - const head = _rest.slice(0, _at4); - _rest = _rest.slice(_at4 + 1); - if (_rest === "") return undefined; - const act = _rest; - _rest = ""; - if (_rest !== "") return undefined; - return { repository, number, head, act }; -} - -/** The key of one value of the state previews under the form "..". */ -export function previewsByRepositoryHeadTrunkKey(repository, head, trunk) { - return repository + "." + head + "." + trunk; -} - -/** The parts of a key of the form "..", or undefined for a key of another form. */ -export function parsePreviewsByRepositoryHeadTrunkKey(_key) { - let _rest = _key; - const _at0 = _rest.indexOf("."); - if (_at0 <= 0) return undefined; - const repository = _rest.slice(0, _at0); - _rest = _rest.slice(_at0 + 1); - const _at2 = _rest.indexOf("."); - if (_at2 <= 0) return undefined; - const head = _rest.slice(0, _at2); - _rest = _rest.slice(_at2 + 1); - if (_rest === "") return undefined; - const trunk = _rest; - _rest = ""; - if (_rest !== "") return undefined; - return { repository, head, trunk }; -} - diff --git a/modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/package-lock.json b/modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/package-lock.json deleted file mode 100644 index c5d3fd93..00000000 --- a/modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/package-lock.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "lockfileVersion": 3, - "name": "@novox/mesh-delivery-contracts-mesh-delivery-checker", - "packages": { - "": { - "name": "@novox/mesh-delivery-contracts-mesh-delivery-checker", - "version": "0.1.0" - } - }, - "requires": true, - "version": "0.1.0" -} diff --git a/modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/package.json b/modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/package.json deleted file mode 100644 index 3eb16f11..00000000 --- a/modules/mesh-delivery-contracts/ts/seats/meshdeliverychecker/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "The contract of the seat mesh-delivery-checker, generated from its definition.", - "exports": { - ".": { - "default": "./index.js", - "types": "./index.d.ts" - } - }, - "files": [ - "index.js", - "index.d.ts", - "parts" - ], - "name": "@novox/mesh-delivery-contracts-mesh-delivery-checker", - "type": "module", - "types": "./index.d.ts", - "version": "0.1.0" -}