diff --git a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go index 78a304fd..18ee10d6 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go @@ -3,6 +3,7 @@ package meshcatalogclient import ( "encoding/json" "errors" + "os" "slices" "strings" "testing" @@ -101,54 +102,30 @@ func TestManifestAndModuleValuesKeepTheirRules(t *testing.T) { } } -// A verdict is taken as the readers have always taken it: a missing one accepted, a refusal held with its problems, a wait -// held with the fields it waits on, and a module's own verdict field gives the same. -func TestVerdictsAreTakenAsTheReadersTookThem(t *testing.T) { - if refused, problems := TakeVerdict(nil); refused || problems != nil { - t.Errorf("no verdict: %v %v", refused, problems) - } - waits := seat.VerdictsByDigestValue{Module: "nats", State: VerdictManifestWaits, Unknown: []string{"series"}, Judge: "j"} - refused, problems := TakeVerdict(&waits) - if !refused || len(problems) != 1 || problems[0] != "it carries series, which the indexer's judge does not know yet" { - t.Errorf("a wait: %v %v", refused, problems) - } - if got := VerdictWhy(waits); got != "the indexer's judge (j) holds the manifest of nats: "+problems[0] { - t.Errorf("VerdictWhy(wait) = %q", got) - } - if as := VerdictAsRefused(waits); as.State != VerdictRefused || len(as.Unknown) != 0 || as.Problems[0] != problems[0] { - t.Errorf("VerdictAsRefused = %+v", as) - } - no := seat.VerdictsByDigestValue{Module: "nats", State: VerdictRefused, Problems: []string{"a", "b"}, Judge: "j"} - if got := VerdictWhy(no); got != "the indexer's judge (j) refused the manifest of nats: a; b" { - t.Errorf("VerdictWhy(refused) = %q", got) - } - if !SameVerdict(no, seat.VerdictsByDigestValue{Module: "nats", State: VerdictRefused, Problems: []string{"a", "b"}, Judge: "k"}) { - t.Error("another judge is another verdict") - } - fromModule := ModuleVerdict("nats", seat.ModulesByModuleValue{Verdict: VerdictRefused, Unknown: []string{"series"}, Problems: []string{"x"}}) - if fromModule == nil || fromModule.State != VerdictManifestWaits || fromModule.Unknown[0] != "series" { - t.Errorf("a refusal naming unknown fields is the wait it was written as: %+v", fromModule) - } - if ModuleVerdict("nats", seat.ModulesByModuleValue{}) != nil { - t.Error("a module with no verdict carries one") - } - for _, bad := range []seat.VerdictsByDigestValue{{Module: "nats", State: "accepted", Problems: []string{"p"}, Judge: "j"}, {Module: "nats", State: "refused", Judge: "j"}, {Module: "nats", State: "accepted"}, {Module: "nats", State: "odd", Judge: "j"}} { - if _, err := EncodeVerdict(bad); err == nil { - t.Errorf("EncodeVerdict(%+v) is accepted", bad) - } - } - raw, err := EncodeVerdict(no) +// design 47 H §745, H-A-79: the validation leaves the take-in, so the seat keeps no state verdicts; a module's own +// verdict field keeps its three states. +func TestNoVerdictsState(t *testing.T) { + raw, err := os.ReadFile("../../../seats/mesh-catalog/seat.json") if err != nil { t.Fatal(err) } - if v, err := DecodeVerdict(raw); err != nil || !SameVerdict(v, no) { - t.Errorf("DecodeVerdict = %+v, %v", v, err) + var def struct { + States []struct { + Name string `json:"name"` + } `json:"states"` } - if k, err := VerdictsKey(hex64("c")); err != nil || k != hex64("c") { - t.Errorf("VerdictsKey = %q %v", k, err) + if err := json.Unmarshal(raw, &def); err != nil { + t.Fatal(err) } - if _, err := ModulesKey("a.b"); err == nil { - t.Error("ModulesKey accepts a dotted name") + for _, st := range def.States { + if st.Name == "verdicts" { + t.Error("the seat mesh-catalog still declares the state verdicts") + } + } + for _, v := range []string{VerdictAccepted, VerdictRefused, VerdictManifestWaits} { + if v == "" { + t.Error("a module's verdict state is empty") + } } } diff --git a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/verdict.go b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/verdict.go index 2f4bcdfb..35144af9 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/verdict.go +++ b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/verdict.go @@ -1,17 +1,7 @@ package meshcatalogclient -import ( - "encoding/json" - "fmt" - "slices" - "strings" - - seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-sdk/go/keys" -) - -// The states of a verdict on a manifest (novox/hq ADR 0578 §1): the indexer judges every manifest it takes in once and -// every other part takes the verdict from the seat's state `verdicts`. +// The states of a module's verdict field on a manifest (novox/hq ADR 0578 §1); the seat keeps no state verdicts, since the +// validation is the pipeline step validate (design 47 H §745, H-A-79). const ( // VerdictAccepted is the state of a manifest the judge found no problem in. VerdictAccepted = "accepted" @@ -22,147 +12,3 @@ const ( // one and keeps what runs. In a `modules` value it is written as a refusal naming the fields. VerdictManifestWaits = "waits" ) - -// VerdictsKey is the key of a `verdicts` value: the digest of the manifest it judges. -func VerdictsKey(digest string) (string, error) { - if !keys.IsHex64(digest) { - return "", fmt.Errorf("meshcatalogclient: %q is not a manifest digest, 64 lowercase hex digits", digest) - } - return seat.VerdictsByDigestKey(digest), nil -} - -// VerdictRefuses says whether v refuses its manifest. -func VerdictRefuses(v seat.VerdictsByDigestValue) bool { return v.State == VerdictRefused } - -// VerdictWaits says whether v says the manifest waits for a judge that knows its fields. -func VerdictWaits(v seat.VerdictsByDigestValue) bool { return v.State == VerdictManifestWaits } - -// VerdictHeld says whether a reader holds the module as refused: the manifest is refused or waits. -func VerdictHeld(v seat.VerdictsByDigestValue) bool { return VerdictRefuses(v) || VerdictWaits(v) } - -// WaitsOn says, in words, what a waiting manifest waits on. -func WaitsOn(v seat.VerdictsByDigestValue) string { - return "it carries " + strings.Join(v.Unknown, ", ") + ", which the indexer's judge does not know yet" -} - -// TakeVerdict is how a reader takes the verdict on a manifest (ADR 0578 §3): held, with its problems, when the indexer -// wrote a refusal, or, for a manifest that waits, with the words that say which fields it waits on. A missing verdict (nil) -// is taken as accepted: every manifest the indexer holds before it has judged it was taken in under the judges that ran -// until then. A reader holds a refused module and names it with VerdictWhy, and reads the rest. -func TakeVerdict(v *seat.VerdictsByDigestValue) (refused bool, problems []string) { - if v == nil || !VerdictHeld(*v) { - return false, nil - } - if VerdictWaits(*v) { - return true, []string{WaitsOn(*v)} - } - return true, v.Problems -} - -// VerdictWhy is a refusal in a reader's words: the module, that the indexer's judge refused its manifest, and each problem. -func VerdictWhy(v seat.VerdictsByDigestValue) string { - if !VerdictHeld(v) { - return "" - } - judge := "the indexer's judge" - if v.Judge != "" { - judge += " (" + v.Judge + ")" - } - if VerdictWaits(v) { - return fmt.Sprintf("%s holds the manifest of %s: %s", judge, v.Module, WaitsOn(v)) - } - why := fmt.Sprintf("%s refused the manifest of %s:", judge, v.Module) - for _, p := range v.Problems { - why += " " + p + ";" - } - return why[:len(why)-1] -} - -// VerdictAsRefused is v as a reader that does not know the waiting state takes it: a waiting verdict is a refusal naming what -// it waits on, any other verdict is v. -func VerdictAsRefused(v seat.VerdictsByDigestValue) seat.VerdictsByDigestValue { - if !VerdictWaits(v) { - return v - } - v.State, v.Problems, v.Unknown = VerdictRefused, []string{WaitsOn(v)}, nil - return v -} - -// SameVerdict says whether v and o say the same of a manifest: the module, the state, the problems, the unknown fields and -// the warnings, whoever judged and when. The indexer writes a verdict only when it is not the same as the one it holds. -func SameVerdict(v, o seat.VerdictsByDigestValue) bool { - return v.Module == o.Module && v.State == o.State && slices.Equal(v.Problems, o.Problems) && slices.Equal(v.Unknown, o.Unknown) && slices.Equal(v.Warnings, o.Warnings) -} - -func checkVerdict(v seat.VerdictsByDigestValue) error { - if err := keys.CheckName("module", v.Module); err != nil { - return err - } - if v.State != VerdictManifestWaits && len(v.Unknown) > 0 { - return fmt.Errorf("meshcatalogclient: the verdict on %s names unknown fields and does not wait", v.Module) - } - switch v.State { - case VerdictAccepted: - if len(v.Problems) > 0 { - return fmt.Errorf("meshcatalogclient: the verdict on %s accepts its manifest and names problems", v.Module) - } - case VerdictRefused: - if len(v.Problems) == 0 { - return fmt.Errorf("meshcatalogclient: the verdict on %s refuses its manifest and names no problem", v.Module) - } - if len(v.Warnings) > 0 { - return fmt.Errorf("meshcatalogclient: the verdict on %s refuses its manifest and warns: a refusal names problems", v.Module) - } - case VerdictManifestWaits: - if len(v.Unknown) == 0 || len(v.Problems) > 0 || len(v.Warnings) > 0 { - return fmt.Errorf("meshcatalogclient: the verdict on %s waits and names no unknown field, or names problems or warnings: a wait names the fields", v.Module) - } - default: - return fmt.Errorf("meshcatalogclient: the verdict on %s is %q, none of %s, %s and %s", v.Module, v.State, VerdictAccepted, VerdictRefused, VerdictManifestWaits) - } - if v.Judge == "" { - return fmt.Errorf("meshcatalogclient: the verdict on %s names no judge", v.Module) - } - return nil -} - -// EncodeVerdict is v as JSON at the kept values' version; it refuses a verdict without a module or a judge, a state other -// than accepted, refused or waits, a refusal naming no problem and an acceptance naming one. -func EncodeVerdict(v seat.VerdictsByDigestValue) ([]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) (seat.VerdictsByDigestValue, error) { - if err := keys.CheckVersion(data); err != nil { - return seat.VerdictsByDigestValue{}, err - } - var v seat.VerdictsByDigestValue - if err := json.Unmarshal(data, &v); err != nil { - return seat.VerdictsByDigestValue{}, fmt.Errorf("meshcatalogclient: value does not fit its shape: %w", err) - } - if err := checkVerdict(v); err != nil { - return seat.VerdictsByDigestValue{}, err - } - return v, nil -} - -// ModuleVerdict is the verdict a `modules` value carries, or nil when it carries none (taken as accepted, TakeVerdict). A -// refusal naming unknown fields is the wait it was written as. -func ModuleVerdict(module string, m seat.ModulesByModuleValue) *seat.VerdictsByDigestValue { - if m.Verdict == "" && len(m.Warnings) == 0 { - return nil - } - if m.Verdict == "" { - return &seat.VerdictsByDigestValue{Module: module, State: VerdictAccepted, Warnings: m.Warnings} - } - if m.Verdict == VerdictRefused && len(m.Unknown) > 0 { - return &seat.VerdictsByDigestValue{Module: module, State: VerdictManifestWaits, Unknown: m.Unknown} - } - return &seat.VerdictsByDigestValue{Module: module, State: m.Verdict, Problems: m.Problems} -} diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go index f236b5e6..da3b1a43 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go @@ -105,7 +105,6 @@ const ( StateManifests = "manifests" StateModules = "modules" StateCandidates = "candidates" - StateVerdicts = "verdicts" StatePredefined = "predefined" StatePackages = "packages" StateCatalogRevisions = "catalog-revisions" @@ -209,37 +208,6 @@ func DecodeCandidatesByGroupValue(raw []byte) (CandidatesByGroupValue, error) { return v, nil } -// VerdictsByDigestKey is the key of one value of the state verdicts under the form "". -func VerdictsByDigestKey(digest string) string { return digest } - -// ParseVerdictsByDigestKey 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 ParseVerdictsByDigestKey(key string) (string, bool) { - rest := key - if rest == "" { - return "", false - } - v0 := rest - rest = "" - if rest != "" { - return "", false - } - return v0, true -} - -// DecodeVerdictsByDigestValue reads one value of the state verdicts under the form "", refusing a field VerdictsByDigestValue does not know and any text after the value. -func DecodeVerdictsByDigestValue(raw []byte) (VerdictsByDigestValue, error) { - var v VerdictsByDigestValue - 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 -} - // PredefinedByListKey is the key of one value of the state predefined under the form "list". func PredefinedByListKey() string { return "list" } @@ -1472,20 +1440,6 @@ type CandidatesByGroupValue struct { V int64 `json:"v,omitempty"` } -// VerdictsByDigestValue is one value of the state verdicts under the key . -type VerdictsByDigestValue struct { - // when (RFC 3339 time) - At *time.Time `json:"at,omitempty"` - Judge string `json:"judge,omitempty"` - Module string `json:"module"` - Problems []string `json:"problems,omitempty"` - State string `json:"state"` - Unknown []string `json:"unknown,omitempty"` - // the layout version - V int64 `json:"v,omitempty"` - Warnings []string `json:"warnings,omitempty"` -} - // PredefinedByListValue is one value of the state predefined under the key list. type PredefinedByListValue struct { // when (RFC 3339 time) diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go index d19839f1..e45c4441 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go @@ -43,8 +43,6 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v ModulesByModuleValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "a candidate", subject: "", given: "{\"base\":3,\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"pulls\":[{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"modules\":[\"nats\"],\"number\":1,\"repository\":\"novox/mesh-sdk\"}],\"v\":1}", wire: "{\"base\":3,\"group\":\"feat/registry\",\"heads\":\"0123456789ab\",\"pulls\":[{\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"modules\":[\"nats\"],\"number\":1,\"repository\":\"novox/mesh-sdk\"}],\"v\":1}", decode: func(b []byte) (any, error) { var v CandidatesByGroupValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "a refused verdict (nats, read through the indexer's verdicts tool)", subject: "", given: "{\"at\":\"2026-11-04T18:51:12.614583047+01:00\",\"judge\":\"exe:661e6fb424d7ffea\",\"module\":\"nats\",\"problems\":[\"this is not a module manifest: a state is either a name or {name, history, ttl-seconds, per-machine, key-ttl}: json: unknown field \\\"read-only\\\" (read without state[2].read-only)\"],\"state\":\"refused\"}", wire: "{\"at\":\"2026-11-04T18:51:12.614583047+01:00\",\"judge\":\"exe:661e6fb424d7ffea\",\"module\":\"nats\",\"problems\":[\"this is not a module manifest: a state is either a name or {name, history, ttl-seconds, per-machine, key-ttl}: json: unknown field \\\"read-only\\\" (read without state[2].read-only)\"],\"state\":\"refused\"}", - decode: func(b []byte) (any, error) { var v VerdictsByDigestValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "the predefined list", subject: "", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"list\":{\"streams\":[]},\"v\":1}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"list\":{\"streams\":[]},\"v\":1}", decode: func(b []byte) (any, error) { var v PredefinedByListValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "a published Go module", subject: "", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"module\":\"git.novox.be/novox/mesh-sdk/go\",\"packages\":[{\"digest\":\"ab\",\"package\":\"git.novox.be/novox/mesh-sdk/go/keys\"}],\"repository\":\"novox/mesh-sdk\",\"v\":1}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"module\":\"git.novox.be/novox/mesh-sdk/go\",\"packages\":[{\"digest\":\"ab\",\"package\":\"git.novox.be/novox/mesh-sdk/go/keys\"}],\"repository\":\"novox/mesh-sdk\",\"v\":1}", diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/states.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/states.json index ea38c88f..13c0a262 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/states.json @@ -39,19 +39,6 @@ ] } }, - { - "name": "a refused verdict (nats, read through the indexer's verdicts tool)", - "of": "state:verdicts/", - "given": { - "module": "nats", - "state": "refused", - "problems": [ - "this is not a module manifest: a state is either a name or {name, history, ttl-seconds, per-machine, key-ttl}: json: unknown field \"read-only\" (read without state[2].read-only)" - ], - "judge": "exe:661e6fb424d7ffea", - "at": "2026-11-04T18:51:12.614583047+01:00" - } - }, { "name": "the predefined list", "of": "state:predefined/list", diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json index b3c7c8a9..3c0efb8e 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json @@ -1125,64 +1125,6 @@ "description": "the candidates of open groups", "history": 10 }, - { - "name": "verdicts", - "template": "state", - "key-forms": [ - { - "key": "", - "value": { - "type": "object", - "properties": { - "v": { - "type": "integer", - "description": "the layout version" - }, - "module": { - "type": "string" - }, - "state": { - "type": "string" - }, - "problems": { - "type": "array", - "items": { - "type": "string" - } - }, - "unknown": { - "type": "array", - "items": { - "type": "string" - } - }, - "warnings": { - "type": "array", - "items": { - "type": "string" - } - }, - "judge": { - "type": "string" - }, - "at": { - "type": "string", - "description": "when (RFC 3339 time)", - "format": "date-time" - } - }, - "required": [ - "module", - "state" - ], - "description": "a manifest's verdict, by the judge named" - }, - "description": "a manifest's verdict by its digest" - } - ], - "description": "the manifest verdicts", - "history": 5 - }, { "name": "predefined", "template": "state", diff --git a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts index 6c5acce9..565cd644 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts @@ -66,7 +66,6 @@ export declare const states: { readonly manifests: "manifests"; readonly modules: "modules"; readonly candidates: "candidates"; - readonly verdicts: "verdicts"; readonly predefined: "predefined"; readonly packages: "packages"; readonly catalogRevisions: "catalog-revisions"; @@ -95,12 +94,6 @@ export declare function candidatesByGroupKey(group: string): string; /** The parts of a key of the form "", or undefined for a key of another form. */ export declare function parseCandidatesByGroupKey(_key: string): { group: string } | undefined; -/** The key of one value of the state verdicts under the form "". */ -export declare function verdictsByDigestKey(digest: string): string; - -/** The parts of a key of the form "", or undefined for a key of another form. */ -export declare function parseVerdictsByDigestKey(_key: string): { digest: string } | undefined; - /** The key of one value of the state predefined under the form "list". */ export declare function predefinedByListKey(): string; @@ -939,20 +932,6 @@ export interface CandidatesByGroupValue { "v"?: number; } -/** is one value of the state verdicts under the key . */ -export interface VerdictsByDigestValue { - /** when (RFC 3339 time) */ - "at"?: string; - "judge"?: string; - "module": string; - "problems"?: string[]; - "state": string; - "unknown"?: string[]; - /** the layout version */ - "v"?: number; - "warnings"?: string[]; -} - /** is one value of the state predefined under the key list. */ export interface PredefinedByListValue { /** when (RFC 3339 time) */ diff --git a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.js b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.js index 4913e7bc..fa0c4b35 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.js @@ -68,7 +68,6 @@ export const states = { manifests: "manifests", modules: "modules", candidates: "candidates", - verdicts: "verdicts", predefined: "predefined", packages: "packages", catalogRevisions: "catalog-revisions", @@ -124,21 +123,6 @@ export function parseCandidatesByGroupKey(_key) { return { group }; } -/** The key of one value of the state verdicts under the form "". */ -export function verdictsByDigestKey(digest) { - return digest; -} - -/** The parts of a key of the form "", or undefined for a key of another form. */ -export function parseVerdictsByDigestKey(_key) { - let _rest = _key; - if (_rest === "") return undefined; - const digest = _rest; - _rest = ""; - if (_rest !== "") return undefined; - return { digest }; -} - /** The key of one value of the state predefined under the form "list". */ export function predefinedByListKey() { return "list";